mirror of
https://github.com/bobranten/Ext4Fsd.git
synced 2025-10-30 05:18:31 -05:00
checksums on extents
This commit is contained in:
@@ -225,23 +225,6 @@ int ext4_ext_check_inode(struct inode *inode)
|
||||
return ext4_ext_check(inode, ext_inode_hdr(inode), ext_depth(inode), 0);
|
||||
}
|
||||
|
||||
static uint32_t ext4_ext_block_csum(struct inode *inode,
|
||||
struct ext4_extent_header *eh)
|
||||
{
|
||||
/*return ext4_crc32c(inode->i_csum, eh, EXT4_EXTENT_TAIL_OFFSET(eh));*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ext4_extent_block_csum_set(struct inode *inode,
|
||||
struct ext4_extent_header *eh)
|
||||
{
|
||||
struct ext4_extent_tail *tail;
|
||||
|
||||
tail = find_ext4_extent_tail(eh);
|
||||
tail->et_checksum = ext4_ext_block_csum(
|
||||
inode, eh);
|
||||
}
|
||||
|
||||
static int ext4_split_extent_at(void *icb,
|
||||
handle_t *handle,
|
||||
struct inode *inode,
|
||||
@@ -410,10 +393,8 @@ static int __ext4_ext_check(const char *function, unsigned int line,
|
||||
}
|
||||
|
||||
tail = find_ext4_extent_tail(eh);
|
||||
if (tail->et_checksum != ext4_ext_block_csum(inode, eh)) {
|
||||
ext_debug("Warning: extent checksum damaged? tail->et_checksum = "
|
||||
"%lu, ext4_ext_block_csum = %lu\n",
|
||||
tail->et_checksum, ext4_ext_block_csum(inode, eh));
|
||||
if (!ext4_extent_block_csum_verify(inode, eh)) {
|
||||
ext_debug("Warning: extent checksum damaged?\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -115,49 +115,6 @@ static void ext4_xattr_rehash(struct ext4_xattr_header *header,
|
||||
header->h_hash = cpu_to_le32(hash);
|
||||
}
|
||||
|
||||
#if CONFIG_META_CSUM_ENABLE
|
||||
static __u32
|
||||
ext4_xattr_block_checksum(PEXT2_MCB inode_ref,
|
||||
ext4_fsblk_t blocknr,
|
||||
struct ext4_xattr_header *header)
|
||||
{
|
||||
__u32 checksum = 0;
|
||||
__u64 le64_blocknr = blocknr;
|
||||
struct ext4_sblock *sb = &inode_ref->fs->sb;
|
||||
|
||||
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM)) {
|
||||
__u32 orig_checksum;
|
||||
|
||||
/* Preparation: temporarily set bg checksum to 0 */
|
||||
orig_checksum = header->h_checksum;
|
||||
header->h_checksum = 0;
|
||||
/* First calculate crc32 checksum against fs uuid */
|
||||
checksum = ext4_crc32c(EXT4_CRC32_INIT, sb->uuid,
|
||||
sizeof(sb->uuid));
|
||||
/* Then calculate crc32 checksum block number */
|
||||
checksum = ext4_crc32c(checksum, &le64_blocknr,
|
||||
sizeof(le64_blocknr));
|
||||
/* Finally calculate crc32 checksum against
|
||||
* the entire xattr block */
|
||||
checksum = ext4_crc32c(checksum, header,
|
||||
ext4_sb_get_block_size(sb));
|
||||
header->h_checksum = orig_checksum;
|
||||
}
|
||||
return checksum;
|
||||
}
|
||||
#else
|
||||
#define ext4_xattr_block_checksum(...) 0
|
||||
#endif
|
||||
|
||||
static void
|
||||
ext4_xattr_set_block_checksum(PEXT2_MCB inode_ref,
|
||||
ext4_fsblk_t blocknr,
|
||||
struct ext4_xattr_header *header)
|
||||
{
|
||||
/* TODO: Need METADATA_CSUM supports. */
|
||||
header->h_checksum = 0;
|
||||
}
|
||||
|
||||
static int ext4_xattr_item_cmp(struct rb_node *_a,
|
||||
struct rb_node *_b)
|
||||
{
|
||||
@@ -965,9 +922,8 @@ static int ext4_xattr_write_to_disk(struct ext4_xattr_ref *xattr_ref)
|
||||
if (block_modified) {
|
||||
ext4_xattr_rehash(block_header,
|
||||
EXT4_XATTR_BFIRST(xattr_ref->block_bh));
|
||||
ext4_xattr_set_block_checksum(xattr_ref->inode_ref,
|
||||
xattr_ref->block_bh->b_blocknr,
|
||||
block_header);
|
||||
/*ext4_xattr_block_csum_set(inode,
|
||||
xattr_ref->block_bh);*/
|
||||
extents_mark_buffer_dirty(xattr_ref->block_bh);
|
||||
}
|
||||
|
||||
|
||||
@@ -3378,6 +3378,10 @@ int ext4_inode_csum_verify(struct inode *inode, struct ext4_inode *raw,
|
||||
struct ext4_inode_info *ei);
|
||||
void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw,
|
||||
struct ext4_inode_info *ei);
|
||||
int ext4_extent_block_csum_verify(struct inode *inode,
|
||||
struct ext4_extent_header *eh);
|
||||
void ext4_extent_block_csum_set(struct inode *inode,
|
||||
struct ext4_extent_header *eh);
|
||||
void initialize_dirent_tail(struct ext4_dir_entry_tail *t,
|
||||
unsigned int blocksize);
|
||||
int ext4_dirent_csum_verify(struct inode *inode, struct ext4_dir_entry *dirent);
|
||||
@@ -3386,6 +3390,10 @@ void ext4_dirent_csum_set(struct inode *inode,
|
||||
int ext4_dx_csum_verify(struct inode *inode,
|
||||
struct ext4_dir_entry *dirent);
|
||||
void ext4_dx_csum_set(struct inode *inode, struct ext4_dir_entry *dirent);
|
||||
int ext4_xattr_block_csum_verify(struct inode *inode,
|
||||
struct buffer_head *bh);
|
||||
void ext4_xattr_block_csum_set(struct inode *inode,
|
||||
struct buffer_head *bh);
|
||||
|
||||
//
|
||||
// Use default packing of structures
|
||||
|
||||
Reference in New Issue
Block a user