aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/resize.c
diff options
context:
space:
mode:
authorLaurent Vivier <Laurent.Vivier@bull.net>2006-10-11 04:21:10 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-11 14:14:17 -0400
commitbd81d8eec043094d3ff729a8ff6d5b3a06d3c4b1 (patch)
tree6813a81b8d8453536839d8bcdc8ed924fdab3f44 /fs/ext4/resize.c
parenta1ddeb7eaecea6a924e3a79aa386797020cb436f (diff)
[PATCH] ext4: 64bit metadata
In-kernel super block changes to support >32 bit free blocks numbers. Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net> Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com> Signed-off-by: Alexandre Ratchov <alexandre.ratchov@bull.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ext4/resize.c')
-rw-r--r--fs/ext4/resize.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index c60bfed5f5e7..3dbf91b82202 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -27,7 +27,7 @@ static int verify_group_input(struct super_block *sb,
27{ 27{
28 struct ext4_sb_info *sbi = EXT4_SB(sb); 28 struct ext4_sb_info *sbi = EXT4_SB(sb);
29 struct ext4_super_block *es = sbi->s_es; 29 struct ext4_super_block *es = sbi->s_es;
30 ext4_fsblk_t start = le32_to_cpu(es->s_blocks_count); 30 ext4_fsblk_t start = ext4_blocks_count(es);
31 ext4_fsblk_t end = start + input->blocks_count; 31 ext4_fsblk_t end = start + input->blocks_count;
32 unsigned group = input->group; 32 unsigned group = input->group;
33 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group; 33 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
@@ -68,43 +68,43 @@ static int verify_group_input(struct super_block *sb,
68 end - 1); 68 end - 1);
69 else if (outside(input->block_bitmap, start, end)) 69 else if (outside(input->block_bitmap, start, end))
70 ext4_warning(sb, __FUNCTION__, 70 ext4_warning(sb, __FUNCTION__,
71 "Block bitmap not in group (block %u)", 71 "Block bitmap not in group (block %llu)",
72 input->block_bitmap); 72 input->block_bitmap);
73 else if (outside(input->inode_bitmap, start, end)) 73 else if (outside(input->inode_bitmap, start, end))
74 ext4_warning(sb, __FUNCTION__, 74 ext4_warning(sb, __FUNCTION__,
75 "Inode bitmap not in group (block %u)", 75 "Inode bitmap not in group (block %llu)",
76 input->inode_bitmap); 76 input->inode_bitmap);
77 else if (outside(input->inode_table, start, end) || 77 else if (outside(input->inode_table, start, end) ||
78 outside(itend - 1, start, end)) 78 outside(itend - 1, start, end))
79 ext4_warning(sb, __FUNCTION__, 79 ext4_warning(sb, __FUNCTION__,
80 "Inode table not in group (blocks %u-"E3FSBLK")", 80 "Inode table not in group (blocks %llu-%llu)",
81 input->inode_table, itend - 1); 81 input->inode_table, itend - 1);
82 else if (input->inode_bitmap == input->block_bitmap) 82 else if (input->inode_bitmap == input->block_bitmap)
83 ext4_warning(sb, __FUNCTION__, 83 ext4_warning(sb, __FUNCTION__,
84 "Block bitmap same as inode bitmap (%u)", 84 "Block bitmap same as inode bitmap (%llu)",
85 input->block_bitmap); 85 input->block_bitmap);
86 else if (inside(input->block_bitmap, input->inode_table, itend)) 86 else if (inside(input->block_bitmap, input->inode_table, itend))
87 ext4_warning(sb, __FUNCTION__, 87 ext4_warning(sb, __FUNCTION__,
88 "Block bitmap (%u) in inode table (%u-"E3FSBLK")", 88 "Block bitmap (%llu) in inode table (%llu-%llu)",
89 input->block_bitmap, input->inode_table, itend-1); 89 input->block_bitmap, input->inode_table, itend-1);
90 else if (inside(input->inode_bitmap, input->inode_table, itend)) 90 else if (inside(input->inode_bitmap, input->inode_table, itend))
91 ext4_warning(sb, __FUNCTION__, 91 ext4_warning(sb, __FUNCTION__,
92 "Inode bitmap (%u) in inode table (%u-"E3FSBLK")", 92 "Inode bitmap (%llu) in inode table (%llu-%llu)",
93 input->inode_bitmap, input->inode_table, itend-1); 93 input->inode_bitmap, input->inode_table, itend-1);
94 else if (inside(input->block_bitmap, start, metaend)) 94 else if (inside(input->block_bitmap, start, metaend))
95 ext4_warning(sb, __FUNCTION__, 95 ext4_warning(sb, __FUNCTION__,
96 "Block bitmap (%u) in GDT table" 96 "Block bitmap (%llu) in GDT table"
97 " ("E3FSBLK"-"E3FSBLK")", 97 " ("E3FSBLK"-"E3FSBLK")",
98 input->block_bitmap, start, metaend - 1); 98 input->block_bitmap, start, metaend - 1);
99 else if (inside(input->inode_bitmap, start, metaend)) 99 else if (inside(input->inode_bitmap, start, metaend))
100 ext4_warning(sb, __FUNCTION__, 100 ext4_warning(sb, __FUNCTION__,
101 "Inode bitmap (%u) in GDT table" 101 "Inode bitmap (%llu) in GDT table"
102 " ("E3FSBLK"-"E3FSBLK")", 102 " ("E3FSBLK"-"E3FSBLK")",
103 input->inode_bitmap, start, metaend - 1); 103 input->inode_bitmap, start, metaend - 1);
104 else if (inside(input->inode_table, start, metaend) || 104 else if (inside(input->inode_table, start, metaend) ||
105 inside(itend - 1, start, metaend)) 105 inside(itend - 1, start, metaend))
106 ext4_warning(sb, __FUNCTION__, 106 ext4_warning(sb, __FUNCTION__,
107 "Inode table (%u-"E3FSBLK") overlaps" 107 "Inode table ("E3FSBLK"-"E3FSBLK") overlaps"
108 "GDT table ("E3FSBLK"-"E3FSBLK")", 108 "GDT table ("E3FSBLK"-"E3FSBLK")",
109 input->inode_table, itend - 1, start, metaend - 1); 109 input->inode_table, itend - 1, start, metaend - 1);
110 else 110 else
@@ -286,6 +286,7 @@ exit_journal:
286 return err; 286 return err;
287} 287}
288 288
289
289/* 290/*
290 * Iterate through the groups which hold BACKUP superblock/GDT copies in an 291 * Iterate through the groups which hold BACKUP superblock/GDT copies in an
291 * ext4 filesystem. The counters should be initialized to 1, 5, and 7 before 292 * ext4 filesystem. The counters should be initialized to 1, 5, and 7 before
@@ -340,12 +341,15 @@ static int verify_reserved_gdb(struct super_block *sb,
340 int gdbackups = 0; 341 int gdbackups = 0;
341 342
342 while ((grp = ext4_list_backups(sb, &three, &five, &seven)) < end) { 343 while ((grp = ext4_list_backups(sb, &three, &five, &seven)) < end) {
343 if (le32_to_cpu(*p++) != grp * EXT4_BLOCKS_PER_GROUP(sb) + blk){ 344 if (le32_to_cpu(*p++) !=
345 grp * EXT4_BLOCKS_PER_GROUP(sb) + blk){
344 ext4_warning(sb, __FUNCTION__, 346 ext4_warning(sb, __FUNCTION__,
345 "reserved GDT "E3FSBLK 347 "reserved GDT "E3FSBLK
346 " missing grp %d ("E3FSBLK")", 348 " missing grp %d ("E3FSBLK")",
347 blk, grp, 349 blk, grp,
348 grp * EXT4_BLOCKS_PER_GROUP(sb) + blk); 350 grp *
351 (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
352 blk);
349 return -EINVAL; 353 return -EINVAL;
350 } 354 }
351 if (++gdbackups > EXT4_ADDR_PER_BLOCK(sb)) 355 if (++gdbackups > EXT4_ADDR_PER_BLOCK(sb))
@@ -731,8 +735,8 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
731 return -EPERM; 735 return -EPERM;
732 } 736 }
733 737
734 if (le32_to_cpu(es->s_blocks_count) + input->blocks_count < 738 if (ext4_blocks_count(es) + input->blocks_count <
735 le32_to_cpu(es->s_blocks_count)) { 739 ext4_blocks_count(es)) {
736 ext4_warning(sb, __FUNCTION__, "blocks_count overflow\n"); 740 ext4_warning(sb, __FUNCTION__, "blocks_count overflow\n");
737 return -EINVAL; 741 return -EINVAL;
738 } 742 }
@@ -830,9 +834,9 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
830 /* Update group descriptor block for new group */ 834 /* Update group descriptor block for new group */
831 gdp = (struct ext4_group_desc *)primary->b_data + gdb_off; 835 gdp = (struct ext4_group_desc *)primary->b_data + gdb_off;
832 836
833 gdp->bg_block_bitmap = cpu_to_le32(input->block_bitmap); 837 ext4_block_bitmap_set(gdp, input->block_bitmap); /* LV FIXME */
834 gdp->bg_inode_bitmap = cpu_to_le32(input->inode_bitmap); 838 ext4_inode_bitmap_set(gdp, input->inode_bitmap); /* LV FIXME */
835 gdp->bg_inode_table = cpu_to_le32(input->inode_table); 839 ext4_inode_table_set(gdp, input->inode_table); /* LV FIXME */
836 gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count); 840 gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count);
837 gdp->bg_free_inodes_count = cpu_to_le16(EXT4_INODES_PER_GROUP(sb)); 841 gdp->bg_free_inodes_count = cpu_to_le16(EXT4_INODES_PER_GROUP(sb));
838 842
@@ -846,7 +850,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
846 * blocks/inodes before the group is live won't actually let us 850 * blocks/inodes before the group is live won't actually let us
847 * allocate the new space yet. 851 * allocate the new space yet.
848 */ 852 */
849 es->s_blocks_count = cpu_to_le32(le32_to_cpu(es->s_blocks_count) + 853 ext4_blocks_count_set(es, ext4_blocks_count(es) +
850 input->blocks_count); 854 input->blocks_count);
851 es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) + 855 es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) +
852 EXT4_INODES_PER_GROUP(sb)); 856 EXT4_INODES_PER_GROUP(sb));
@@ -882,7 +886,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
882 886
883 /* Update the reserved block counts only once the new group is 887 /* Update the reserved block counts only once the new group is
884 * active. */ 888 * active. */
885 es->s_r_blocks_count = cpu_to_le32(le32_to_cpu(es->s_r_blocks_count) + 889 ext4_r_blocks_count_set(es, ext4_r_blocks_count(es) +
886 input->reserved_blocks); 890 input->reserved_blocks);
887 891
888 /* Update the free space counts */ 892 /* Update the free space counts */
@@ -933,7 +937,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
933 /* We don't need to worry about locking wrt other resizers just 937 /* We don't need to worry about locking wrt other resizers just
934 * yet: we're going to revalidate es->s_blocks_count after 938 * yet: we're going to revalidate es->s_blocks_count after
935 * taking lock_super() below. */ 939 * taking lock_super() below. */
936 o_blocks_count = le32_to_cpu(es->s_blocks_count); 940 o_blocks_count = ext4_blocks_count(es);
937 o_groups_count = EXT4_SB(sb)->s_groups_count; 941 o_groups_count = EXT4_SB(sb)->s_groups_count;
938 942
939 if (test_opt(sb, DEBUG)) 943 if (test_opt(sb, DEBUG))
@@ -1004,7 +1008,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
1004 } 1008 }
1005 1009
1006 lock_super(sb); 1010 lock_super(sb);
1007 if (o_blocks_count != le32_to_cpu(es->s_blocks_count)) { 1011 if (o_blocks_count != ext4_blocks_count(es)) {
1008 ext4_warning(sb, __FUNCTION__, 1012 ext4_warning(sb, __FUNCTION__,
1009 "multiple resizers run on filesystem!"); 1013 "multiple resizers run on filesystem!");
1010 unlock_super(sb); 1014 unlock_super(sb);
@@ -1020,7 +1024,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
1020 ext4_journal_stop(handle); 1024 ext4_journal_stop(handle);
1021 goto exit_put; 1025 goto exit_put;
1022 } 1026 }
1023 es->s_blocks_count = cpu_to_le32(o_blocks_count + add); 1027 ext4_blocks_count_set(es, o_blocks_count + add);
1024 ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh); 1028 ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
1025 sb->s_dirt = 1; 1029 sb->s_dirt = 1;
1026 unlock_super(sb); 1030 unlock_super(sb);
@@ -1032,8 +1036,8 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
1032 if ((err = ext4_journal_stop(handle))) 1036 if ((err = ext4_journal_stop(handle)))
1033 goto exit_put; 1037 goto exit_put;
1034 if (test_opt(sb, DEBUG)) 1038 if (test_opt(sb, DEBUG))
1035 printk(KERN_DEBUG "EXT4-fs: extended group to %u blocks\n", 1039 printk(KERN_DEBUG "EXT4-fs: extended group to %llu blocks\n",
1036 le32_to_cpu(es->s_blocks_count)); 1040 ext4_blocks_count(es));
1037 update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr, (char *)es, 1041 update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr, (char *)es,
1038 sizeof(struct ext4_super_block)); 1042 sizeof(struct ext4_super_block));
1039exit_put: 1043exit_put: