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. > + 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. - Eric