aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/ext3/balloc.c215
-rw-r--r--fs/ext3/ialloc.c10
-rw-r--r--fs/ext3/inode.c2
-rw-r--r--fs/ext3/resize.c43
-rw-r--r--fs/ext3/super.c2
-rw-r--r--fs/ext3/xattr.c27
6 files changed, 158 insertions, 141 deletions
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 77927d6938f6..b1633cd28eca 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -163,10 +163,10 @@ restart:
163#endif 163#endif
164 164
165static int 165static int
166goal_in_my_reservation(struct ext3_reserve_window *rsv, int goal, 166goal_in_my_reservation(struct ext3_reserve_window *rsv, ext3_grpblk_t grp_goal,
167 unsigned int group, struct super_block * sb) 167 unsigned int group, struct super_block * sb)
168{ 168{
169 unsigned long group_first_block, group_last_block; 169 ext3_fsblk_t group_first_block, group_last_block;
170 170
171 group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + 171 group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
172 group * EXT3_BLOCKS_PER_GROUP(sb); 172 group * EXT3_BLOCKS_PER_GROUP(sb);
@@ -175,8 +175,8 @@ goal_in_my_reservation(struct ext3_reserve_window *rsv, int goal,
175 if ((rsv->_rsv_start > group_last_block) || 175 if ((rsv->_rsv_start > group_last_block) ||
176 (rsv->_rsv_end < group_first_block)) 176 (rsv->_rsv_end < group_first_block))
177 return 0; 177 return 0;
178 if ((goal >= 0) && ((goal + group_first_block < rsv->_rsv_start) 178 if ((grp_goal >= 0) && ((grp_goal + group_first_block < rsv->_rsv_start)
179 || (goal + group_first_block > rsv->_rsv_end))) 179 || (grp_goal + group_first_block > rsv->_rsv_end)))
180 return 0; 180 return 0;
181 return 1; 181 return 1;
182} 182}
@@ -187,7 +187,7 @@ goal_in_my_reservation(struct ext3_reserve_window *rsv, int goal,
187 * Returns NULL if there are no windows or if all windows start after the goal. 187 * Returns NULL if there are no windows or if all windows start after the goal.
188 */ 188 */
189static struct ext3_reserve_window_node * 189static struct ext3_reserve_window_node *
190search_reserve_window(struct rb_root *root, unsigned long goal) 190search_reserve_window(struct rb_root *root, ext3_fsblk_t goal)
191{ 191{
192 struct rb_node *n = root->rb_node; 192 struct rb_node *n = root->rb_node;
193 struct ext3_reserve_window_node *rsv; 193 struct ext3_reserve_window_node *rsv;
@@ -223,7 +223,7 @@ void ext3_rsv_window_add(struct super_block *sb,
223{ 223{
224 struct rb_root *root = &EXT3_SB(sb)->s_rsv_window_root; 224 struct rb_root *root = &EXT3_SB(sb)->s_rsv_window_root;
225 struct rb_node *node = &rsv->rsv_node; 225 struct rb_node *node = &rsv->rsv_node;
226 unsigned int start = rsv->rsv_start; 226 ext3_fsblk_t start = rsv->rsv_start;
227 227
228 struct rb_node ** p = &root->rb_node; 228 struct rb_node ** p = &root->rb_node;
229 struct rb_node * parent = NULL; 229 struct rb_node * parent = NULL;
@@ -310,20 +310,20 @@ void ext3_discard_reservation(struct inode *inode)
310 310
311/* Free given blocks, update quota and i_blocks field */ 311/* Free given blocks, update quota and i_blocks field */
312void ext3_free_blocks_sb(handle_t *handle, struct super_block *sb, 312void ext3_free_blocks_sb(handle_t *handle, struct super_block *sb,
313 unsigned long block, unsigned long count, 313 ext3_fsblk_t block, unsigned long count,
314 int *pdquot_freed_blocks) 314 unsigned long *pdquot_freed_blocks)
315{ 315{
316 struct buffer_head *bitmap_bh = NULL; 316 struct buffer_head *bitmap_bh = NULL;
317 struct buffer_head *gd_bh; 317 struct buffer_head *gd_bh;
318 unsigned long block_group; 318 unsigned long block_group;
319 unsigned long bit; 319 ext3_grpblk_t bit;
320 unsigned long i; 320 unsigned long i;
321 unsigned long overflow; 321 unsigned long overflow;
322 struct ext3_group_desc * desc; 322 struct ext3_group_desc * desc;
323 struct ext3_super_block * es; 323 struct ext3_super_block * es;
324 struct ext3_sb_info *sbi; 324 struct ext3_sb_info *sbi;
325 int err = 0, ret; 325 int err = 0, ret;
326 unsigned group_freed; 326 ext3_grpblk_t group_freed;
327 327
328 *pdquot_freed_blocks = 0; 328 *pdquot_freed_blocks = 0;
329 sbi = EXT3_SB(sb); 329 sbi = EXT3_SB(sb);
@@ -333,7 +333,7 @@ void ext3_free_blocks_sb(handle_t *handle, struct super_block *sb,
333 block + count > le32_to_cpu(es->s_blocks_count)) { 333 block + count > le32_to_cpu(es->s_blocks_count)) {
334 ext3_error (sb, "ext3_free_blocks", 334 ext3_error (sb, "ext3_free_blocks",
335 "Freeing blocks not in datazone - " 335 "Freeing blocks not in datazone - "
336 "block = %lu, count = %lu", block, count); 336 "block = "E3FSBLK", count = %lu", block, count);
337 goto error_return; 337 goto error_return;
338 } 338 }
339 339
@@ -369,7 +369,7 @@ do_more:
369 sbi->s_itb_per_group)) 369 sbi->s_itb_per_group))
370 ext3_error (sb, "ext3_free_blocks", 370 ext3_error (sb, "ext3_free_blocks",
371 "Freeing blocks in system zones - " 371 "Freeing blocks in system zones - "
372 "Block = %lu, count = %lu", 372 "Block = "E3FSBLK", count = %lu",
373 block, count); 373 block, count);
374 374
375 /* 375 /*
@@ -453,7 +453,8 @@ do_more:
453 bit + i, bitmap_bh->b_data)) { 453 bit + i, bitmap_bh->b_data)) {
454 jbd_unlock_bh_state(bitmap_bh); 454 jbd_unlock_bh_state(bitmap_bh);
455 ext3_error(sb, __FUNCTION__, 455 ext3_error(sb, __FUNCTION__,
456 "bit already cleared for block %lu", block + i); 456 "bit already cleared for block "E3FSBLK,
457 block + i);
457 jbd_lock_bh_state(bitmap_bh); 458 jbd_lock_bh_state(bitmap_bh);
458 BUFFER_TRACE(bitmap_bh, "bit already cleared"); 459 BUFFER_TRACE(bitmap_bh, "bit already cleared");
459 } else { 460 } else {
@@ -493,10 +494,10 @@ error_return:
493 494
494/* Free given blocks, update quota and i_blocks field */ 495/* Free given blocks, update quota and i_blocks field */
495void ext3_free_blocks(handle_t *handle, struct inode *inode, 496void ext3_free_blocks(handle_t *handle, struct inode *inode,
496 unsigned long block, unsigned long count) 497 ext3_fsblk_t block, unsigned long count)
497{ 498{
498 struct super_block * sb; 499 struct super_block * sb;
499 int dquot_freed_blocks; 500 unsigned long dquot_freed_blocks;
500 501
501 sb = inode->i_sb; 502 sb = inode->i_sb;
502 if (!sb) { 503 if (!sb) {
@@ -525,7 +526,7 @@ void ext3_free_blocks(handle_t *handle, struct inode *inode,
525 * data-writes at some point, and disable it for metadata allocations or 526 * data-writes at some point, and disable it for metadata allocations or
526 * sync-data inodes. 527 * sync-data inodes.
527 */ 528 */
528static int ext3_test_allocatable(int nr, struct buffer_head *bh) 529static int ext3_test_allocatable(ext3_grpblk_t nr, struct buffer_head *bh)
529{ 530{
530 int ret; 531 int ret;
531 struct journal_head *jh = bh2jh(bh); 532 struct journal_head *jh = bh2jh(bh);
@@ -542,11 +543,11 @@ static int ext3_test_allocatable(int nr, struct buffer_head *bh)
542 return ret; 543 return ret;
543} 544}
544 545
545static int 546static ext3_grpblk_t
546bitmap_search_next_usable_block(int start, struct buffer_head *bh, 547bitmap_search_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
547 int maxblocks) 548 ext3_grpblk_t maxblocks)
548{ 549{
549 int next; 550 ext3_grpblk_t next;
550 struct journal_head *jh = bh2jh(bh); 551 struct journal_head *jh = bh2jh(bh);
551 552
552 /* 553 /*
@@ -576,10 +577,11 @@ bitmap_search_next_usable_block(int start, struct buffer_head *bh,
576 * the initial goal; then for a free byte somewhere in the bitmap; then 577 * the initial goal; then for a free byte somewhere in the bitmap; then
577 * for any free bit in the bitmap. 578 * for any free bit in the bitmap.
578 */ 579 */
579static int 580static ext3_grpblk_t
580find_next_usable_block(int start, struct buffer_head *bh, int maxblocks) 581find_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
582 ext3_grpblk_t maxblocks)
581{ 583{
582 int here, next; 584 ext3_grpblk_t here, next;
583 char *p, *r; 585 char *p, *r;
584 586
585 if (start > 0) { 587 if (start > 0) {
@@ -591,7 +593,7 @@ find_next_usable_block(int start, struct buffer_head *bh, int maxblocks)
591 * less than EXT3_BLOCKS_PER_GROUP. Aligning up to the 593 * less than EXT3_BLOCKS_PER_GROUP. Aligning up to the
592 * next 64-bit boundary is simple.. 594 * next 64-bit boundary is simple..
593 */ 595 */
594 int end_goal = (start + 63) & ~63; 596 ext3_grpblk_t end_goal = (start + 63) & ~63;
595 if (end_goal > maxblocks) 597 if (end_goal > maxblocks)
596 end_goal = maxblocks; 598 end_goal = maxblocks;
597 here = ext3_find_next_zero_bit(bh->b_data, end_goal, start); 599 here = ext3_find_next_zero_bit(bh->b_data, end_goal, start);
@@ -628,7 +630,7 @@ find_next_usable_block(int start, struct buffer_head *bh, int maxblocks)
628 * zero (failure). 630 * zero (failure).
629 */ 631 */
630static inline int 632static inline int
631claim_block(spinlock_t *lock, int block, struct buffer_head *bh) 633claim_block(spinlock_t *lock, ext3_grpblk_t block, struct buffer_head *bh)
632{ 634{
633 struct journal_head *jh = bh2jh(bh); 635 struct journal_head *jh = bh2jh(bh);
634 int ret; 636 int ret;
@@ -651,12 +653,13 @@ claim_block(spinlock_t *lock, int block, struct buffer_head *bh)
651 * new bitmap. In that case we must release write access to the old one via 653 * new bitmap. In that case we must release write access to the old one via
652 * ext3_journal_release_buffer(), else we'll run out of credits. 654 * ext3_journal_release_buffer(), else we'll run out of credits.
653 */ 655 */
654static int 656static ext3_grpblk_t
655ext3_try_to_allocate(struct super_block *sb, handle_t *handle, int group, 657ext3_try_to_allocate(struct super_block *sb, handle_t *handle, int group,
656 struct buffer_head *bitmap_bh, int goal, 658 struct buffer_head *bitmap_bh, ext3_grpblk_t grp_goal,
657 unsigned long *count, struct ext3_reserve_window *my_rsv) 659 unsigned long *count, struct ext3_reserve_window *my_rsv)
658{ 660{
659 int group_first_block, start, end; 661 ext3_fsblk_t group_first_block;
662 ext3_grpblk_t start, end;
660 unsigned long num = 0; 663 unsigned long num = 0;
661 664
662 /* we do allocation within the reservation window if we have a window */ 665 /* we do allocation within the reservation window if we have a window */
@@ -673,13 +676,13 @@ ext3_try_to_allocate(struct super_block *sb, handle_t *handle, int group,
673 if (end > EXT3_BLOCKS_PER_GROUP(sb)) 676 if (end > EXT3_BLOCKS_PER_GROUP(sb))
674 /* reservation window crosses group boundary */ 677 /* reservation window crosses group boundary */
675 end = EXT3_BLOCKS_PER_GROUP(sb); 678 end = EXT3_BLOCKS_PER_GROUP(sb);
676 if ((start <= goal) && (goal < end)) 679 if ((start <= grp_goal) && (grp_goal < end))
677 start = goal; 680 start = grp_goal;
678 else 681 else
679 goal = -1; 682 grp_goal = -1;
680 } else { 683 } else {
681 if (goal > 0) 684 if (grp_goal > 0)
682 start = goal; 685 start = grp_goal;
683 else 686 else
684 start = 0; 687 start = 0;
685 end = EXT3_BLOCKS_PER_GROUP(sb); 688 end = EXT3_BLOCKS_PER_GROUP(sb);
@@ -688,43 +691,43 @@ ext3_try_to_allocate(struct super_block *sb, handle_t *handle, int group,
688 BUG_ON(start > EXT3_BLOCKS_PER_GROUP(sb)); 691 BUG_ON(start > EXT3_BLOCKS_PER_GROUP(sb));
689 692
690repeat: 693repeat:
691 if (goal < 0 || !ext3_test_allocatable(goal, bitmap_bh)) { 694 if (grp_goal < 0 || !ext3_test_allocatable(grp_goal, bitmap_bh)) {
692 goal = find_next_usable_block(start, bitmap_bh, end); 695 grp_goal = find_next_usable_block(start, bitmap_bh, end);
693 if (goal < 0) 696 if (grp_goal < 0)
694 goto fail_access; 697 goto fail_access;
695 if (!my_rsv) { 698 if (!my_rsv) {
696 int i; 699 int i;
697 700
698 for (i = 0; i < 7 && goal > start && 701 for (i = 0; i < 7 && grp_goal > start &&
699 ext3_test_allocatable(goal - 1, 702 ext3_test_allocatable(grp_goal - 1,
700 bitmap_bh); 703 bitmap_bh);
701 i++, goal--) 704 i++, grp_goal--)
702 ; 705 ;
703 } 706 }
704 } 707 }
705 start = goal; 708 start = grp_goal;
706 709
707 if (!claim_block(sb_bgl_lock(EXT3_SB(sb), group), goal, bitmap_bh)) { 710 if (!claim_block(sb_bgl_lock(EXT3_SB(sb), group), grp_goal, bitmap_bh)) {
708 /* 711 /*
709 * The block was allocated by another thread, or it was 712 * The block was allocated by another thread, or it was
710 * allocated and then freed by another thread 713 * allocated and then freed by another thread
711 */ 714 */
712 start++; 715 start++;
713 goal++; 716 grp_goal++;
714 if (start >= end) 717 if (start >= end)
715 goto fail_access; 718 goto fail_access;
716 goto repeat; 719 goto repeat;
717 } 720 }
718 num++; 721 num++;
719 goal++; 722 grp_goal++;
720 while (num < *count && goal < end 723 while (num < *count && grp_goal < end
721 && ext3_test_allocatable(goal, bitmap_bh) 724 && ext3_test_allocatable(grp_goal, bitmap_bh)
722 && claim_block(sb_bgl_lock(EXT3_SB(sb), group), goal, bitmap_bh)) { 725 && claim_block(sb_bgl_lock(EXT3_SB(sb), group), grp_goal, bitmap_bh)) {
723 num++; 726 num++;
724 goal++; 727 grp_goal++;
725 } 728 }
726 *count = num; 729 *count = num;
727 return goal - num; 730 return grp_goal - num;
728fail_access: 731fail_access:
729 *count = num; 732 *count = num;
730 return -1; 733 return -1;
@@ -766,12 +769,13 @@ fail_access:
766static int find_next_reservable_window( 769static int find_next_reservable_window(
767 struct ext3_reserve_window_node *search_head, 770 struct ext3_reserve_window_node *search_head,
768 struct ext3_reserve_window_node *my_rsv, 771 struct ext3_reserve_window_node *my_rsv,
769 struct super_block * sb, int start_block, 772 struct super_block * sb,
770 int last_block) 773 ext3_fsblk_t start_block,
774 ext3_fsblk_t last_block)
771{ 775{
772 struct rb_node *next; 776 struct rb_node *next;
773 struct ext3_reserve_window_node *rsv, *prev; 777 struct ext3_reserve_window_node *rsv, *prev;
774 int cur; 778 ext3_fsblk_t cur;
775 int size = my_rsv->rsv_goal_size; 779 int size = my_rsv->rsv_goal_size;
776 780
777 /* TODO: make the start of the reservation window byte-aligned */ 781 /* TODO: make the start of the reservation window byte-aligned */
@@ -873,10 +877,10 @@ static int find_next_reservable_window(
873 * 877 *
874 * @rsv: the reservation 878 * @rsv: the reservation
875 * 879 *
876 * @goal: The goal (group-relative). It is where the search for a 880 * @grp_goal: The goal (group-relative). It is where the search for a
877 * free reservable space should start from. 881 * free reservable space should start from.
878 * if we have a goal(goal >0 ), then start from there, 882 * if we have a grp_goal(grp_goal >0 ), then start from there,
879 * no goal(goal = -1), we start from the first block 883 * no grp_goal(grp_goal = -1), we start from the first block
880 * of the group. 884 * of the group.
881 * 885 *
882 * @sb: the super block 886 * @sb: the super block
@@ -885,12 +889,12 @@ static int find_next_reservable_window(
885 * 889 *
886 */ 890 */
887static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv, 891static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv,
888 int goal, struct super_block *sb, 892 ext3_grpblk_t grp_goal, struct super_block *sb,
889 unsigned int group, struct buffer_head *bitmap_bh) 893 unsigned int group, struct buffer_head *bitmap_bh)
890{ 894{
891 struct ext3_reserve_window_node *search_head; 895 struct ext3_reserve_window_node *search_head;
892 int group_first_block, group_end_block, start_block; 896 ext3_fsblk_t group_first_block, group_end_block, start_block;
893 int first_free_block; 897 ext3_grpblk_t first_free_block;
894 struct rb_root *fs_rsv_root = &EXT3_SB(sb)->s_rsv_window_root; 898 struct rb_root *fs_rsv_root = &EXT3_SB(sb)->s_rsv_window_root;
895 unsigned long size; 899 unsigned long size;
896 int ret; 900 int ret;
@@ -900,10 +904,10 @@ static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv,
900 group * EXT3_BLOCKS_PER_GROUP(sb); 904 group * EXT3_BLOCKS_PER_GROUP(sb);
901 group_end_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1; 905 group_end_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1;
902 906
903 if (goal < 0) 907 if (grp_goal < 0)
904 start_block = group_first_block; 908 start_block = group_first_block;
905 else 909 else
906 start_block = goal + group_first_block; 910 start_block = grp_goal + group_first_block;
907 911
908 size = my_rsv->rsv_goal_size; 912 size = my_rsv->rsv_goal_size;
909 913
@@ -1057,14 +1061,15 @@ static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv,
1057 * sorted double linked list should be fast. 1061 * sorted double linked list should be fast.
1058 * 1062 *
1059 */ 1063 */
1060static int 1064static ext3_grpblk_t
1061ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle, 1065ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1062 unsigned int group, struct buffer_head *bitmap_bh, 1066 unsigned int group, struct buffer_head *bitmap_bh,
1063 int goal, struct ext3_reserve_window_node * my_rsv, 1067 ext3_grpblk_t grp_goal,
1068 struct ext3_reserve_window_node * my_rsv,
1064 unsigned long *count, int *errp) 1069 unsigned long *count, int *errp)
1065{ 1070{
1066 unsigned long group_first_block; 1071 ext3_fsblk_t group_first_block;
1067 int ret = 0; 1072 ext3_grpblk_t ret = 0;
1068 int fatal; 1073 int fatal;
1069 unsigned long num = *count; 1074 unsigned long num = *count;
1070 1075
@@ -1090,12 +1095,12 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1090 */ 1095 */
1091 if (my_rsv == NULL ) { 1096 if (my_rsv == NULL ) {
1092 ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh, 1097 ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh,
1093 goal, count, NULL); 1098 grp_goal, count, NULL);
1094 goto out; 1099 goto out;
1095 } 1100 }
1096 /* 1101 /*
1097 * goal is a group relative block number (if there is a goal) 1102 * grp_goal is a group relative block number (if there is a goal)
1098 * 0 < goal < EXT3_BLOCKS_PER_GROUP(sb) 1103 * 0 < grp_goal < EXT3_BLOCKS_PER_GROUP(sb)
1099 * first block is a filesystem wide block number 1104 * first block is a filesystem wide block number
1100 * first block is the block number of the first block in this group 1105 * first block is the block number of the first block in this group
1101 */ 1106 */
@@ -1119,24 +1124,24 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1119 */ 1124 */
1120 while (1) { 1125 while (1) {
1121 if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) || 1126 if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) ||
1122 !goal_in_my_reservation(&my_rsv->rsv_window, goal, group, sb)) { 1127 !goal_in_my_reservation(&my_rsv->rsv_window, grp_goal, group, sb)) {
1123 if (my_rsv->rsv_goal_size < *count) 1128 if (my_rsv->rsv_goal_size < *count)
1124 my_rsv->rsv_goal_size = *count; 1129 my_rsv->rsv_goal_size = *count;
1125 ret = alloc_new_reservation(my_rsv, goal, sb, 1130 ret = alloc_new_reservation(my_rsv, grp_goal, sb,
1126 group, bitmap_bh); 1131 group, bitmap_bh);
1127 if (ret < 0) 1132 if (ret < 0)
1128 break; /* failed */ 1133 break; /* failed */
1129 1134
1130 if (!goal_in_my_reservation(&my_rsv->rsv_window, goal, group, sb)) 1135 if (!goal_in_my_reservation(&my_rsv->rsv_window, grp_goal, group, sb))
1131 goal = -1; 1136 grp_goal = -1;
1132 } else if (goal > 0 && (my_rsv->rsv_end-goal+1) < *count) 1137 } else if (grp_goal > 0 && (my_rsv->rsv_end-grp_goal+1) < *count)
1133 try_to_extend_reservation(my_rsv, sb, 1138 try_to_extend_reservation(my_rsv, sb,
1134 *count-my_rsv->rsv_end + goal - 1); 1139 *count-my_rsv->rsv_end + grp_goal - 1);
1135 1140
1136 if ((my_rsv->rsv_start >= group_first_block + EXT3_BLOCKS_PER_GROUP(sb)) 1141 if ((my_rsv->rsv_start >= group_first_block + EXT3_BLOCKS_PER_GROUP(sb))
1137 || (my_rsv->rsv_end < group_first_block)) 1142 || (my_rsv->rsv_end < group_first_block))
1138 BUG(); 1143 BUG();
1139 ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh, goal, 1144 ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh, grp_goal,
1140 &num, &my_rsv->rsv_window); 1145 &num, &my_rsv->rsv_window);
1141 if (ret >= 0) { 1146 if (ret >= 0) {
1142 my_rsv->rsv_alloc_hit += num; 1147 my_rsv->rsv_alloc_hit += num;
@@ -1164,7 +1169,7 @@ out:
1164 1169
1165static int ext3_has_free_blocks(struct ext3_sb_info *sbi) 1170static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
1166{ 1171{
1167 int free_blocks, root_blocks; 1172 ext3_fsblk_t free_blocks, root_blocks;
1168 1173
1169 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter); 1174 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
1170 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count); 1175 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
@@ -1200,19 +1205,20 @@ int ext3_should_retry_alloc(struct super_block *sb, int *retries)
1200 * bitmap, and then for any free bit if that fails. 1205 * bitmap, and then for any free bit if that fails.
1201 * This function also updates quota and i_blocks field. 1206 * This function also updates quota and i_blocks field.
1202 */ 1207 */
1203int ext3_new_blocks(handle_t *handle, struct inode *inode, 1208ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
1204 unsigned long goal, unsigned long *count, int *errp) 1209 ext3_fsblk_t goal, unsigned long *count, int *errp)
1205{ 1210{
1206 struct buffer_head *bitmap_bh = NULL; 1211 struct buffer_head *bitmap_bh = NULL;
1207 struct buffer_head *gdp_bh; 1212 struct buffer_head *gdp_bh;
1208 int group_no; 1213 int group_no;
1209 int goal_group; 1214 int goal_group;
1210 int ret_block; 1215 ext3_grpblk_t grp_target_blk; /* blockgroup relative goal block */
1216 ext3_grpblk_t grp_alloc_blk; /* blockgroup-relative allocated block*/
1217 ext3_fsblk_t ret_block; /* filesyetem-wide allocated block */
1211 int bgi; /* blockgroup iteration index */ 1218 int bgi; /* blockgroup iteration index */
1212 int target_block;
1213 int fatal = 0, err; 1219 int fatal = 0, err;
1214 int performed_allocation = 0; 1220 int performed_allocation = 0;
1215 int free_blocks; 1221 ext3_grpblk_t free_blocks; /* number of free blocks in a group */
1216 struct super_block *sb; 1222 struct super_block *sb;
1217 struct ext3_group_desc *gdp; 1223 struct ext3_group_desc *gdp;
1218 struct ext3_super_block *es; 1224 struct ext3_super_block *es;
@@ -1285,16 +1291,17 @@ retry:
1285 my_rsv = NULL; 1291 my_rsv = NULL;
1286 1292
1287 if (free_blocks > 0) { 1293 if (free_blocks > 0) {
1288 ret_block = ((goal - le32_to_cpu(es->s_first_data_block)) % 1294 grp_target_blk = ((goal - le32_to_cpu(es->s_first_data_block)) %
1289 EXT3_BLOCKS_PER_GROUP(sb)); 1295 EXT3_BLOCKS_PER_GROUP(sb));
1290 bitmap_bh = read_block_bitmap(sb, group_no); 1296 bitmap_bh = read_block_bitmap(sb, group_no);
1291 if (!bitmap_bh) 1297 if (!bitmap_bh)
1292 goto io_error; 1298 goto io_error;
1293 ret_block = ext3_try_to_allocate_with_rsv(sb, handle, group_no, 1299 grp_alloc_blk = ext3_try_to_allocate_with_rsv(sb, handle,
1294 bitmap_bh, ret_block, my_rsv, &num, &fatal); 1300 group_no, bitmap_bh, grp_target_blk,
1301 my_rsv, &num, &fatal);
1295 if (fatal) 1302 if (fatal)
1296 goto out; 1303 goto out;
1297 if (ret_block >= 0) 1304 if (grp_alloc_blk >= 0)
1298 goto allocated; 1305 goto allocated;
1299 } 1306 }
1300 1307
@@ -1327,11 +1334,15 @@ retry:
1327 bitmap_bh = read_block_bitmap(sb, group_no); 1334 bitmap_bh = read_block_bitmap(sb, group_no);
1328 if (!bitmap_bh) 1335 if (!bitmap_bh)
1329 goto io_error; 1336 goto io_error;
1330 ret_block = ext3_try_to_allocate_with_rsv(sb, handle, group_no, 1337 /*
1331 bitmap_bh, -1, my_rsv, &num, &fatal); 1338 * try to allocate block(s) from this group, without a goal(-1).
1339 */
1340 grp_alloc_blk = ext3_try_to_allocate_with_rsv(sb, handle,
1341 group_no, bitmap_bh, -1, my_rsv,
1342 &num, &fatal);
1332 if (fatal) 1343 if (fatal)
1333 goto out; 1344 goto out;
1334 if (ret_block >= 0) 1345 if (grp_alloc_blk >= 0)
1335 goto allocated; 1346 goto allocated;
1336 } 1347 }
1337 /* 1348 /*
@@ -1360,18 +1371,19 @@ allocated:
1360 if (fatal) 1371 if (fatal)
1361 goto out; 1372 goto out;
1362 1373
1363 target_block = ret_block + group_no * EXT3_BLOCKS_PER_GROUP(sb) 1374 ret_block = grp_alloc_blk + group_no * EXT3_BLOCKS_PER_GROUP(sb)
1364 + le32_to_cpu(es->s_first_data_block); 1375 + le32_to_cpu(es->s_first_data_block);
1365 1376
1366 if (in_range(le32_to_cpu(gdp->bg_block_bitmap), target_block, num) || 1377 if (in_range(le32_to_cpu(gdp->bg_block_bitmap), ret_block, num) ||
1367 in_range(le32_to_cpu(gdp->bg_inode_bitmap), target_block, num) || 1378 in_range(le32_to_cpu(gdp->bg_inode_bitmap), ret_block, num) ||
1368 in_range(target_block, le32_to_cpu(gdp->bg_inode_table), 1379 in_range(ret_block, le32_to_cpu(gdp->bg_inode_table),
1369 EXT3_SB(sb)->s_itb_per_group) || 1380 EXT3_SB(sb)->s_itb_per_group) ||
1370 in_range(target_block + num - 1, le32_to_cpu(gdp->bg_inode_table), 1381 in_range(ret_block + num - 1, le32_to_cpu(gdp->bg_inode_table),
1371 EXT3_SB(sb)->s_itb_per_group)) 1382 EXT3_SB(sb)->s_itb_per_group))
1372 ext3_error(sb, "ext3_new_block", 1383 ext3_error(sb, "ext3_new_block",
1373 "Allocating block in system zone - " 1384 "Allocating block in system zone - "
1374 "blocks from %u, length %lu", target_block, num); 1385 "blocks from "E3FSBLK", length %lu",
1386 ret_block, num);
1375 1387
1376 performed_allocation = 1; 1388 performed_allocation = 1;
1377 1389
@@ -1380,7 +1392,7 @@ allocated:
1380 struct buffer_head *debug_bh; 1392 struct buffer_head *debug_bh;
1381 1393
1382 /* Record bitmap buffer state in the newly allocated block */ 1394 /* Record bitmap buffer state in the newly allocated block */
1383 debug_bh = sb_find_get_block(sb, target_block); 1395 debug_bh = sb_find_get_block(sb, ret_block);
1384 if (debug_bh) { 1396 if (debug_bh) {
1385 BUFFER_TRACE(debug_bh, "state when allocated"); 1397 BUFFER_TRACE(debug_bh, "state when allocated");
1386 BUFFER_TRACE2(debug_bh, bitmap_bh, "bitmap state"); 1398 BUFFER_TRACE2(debug_bh, bitmap_bh, "bitmap state");
@@ -1393,24 +1405,21 @@ allocated:
1393 int i; 1405 int i;
1394 1406
1395 for (i = 0; i < num; i++) { 1407 for (i = 0; i < num; i++) {
1396 if (ext3_test_bit(ret_block, 1408 if (ext3_test_bit(grp_alloc_blk+i,
1397 bh2jh(bitmap_bh)->b_committed_data)) { 1409 bh2jh(bitmap_bh)->b_committed_data)) {
1398 printk("%s: block was unexpectedly set in " 1410 printk("%s: block was unexpectedly set in "
1399 "b_committed_data\n", __FUNCTION__); 1411 "b_committed_data\n", __FUNCTION__);
1400 } 1412 }
1401 } 1413 }
1402 } 1414 }
1403 ext3_debug("found bit %d\n", ret_block); 1415 ext3_debug("found bit %d\n", grp_alloc_blk);
1404 spin_unlock(sb_bgl_lock(sbi, group_no)); 1416 spin_unlock(sb_bgl_lock(sbi, group_no));
1405 jbd_unlock_bh_state(bitmap_bh); 1417 jbd_unlock_bh_state(bitmap_bh);
1406#endif 1418#endif
1407 1419
1408 /* ret_block was blockgroup-relative. Now it becomes fs-relative */
1409 ret_block = target_block;
1410
1411 if (ret_block + num - 1 >= le32_to_cpu(es->s_blocks_count)) { 1420 if (ret_block + num - 1 >= le32_to_cpu(es->s_blocks_count)) {
1412 ext3_error(sb, "ext3_new_block", 1421 ext3_error(sb, "ext3_new_block",
1413 "block(%d) >= blocks count(%d) - " 1422 "block("E3FSBLK") >= blocks count(%d) - "
1414 "block_group = %d, es == %p ", ret_block, 1423 "block_group = %d, es == %p ", ret_block,
1415 le32_to_cpu(es->s_blocks_count), group_no, es); 1424 le32_to_cpu(es->s_blocks_count), group_no, es);
1416 goto out; 1425 goto out;
@@ -1421,7 +1430,7 @@ allocated:
1421 * list of some description. We don't know in advance whether 1430 * list of some description. We don't know in advance whether
1422 * the caller wants to use it as metadata or data. 1431 * the caller wants to use it as metadata or data.
1423 */ 1432 */
1424 ext3_debug("allocating block %d. Goal hits %d of %d.\n", 1433 ext3_debug("allocating block %lu. Goal hits %d of %d.\n",
1425 ret_block, goal_hits, goal_attempts); 1434 ret_block, goal_hits, goal_attempts);
1426 1435
1427 spin_lock(sb_bgl_lock(sbi, group_no)); 1436 spin_lock(sb_bgl_lock(sbi, group_no));
@@ -1461,8 +1470,8 @@ out:
1461 return 0; 1470 return 0;
1462} 1471}
1463 1472
1464int ext3_new_block(handle_t *handle, struct inode *inode, 1473ext3_fsblk_t ext3_new_block(handle_t *handle, struct inode *inode,
1465 unsigned long goal, int *errp) 1474 ext3_fsblk_t goal, int *errp)
1466{ 1475{
1467 unsigned long count = 1; 1476 unsigned long count = 1;
1468 1477
@@ -1520,7 +1529,7 @@ unsigned long ext3_count_free_blocks(struct super_block *sb)
1520} 1529}
1521 1530
1522static inline int 1531static inline int
1523block_in_use(unsigned long block, struct super_block *sb, unsigned char *map) 1532block_in_use(ext3_fsblk_t block, struct super_block *sb, unsigned char *map)
1524{ 1533{
1525 return ext3_test_bit ((block - 1534 return ext3_test_bit ((block -
1526 le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block)) % 1535 le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block)) %
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index dc826464f313..36546ed36a14 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -262,9 +262,11 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
262 int ngroups = sbi->s_groups_count; 262 int ngroups = sbi->s_groups_count;
263 int inodes_per_group = EXT3_INODES_PER_GROUP(sb); 263 int inodes_per_group = EXT3_INODES_PER_GROUP(sb);
264 int freei, avefreei; 264 int freei, avefreei;
265 int freeb, avefreeb; 265 ext3_fsblk_t freeb, avefreeb;
266 int blocks_per_dir, ndirs; 266 ext3_fsblk_t blocks_per_dir;
267 int max_debt, max_dirs, min_blocks, min_inodes; 267 int ndirs;
268 int max_debt, max_dirs, min_inodes;
269 ext3_grpblk_t min_blocks;
268 int group = -1, i; 270 int group = -1, i;
269 struct ext3_group_desc *desc; 271 struct ext3_group_desc *desc;
270 struct buffer_head *bh; 272 struct buffer_head *bh;
@@ -307,7 +309,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
307 min_inodes = avefreei - inodes_per_group / 4; 309 min_inodes = avefreei - inodes_per_group / 4;
308 min_blocks = avefreeb - EXT3_BLOCKS_PER_GROUP(sb) / 4; 310 min_blocks = avefreeb - EXT3_BLOCKS_PER_GROUP(sb) / 4;
309 311
310 max_debt = EXT3_BLOCKS_PER_GROUP(sb) / max(blocks_per_dir, BLOCK_COST); 312 max_debt = EXT3_BLOCKS_PER_GROUP(sb) / max(blocks_per_dir, (ext3_fsblk_t)BLOCK_COST);
311 if (max_debt * INODE_COST > inodes_per_group) 313 if (max_debt * INODE_COST > inodes_per_group)
312 max_debt = inodes_per_group / INODE_COST; 314 max_debt = inodes_per_group / INODE_COST;
313 if (max_debt > 255) 315 if (max_debt > 255)
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 2edd7eec88fd..b02bc32c57a4 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -62,7 +62,7 @@ static int ext3_inode_is_fast_symlink(struct inode *inode)
62 * still needs to be revoked. 62 * still needs to be revoked.
63 */ 63 */
64int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode, 64int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode,
65 struct buffer_head *bh, int blocknr) 65 struct buffer_head *bh, ext3_fsblk_t blocknr)
66{ 66{
67 int err; 67 int err;
68 68
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index a31dff81ed77..82c678e92682 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -28,16 +28,16 @@ static int verify_group_input(struct super_block *sb,
28{ 28{
29 struct ext3_sb_info *sbi = EXT3_SB(sb); 29 struct ext3_sb_info *sbi = EXT3_SB(sb);
30 struct ext3_super_block *es = sbi->s_es; 30 struct ext3_super_block *es = sbi->s_es;
31 unsigned start = le32_to_cpu(es->s_blocks_count); 31 ext3_fsblk_t start = le32_to_cpu(es->s_blocks_count);
32 unsigned end = start + input->blocks_count; 32 ext3_fsblk_t end = start + input->blocks_count;
33 unsigned group = input->group; 33 unsigned group = input->group;
34 unsigned itend = input->inode_table + sbi->s_itb_per_group; 34 ext3_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
35 unsigned overhead = ext3_bg_has_super(sb, group) ? 35 unsigned overhead = ext3_bg_has_super(sb, group) ?
36 (1 + ext3_bg_num_gdb(sb, group) + 36 (1 + ext3_bg_num_gdb(sb, group) +
37 le16_to_cpu(es->s_reserved_gdt_blocks)) : 0; 37 le16_to_cpu(es->s_reserved_gdt_blocks)) : 0;
38 unsigned metaend = start + overhead; 38 ext3_fsblk_t metaend = start + overhead;
39 struct buffer_head *bh = NULL; 39 struct buffer_head *bh = NULL;
40 int free_blocks_count; 40 ext3_grpblk_t free_blocks_count;
41 int err = -EINVAL; 41 int err = -EINVAL;
42 42
43 input->free_blocks_count = free_blocks_count = 43 input->free_blocks_count = free_blocks_count =
@@ -64,7 +64,8 @@ static int verify_group_input(struct super_block *sb,
64 ext3_warning(sb, __FUNCTION__, "Bad blocks count %u", 64 ext3_warning(sb, __FUNCTION__, "Bad blocks count %u",
65 input->blocks_count); 65 input->blocks_count);
66 else if (!(bh = sb_bread(sb, end - 1))) 66 else if (!(bh = sb_bread(sb, end - 1)))
67 ext3_warning(sb, __FUNCTION__, "Cannot read last block (%u)", 67 ext3_warning(sb, __FUNCTION__,
68 "Cannot read last block ("E3FSBLK")",
68 end - 1); 69 end - 1);
69 else if (outside(input->block_bitmap, start, end)) 70 else if (outside(input->block_bitmap, start, end))
70 ext3_warning(sb, __FUNCTION__, 71 ext3_warning(sb, __FUNCTION__,
@@ -77,7 +78,7 @@ static int verify_group_input(struct super_block *sb,
77 else if (outside(input->inode_table, start, end) || 78 else if (outside(input->inode_table, start, end) ||
78 outside(itend - 1, start, end)) 79 outside(itend - 1, start, end))
79 ext3_warning(sb, __FUNCTION__, 80 ext3_warning(sb, __FUNCTION__,
80 "Inode table not in group (blocks %u-%u)", 81 "Inode table not in group (blocks %u-"E3FSBLK")",
81 input->inode_table, itend - 1); 82 input->inode_table, itend - 1);
82 else if (input->inode_bitmap == input->block_bitmap) 83 else if (input->inode_bitmap == input->block_bitmap)
83 ext3_warning(sb, __FUNCTION__, 84 ext3_warning(sb, __FUNCTION__,
@@ -85,24 +86,27 @@ static int verify_group_input(struct super_block *sb,
85 input->block_bitmap); 86 input->block_bitmap);
86 else if (inside(input->block_bitmap, input->inode_table, itend)) 87 else if (inside(input->block_bitmap, input->inode_table, itend))
87 ext3_warning(sb, __FUNCTION__, 88 ext3_warning(sb, __FUNCTION__,
88 "Block bitmap (%u) in inode table (%u-%u)", 89 "Block bitmap (%u) in inode table (%u-"E3FSBLK")",
89 input->block_bitmap, input->inode_table, itend-1); 90 input->block_bitmap, input->inode_table, itend-1);
90 else if (inside(input->inode_bitmap, input->inode_table, itend)) 91 else if (inside(input->inode_bitmap, input->inode_table, itend))
91 ext3_warning(sb, __FUNCTION__, 92 ext3_warning(sb, __FUNCTION__,
92 "Inode bitmap (%u) in inode table (%u-%u)", 93 "Inode bitmap (%u) in inode table (%u-"E3FSBLK")",
93 input->inode_bitmap, input->inode_table, itend-1); 94 input->inode_bitmap, input->inode_table, itend-1);
94 else if (inside(input->block_bitmap, start, metaend)) 95 else if (inside(input->block_bitmap, start, metaend))
95 ext3_warning(sb, __FUNCTION__, 96 ext3_warning(sb, __FUNCTION__,
96 "Block bitmap (%u) in GDT table (%u-%u)", 97 "Block bitmap (%u) in GDT table"
98 " ("E3FSBLK"-"E3FSBLK")",
97 input->block_bitmap, start, metaend - 1); 99 input->block_bitmap, start, metaend - 1);
98 else if (inside(input->inode_bitmap, start, metaend)) 100 else if (inside(input->inode_bitmap, start, metaend))
99 ext3_warning(sb, __FUNCTION__, 101 ext3_warning(sb, __FUNCTION__,
100 "Inode bitmap (%u) in GDT table (%u-%u)", 102 "Inode bitmap (%u) in GDT table"
103 " ("E3FSBLK"-"E3FSBLK")",
101 input->inode_bitmap, start, metaend - 1); 104 input->inode_bitmap, start, metaend - 1);
102 else if (inside(input->inode_table, start, metaend) || 105 else if (inside(input->inode_table, start, metaend) ||
103 inside(itend - 1, start, metaend)) 106 inside(itend - 1, start, metaend))
104 ext3_warning(sb, __FUNCTION__, 107 ext3_warning(sb, __FUNCTION__,
105 "Inode table (%u-%u) overlaps GDT table (%u-%u)", 108 "Inode table (%u-"E3FSBLK") overlaps"
109 "GDT table ("E3FSBLK"-"E3FSBLK")",
106 input->inode_table, itend - 1, start, metaend - 1); 110 input->inode_table, itend - 1, start, metaend - 1);
107 else 111 else
108 err = 0; 112 err = 0;
@@ -171,7 +175,7 @@ static int setup_new_group_blocks(struct super_block *sb,
171 struct buffer_head *bh; 175 struct buffer_head *bh;
172 handle_t *handle; 176 handle_t *handle;
173 unsigned long block; 177 unsigned long block;
174 int bit; 178 ext3_grpblk_t bit;
175 int i; 179 int i;
176 int err = 0, err2; 180 int err = 0, err2;
177 181
@@ -340,7 +344,7 @@ static int verify_reserved_gdb(struct super_block *sb,
340 while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) { 344 while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) {
341 if (le32_to_cpu(*p++) != grp * EXT3_BLOCKS_PER_GROUP(sb) + blk){ 345 if (le32_to_cpu(*p++) != grp * EXT3_BLOCKS_PER_GROUP(sb) + blk){
342 ext3_warning(sb, __FUNCTION__, 346 ext3_warning(sb, __FUNCTION__,
343 "reserved GDT %ld missing grp %d (%ld)", 347 "reserved GDT %lu missing grp %d (%lu)",
344 blk, grp, 348 blk, grp,
345 grp * EXT3_BLOCKS_PER_GROUP(sb) + blk); 349 grp * EXT3_BLOCKS_PER_GROUP(sb) + blk);
346 return -EINVAL; 350 return -EINVAL;
@@ -906,11 +910,12 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
906{ 910{
907 unsigned long o_blocks_count; 911 unsigned long o_blocks_count;
908 unsigned long o_groups_count; 912 unsigned long o_groups_count;
909 unsigned long last; 913 ext3_grpblk_t last;
910 int add; 914 ext3_grpblk_t add;
911 struct buffer_head * bh; 915 struct buffer_head * bh;
912 handle_t *handle; 916 handle_t *handle;
913 int err, freed_blocks; 917 int err;
918 unsigned long freed_blocks;
914 919
915 /* We don't need to worry about locking wrt other resizers just 920 /* We don't need to worry about locking wrt other resizers just
916 * yet: we're going to revalidate es->s_blocks_count after 921 * yet: we're going to revalidate es->s_blocks_count after
@@ -1001,10 +1006,10 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
1001 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); 1006 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
1002 sb->s_dirt = 1; 1007 sb->s_dirt = 1;
1003 unlock_super(sb); 1008 unlock_super(sb);
1004 ext3_debug("freeing blocks %ld through %ld\n", o_blocks_count, 1009 ext3_debug("freeing blocks %lu through %lu\n", o_blocks_count,
1005 o_blocks_count + add); 1010 o_blocks_count + add);
1006 ext3_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks); 1011 ext3_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks);
1007 ext3_debug("freed blocks %ld through %ld\n", o_blocks_count, 1012 ext3_debug("freed blocks %lu through %lu\n", o_blocks_count,
1008 o_blocks_count + add); 1013 o_blocks_count + add);
1009 if ((err = ext3_journal_stop(handle))) 1014 if ((err = ext3_journal_stop(handle)))
1010 goto exit_put; 1015 goto exit_put;
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index e0fc0c83be90..94113500fc55 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1841,7 +1841,7 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
1841 struct buffer_head * bh; 1841 struct buffer_head * bh;
1842 journal_t *journal; 1842 journal_t *journal;
1843 int start; 1843 int start;
1844 int len; 1844 ext3_fsblk_t len;
1845 int hblock, blocksize; 1845 int hblock, blocksize;
1846 unsigned long sb_block; 1846 unsigned long sb_block;
1847 unsigned long offset; 1847 unsigned long offset;
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index e8d60bf6b7df..1ba515de5a75 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -225,7 +225,7 @@ ext3_xattr_block_get(struct inode *inode, int name_index, const char *name,
225 error = -ENODATA; 225 error = -ENODATA;
226 if (!EXT3_I(inode)->i_file_acl) 226 if (!EXT3_I(inode)->i_file_acl)
227 goto cleanup; 227 goto cleanup;
228 ea_idebug(inode, "reading block %d", EXT3_I(inode)->i_file_acl); 228 ea_idebug(inode, "reading block %u", EXT3_I(inode)->i_file_acl);
229 bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl); 229 bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl);
230 if (!bh) 230 if (!bh)
231 goto cleanup; 231 goto cleanup;
@@ -233,7 +233,7 @@ ext3_xattr_block_get(struct inode *inode, int name_index, const char *name,
233 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); 233 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
234 if (ext3_xattr_check_block(bh)) { 234 if (ext3_xattr_check_block(bh)) {
235bad_block: ext3_error(inode->i_sb, __FUNCTION__, 235bad_block: ext3_error(inode->i_sb, __FUNCTION__,
236 "inode %ld: bad block %d", inode->i_ino, 236 "inode %ld: bad block %u", inode->i_ino,
237 EXT3_I(inode)->i_file_acl); 237 EXT3_I(inode)->i_file_acl);
238 error = -EIO; 238 error = -EIO;
239 goto cleanup; 239 goto cleanup;
@@ -366,7 +366,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
366 error = 0; 366 error = 0;
367 if (!EXT3_I(inode)->i_file_acl) 367 if (!EXT3_I(inode)->i_file_acl)
368 goto cleanup; 368 goto cleanup;
369 ea_idebug(inode, "reading block %d", EXT3_I(inode)->i_file_acl); 369 ea_idebug(inode, "reading block %u", EXT3_I(inode)->i_file_acl);
370 bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl); 370 bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl);
371 error = -EIO; 371 error = -EIO;
372 if (!bh) 372 if (!bh)
@@ -375,7 +375,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
375 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); 375 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
376 if (ext3_xattr_check_block(bh)) { 376 if (ext3_xattr_check_block(bh)) {
377 ext3_error(inode->i_sb, __FUNCTION__, 377 ext3_error(inode->i_sb, __FUNCTION__,
378 "inode %ld: bad block %d", inode->i_ino, 378 "inode %ld: bad block %u", inode->i_ino,
379 EXT3_I(inode)->i_file_acl); 379 EXT3_I(inode)->i_file_acl);
380 error = -EIO; 380 error = -EIO;
381 goto cleanup; 381 goto cleanup;
@@ -647,7 +647,7 @@ ext3_xattr_block_find(struct inode *inode, struct ext3_xattr_info *i,
647 le32_to_cpu(BHDR(bs->bh)->h_refcount)); 647 le32_to_cpu(BHDR(bs->bh)->h_refcount));
648 if (ext3_xattr_check_block(bs->bh)) { 648 if (ext3_xattr_check_block(bs->bh)) {
649 ext3_error(sb, __FUNCTION__, 649 ext3_error(sb, __FUNCTION__,
650 "inode %ld: bad block %d", inode->i_ino, 650 "inode %ld: bad block %u", inode->i_ino,
651 EXT3_I(inode)->i_file_acl); 651 EXT3_I(inode)->i_file_acl);
652 error = -EIO; 652 error = -EIO;
653 goto cleanup; 653 goto cleanup;
@@ -792,11 +792,12 @@ inserted:
792 get_bh(new_bh); 792 get_bh(new_bh);
793 } else { 793 } else {
794 /* We need to allocate a new block */ 794 /* We need to allocate a new block */
795 int goal = le32_to_cpu( 795 ext3_fsblk_t goal = le32_to_cpu(
796 EXT3_SB(sb)->s_es->s_first_data_block) + 796 EXT3_SB(sb)->s_es->s_first_data_block) +
797 EXT3_I(inode)->i_block_group * 797 (ext3_fsblk_t)EXT3_I(inode)->i_block_group *
798 EXT3_BLOCKS_PER_GROUP(sb); 798 EXT3_BLOCKS_PER_GROUP(sb);
799 int block = ext3_new_block(handle, inode, goal, &error); 799 ext3_fsblk_t block = ext3_new_block(handle, inode,
800 goal, &error);
800 if (error) 801 if (error)
801 goto cleanup; 802 goto cleanup;
802 ea_idebug(inode, "creating block %d", block); 803 ea_idebug(inode, "creating block %d", block);
@@ -847,7 +848,7 @@ cleanup_dquot:
847 848
848bad_block: 849bad_block:
849 ext3_error(inode->i_sb, __FUNCTION__, 850 ext3_error(inode->i_sb, __FUNCTION__,
850 "inode %ld: bad block %d", inode->i_ino, 851 "inode %ld: bad block %u", inode->i_ino,
851 EXT3_I(inode)->i_file_acl); 852 EXT3_I(inode)->i_file_acl);
852 goto cleanup; 853 goto cleanup;
853 854
@@ -1076,14 +1077,14 @@ ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
1076 bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl); 1077 bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl);
1077 if (!bh) { 1078 if (!bh) {
1078 ext3_error(inode->i_sb, __FUNCTION__, 1079 ext3_error(inode->i_sb, __FUNCTION__,
1079 "inode %ld: block %d read error", inode->i_ino, 1080 "inode %ld: block %u read error", inode->i_ino,
1080 EXT3_I(inode)->i_file_acl); 1081 EXT3_I(inode)->i_file_acl);
1081 goto cleanup; 1082 goto cleanup;
1082 } 1083 }
1083 if (BHDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) || 1084 if (BHDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
1084 BHDR(bh)->h_blocks != cpu_to_le32(1)) { 1085 BHDR(bh)->h_blocks != cpu_to_le32(1)) {
1085 ext3_error(inode->i_sb, __FUNCTION__, 1086 ext3_error(inode->i_sb, __FUNCTION__,
1086 "inode %ld: bad block %d", inode->i_ino, 1087 "inode %ld: bad block %u", inode->i_ino,
1087 EXT3_I(inode)->i_file_acl); 1088 EXT3_I(inode)->i_file_acl);
1088 goto cleanup; 1089 goto cleanup;
1089 } 1090 }
@@ -1210,11 +1211,11 @@ again:
1210 bh = sb_bread(inode->i_sb, ce->e_block); 1211 bh = sb_bread(inode->i_sb, ce->e_block);
1211 if (!bh) { 1212 if (!bh) {
1212 ext3_error(inode->i_sb, __FUNCTION__, 1213 ext3_error(inode->i_sb, __FUNCTION__,
1213 "inode %ld: block %ld read error", 1214 "inode %ld: block %lu read error",
1214 inode->i_ino, (unsigned long) ce->e_block); 1215 inode->i_ino, (unsigned long) ce->e_block);
1215 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >= 1216 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >=
1216 EXT3_XATTR_REFCOUNT_MAX) { 1217 EXT3_XATTR_REFCOUNT_MAX) {
1217 ea_idebug(inode, "block %ld refcount %d>=%d", 1218 ea_idebug(inode, "block %lu refcount %d>=%d",
1218 (unsigned long) ce->e_block, 1219 (unsigned long) ce->e_block,
1219 le32_to_cpu(BHDR(bh)->h_refcount), 1220 le32_to_cpu(BHDR(bh)->h_refcount),
1220 EXT3_XATTR_REFCOUNT_MAX); 1221 EXT3_XATTR_REFCOUNT_MAX);