linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: <jaegeuk@kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-f2fs-devel@lists.sourceforge.net>
Subject: Re: [f2fs-dev] [PATCH v3] f2fs: compress: support chksum
Date: Tue, 8 Dec 2020 09:18:37 +0800	[thread overview]
Message-ID: <e6bc842d-90a2-d4ce-56be-594bcebaea37@huawei.com> (raw)
In-Reply-To: <X86Sb2pvD53MzO5+@gmail.com>

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,

Jaegeuk, thoughts?

Thanks,

> 
> - Eric
> .
> 

  parent reply	other threads:[~2020-12-08  1:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-26 10:32 [PATCH v3] f2fs: compress: support chksum Chao Yu
2020-12-07 20:37 ` [f2fs-dev] " Eric Biggers
2020-12-07 21:53   ` Joe Perches
2020-12-08  1:18   ` Chao Yu [this message]
2020-12-08  1:26     ` Jaegeuk Kim
2020-12-08  1:31       ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6bc842d-90a2-d4ce-56be-594bcebaea37@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=ebiggers@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).