aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <[email protected]>2022-03-25 17:37:59 +0800
committerDavid Sterba <[email protected]>2022-05-16 17:03:10 +0200
commitb06660b59545f5c2a5c7f12fabaad73f9c6e2e33 (patch)
tree7a81d28c6d77b7228356ba8b13855ebc00d624af
parentd4135134ab8feb994369d44884733e8031b0f800 (diff)
btrfs: replace memset with memzero_page in data checksum verification
The original code resets the page to 0x1 for not apparent reason, it's been like that since the initial 2007 code added in commit 07157aacb1ec ("Btrfs: Add file data csums back in via hooks in the extent map code"). It could mean that a failed buffer can be detected from the data but that's just a guess and any value is good. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> [ update changelog ] Signed-off-by: David Sterba <[email protected]>
-rw-r--r--fs/btrfs/inode.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b3f2010d9df5..d16d1dc8f54c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3275,11 +3275,11 @@ static int check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
shash->tfm = fs_info->csum_shash;
crypto_shash_digest(shash, kaddr + pgoff, len, csum);
+ kunmap_atomic(kaddr);
if (memcmp(csum, csum_expected, csum_size))
goto zeroit;
- kunmap_atomic(kaddr);
return 0;
zeroit:
btrfs_print_data_csum_error(BTRFS_I(inode), start, csum, csum_expected,
@@ -3287,9 +3287,7 @@ zeroit:
if (bbio->device)
btrfs_dev_stat_inc_and_print(bbio->device,
BTRFS_DEV_STAT_CORRUPTION_ERRS);
- memset(kaddr + pgoff, 1, len);
- flush_dcache_page(page);
- kunmap_atomic(kaddr);
+ memzero_page(page, pgoff, len);
return -EIO;
}