Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2681841pxu; Mon, 7 Dec 2020 12:40:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9hV+vUxQ6mz8689pWXZHxU8Ru2HP+ssiEyzcz05hpgpme9mJIlVXXT+kYQDe+fepJr2ci X-Received: by 2002:a17:906:710b:: with SMTP id x11mr21298268ejj.433.1607373646674; Mon, 07 Dec 2020 12:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607373646; cv=none; d=google.com; s=arc-20160816; b=h7UNp61NZdSivURmGaEfRwSr+ajhXcwTEnvT1323q6K8NjksYAOVQ3p6DN7dPnrUKH zfkvudXjN+bQ82hHAL/x53Y75JcX78vRo1Xzo+XE+1oyyht1xEHnjClntv6Url8Hntah aaB1diijNhSSgZckRLdI27gTKW+q3eILiBuAkMwe3hJ/5xDxPucJgEFeFE6wJuCpVdjB NLihKoPgraQIqGzSouk6PjNMIKic5vp37848Kyp1HbA5iQy7O/9w5eCueXlxwZqK+FgE 08aHNpzDZa6R23gHqdxE+PEHMAzNuIfbW+7fspiadOe/zQQKb4JUGRxQt/Kbf0Y3rcxx 8xeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=c0ho6F75cwkHeuWeY13hJc4OOnbZnjP8yYh92U1O3hI=; b=0rM8SmOrHPKRtXCT0vxyLLrDfaJn+N9DqLAnwVhd41VbcdcmzSXt/doZgWJVqqR5QD 3TSWaeDPpqLiYhxeE6B+1l+nhxEf+xPElC37MrfoIcyxtqwuOFGhKJFD4QRH+c6IycZJ aVX7ysLNkb6gFSbEcLSWMomSaiB5PwFiyN4Ni6RwGoCU78ZzOG6dbxOmAZhMppx8S7Ld jbm8qOPCSjQsAmfe39Y7zcQ9j49oxcDMLN+vBYPpBaptLxCg2xsAyuB7znfRPvBGAX4l QQ2ZmkGjZcu6Eh+I2b1UQTqTmLZe+EKo76vkhgvWZuIpf3feU81AgpnLsJt5wxRo2aCd zgUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GHWaYwId; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si7764325ejb.581.2020.12.07.12.40.22; Mon, 07 Dec 2020 12:40:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GHWaYwId; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726552AbgLGUhq (ORCPT + 99 others); Mon, 7 Dec 2020 15:37:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:47880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbgLGUhq (ORCPT ); Mon, 7 Dec 2020 15:37:46 -0500 Date: Mon, 7 Dec 2020 12:37:03 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607373425; bh=0D2ooDXaNUKeLHALauHhhHNJgFgomBWbSNKb8afQF9Y=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=GHWaYwIdIq/2b1iiexqNp0nTo6SXKpcxAPzqgOFZi9HcabPKpSqHTjZCOeDNVFuxu WEwMAsLHSPmv48f8Ev6/vV91rsLTrMAZQVwL4N3La/Vgt8vYrwI0cIkvdN9CKivntm 1PDs+mICJYJXQzzAVJW1H4zZD9aPNP1MliCB8jcRl/fTehGnUAbiXkIoLP0ps+grn9 z+ilu2jMfrWIxlzAiV81gXXC/0VpXQUOAhzLxGql/ccrd1Thof74vT7f0o5Ed6dBb0 9cOWZh7j1zSvct+E7yEESm8X/WcU7pKNqBH8LOrA+SfTNi7N4ypcJ2POhdX+cYMsIg RLyrF745SUlGg== From: Eric Biggers To: Chao Yu 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 Message-ID: References: <20201126103209.67985-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126103209.67985-1-yuchao0@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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