diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2012-04-29 18:45:10 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-04-29 18:45:10 -0400 |
commit | feb0ab32a57e4e6c8b24f6fb68f0ce08efe4603c (patch) | |
tree | 6438fc46013c2f5d60e78060c66e2809c6056f1a /fs/ext4/ialloc.c | |
parent | cc8e94fd126ab2d2e4bcb1b65c7316196f0cec8c (diff) |
ext4: make block group checksums use metadata_csum algorithm
metadata_csum supersedes uninit_bg. Convert the ROCOMPAT uninit_bg
flag check to a helper function that covers both, and make the
checksum calculation algorithm use either crc16 or the metadata_csum
chosen algorithm depending on which flag is set. Print a warning if
we try to mount a filesystem with both feature flags set.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/ialloc.c')
-rw-r--r-- | fs/ext4/ialloc.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index a6383fcb714b..a044a9b77491 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -70,13 +70,11 @@ static unsigned ext4_init_inode_bitmap(struct super_block *sb, | |||
70 | ext4_group_t block_group, | 70 | ext4_group_t block_group, |
71 | struct ext4_group_desc *gdp) | 71 | struct ext4_group_desc *gdp) |
72 | { | 72 | { |
73 | struct ext4_sb_info *sbi = EXT4_SB(sb); | ||
74 | |||
75 | J_ASSERT_BH(bh, buffer_locked(bh)); | 73 | J_ASSERT_BH(bh, buffer_locked(bh)); |
76 | 74 | ||
77 | /* If checksum is bad mark all blocks and inodes use to prevent | 75 | /* If checksum is bad mark all blocks and inodes use to prevent |
78 | * allocation, essentially implementing a per-group read-only flag. */ | 76 | * allocation, essentially implementing a per-group read-only flag. */ |
79 | if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) { | 77 | if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { |
80 | ext4_error(sb, "Checksum bad for group %u", block_group); | 78 | ext4_error(sb, "Checksum bad for group %u", block_group); |
81 | ext4_free_group_clusters_set(sb, gdp, 0); | 79 | ext4_free_group_clusters_set(sb, gdp, 0); |
82 | ext4_free_inodes_set(sb, gdp, 0); | 80 | ext4_free_inodes_set(sb, gdp, 0); |
@@ -92,7 +90,7 @@ static unsigned ext4_init_inode_bitmap(struct super_block *sb, | |||
92 | bh->b_data); | 90 | bh->b_data); |
93 | ext4_inode_bitmap_csum_set(sb, block_group, gdp, bh, | 91 | ext4_inode_bitmap_csum_set(sb, block_group, gdp, bh, |
94 | EXT4_INODES_PER_GROUP(sb) / 8); | 92 | EXT4_INODES_PER_GROUP(sb) / 8); |
95 | gdp->bg_checksum = ext4_group_desc_csum(sbi, block_group, gdp); | 93 | ext4_group_desc_csum_set(sb, block_group, gdp); |
96 | 94 | ||
97 | return EXT4_INODES_PER_GROUP(sb); | 95 | return EXT4_INODES_PER_GROUP(sb); |
98 | } | 96 | } |
@@ -298,7 +296,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) | |||
298 | } | 296 | } |
299 | ext4_inode_bitmap_csum_set(sb, block_group, gdp, bitmap_bh, | 297 | ext4_inode_bitmap_csum_set(sb, block_group, gdp, bitmap_bh, |
300 | EXT4_INODES_PER_GROUP(sb) / 8); | 298 | EXT4_INODES_PER_GROUP(sb) / 8); |
301 | gdp->bg_checksum = ext4_group_desc_csum(sbi, block_group, gdp); | 299 | ext4_group_desc_csum_set(sb, block_group, gdp); |
302 | ext4_unlock_group(sb, block_group); | 300 | ext4_unlock_group(sb, block_group); |
303 | 301 | ||
304 | percpu_counter_inc(&sbi->s_freeinodes_counter); | 302 | percpu_counter_inc(&sbi->s_freeinodes_counter); |
@@ -731,7 +729,7 @@ repeat_in_this_group: | |||
731 | 729 | ||
732 | got: | 730 | got: |
733 | /* We may have to initialize the block bitmap if it isn't already */ | 731 | /* We may have to initialize the block bitmap if it isn't already */ |
734 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM) && | 732 | if (ext4_has_group_desc_csum(sb) && |
735 | gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { | 733 | gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { |
736 | struct buffer_head *block_bitmap_bh; | 734 | struct buffer_head *block_bitmap_bh; |
737 | 735 | ||
@@ -757,8 +755,7 @@ got: | |||
757 | block_bitmap_bh, | 755 | block_bitmap_bh, |
758 | EXT4_BLOCKS_PER_GROUP(sb) / | 756 | EXT4_BLOCKS_PER_GROUP(sb) / |
759 | 8); | 757 | 8); |
760 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group, | 758 | ext4_group_desc_csum_set(sb, group, gdp); |
761 | gdp); | ||
762 | } | 759 | } |
763 | ext4_unlock_group(sb, group); | 760 | ext4_unlock_group(sb, group); |
764 | 761 | ||
@@ -811,7 +808,7 @@ got: | |||
811 | if (ext4_has_group_desc_csum(sb)) { | 808 | if (ext4_has_group_desc_csum(sb)) { |
812 | ext4_inode_bitmap_csum_set(sb, group, gdp, inode_bitmap_bh, | 809 | ext4_inode_bitmap_csum_set(sb, group, gdp, inode_bitmap_bh, |
813 | EXT4_INODES_PER_GROUP(sb) / 8); | 810 | EXT4_INODES_PER_GROUP(sb) / 8); |
814 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp); | 811 | ext4_group_desc_csum_set(sb, group, gdp); |
815 | ext4_unlock_group(sb, group); | 812 | ext4_unlock_group(sb, group); |
816 | } | 813 | } |
817 | 814 | ||
@@ -1181,7 +1178,7 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group, | |||
1181 | skip_zeroout: | 1178 | skip_zeroout: |
1182 | ext4_lock_group(sb, group); | 1179 | ext4_lock_group(sb, group); |
1183 | gdp->bg_flags |= cpu_to_le16(EXT4_BG_INODE_ZEROED); | 1180 | gdp->bg_flags |= cpu_to_le16(EXT4_BG_INODE_ZEROED); |
1184 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp); | 1181 | ext4_group_desc_csum_set(sb, group, gdp); |
1185 | ext4_unlock_group(sb, group); | 1182 | ext4_unlock_group(sb, group); |
1186 | 1183 | ||
1187 | BUFFER_TRACE(group_desc_bh, | 1184 | BUFFER_TRACE(group_desc_bh, |