Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp799226ybh; Tue, 10 Mar 2020 08:28:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vscL/yrIV3ocRUcDbHRZu0MUER0Uv2ZJSXzZJpvM0tOO3oH3rIGFtPpIJ9kCV82RXvgFyb5 X-Received: by 2002:aca:1317:: with SMTP id e23mr1591937oii.109.1583854083727; Tue, 10 Mar 2020 08:28:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583854083; cv=none; d=google.com; s=arc-20160816; b=Qq4ftNDSG3ft3Ihs3jTAToA7eqWW3yUoYHfZHYlU1nvVxfGybqcHDTg/ZniiMpFqE7 nWC29AWLrrN2HZpOmKR9Itm1vnAXMONaLUkE9VXdzoNxzyLqcPjVbrlxcgiCSbisM0JQ qqqnj3Wy2XtW3pe7OKXcI8C9nElgEjMIo1nemgLE8JxCwP8dqQcvmTA1ai/uEodKfLX3 sfy5l/lDA6jct1MpdGasB5n4vHLpG5Ow+v4rSKcuYp/SXudNs4DFi1CbAttaFenEjExt xk+U8Yv7+7bw4p5EGXOkZMOFoNDtqPUV6BxnzFSWs6VDIpHQ5KLvgjE/r2Jv5J8pOrMd BovQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature; bh=jtfiDPMSkTVnZTj3/9nM9bWqjJOH2eOGPT15shrtb6s=; b=kcrJmGDtb5dRtUq28u7ulm93G+JQt9ggI+tTh12GP+3VSIR2VJxlW8TT4dEXcHCUhg atAOLhcLrDLiQUYPWDubAlG+3qoiiPkUNXxCefSrSPSu1lUiZ+A+frbqpKyextLzQApB 9qSjQSWpvea9MNAHu0d1d0b4ytQXSxENZgTm/jD5TvAdeO6Ob6Qs/0eMxhsp9rFEQkly EAJGQXAzU7p8rlJiOaSigWUsDqWk5vQPsO9mMtXmVy17rQRN8YkcV+cafqN4omSGfKuS GkyvecKGPTgR+c00hDhvdPOBnyi9FjM5TJ7NY1nuwJ8xEs2m9oVjj8c2XGUVtr1dqpsH Bvvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1yEkke95; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id u7si5629840otq.323.2020.03.10.08.27.50; Tue, 10 Mar 2020 08:28:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1yEkke95; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726695AbgCJP1U (ORCPT + 99 others); Tue, 10 Mar 2020 11:27:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:50538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbgCJP1T (ORCPT ); Tue, 10 Mar 2020 11:27:19 -0400 Received: from [192.168.0.107] (unknown [117.89.210.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 559CA20578; Tue, 10 Mar 2020 15:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583854039; bh=zkJ/Qq9oLoVH+s4+41brSYvvL5jdsRF7cJDAHbNUSRE=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From; b=1yEkke95RfXMVwnDFxPRDOWM7JJXcFL82SV7/dpNGtu1Fg9IWsWE8OWU3gknzl4m6 /ZfukMh03tIZhU8+1uk8DLWkVwjaU0axChTUs7cRCLYilFL/qx6okU1snmiPKX69dR 20AKqlQFigPpdJxyI9a4At04pTxlI6eQk5q5ZH+A= Subject: Re: [PATCH] f2fs: fix to check i_compr_blocks correctly To: Chao Yu , jaegeuk@kernel.org References: <20200225102646.43367-1-yuchao0@huawei.com> Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org From: Chao Yu Message-ID: <3525f924-7d65-c005-a7e6-d315cf14aab2@kernel.org> Date: Tue, 10 Mar 2020 23:26:42 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20200225102646.43367-1-yuchao0@huawei.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jaegeuk, On 2020-2-25 18:26, Chao Yu wrote: > inode.i_blocks counts based on 512byte sector, we need to convert > to 4kb sized block count before comparing to i_compr_blocks. > > In addition, add to print message when sanity check on inode > compression configs failed. > > Signed-off-by: Chao Yu > --- > fs/f2fs/inode.c | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c > index 156cc5ef3044..299611562f7e 100644 > --- a/fs/f2fs/inode.c > +++ b/fs/f2fs/inode.c > @@ -291,13 +291,30 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) > fi->i_flags & F2FS_COMPR_FL && > F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, > i_log_cluster_size)) { > - if (ri->i_compress_algorithm >= COMPRESS_MAX) > + if (ri->i_compress_algorithm >= COMPRESS_MAX) { > + f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported " > + "compress algorithm: %u, run fsck to fix", > + __func__, inode->i_ino, > + ri->i_compress_algorithm); > return false; > - if (le64_to_cpu(ri->i_compr_blocks) > inode->i_blocks) > + } > + if (le64_to_cpu(ri->i_compr_blocks) > > + SECTOR_TO_BLOCK(inode->i_blocks)) { > + f2fs_warn(sbi, "%s: inode (ino=%lx) hash inconsistent " This is a typo: hash -> has Could you please manually fix this in your tree? Thanks > + "i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix", > + __func__, inode->i_ino, > + le64_to_cpu(ri->i_compr_blocks), > + SECTOR_TO_BLOCK(inode->i_blocks)); > return false; > + } > if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE || > - ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) > + ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) { > + f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported " > + "log cluster size: %u, run fsck to fix", > + __func__, inode->i_ino, > + ri->i_log_cluster_size); > return false; > + } > } > > return true; >