lkml.org 
[lkml]   [2020]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [f2fs-dev] [PATCH v3] f2fs: compress: support chksum
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

\
 
 \ /
  Last update: 2020-12-07 21:39    [W:2.345 / U:0.752 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site