aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/localalloc.c
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2006-10-05 18:42:08 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2006-12-01 21:27:08 -0500
commit8898a5a58fb2a2f78a15b046588b5b3adccb82c4 (patch)
tree01960858465f6b2b318d127266e243d7983a4e19 /fs/ocfs2/localalloc.c
parentc161f89be7d57af863e434e9b15afaa863343a7a (diff)
ocfs2: don't pass handle to ocfs2_meta_lock() in localalloc.c
Take and drop the locks directly. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2/localalloc.c')
-rw-r--r--fs/ocfs2/localalloc.c84
1 files changed, 40 insertions, 44 deletions
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index f2f384dd5ba8..75f09f1b4ced 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -196,7 +196,7 @@ bail:
196void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) 196void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
197{ 197{
198 int status; 198 int status;
199 struct ocfs2_journal_handle *handle = NULL; 199 struct ocfs2_journal_handle *handle;
200 struct inode *local_alloc_inode = NULL; 200 struct inode *local_alloc_inode = NULL;
201 struct buffer_head *bh = NULL; 201 struct buffer_head *bh = NULL;
202 struct buffer_head *main_bm_bh = NULL; 202 struct buffer_head *main_bm_bh = NULL;
@@ -207,7 +207,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
207 mlog_entry_void(); 207 mlog_entry_void();
208 208
209 if (osb->local_alloc_state == OCFS2_LA_UNUSED) 209 if (osb->local_alloc_state == OCFS2_LA_UNUSED)
210 goto bail; 210 goto out;
211 211
212 local_alloc_inode = 212 local_alloc_inode =
213 ocfs2_get_system_file_inode(osb, 213 ocfs2_get_system_file_inode(osb,
@@ -216,40 +216,34 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
216 if (!local_alloc_inode) { 216 if (!local_alloc_inode) {
217 status = -ENOENT; 217 status = -ENOENT;
218 mlog_errno(status); 218 mlog_errno(status);
219 goto bail; 219 goto out;
220 } 220 }
221 221
222 osb->local_alloc_state = OCFS2_LA_DISABLED; 222 osb->local_alloc_state = OCFS2_LA_DISABLED;
223 223
224 handle = ocfs2_alloc_handle(osb);
225 if (!handle) {
226 status = -ENOMEM;
227 mlog_errno(status);
228 goto bail;
229 }
230
231 main_bm_inode = ocfs2_get_system_file_inode(osb, 224 main_bm_inode = ocfs2_get_system_file_inode(osb,
232 GLOBAL_BITMAP_SYSTEM_INODE, 225 GLOBAL_BITMAP_SYSTEM_INODE,
233 OCFS2_INVALID_SLOT); 226 OCFS2_INVALID_SLOT);
234 if (!main_bm_inode) { 227 if (!main_bm_inode) {
235 status = -EINVAL; 228 status = -EINVAL;
236 mlog_errno(status); 229 mlog_errno(status);
237 goto bail; 230 goto out;
238 } 231 }
239 232
240 ocfs2_handle_add_inode(handle, main_bm_inode); 233 mutex_lock(&main_bm_inode->i_mutex);
241 status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1); 234
235 status = ocfs2_meta_lock(main_bm_inode, NULL, &main_bm_bh, 1);
242 if (status < 0) { 236 if (status < 0) {
243 mlog_errno(status); 237 mlog_errno(status);
244 goto bail; 238 goto out_mutex;
245 } 239 }
246 240
247 /* WINDOW_MOVE_CREDITS is a bit heavy... */ 241 /* WINDOW_MOVE_CREDITS is a bit heavy... */
248 handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); 242 handle = ocfs2_start_trans(osb, NULL, OCFS2_WINDOW_MOVE_CREDITS);
249 if (IS_ERR(handle)) { 243 if (IS_ERR(handle)) {
250 mlog_errno(PTR_ERR(handle)); 244 mlog_errno(PTR_ERR(handle));
251 handle = NULL; 245 handle = NULL;
252 goto bail; 246 goto out_unlock;
253 } 247 }
254 248
255 bh = osb->local_alloc_bh; 249 bh = osb->local_alloc_bh;
@@ -258,7 +252,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
258 alloc_copy = kmalloc(bh->b_size, GFP_KERNEL); 252 alloc_copy = kmalloc(bh->b_size, GFP_KERNEL);
259 if (!alloc_copy) { 253 if (!alloc_copy) {
260 status = -ENOMEM; 254 status = -ENOMEM;
261 goto bail; 255 goto out_commit;
262 } 256 }
263 memcpy(alloc_copy, alloc, bh->b_size); 257 memcpy(alloc_copy, alloc, bh->b_size);
264 258
@@ -266,7 +260,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
266 OCFS2_JOURNAL_ACCESS_WRITE); 260 OCFS2_JOURNAL_ACCESS_WRITE);
267 if (status < 0) { 261 if (status < 0) {
268 mlog_errno(status); 262 mlog_errno(status);
269 goto bail; 263 goto out_commit;
270 } 264 }
271 265
272 ocfs2_clear_local_alloc(alloc); 266 ocfs2_clear_local_alloc(alloc);
@@ -274,7 +268,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
274 status = ocfs2_journal_dirty(handle, bh); 268 status = ocfs2_journal_dirty(handle, bh);
275 if (status < 0) { 269 if (status < 0) {
276 mlog_errno(status); 270 mlog_errno(status);
277 goto bail; 271 goto out_commit;
278 } 272 }
279 273
280 brelse(bh); 274 brelse(bh);
@@ -286,16 +280,20 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
286 if (status < 0) 280 if (status < 0)
287 mlog_errno(status); 281 mlog_errno(status);
288 282
289bail: 283out_commit:
290 if (handle) 284 ocfs2_commit_trans(handle);
291 ocfs2_commit_trans(handle);
292 285
286out_unlock:
293 if (main_bm_bh) 287 if (main_bm_bh)
294 brelse(main_bm_bh); 288 brelse(main_bm_bh);
295 289
296 if (main_bm_inode) 290 ocfs2_meta_unlock(main_bm_inode, 1);
297 iput(main_bm_inode);
298 291
292out_mutex:
293 mutex_unlock(&main_bm_inode->i_mutex);
294 iput(main_bm_inode);
295
296out:
299 if (local_alloc_inode) 297 if (local_alloc_inode)
300 iput(local_alloc_inode); 298 iput(local_alloc_inode);
301 299
@@ -385,41 +383,35 @@ int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb,
385 struct ocfs2_dinode *alloc) 383 struct ocfs2_dinode *alloc)
386{ 384{
387 int status; 385 int status;
388 struct ocfs2_journal_handle *handle = NULL; 386 struct ocfs2_journal_handle *handle;
389 struct buffer_head *main_bm_bh = NULL; 387 struct buffer_head *main_bm_bh = NULL;
390 struct inode *main_bm_inode = NULL; 388 struct inode *main_bm_inode;
391 389
392 mlog_entry_void(); 390 mlog_entry_void();
393 391
394 handle = ocfs2_alloc_handle(osb);
395 if (!handle) {
396 status = -ENOMEM;
397 mlog_errno(status);
398 goto bail;
399 }
400
401 main_bm_inode = ocfs2_get_system_file_inode(osb, 392 main_bm_inode = ocfs2_get_system_file_inode(osb,
402 GLOBAL_BITMAP_SYSTEM_INODE, 393 GLOBAL_BITMAP_SYSTEM_INODE,
403 OCFS2_INVALID_SLOT); 394 OCFS2_INVALID_SLOT);
404 if (!main_bm_inode) { 395 if (!main_bm_inode) {
405 status = -EINVAL; 396 status = -EINVAL;
406 mlog_errno(status); 397 mlog_errno(status);
407 goto bail; 398 goto out;
408 } 399 }
409 400
410 ocfs2_handle_add_inode(handle, main_bm_inode); 401 mutex_lock(&main_bm_inode->i_mutex);
411 status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1); 402
403 status = ocfs2_meta_lock(main_bm_inode, NULL, &main_bm_bh, 1);
412 if (status < 0) { 404 if (status < 0) {
413 mlog_errno(status); 405 mlog_errno(status);
414 goto bail; 406 goto out_mutex;
415 } 407 }
416 408
417 handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); 409 handle = ocfs2_start_trans(osb, NULL, OCFS2_WINDOW_MOVE_CREDITS);
418 if (IS_ERR(handle)) { 410 if (IS_ERR(handle)) {
419 status = PTR_ERR(handle); 411 status = PTR_ERR(handle);
420 handle = NULL; 412 handle = NULL;
421 mlog_errno(status); 413 mlog_errno(status);
422 goto bail; 414 goto out_unlock;
423 } 415 }
424 416
425 /* we want the bitmap change to be recorded on disk asap */ 417 /* we want the bitmap change to be recorded on disk asap */
@@ -430,16 +422,20 @@ int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb,
430 if (status < 0) 422 if (status < 0)
431 mlog_errno(status); 423 mlog_errno(status);
432 424
433bail: 425 ocfs2_commit_trans(handle);
434 if (handle) 426
435 ocfs2_commit_trans(handle); 427out_unlock:
428 ocfs2_meta_unlock(main_bm_inode, 1);
429
430out_mutex:
431 mutex_unlock(&main_bm_inode->i_mutex);
436 432
437 if (main_bm_bh) 433 if (main_bm_bh)
438 brelse(main_bm_bh); 434 brelse(main_bm_bh);
439 435
440 if (main_bm_inode) 436 iput(main_bm_inode);
441 iput(main_bm_inode);
442 437
438out:
443 mlog_exit(status); 439 mlog_exit(status);
444 return status; 440 return status;
445} 441}