[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221014084837.1787196-8-hrkanabar@gmail.com>
Date: Fri, 14 Oct 2022 08:48:37 +0000
From: Hrutvik Kanabar <hrkanabar@...il.com>
To: Hrutvik Kanabar <hrutvik@...gle.com>
Cc: Marco Elver <elver@...gle.com>,
Aleksandr Nogikh <nogikh@...gle.com>,
kasan-dev@...glegroups.com,
Alexander Viro <viro@...iv.linux.org.uk>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
Theodore Ts'o <tytso@....edu>,
Andreas Dilger <adilger.kernel@...ger.ca>,
linux-ext4@...r.kernel.org, Chris Mason <clm@...com>,
Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>, linux-btrfs@...r.kernel.org,
Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>,
linux-f2fs-devel@...ts.sourceforge.net,
"Darrick J . Wong" <djwong@...nel.org>, linux-xfs@...r.kernel.org,
Namjae Jeon <linkinjeon@...nel.org>,
Sungjong Seo <sj1557.seo@...sung.com>,
Anton Altaparmakov <anton@...era.com>,
linux-ntfs-dev@...ts.sourceforge.net
Subject: [PATCH RFC 7/7] fs/f2fs: support `DISABLE_FS_CSUM_VERIFICATION` config option
From: Hrutvik Kanabar <hrutvik@...gle.com>
When `DISABLE_FS_CSUM_VERIFICATION` is enabled, bypass checksum
verification.
Signed-off-by: Hrutvik Kanabar <hrutvik@...gle.com>
---
fs/f2fs/checkpoint.c | 3 ++-
fs/f2fs/compress.c | 3 ++-
fs/f2fs/f2fs.h | 2 ++
fs/f2fs/inode.c | 3 +++
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 0c82dae082aa..cc5043fbffcb 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -864,7 +864,8 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
}
crc = f2fs_checkpoint_chksum(sbi, *cp_block);
- if (crc != cur_cp_crc(*cp_block)) {
+ if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) &&
+ crc != cur_cp_crc(*cp_block)) {
f2fs_put_page(*cp_page, 1);
f2fs_warn(sbi, "invalid crc value");
return -EINVAL;
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index d315c2de136f..d0bce92dbf38 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -772,7 +772,8 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task)
u32 provided = le32_to_cpu(dic->cbuf->chksum);
u32 calculated = f2fs_crc32(sbi, dic->cbuf->cdata, dic->clen);
- if (provided != calculated) {
+ if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) &&
+ provided != calculated) {
if (!is_inode_flag_set(dic->inode, FI_COMPRESS_CORRUPT)) {
set_inode_flag(dic->inode, FI_COMPRESS_CORRUPT);
printk_ratelimited(
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e6355a5683b7..b27f1ec9b49f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1976,6 +1976,8 @@ static inline u32 f2fs_crc32(struct f2fs_sb_info *sbi, const void *address,
static inline bool f2fs_crc_valid(struct f2fs_sb_info *sbi, __u32 blk_crc,
void *buf, size_t buf_size)
{
+ if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION))
+ return true;
return f2fs_crc32(sbi, buf, buf_size) == blk_crc;
}
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 9f0d3864d9f1..239bb08e45b1 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -181,6 +181,9 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page)
#endif
return true;
+ if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION))
+ return true;
+
ri = &F2FS_NODE(page)->i;
provided = le32_to_cpu(ri->i_inode_checksum);
calculated = f2fs_inode_chksum(sbi, page);
--
2.38.0.413.g74048e4d9e-goog
Powered by blists - more mailing lists