On 2020/12/8 9:26, Jaegeuk Kim wrote:
On 12/08, Chao Yu wrote:
On 2020/12/8 4:37, Eric Biggers wrote:
On Thu, Nov 26, 2020 at 06:32:09PM +0800, Chao Yu wrote:
+       if (!ret && fi->i_compress_flag & 1 << COMPRESS_CHKSUM) {

This really could use some parentheses.  People shouldn't have to look up a
C operator precedence table to understand the code.

Will add parentheses to avoid misread.


+               u32 provided = le32_to_cpu(dic->cbuf->chksum);
+               u32 calculated = f2fs_crc32(sbi, dic->cbuf->cdata, dic->clen);
+
+               if (provided != calculated) {
+                       if (!is_inode_flag_set(dic->inode, 
FI_COMPRESS_CORRUPT)) {
+                               set_inode_flag(dic->inode, FI_COMPRESS_CORRUPT);
+                               printk_ratelimited(
+                                       "%sF2FS-fs (%s): checksum invalid, nid = 
%lu, %x vs %x",
+                                       KERN_INFO, sbi->sb->s_id, 
dic->inode->i_ino,
+                                       provided, calculated);
+                       }
+                       set_sbi_flag(sbi, SBI_NEED_FSCK);
+                       WARN_ON_ONCE(1);

WARN, WARN_ON_ONCE, BUG, BUG_ON, etc. are only for kernel bugs, not for invalid
inputs from disk or userspace.

There is already a log message printed just above, so it seems this WARN_ON_ONCE
should just be removed.

Jaegeuk wants to give WARN_ON and marking a FSCK flag without returning 
EFSCORRUPTED,

I think above printk_ratelimited should be enough.

Okay, so let me update the patch.

Thanks,



Jaegeuk, thoughts?

Thanks,


- Eric
.

.

Reply via email to