aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/suballoc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/suballoc.c')
-rw-r--r--fs/ocfs2/suballoc.c174
1 files changed, 74 insertions, 100 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 9d91e66f51a9..000d71cca6c5 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -49,7 +49,7 @@
49static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg); 49static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg);
50static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe); 50static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe);
51static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl); 51static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl);
52static int ocfs2_block_group_fill(struct ocfs2_journal_handle *handle, 52static int ocfs2_block_group_fill(handle_t *handle,
53 struct inode *alloc_inode, 53 struct inode *alloc_inode,
54 struct buffer_head *bg_bh, 54 struct buffer_head *bg_bh,
55 u64 group_blkno, 55 u64 group_blkno,
@@ -59,9 +59,6 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
59 struct inode *alloc_inode, 59 struct inode *alloc_inode,
60 struct buffer_head *bh); 60 struct buffer_head *bh);
61 61
62static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
63 struct ocfs2_alloc_context *ac);
64
65static int ocfs2_cluster_group_search(struct inode *inode, 62static int ocfs2_cluster_group_search(struct inode *inode,
66 struct buffer_head *group_bh, 63 struct buffer_head *group_bh,
67 u32 bits_wanted, u32 min_bits, 64 u32 bits_wanted, u32 min_bits,
@@ -72,6 +69,7 @@ static int ocfs2_block_group_search(struct inode *inode,
72 u16 *bit_off, u16 *bits_found); 69 u16 *bit_off, u16 *bits_found);
73static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, 70static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
74 struct ocfs2_alloc_context *ac, 71 struct ocfs2_alloc_context *ac,
72 handle_t *handle,
75 u32 bits_wanted, 73 u32 bits_wanted,
76 u32 min_bits, 74 u32 min_bits,
77 u16 *bit_off, 75 u16 *bit_off,
@@ -79,20 +77,20 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
79 u64 *bg_blkno); 77 u64 *bg_blkno);
80static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh, 78static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
81 int nr); 79 int nr);
82static inline int ocfs2_block_group_set_bits(struct ocfs2_journal_handle *handle, 80static inline int ocfs2_block_group_set_bits(handle_t *handle,
83 struct inode *alloc_inode, 81 struct inode *alloc_inode,
84 struct ocfs2_group_desc *bg, 82 struct ocfs2_group_desc *bg,
85 struct buffer_head *group_bh, 83 struct buffer_head *group_bh,
86 unsigned int bit_off, 84 unsigned int bit_off,
87 unsigned int num_bits); 85 unsigned int num_bits);
88static inline int ocfs2_block_group_clear_bits(struct ocfs2_journal_handle *handle, 86static inline int ocfs2_block_group_clear_bits(handle_t *handle,
89 struct inode *alloc_inode, 87 struct inode *alloc_inode,
90 struct ocfs2_group_desc *bg, 88 struct ocfs2_group_desc *bg,
91 struct buffer_head *group_bh, 89 struct buffer_head *group_bh,
92 unsigned int bit_off, 90 unsigned int bit_off,
93 unsigned int num_bits); 91 unsigned int num_bits);
94 92
95static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle, 93static int ocfs2_relink_block_group(handle_t *handle,
96 struct inode *alloc_inode, 94 struct inode *alloc_inode,
97 struct buffer_head *fe_bh, 95 struct buffer_head *fe_bh,
98 struct buffer_head *bg_bh, 96 struct buffer_head *bg_bh,
@@ -100,7 +98,7 @@ static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle,
100 u16 chain); 98 u16 chain);
101static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg, 99static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg,
102 u32 wanted); 100 u32 wanted);
103static int ocfs2_free_suballoc_bits(struct ocfs2_journal_handle *handle, 101static int ocfs2_free_suballoc_bits(handle_t *handle,
104 struct inode *alloc_inode, 102 struct inode *alloc_inode,
105 struct buffer_head *alloc_bh, 103 struct buffer_head *alloc_bh,
106 unsigned int start_bit, 104 unsigned int start_bit,
@@ -120,8 +118,16 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode,
120 118
121void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) 119void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac)
122{ 120{
123 if (ac->ac_inode) 121 struct inode *inode = ac->ac_inode;
124 iput(ac->ac_inode); 122
123 if (inode) {
124 if (ac->ac_which != OCFS2_AC_USE_LOCAL)
125 ocfs2_meta_unlock(inode, 1);
126
127 mutex_unlock(&inode->i_mutex);
128
129 iput(inode);
130 }
125 if (ac->ac_bh) 131 if (ac->ac_bh)
126 brelse(ac->ac_bh); 132 brelse(ac->ac_bh);
127 kfree(ac); 133 kfree(ac);
@@ -190,7 +196,7 @@ static int ocfs2_check_group_descriptor(struct super_block *sb,
190 return 0; 196 return 0;
191} 197}
192 198
193static int ocfs2_block_group_fill(struct ocfs2_journal_handle *handle, 199static int ocfs2_block_group_fill(handle_t *handle,
194 struct inode *alloc_inode, 200 struct inode *alloc_inode,
195 struct buffer_head *bg_bh, 201 struct buffer_head *bg_bh,
196 u64 group_blkno, 202 u64 group_blkno,
@@ -273,7 +279,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
273 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; 279 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data;
274 struct ocfs2_chain_list *cl; 280 struct ocfs2_chain_list *cl;
275 struct ocfs2_alloc_context *ac = NULL; 281 struct ocfs2_alloc_context *ac = NULL;
276 struct ocfs2_journal_handle *handle = NULL; 282 handle_t *handle = NULL;
277 u32 bit_off, num_bits; 283 u32 bit_off, num_bits;
278 u16 alloc_rec; 284 u16 alloc_rec;
279 u64 bg_blkno; 285 u64 bg_blkno;
@@ -284,16 +290,8 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
284 290
285 mlog_entry_void(); 291 mlog_entry_void();
286 292
287 handle = ocfs2_alloc_handle(osb);
288 if (!handle) {
289 status = -ENOMEM;
290 mlog_errno(status);
291 goto bail;
292 }
293
294 cl = &fe->id2.i_chain; 293 cl = &fe->id2.i_chain;
295 status = ocfs2_reserve_clusters(osb, 294 status = ocfs2_reserve_clusters(osb,
296 handle,
297 le16_to_cpu(cl->cl_cpg), 295 le16_to_cpu(cl->cl_cpg),
298 &ac); 296 &ac);
299 if (status < 0) { 297 if (status < 0) {
@@ -304,7 +302,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
304 302
305 credits = ocfs2_calc_group_alloc_credits(osb->sb, 303 credits = ocfs2_calc_group_alloc_credits(osb->sb,
306 le16_to_cpu(cl->cl_cpg)); 304 le16_to_cpu(cl->cl_cpg));
307 handle = ocfs2_start_trans(osb, handle, credits); 305 handle = ocfs2_start_trans(osb, credits);
308 if (IS_ERR(handle)) { 306 if (IS_ERR(handle)) {
309 status = PTR_ERR(handle); 307 status = PTR_ERR(handle);
310 handle = NULL; 308 handle = NULL;
@@ -389,7 +387,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
389 status = 0; 387 status = 0;
390bail: 388bail:
391 if (handle) 389 if (handle)
392 ocfs2_commit_trans(handle); 390 ocfs2_commit_trans(osb, handle);
393 391
394 if (ac) 392 if (ac)
395 ocfs2_free_alloc_context(ac); 393 ocfs2_free_alloc_context(ac);
@@ -402,27 +400,38 @@ bail:
402} 400}
403 401
404static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, 402static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
405 struct ocfs2_alloc_context *ac) 403 struct ocfs2_alloc_context *ac,
404 int type,
405 u32 slot)
406{ 406{
407 int status; 407 int status;
408 u32 bits_wanted = ac->ac_bits_wanted; 408 u32 bits_wanted = ac->ac_bits_wanted;
409 struct inode *alloc_inode = ac->ac_inode; 409 struct inode *alloc_inode;
410 struct buffer_head *bh = NULL; 410 struct buffer_head *bh = NULL;
411 struct ocfs2_journal_handle *handle = ac->ac_handle;
412 struct ocfs2_dinode *fe; 411 struct ocfs2_dinode *fe;
413 u32 free_bits; 412 u32 free_bits;
414 413
415 mlog_entry_void(); 414 mlog_entry_void();
416 415
417 BUG_ON(handle->flags & OCFS2_HANDLE_STARTED); 416 alloc_inode = ocfs2_get_system_file_inode(osb, type, slot);
417 if (!alloc_inode) {
418 mlog_errno(-EINVAL);
419 return -EINVAL;
420 }
418 421
419 ocfs2_handle_add_inode(handle, alloc_inode); 422 mutex_lock(&alloc_inode->i_mutex);
420 status = ocfs2_meta_lock(alloc_inode, handle, &bh, 1); 423
424 status = ocfs2_meta_lock(alloc_inode, &bh, 1);
421 if (status < 0) { 425 if (status < 0) {
426 mutex_unlock(&alloc_inode->i_mutex);
427 iput(alloc_inode);
428
422 mlog_errno(status); 429 mlog_errno(status);
423 goto bail; 430 return status;
424 } 431 }
425 432
433 ac->ac_inode = alloc_inode;
434
426 fe = (struct ocfs2_dinode *) bh->b_data; 435 fe = (struct ocfs2_dinode *) bh->b_data;
427 if (!OCFS2_IS_VALID_DINODE(fe)) { 436 if (!OCFS2_IS_VALID_DINODE(fe)) {
428 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); 437 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe);
@@ -473,12 +482,11 @@ bail:
473} 482}
474 483
475int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, 484int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
476 struct ocfs2_journal_handle *handle,
477 struct ocfs2_dinode *fe, 485 struct ocfs2_dinode *fe,
478 struct ocfs2_alloc_context **ac) 486 struct ocfs2_alloc_context **ac)
479{ 487{
480 int status; 488 int status;
481 struct inode *alloc_inode = NULL; 489 u32 slot;
482 490
483 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 491 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
484 if (!(*ac)) { 492 if (!(*ac)) {
@@ -488,28 +496,18 @@ int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
488 } 496 }
489 497
490 (*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe); 498 (*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe);
491 (*ac)->ac_handle = handle;
492 (*ac)->ac_which = OCFS2_AC_USE_META; 499 (*ac)->ac_which = OCFS2_AC_USE_META;
493 500
494#ifndef OCFS2_USE_ALL_METADATA_SUBALLOCATORS 501#ifndef OCFS2_USE_ALL_METADATA_SUBALLOCATORS
495 alloc_inode = ocfs2_get_system_file_inode(osb, 502 slot = 0;
496 EXTENT_ALLOC_SYSTEM_INODE,
497 0);
498#else 503#else
499 alloc_inode = ocfs2_get_system_file_inode(osb, 504 slot = osb->slot_num;
500 EXTENT_ALLOC_SYSTEM_INODE,
501 osb->slot_num);
502#endif 505#endif
503 if (!alloc_inode) {
504 status = -ENOMEM;
505 mlog_errno(status);
506 goto bail;
507 }
508 506
509 (*ac)->ac_inode = igrab(alloc_inode);
510 (*ac)->ac_group_search = ocfs2_block_group_search; 507 (*ac)->ac_group_search = ocfs2_block_group_search;
511 508
512 status = ocfs2_reserve_suballoc_bits(osb, (*ac)); 509 status = ocfs2_reserve_suballoc_bits(osb, (*ac),
510 EXTENT_ALLOC_SYSTEM_INODE, slot);
513 if (status < 0) { 511 if (status < 0) {
514 if (status != -ENOSPC) 512 if (status != -ENOSPC)
515 mlog_errno(status); 513 mlog_errno(status);
@@ -523,19 +521,14 @@ bail:
523 *ac = NULL; 521 *ac = NULL;
524 } 522 }
525 523
526 if (alloc_inode)
527 iput(alloc_inode);
528
529 mlog_exit(status); 524 mlog_exit(status);
530 return status; 525 return status;
531} 526}
532 527
533int ocfs2_reserve_new_inode(struct ocfs2_super *osb, 528int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
534 struct ocfs2_journal_handle *handle,
535 struct ocfs2_alloc_context **ac) 529 struct ocfs2_alloc_context **ac)
536{ 530{
537 int status; 531 int status;
538 struct inode *alloc_inode = NULL;
539 532
540 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 533 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
541 if (!(*ac)) { 534 if (!(*ac)) {
@@ -545,22 +538,13 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
545 } 538 }
546 539
547 (*ac)->ac_bits_wanted = 1; 540 (*ac)->ac_bits_wanted = 1;
548 (*ac)->ac_handle = handle;
549 (*ac)->ac_which = OCFS2_AC_USE_INODE; 541 (*ac)->ac_which = OCFS2_AC_USE_INODE;
550 542
551 alloc_inode = ocfs2_get_system_file_inode(osb,
552 INODE_ALLOC_SYSTEM_INODE,
553 osb->slot_num);
554 if (!alloc_inode) {
555 status = -ENOMEM;
556 mlog_errno(status);
557 goto bail;
558 }
559
560 (*ac)->ac_inode = igrab(alloc_inode);
561 (*ac)->ac_group_search = ocfs2_block_group_search; 543 (*ac)->ac_group_search = ocfs2_block_group_search;
562 544
563 status = ocfs2_reserve_suballoc_bits(osb, *ac); 545 status = ocfs2_reserve_suballoc_bits(osb, *ac,
546 INODE_ALLOC_SYSTEM_INODE,
547 osb->slot_num);
564 if (status < 0) { 548 if (status < 0) {
565 if (status != -ENOSPC) 549 if (status != -ENOSPC)
566 mlog_errno(status); 550 mlog_errno(status);
@@ -574,9 +558,6 @@ bail:
574 *ac = NULL; 558 *ac = NULL;
575 } 559 }
576 560
577 if (alloc_inode)
578 iput(alloc_inode);
579
580 mlog_exit(status); 561 mlog_exit(status);
581 return status; 562 return status;
582} 563}
@@ -588,20 +569,17 @@ int ocfs2_reserve_cluster_bitmap_bits(struct ocfs2_super *osb,
588{ 569{
589 int status; 570 int status;
590 571
591 ac->ac_inode = ocfs2_get_system_file_inode(osb,
592 GLOBAL_BITMAP_SYSTEM_INODE,
593 OCFS2_INVALID_SLOT);
594 if (!ac->ac_inode) {
595 status = -EINVAL;
596 mlog(ML_ERROR, "Could not get bitmap inode!\n");
597 goto bail;
598 }
599 ac->ac_which = OCFS2_AC_USE_MAIN; 572 ac->ac_which = OCFS2_AC_USE_MAIN;
600 ac->ac_group_search = ocfs2_cluster_group_search; 573 ac->ac_group_search = ocfs2_cluster_group_search;
601 574
602 status = ocfs2_reserve_suballoc_bits(osb, ac); 575 status = ocfs2_reserve_suballoc_bits(osb, ac,
603 if (status < 0 && status != -ENOSPC) 576 GLOBAL_BITMAP_SYSTEM_INODE,
577 OCFS2_INVALID_SLOT);
578 if (status < 0 && status != -ENOSPC) {
604 mlog_errno(status); 579 mlog_errno(status);
580 goto bail;
581 }
582
605bail: 583bail:
606 return status; 584 return status;
607} 585}
@@ -610,7 +588,6 @@ bail:
610 * use so we figure it out for them, but unfortunately this clutters 588 * use so we figure it out for them, but unfortunately this clutters
611 * things a bit. */ 589 * things a bit. */
612int ocfs2_reserve_clusters(struct ocfs2_super *osb, 590int ocfs2_reserve_clusters(struct ocfs2_super *osb,
613 struct ocfs2_journal_handle *handle,
614 u32 bits_wanted, 591 u32 bits_wanted,
615 struct ocfs2_alloc_context **ac) 592 struct ocfs2_alloc_context **ac)
616{ 593{
@@ -618,8 +595,6 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb,
618 595
619 mlog_entry_void(); 596 mlog_entry_void();
620 597
621 BUG_ON(!handle);
622
623 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 598 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
624 if (!(*ac)) { 599 if (!(*ac)) {
625 status = -ENOMEM; 600 status = -ENOMEM;
@@ -628,12 +603,10 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb,
628 } 603 }
629 604
630 (*ac)->ac_bits_wanted = bits_wanted; 605 (*ac)->ac_bits_wanted = bits_wanted;
631 (*ac)->ac_handle = handle;
632 606
633 status = -ENOSPC; 607 status = -ENOSPC;
634 if (ocfs2_alloc_should_use_local(osb, bits_wanted)) { 608 if (ocfs2_alloc_should_use_local(osb, bits_wanted)) {
635 status = ocfs2_reserve_local_alloc_bits(osb, 609 status = ocfs2_reserve_local_alloc_bits(osb,
636 handle,
637 bits_wanted, 610 bits_wanted,
638 *ac); 611 *ac);
639 if ((status < 0) && (status != -ENOSPC)) { 612 if ((status < 0) && (status != -ENOSPC)) {
@@ -774,7 +747,7 @@ static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb,
774 return status; 747 return status;
775} 748}
776 749
777static inline int ocfs2_block_group_set_bits(struct ocfs2_journal_handle *handle, 750static inline int ocfs2_block_group_set_bits(handle_t *handle,
778 struct inode *alloc_inode, 751 struct inode *alloc_inode,
779 struct ocfs2_group_desc *bg, 752 struct ocfs2_group_desc *bg,
780 struct buffer_head *group_bh, 753 struct buffer_head *group_bh,
@@ -845,7 +818,7 @@ static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl)
845 return best; 818 return best;
846} 819}
847 820
848static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle, 821static int ocfs2_relink_block_group(handle_t *handle,
849 struct inode *alloc_inode, 822 struct inode *alloc_inode,
850 struct buffer_head *fe_bh, 823 struct buffer_head *fe_bh,
851 struct buffer_head *bg_bh, 824 struct buffer_head *bg_bh,
@@ -1025,7 +998,7 @@ static int ocfs2_block_group_search(struct inode *inode,
1025} 998}
1026 999
1027static int ocfs2_alloc_dinode_update_counts(struct inode *inode, 1000static int ocfs2_alloc_dinode_update_counts(struct inode *inode,
1028 struct ocfs2_journal_handle *handle, 1001 handle_t *handle,
1029 struct buffer_head *di_bh, 1002 struct buffer_head *di_bh,
1030 u32 num_bits, 1003 u32 num_bits,
1031 u16 chain) 1004 u16 chain)
@@ -1055,6 +1028,7 @@ out:
1055} 1028}
1056 1029
1057static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, 1030static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac,
1031 handle_t *handle,
1058 u32 bits_wanted, 1032 u32 bits_wanted,
1059 u32 min_bits, 1033 u32 min_bits,
1060 u16 *bit_off, 1034 u16 *bit_off,
@@ -1067,7 +1041,6 @@ static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac,
1067 struct buffer_head *group_bh = NULL; 1041 struct buffer_head *group_bh = NULL;
1068 struct ocfs2_group_desc *gd; 1042 struct ocfs2_group_desc *gd;
1069 struct inode *alloc_inode = ac->ac_inode; 1043 struct inode *alloc_inode = ac->ac_inode;
1070 struct ocfs2_journal_handle *handle = ac->ac_handle;
1071 1044
1072 ret = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), gd_blkno, 1045 ret = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), gd_blkno,
1073 &group_bh, OCFS2_BH_CACHED, alloc_inode); 1046 &group_bh, OCFS2_BH_CACHED, alloc_inode);
@@ -1115,6 +1088,7 @@ out:
1115} 1088}
1116 1089
1117static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, 1090static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1091 handle_t *handle,
1118 u32 bits_wanted, 1092 u32 bits_wanted,
1119 u32 min_bits, 1093 u32 min_bits,
1120 u16 *bit_off, 1094 u16 *bit_off,
@@ -1126,7 +1100,6 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1126 u16 chain, tmp_bits; 1100 u16 chain, tmp_bits;
1127 u32 tmp_used; 1101 u32 tmp_used;
1128 u64 next_group; 1102 u64 next_group;
1129 struct ocfs2_journal_handle *handle = ac->ac_handle;
1130 struct inode *alloc_inode = ac->ac_inode; 1103 struct inode *alloc_inode = ac->ac_inode;
1131 struct buffer_head *group_bh = NULL; 1104 struct buffer_head *group_bh = NULL;
1132 struct buffer_head *prev_group_bh = NULL; 1105 struct buffer_head *prev_group_bh = NULL;
@@ -1272,6 +1245,7 @@ bail:
1272/* will give out up to bits_wanted contiguous bits. */ 1245/* will give out up to bits_wanted contiguous bits. */
1273static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, 1246static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1274 struct ocfs2_alloc_context *ac, 1247 struct ocfs2_alloc_context *ac,
1248 handle_t *handle,
1275 u32 bits_wanted, 1249 u32 bits_wanted,
1276 u32 min_bits, 1250 u32 min_bits,
1277 u16 *bit_off, 1251 u16 *bit_off,
@@ -1313,8 +1287,8 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1313 * by jumping straight to the most recently used 1287 * by jumping straight to the most recently used
1314 * allocation group. This helps us mantain some 1288 * allocation group. This helps us mantain some
1315 * contiguousness across allocations. */ 1289 * contiguousness across allocations. */
1316 status = ocfs2_search_one_group(ac, bits_wanted, min_bits, 1290 status = ocfs2_search_one_group(ac, handle, bits_wanted,
1317 bit_off, num_bits, 1291 min_bits, bit_off, num_bits,
1318 hint_blkno, &bits_left); 1292 hint_blkno, &bits_left);
1319 if (!status) { 1293 if (!status) {
1320 /* Be careful to update *bg_blkno here as the 1294 /* Be careful to update *bg_blkno here as the
@@ -1336,7 +1310,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1336 ac->ac_chain = victim; 1310 ac->ac_chain = victim;
1337 ac->ac_allow_chain_relink = 1; 1311 ac->ac_allow_chain_relink = 1;
1338 1312
1339 status = ocfs2_search_chain(ac, bits_wanted, min_bits, bit_off, 1313 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, bit_off,
1340 num_bits, bg_blkno, &bits_left); 1314 num_bits, bg_blkno, &bits_left);
1341 if (!status) 1315 if (!status)
1342 goto set_hint; 1316 goto set_hint;
@@ -1360,7 +1334,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1360 continue; 1334 continue;
1361 1335
1362 ac->ac_chain = i; 1336 ac->ac_chain = i;
1363 status = ocfs2_search_chain(ac, bits_wanted, min_bits, 1337 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
1364 bit_off, num_bits, bg_blkno, 1338 bit_off, num_bits, bg_blkno,
1365 &bits_left); 1339 &bits_left);
1366 if (!status) 1340 if (!status)
@@ -1388,7 +1362,7 @@ bail:
1388} 1362}
1389 1363
1390int ocfs2_claim_metadata(struct ocfs2_super *osb, 1364int ocfs2_claim_metadata(struct ocfs2_super *osb,
1391 struct ocfs2_journal_handle *handle, 1365 handle_t *handle,
1392 struct ocfs2_alloc_context *ac, 1366 struct ocfs2_alloc_context *ac,
1393 u32 bits_wanted, 1367 u32 bits_wanted,
1394 u16 *suballoc_bit_start, 1368 u16 *suballoc_bit_start,
@@ -1401,10 +1375,10 @@ int ocfs2_claim_metadata(struct ocfs2_super *osb,
1401 BUG_ON(!ac); 1375 BUG_ON(!ac);
1402 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); 1376 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted));
1403 BUG_ON(ac->ac_which != OCFS2_AC_USE_META); 1377 BUG_ON(ac->ac_which != OCFS2_AC_USE_META);
1404 BUG_ON(ac->ac_handle != handle);
1405 1378
1406 status = ocfs2_claim_suballoc_bits(osb, 1379 status = ocfs2_claim_suballoc_bits(osb,
1407 ac, 1380 ac,
1381 handle,
1408 bits_wanted, 1382 bits_wanted,
1409 1, 1383 1,
1410 suballoc_bit_start, 1384 suballoc_bit_start,
@@ -1425,7 +1399,7 @@ bail:
1425} 1399}
1426 1400
1427int ocfs2_claim_new_inode(struct ocfs2_super *osb, 1401int ocfs2_claim_new_inode(struct ocfs2_super *osb,
1428 struct ocfs2_journal_handle *handle, 1402 handle_t *handle,
1429 struct ocfs2_alloc_context *ac, 1403 struct ocfs2_alloc_context *ac,
1430 u16 *suballoc_bit, 1404 u16 *suballoc_bit,
1431 u64 *fe_blkno) 1405 u64 *fe_blkno)
@@ -1440,10 +1414,10 @@ int ocfs2_claim_new_inode(struct ocfs2_super *osb,
1440 BUG_ON(ac->ac_bits_given != 0); 1414 BUG_ON(ac->ac_bits_given != 0);
1441 BUG_ON(ac->ac_bits_wanted != 1); 1415 BUG_ON(ac->ac_bits_wanted != 1);
1442 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); 1416 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE);
1443 BUG_ON(ac->ac_handle != handle);
1444 1417
1445 status = ocfs2_claim_suballoc_bits(osb, 1418 status = ocfs2_claim_suballoc_bits(osb,
1446 ac, 1419 ac,
1420 handle,
1447 1, 1421 1,
1448 1, 1422 1,
1449 suballoc_bit, 1423 suballoc_bit,
@@ -1528,7 +1502,7 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode,
1528 * of any size. 1502 * of any size.
1529 */ 1503 */
1530int ocfs2_claim_clusters(struct ocfs2_super *osb, 1504int ocfs2_claim_clusters(struct ocfs2_super *osb,
1531 struct ocfs2_journal_handle *handle, 1505 handle_t *handle,
1532 struct ocfs2_alloc_context *ac, 1506 struct ocfs2_alloc_context *ac,
1533 u32 min_clusters, 1507 u32 min_clusters,
1534 u32 *cluster_start, 1508 u32 *cluster_start,
@@ -1546,7 +1520,6 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb,
1546 1520
1547 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL 1521 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL
1548 && ac->ac_which != OCFS2_AC_USE_MAIN); 1522 && ac->ac_which != OCFS2_AC_USE_MAIN);
1549 BUG_ON(ac->ac_handle != handle);
1550 1523
1551 if (ac->ac_which == OCFS2_AC_USE_LOCAL) { 1524 if (ac->ac_which == OCFS2_AC_USE_LOCAL) {
1552 status = ocfs2_claim_local_alloc_bits(osb, 1525 status = ocfs2_claim_local_alloc_bits(osb,
@@ -1572,6 +1545,7 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb,
1572 1545
1573 status = ocfs2_claim_suballoc_bits(osb, 1546 status = ocfs2_claim_suballoc_bits(osb,
1574 ac, 1547 ac,
1548 handle,
1575 bits_wanted, 1549 bits_wanted,
1576 min_clusters, 1550 min_clusters,
1577 &bg_bit_off, 1551 &bg_bit_off,
@@ -1598,7 +1572,7 @@ bail:
1598 return status; 1572 return status;
1599} 1573}
1600 1574
1601static inline int ocfs2_block_group_clear_bits(struct ocfs2_journal_handle *handle, 1575static inline int ocfs2_block_group_clear_bits(handle_t *handle,
1602 struct inode *alloc_inode, 1576 struct inode *alloc_inode,
1603 struct ocfs2_group_desc *bg, 1577 struct ocfs2_group_desc *bg,
1604 struct buffer_head *group_bh, 1578 struct buffer_head *group_bh,
@@ -1653,7 +1627,7 @@ bail:
1653/* 1627/*
1654 * expects the suballoc inode to already be locked. 1628 * expects the suballoc inode to already be locked.
1655 */ 1629 */
1656static int ocfs2_free_suballoc_bits(struct ocfs2_journal_handle *handle, 1630static int ocfs2_free_suballoc_bits(handle_t *handle,
1657 struct inode *alloc_inode, 1631 struct inode *alloc_inode,
1658 struct buffer_head *alloc_bh, 1632 struct buffer_head *alloc_bh,
1659 unsigned int start_bit, 1633 unsigned int start_bit,
@@ -1737,7 +1711,7 @@ static inline u64 ocfs2_which_suballoc_group(u64 block, unsigned int bit)
1737 return group; 1711 return group;
1738} 1712}
1739 1713
1740int ocfs2_free_dinode(struct ocfs2_journal_handle *handle, 1714int ocfs2_free_dinode(handle_t *handle,
1741 struct inode *inode_alloc_inode, 1715 struct inode *inode_alloc_inode,
1742 struct buffer_head *inode_alloc_bh, 1716 struct buffer_head *inode_alloc_bh,
1743 struct ocfs2_dinode *di) 1717 struct ocfs2_dinode *di)
@@ -1750,7 +1724,7 @@ int ocfs2_free_dinode(struct ocfs2_journal_handle *handle,
1750 inode_alloc_bh, bit, bg_blkno, 1); 1724 inode_alloc_bh, bit, bg_blkno, 1);
1751} 1725}
1752 1726
1753int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle, 1727int ocfs2_free_extent_block(handle_t *handle,
1754 struct inode *eb_alloc_inode, 1728 struct inode *eb_alloc_inode,
1755 struct buffer_head *eb_alloc_bh, 1729 struct buffer_head *eb_alloc_bh,
1756 struct ocfs2_extent_block *eb) 1730 struct ocfs2_extent_block *eb)
@@ -1763,7 +1737,7 @@ int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle,
1763 bit, bg_blkno, 1); 1737 bit, bg_blkno, 1);
1764} 1738}
1765 1739
1766int ocfs2_free_clusters(struct ocfs2_journal_handle *handle, 1740int ocfs2_free_clusters(handle_t *handle,
1767 struct inode *bitmap_inode, 1741 struct inode *bitmap_inode,
1768 struct buffer_head *bitmap_bh, 1742 struct buffer_head *bitmap_bh,
1769 u64 start_blk, 1743 u64 start_blk,