diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2012-04-29 18:33:10 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-04-29 18:33:10 -0400 |
commit | 41a246d1ff75a95d2be3191ca6e6db139dc0f430 (patch) | |
tree | 0b5150f476dd69726ffe7ea1ba83832c42b441be /fs/ext4/resize.c | |
parent | 814525f4df50a196464ce2c7abe91f693203060f (diff) |
ext4: calculate and verify checksums for inode bitmaps
Compute and verify the checksum of the inode bitmap; the checkum is
stored in the block group descriptor.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/resize.c')
-rw-r--r-- | fs/ext4/resize.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index e0374757a94b..7810cac241e1 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -1069,6 +1069,47 @@ static int ext4_add_new_descs(handle_t *handle, struct super_block *sb, | |||
1069 | return err; | 1069 | return err; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block) | ||
1073 | { | ||
1074 | struct buffer_head *bh = sb_getblk(sb, block); | ||
1075 | if (!bh) | ||
1076 | return NULL; | ||
1077 | |||
1078 | if (bitmap_uptodate(bh)) | ||
1079 | return bh; | ||
1080 | |||
1081 | lock_buffer(bh); | ||
1082 | if (bh_submit_read(bh) < 0) { | ||
1083 | unlock_buffer(bh); | ||
1084 | brelse(bh); | ||
1085 | return NULL; | ||
1086 | } | ||
1087 | unlock_buffer(bh); | ||
1088 | |||
1089 | return bh; | ||
1090 | } | ||
1091 | |||
1092 | static int ext4_set_bitmap_checksums(struct super_block *sb, | ||
1093 | ext4_group_t group, | ||
1094 | struct ext4_group_desc *gdp, | ||
1095 | struct ext4_new_group_data *group_data) | ||
1096 | { | ||
1097 | struct buffer_head *bh; | ||
1098 | |||
1099 | if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, | ||
1100 | EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) | ||
1101 | return 0; | ||
1102 | |||
1103 | bh = ext4_get_bitmap(sb, group_data->inode_bitmap); | ||
1104 | if (!bh) | ||
1105 | return -EIO; | ||
1106 | ext4_inode_bitmap_csum_set(sb, group, gdp, bh, | ||
1107 | EXT4_INODES_PER_GROUP(sb) / 8); | ||
1108 | brelse(bh); | ||
1109 | |||
1110 | return 0; | ||
1111 | } | ||
1112 | |||
1072 | /* | 1113 | /* |
1073 | * ext4_setup_new_descs() will set up the group descriptor descriptors of a flex bg | 1114 | * ext4_setup_new_descs() will set up the group descriptor descriptors of a flex bg |
1074 | */ | 1115 | */ |
@@ -1101,6 +1142,12 @@ static int ext4_setup_new_descs(handle_t *handle, struct super_block *sb, | |||
1101 | memset(gdp, 0, EXT4_DESC_SIZE(sb)); | 1142 | memset(gdp, 0, EXT4_DESC_SIZE(sb)); |
1102 | ext4_block_bitmap_set(sb, gdp, group_data->block_bitmap); | 1143 | ext4_block_bitmap_set(sb, gdp, group_data->block_bitmap); |
1103 | ext4_inode_bitmap_set(sb, gdp, group_data->inode_bitmap); | 1144 | ext4_inode_bitmap_set(sb, gdp, group_data->inode_bitmap); |
1145 | err = ext4_set_bitmap_checksums(sb, group, gdp, group_data); | ||
1146 | if (err) { | ||
1147 | ext4_std_error(sb, err); | ||
1148 | break; | ||
1149 | } | ||
1150 | |||
1104 | ext4_inode_table_set(sb, gdp, group_data->inode_table); | 1151 | ext4_inode_table_set(sb, gdp, group_data->inode_table); |
1105 | ext4_free_group_clusters_set(sb, gdp, | 1152 | ext4_free_group_clusters_set(sb, gdp, |
1106 | EXT4_B2C(sbi, group_data->free_blocks_count)); | 1153 | EXT4_B2C(sbi, group_data->free_blocks_count)); |