aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/mballoc.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2009-01-05 22:18:16 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-01-05 22:18:16 -0500
commita9df9a49102f3578909cba7bd33784eb3b9caaa4 (patch)
tree1d383d422bf7185e8e87c1bcfc80f9beb3074cf8 /fs/ext4/mballoc.c
parentcde6436004ad9cd8cab5a874b6fa8b01f1da91bf (diff)
ext4: Make ext4_group_t be an unsigned int
Nearly all places in the ext3/4 code which uses "unsigned long" is probably a bug, since on 32-bit systems a ulong a 32-bits, which means we are wasting stack space on 64-bit systems. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r--fs/ext4/mballoc.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 6dea637b020a..6cfe68a7e070 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -447,7 +447,7 @@ static void mb_free_blocks_double(struct inode *inode, struct ext4_buddy *e4b,
447 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); 447 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
448 448
449 ext4_error(sb, __func__, "double-free of inode" 449 ext4_error(sb, __func__, "double-free of inode"
450 " %lu's block %llu(bit %u in group %lu)", 450 " %lu's block %llu(bit %u in group %u)",
451 inode ? inode->i_ino : 0, blocknr, 451 inode ? inode->i_ino : 0, blocknr,
452 first + i, e4b->bd_group); 452 first + i, e4b->bd_group);
453 } 453 }
@@ -477,7 +477,7 @@ static void mb_cmp_bitmaps(struct ext4_buddy *e4b, void *bitmap)
477 b2 = (unsigned char *) bitmap; 477 b2 = (unsigned char *) bitmap;
478 for (i = 0; i < e4b->bd_sb->s_blocksize; i++) { 478 for (i = 0; i < e4b->bd_sb->s_blocksize; i++) {
479 if (b1[i] != b2[i]) { 479 if (b1[i] != b2[i]) {
480 printk(KERN_ERR "corruption in group %lu " 480 printk(KERN_ERR "corruption in group %u "
481 "at byte %u(%u): %x in copy != %x " 481 "at byte %u(%u): %x in copy != %x "
482 "on disk/prealloc\n", 482 "on disk/prealloc\n",
483 e4b->bd_group, i, i * 8, b1[i], b2[i]); 483 e4b->bd_group, i, i * 8, b1[i], b2[i]);
@@ -691,7 +691,7 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
691 691
692 if (free != grp->bb_free) { 692 if (free != grp->bb_free) {
693 ext4_error(sb, __func__, 693 ext4_error(sb, __func__,
694 "EXT4-fs: group %lu: %u blocks in bitmap, %u in gd", 694 "EXT4-fs: group %u: %u blocks in bitmap, %u in gd",
695 group, free, grp->bb_free); 695 group, free, grp->bb_free);
696 /* 696 /*
697 * If we intent to continue, we consider group descritor 697 * If we intent to continue, we consider group descritor
@@ -800,7 +800,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore)
800 get_bh(bh[i]); 800 get_bh(bh[i]);
801 bh[i]->b_end_io = end_buffer_read_sync; 801 bh[i]->b_end_io = end_buffer_read_sync;
802 submit_bh(READ, bh[i]); 802 submit_bh(READ, bh[i]);
803 mb_debug("read bitmap for group %lu\n", first_group + i); 803 mb_debug("read bitmap for group %u\n", first_group + i);
804 } 804 }
805 805
806 /* wait for I/O completion */ 806 /* wait for I/O completion */
@@ -895,7 +895,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
895 struct page *page; 895 struct page *page;
896 int ret; 896 int ret;
897 897
898 mb_debug("load group %lu\n", group); 898 mb_debug("load group %u\n", group);
899 899
900 blocks_per_page = PAGE_CACHE_SIZE / sb->s_blocksize; 900 blocks_per_page = PAGE_CACHE_SIZE / sb->s_blocksize;
901 901
@@ -1096,7 +1096,7 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
1096 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); 1096 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
1097 ext4_unlock_group(sb, e4b->bd_group); 1097 ext4_unlock_group(sb, e4b->bd_group);
1098 ext4_error(sb, __func__, "double-free of inode" 1098 ext4_error(sb, __func__, "double-free of inode"
1099 " %lu's block %llu(bit %u in group %lu)", 1099 " %lu's block %llu(bit %u in group %u)",
1100 inode ? inode->i_ino : 0, blocknr, block, 1100 inode ? inode->i_ino : 0, blocknr, block,
1101 e4b->bd_group); 1101 e4b->bd_group);
1102 ext4_lock_group(sb, e4b->bd_group); 1102 ext4_lock_group(sb, e4b->bd_group);
@@ -1934,13 +1934,13 @@ static int ext4_mb_seq_history_show(struct seq_file *seq, void *v)
1934 if (hs->op == EXT4_MB_HISTORY_ALLOC) { 1934 if (hs->op == EXT4_MB_HISTORY_ALLOC) {
1935 fmt = "%-5u %-8u %-23s %-23s %-23s %-5u %-5u %-2u " 1935 fmt = "%-5u %-8u %-23s %-23s %-23s %-5u %-5u %-2u "
1936 "%-5u %-5s %-5u %-6u\n"; 1936 "%-5u %-5s %-5u %-6u\n";
1937 sprintf(buf2, "%lu/%d/%u@%u", hs->result.fe_group, 1937 sprintf(buf2, "%u/%d/%u@%u", hs->result.fe_group,
1938 hs->result.fe_start, hs->result.fe_len, 1938 hs->result.fe_start, hs->result.fe_len,
1939 hs->result.fe_logical); 1939 hs->result.fe_logical);
1940 sprintf(buf, "%lu/%d/%u@%u", hs->orig.fe_group, 1940 sprintf(buf, "%u/%d/%u@%u", hs->orig.fe_group,
1941 hs->orig.fe_start, hs->orig.fe_len, 1941 hs->orig.fe_start, hs->orig.fe_len,
1942 hs->orig.fe_logical); 1942 hs->orig.fe_logical);
1943 sprintf(buf3, "%lu/%d/%u@%u", hs->goal.fe_group, 1943 sprintf(buf3, "%u/%d/%u@%u", hs->goal.fe_group,
1944 hs->goal.fe_start, hs->goal.fe_len, 1944 hs->goal.fe_start, hs->goal.fe_len,
1945 hs->goal.fe_logical); 1945 hs->goal.fe_logical);
1946 seq_printf(seq, fmt, hs->pid, hs->ino, buf, buf3, buf2, 1946 seq_printf(seq, fmt, hs->pid, hs->ino, buf, buf3, buf2,
@@ -1949,20 +1949,20 @@ static int ext4_mb_seq_history_show(struct seq_file *seq, void *v)
1949 hs->buddy ? 1 << hs->buddy : 0); 1949 hs->buddy ? 1 << hs->buddy : 0);
1950 } else if (hs->op == EXT4_MB_HISTORY_PREALLOC) { 1950 } else if (hs->op == EXT4_MB_HISTORY_PREALLOC) {
1951 fmt = "%-5u %-8u %-23s %-23s %-23s\n"; 1951 fmt = "%-5u %-8u %-23s %-23s %-23s\n";
1952 sprintf(buf2, "%lu/%d/%u@%u", hs->result.fe_group, 1952 sprintf(buf2, "%u/%d/%u@%u", hs->result.fe_group,
1953 hs->result.fe_start, hs->result.fe_len, 1953 hs->result.fe_start, hs->result.fe_len,
1954 hs->result.fe_logical); 1954 hs->result.fe_logical);
1955 sprintf(buf, "%lu/%d/%u@%u", hs->orig.fe_group, 1955 sprintf(buf, "%u/%d/%u@%u", hs->orig.fe_group,
1956 hs->orig.fe_start, hs->orig.fe_len, 1956 hs->orig.fe_start, hs->orig.fe_len,
1957 hs->orig.fe_logical); 1957 hs->orig.fe_logical);
1958 seq_printf(seq, fmt, hs->pid, hs->ino, buf, "", buf2); 1958 seq_printf(seq, fmt, hs->pid, hs->ino, buf, "", buf2);
1959 } else if (hs->op == EXT4_MB_HISTORY_DISCARD) { 1959 } else if (hs->op == EXT4_MB_HISTORY_DISCARD) {
1960 sprintf(buf2, "%lu/%d/%u", hs->result.fe_group, 1960 sprintf(buf2, "%u/%d/%u", hs->result.fe_group,
1961 hs->result.fe_start, hs->result.fe_len); 1961 hs->result.fe_start, hs->result.fe_len);
1962 seq_printf(seq, "%-5u %-8u %-23s discard\n", 1962 seq_printf(seq, "%-5u %-8u %-23s discard\n",
1963 hs->pid, hs->ino, buf2); 1963 hs->pid, hs->ino, buf2);
1964 } else if (hs->op == EXT4_MB_HISTORY_FREE) { 1964 } else if (hs->op == EXT4_MB_HISTORY_FREE) {
1965 sprintf(buf2, "%lu/%d/%u", hs->result.fe_group, 1965 sprintf(buf2, "%u/%d/%u", hs->result.fe_group,
1966 hs->result.fe_start, hs->result.fe_len); 1966 hs->result.fe_start, hs->result.fe_len);
1967 seq_printf(seq, "%-5u %-8u %-23s free\n", 1967 seq_printf(seq, "%-5u %-8u %-23s free\n",
1968 hs->pid, hs->ino, buf2); 1968 hs->pid, hs->ino, buf2);
@@ -2075,7 +2075,7 @@ static void *ext4_mb_seq_groups_start(struct seq_file *seq, loff_t *pos)
2075 return NULL; 2075 return NULL;
2076 2076
2077 group = *pos + 1; 2077 group = *pos + 1;
2078 return (void *) group; 2078 return (void *) ((unsigned long) group);
2079} 2079}
2080 2080
2081static void *ext4_mb_seq_groups_next(struct seq_file *seq, void *v, loff_t *pos) 2081static void *ext4_mb_seq_groups_next(struct seq_file *seq, void *v, loff_t *pos)
@@ -2088,13 +2088,13 @@ static void *ext4_mb_seq_groups_next(struct seq_file *seq, void *v, loff_t *pos)
2088 if (*pos < 0 || *pos >= sbi->s_groups_count) 2088 if (*pos < 0 || *pos >= sbi->s_groups_count)
2089 return NULL; 2089 return NULL;
2090 group = *pos + 1; 2090 group = *pos + 1;
2091 return (void *) group;; 2091 return (void *) ((unsigned long) group);
2092} 2092}
2093 2093
2094static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) 2094static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
2095{ 2095{
2096 struct super_block *sb = seq->private; 2096 struct super_block *sb = seq->private;
2097 long group = (long) v; 2097 ext4_group_t group = (ext4_group_t) ((unsigned long) v);
2098 int i; 2098 int i;
2099 int err; 2099 int err;
2100 struct ext4_buddy e4b; 2100 struct ext4_buddy e4b;
@@ -2116,7 +2116,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
2116 sizeof(struct ext4_group_info); 2116 sizeof(struct ext4_group_info);
2117 err = ext4_mb_load_buddy(sb, group, &e4b); 2117 err = ext4_mb_load_buddy(sb, group, &e4b);
2118 if (err) { 2118 if (err) {
2119 seq_printf(seq, "#%-5lu: I/O error\n", group); 2119 seq_printf(seq, "#%-5u: I/O error\n", group);
2120 return 0; 2120 return 0;
2121 } 2121 }
2122 ext4_lock_group(sb, group); 2122 ext4_lock_group(sb, group);
@@ -2124,7 +2124,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
2124 ext4_unlock_group(sb, group); 2124 ext4_unlock_group(sb, group);
2125 ext4_mb_release_desc(&e4b); 2125 ext4_mb_release_desc(&e4b);
2126 2126
2127 seq_printf(seq, "#%-5lu: %-5u %-5u %-5u [", group, sg.info.bb_free, 2127 seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free,
2128 sg.info.bb_fragments, sg.info.bb_first_free); 2128 sg.info.bb_fragments, sg.info.bb_first_free);
2129 for (i = 0; i <= 13; i++) 2129 for (i = 0; i <= 13; i++)
2130 seq_printf(seq, " %-5u", i <= sb->s_blocksize_bits + 1 ? 2130 seq_printf(seq, " %-5u", i <= sb->s_blocksize_bits + 1 ?
@@ -2459,7 +2459,7 @@ static int ext4_mb_init_backend(struct super_block *sb)
2459 desc = ext4_get_group_desc(sb, i, NULL); 2459 desc = ext4_get_group_desc(sb, i, NULL);
2460 if (desc == NULL) { 2460 if (desc == NULL) {
2461 printk(KERN_ERR 2461 printk(KERN_ERR
2462 "EXT4-fs: can't read descriptor %lu\n", i); 2462 "EXT4-fs: can't read descriptor %u\n", i);
2463 goto err_freebuddy; 2463 goto err_freebuddy;
2464 } 2464 }
2465 if (ext4_mb_add_groupinfo(sb, i, desc) != 0) 2465 if (ext4_mb_add_groupinfo(sb, i, desc) != 0)
@@ -2657,7 +2657,7 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn)
2657 list_for_each_safe(l, ltmp, &txn->t_private_list) { 2657 list_for_each_safe(l, ltmp, &txn->t_private_list) {
2658 entry = list_entry(l, struct ext4_free_data, list); 2658 entry = list_entry(l, struct ext4_free_data, list);
2659 2659
2660 mb_debug("gonna free %u blocks in group %lu (0x%p):", 2660 mb_debug("gonna free %u blocks in group %u (0x%p):",
2661 entry->count, entry->group, entry); 2661 entry->count, entry->group, entry);
2662 2662
2663 err = ext4_mb_load_buddy(sb, entry->group, &e4b); 2663 err = ext4_mb_load_buddy(sb, entry->group, &e4b);
@@ -2829,7 +2829,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
2829 if (!gdp) 2829 if (!gdp)
2830 goto out_err; 2830 goto out_err;
2831 2831
2832 ext4_debug("using block group %lu(%d)\n", ac->ac_b_ex.fe_group, 2832 ext4_debug("using block group %u(%d)\n", ac->ac_b_ex.fe_group,
2833 gdp->bg_free_blocks_count); 2833 gdp->bg_free_blocks_count);
2834 2834
2835 err = ext4_journal_get_write_access(handle, gdp_bh); 2835 err = ext4_journal_get_write_access(handle, gdp_bh);
@@ -3351,7 +3351,7 @@ static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
3351 preallocated += len; 3351 preallocated += len;
3352 count++; 3352 count++;
3353 } 3353 }
3354 mb_debug("prellocated %u for group %lu\n", preallocated, group); 3354 mb_debug("prellocated %u for group %u\n", preallocated, group);
3355} 3355}
3356 3356
3357static void ext4_mb_pa_callback(struct rcu_head *head) 3357static void ext4_mb_pa_callback(struct rcu_head *head)
@@ -3368,7 +3368,7 @@ static void ext4_mb_pa_callback(struct rcu_head *head)
3368static void ext4_mb_put_pa(struct ext4_allocation_context *ac, 3368static void ext4_mb_put_pa(struct ext4_allocation_context *ac,
3369 struct super_block *sb, struct ext4_prealloc_space *pa) 3369 struct super_block *sb, struct ext4_prealloc_space *pa)
3370{ 3370{
3371 unsigned long grp; 3371 ext4_group_t grp;
3372 3372
3373 if (!atomic_dec_and_test(&pa->pa_count) || pa->pa_free != 0) 3373 if (!atomic_dec_and_test(&pa->pa_count) || pa->pa_free != 0)
3374 return; 3374 return;
@@ -3697,7 +3697,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
3697 int busy = 0; 3697 int busy = 0;
3698 int free = 0; 3698 int free = 0;
3699 3699
3700 mb_debug("discard preallocation for group %lu\n", group); 3700 mb_debug("discard preallocation for group %u\n", group);
3701 3701
3702 if (list_empty(&grp->bb_prealloc_list)) 3702 if (list_empty(&grp->bb_prealloc_list))
3703 return 0; 3703 return 0;
@@ -3705,14 +3705,14 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
3705 bitmap_bh = ext4_read_block_bitmap(sb, group); 3705 bitmap_bh = ext4_read_block_bitmap(sb, group);
3706 if (bitmap_bh == NULL) { 3706 if (bitmap_bh == NULL) {
3707 ext4_error(sb, __func__, "Error in reading block " 3707 ext4_error(sb, __func__, "Error in reading block "
3708 "bitmap for %lu", group); 3708 "bitmap for %u", group);
3709 return 0; 3709 return 0;
3710 } 3710 }
3711 3711
3712 err = ext4_mb_load_buddy(sb, group, &e4b); 3712 err = ext4_mb_load_buddy(sb, group, &e4b);
3713 if (err) { 3713 if (err) {
3714 ext4_error(sb, __func__, "Error in loading buddy " 3714 ext4_error(sb, __func__, "Error in loading buddy "
3715 "information for %lu", group); 3715 "information for %u", group);
3716 put_bh(bitmap_bh); 3716 put_bh(bitmap_bh);
3717 return 0; 3717 return 0;
3718 } 3718 }
@@ -3879,14 +3879,14 @@ repeat:
3879 err = ext4_mb_load_buddy(sb, group, &e4b); 3879 err = ext4_mb_load_buddy(sb, group, &e4b);
3880 if (err) { 3880 if (err) {
3881 ext4_error(sb, __func__, "Error in loading buddy " 3881 ext4_error(sb, __func__, "Error in loading buddy "
3882 "information for %lu", group); 3882 "information for %u", group);
3883 continue; 3883 continue;
3884 } 3884 }
3885 3885
3886 bitmap_bh = ext4_read_block_bitmap(sb, group); 3886 bitmap_bh = ext4_read_block_bitmap(sb, group);
3887 if (bitmap_bh == NULL) { 3887 if (bitmap_bh == NULL) {
3888 ext4_error(sb, __func__, "Error in reading block " 3888 ext4_error(sb, __func__, "Error in reading block "
3889 "bitmap for %lu", group); 3889 "bitmap for %u", group);
3890 ext4_mb_release_desc(&e4b); 3890 ext4_mb_release_desc(&e4b);
3891 continue; 3891 continue;
3892 } 3892 }
@@ -4151,7 +4151,7 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb,
4151 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL); 4151 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL);
4152 if (ext4_mb_load_buddy(sb, group, &e4b)) { 4152 if (ext4_mb_load_buddy(sb, group, &e4b)) {
4153 ext4_error(sb, __func__, "Error in loading buddy " 4153 ext4_error(sb, __func__, "Error in loading buddy "
4154 "information for %lu", group); 4154 "information for %u", group);
4155 continue; 4155 continue;
4156 } 4156 }
4157 ext4_lock_group(sb, group); 4157 ext4_lock_group(sb, group);