[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e6bc842d-90a2-d4ce-56be-594bcebaea37@huawei.com>
Date: Tue, 8 Dec 2020 09:18:37 +0800
From: Chao Yu <yuchao0@...wei.com>
To: Eric Biggers <ebiggers@...nel.org>
CC: <jaegeuk@...nel.org>, <linux-kernel@...r.kernel.org>,
<linux-f2fs-devel@...ts.sourceforge.net>
Subject: Re: [f2fs-dev] [PATCH v3] f2fs: compress: support chksum
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
> .
>
Powered by blists - more mailing lists