diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2012-04-30 00:31:10 +0200 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-04-30 00:31:10 +0200 |
commit | 814525f4df50a196464ce2c7abe91f693203060f (patch) | |
tree | 221de5b0331240ff6bc99a2dd7c48460e1305075 /fs/ext4/ialloc.c | |
parent | ext4: calculate and verify superblock checksum (diff) | |
download | linux-814525f4df50a196464ce2c7abe91f693203060f.tar.xz linux-814525f4df50a196464ce2c7abe91f693203060f.zip |
ext4: calculate and verify inode checksums
This patch introduces to ext4 the ability to calculate and verify
inode checksums. This requires the use of a new ro compatibility flag
and some accompanying e2fsprogs patches to provide the relevant
features in tune2fs and e2fsck. The inode generation changes have
been integrated into this patch.
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 | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 409c2ee7750a..8207dfab2682 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -850,6 +850,19 @@ got: inode->i_generation = sbi->s_next_generation++; spin_unlock(&sbi->s_next_gen_lock); + /* Precompute checksum seed for inode metadata */ + if (EXT4_HAS_RO_COMPAT_FEATURE(sb, + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) { + __u32 csum; + struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); + __le32 inum = cpu_to_le32(inode->i_ino); + __le32 gen = cpu_to_le32(inode->i_generation); + csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum, + sizeof(inum)); + ei->i_csum_seed = ext4_chksum(sbi, csum, (__u8 *)&gen, + sizeof(gen)); + } + ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ ext4_set_inode_state(inode, EXT4_STATE_NEW); |