mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
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>
This commit is contained in:
parent
814525f4df
commit
41a246d1ff
4 changed files with 135 additions and 5 deletions
|
@ -1069,6 +1069,47 @@ static int ext4_add_new_descs(handle_t *handle, struct super_block *sb,
|
|||
return err;
|
||||
}
|
||||
|
||||
static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block)
|
||||
{
|
||||
struct buffer_head *bh = sb_getblk(sb, block);
|
||||
if (!bh)
|
||||
return NULL;
|
||||
|
||||
if (bitmap_uptodate(bh))
|
||||
return bh;
|
||||
|
||||
lock_buffer(bh);
|
||||
if (bh_submit_read(bh) < 0) {
|
||||
unlock_buffer(bh);
|
||||
brelse(bh);
|
||||
return NULL;
|
||||
}
|
||||
unlock_buffer(bh);
|
||||
|
||||
return bh;
|
||||
}
|
||||
|
||||
static int ext4_set_bitmap_checksums(struct super_block *sb,
|
||||
ext4_group_t group,
|
||||
struct ext4_group_desc *gdp,
|
||||
struct ext4_new_group_data *group_data)
|
||||
{
|
||||
struct buffer_head *bh;
|
||||
|
||||
if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
|
||||
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
|
||||
return 0;
|
||||
|
||||
bh = ext4_get_bitmap(sb, group_data->inode_bitmap);
|
||||
if (!bh)
|
||||
return -EIO;
|
||||
ext4_inode_bitmap_csum_set(sb, group, gdp, bh,
|
||||
EXT4_INODES_PER_GROUP(sb) / 8);
|
||||
brelse(bh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ext4_setup_new_descs() will set up the group descriptor descriptors of a flex bg
|
||||
*/
|
||||
|
@ -1101,6 +1142,12 @@ static int ext4_setup_new_descs(handle_t *handle, struct super_block *sb,
|
|||
memset(gdp, 0, EXT4_DESC_SIZE(sb));
|
||||
ext4_block_bitmap_set(sb, gdp, group_data->block_bitmap);
|
||||
ext4_inode_bitmap_set(sb, gdp, group_data->inode_bitmap);
|
||||
err = ext4_set_bitmap_checksums(sb, group, gdp, group_data);
|
||||
if (err) {
|
||||
ext4_std_error(sb, err);
|
||||
break;
|
||||
}
|
||||
|
||||
ext4_inode_table_set(sb, gdp, group_data->inode_table);
|
||||
ext4_free_group_clusters_set(sb, gdp,
|
||||
EXT4_B2C(sbi, group_data->free_blocks_count));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue