aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/resize.c
diff options
context:
space:
mode:
authorMingming Cao <cmm@us.ibm.com>2006-06-25 08:48:06 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:10 -0400
commit1c2bf374a4b8c2e1a3e6ff3a64fb67272a8cd2e2 (patch)
treeabb4e01a4bc146183d5cf1f0e18c1aa6e847aa5e /fs/ext3/resize.c
parentcedfb178ada245b6c52a654936b34d7996e26a1d (diff)
[PATCH] ext3_fsblk_t: filesystem, group blocks and bug fixes
Some of the in-kernel ext3 block variable type are treated as signed 4 bytes int type, thus limited ext3 filesystem to 8TB (4kblock size based). While trying to fix them, it seems quite confusing in the ext3 code where some blocks are filesystem-wide blocks, some are group relative offsets that need to be signed value (as -1 has special meaning). So it seem saner to define two types of physical blocks: one is filesystem wide blocks, another is group-relative blocks. The following patches clarify these two types of blocks in the ext3 code, and fix the type bugs which limit current 32 bit ext3 filesystem limit to 8TB. With this series of patches and the percpu counter data type changes in the mm tree, we are able to extend exts filesystem limit to 16TB. This work is also a pre-request for the recent >32 bit ext3 work, and makes the kernel to able to address 48 bit ext3 block a lot easier: Simply redefine ext3_fsblk_t from unsigned long to sector_t and redefine the format string for ext3 filesystem block corresponding. Two RFC with a series patches have been posted to ext2-devel list and have been reviewed and discussed: http://marc.theaimsgroup.com/?l=ext2-devel&m=114722190816690&w=2 http://marc.theaimsgroup.com/?l=ext2-devel&m=114784919525942&w=2 Patches are tested on both 32 bit machine and 64 bit machine, <8TB ext3 and >8TB ext3 filesystem(with the latest to be released e2fsprogs-1.39). Tests includes overnight fsx, tiobench, dbench and fsstress. This patch: Defines ext3_fsblk_t and ext3_grpblk_t, and the printk format string for filesystem wide blocks. This patch classifies all block group relative blocks, and ext3_fsblk_t blocks occurs in the same function where used to be confusing before. Also include kernel bug fixes for filesystem wide in-kernel block variables. There are some fileystem wide blocks are treated as int/unsigned int type in the kernel currently, especially in ext3 block allocation and reservation code. This patch fixed those bugs by converting those variables to ext3_fsblk_t(unsigned long) type. Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ext3/resize.c')
-rw-r--r--fs/ext3/resize.c43
1 files changed, 24 insertions, 19 deletions
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;