Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1742483pxu; Thu, 8 Oct 2020 21:08:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzao5dfu7q3Yj+8VbVO1Kt7M4UIu5piLMznq7e34WgJYk7ySLHCRRx3KC54W6lHCf8d56PB X-Received: by 2002:a17:906:1f53:: with SMTP id d19mr12156077ejk.255.1602216495903; Thu, 08 Oct 2020 21:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602216495; cv=none; d=google.com; s=arc-20160816; b=HLbHdgjmrYQhusi+ngI0VZJS0v8fXkg5UleCC1562gPLdEWciC7/RYecVF3zqpnMdl 93O41t1f6NoTsx3qwmr7nGHpy3jWSZCEDr8z99PCU5p7Q4KOC1JXtumSU/pVqbJ1fAM2 MBauH0LrlWpgr6eQCD5f9ZQDccaJoCIxAa4mroWAu8sZG2q+iN7r4GxjBg/PiCW35c8M 3KTlAqk6YO8MEyUIkT+g6a7HPrSt4OvsrYtrQ8hANCdjD6l77NaYRvQI1jLSz0O0DidL A+TyiCBjluRW5JsuW+fKKOD2JocFEd+ZNe3S3dv1GEnsYGyhkqqXsbfIVFi8mEEOacPl O8Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=98+EjAj+wXLEg6N5MEb+rOg7/7RA3218XEL5GRQNkfg=; b=g4XthHbL0JDBxQSQ+VSDli9n9f4cS6xIFeTJS+m/mmsbpqXn6GatNhCopLPIHUHB/e B8prTK1gOjW8DtdiJwbnmkSxLvrRXkiwOVMnGnMdP/ybIhXJ7n3n6frVwxP1yJV6aJtX M0AhyhtBlrYRnTl+Y7N0mN2KWD2RfJRzcsHUCjZzQ10k02TMtKE6BHXxztNL3FgRLwrw d8Sa4psDlk9A7/4MSQMmCpU59+kxpZ1TMnJ7EpE0LSGpTvIqcWQCr4EfybOlbMKPgQAy FIRWsy6g6YzzIAf4+ILu+4ei3klHZ4qXK2piNsVVveOjB3Ot9LvX3cnhZjQvyTox9JQm 5Dkw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz3si5271779ejb.557.2020.10.08.21.07.53; Thu, 08 Oct 2020 21:08:15 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729268AbgJIClR (ORCPT + 99 others); Thu, 8 Oct 2020 22:41:17 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14754 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725908AbgJIClR (ORCPT ); Thu, 8 Oct 2020 22:41:17 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D15DD647429D0F77E087; Fri, 9 Oct 2020 10:41:14 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Fri, 9 Oct 2020 10:41:09 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH] f2fs: fix to set SBI_NEED_FSCK flag for inconsistent inode Date: Fri, 9 Oct 2020 10:40:48 +0800 Message-ID: <20201009024048.50089-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If compressed inode has inconsistent fields on i_compress_algorithm, i_compr_blocks and i_log_cluster_size, we missed to set SBI_NEED_FSCK to notice fsck to repair the inode, fix it. Signed-off-by: Chao Yu --- fs/f2fs/inode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index d5664bc7d6c6..657db2fb6739 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -299,6 +299,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_log_cluster_size)) { if (ri->i_compress_algorithm >= COMPRESS_MAX) { + set_sbi_flag(sbi, SBI_NEED_FSCK); f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported " "compress algorithm: %u, run fsck to fix", __func__, inode->i_ino, @@ -307,6 +308,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) } if (le64_to_cpu(ri->i_compr_blocks) > SECTOR_TO_BLOCK(inode->i_blocks)) { + set_sbi_flag(sbi, SBI_NEED_FSCK); f2fs_warn(sbi, "%s: inode (ino=%lx) has inconsistent " "i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix", __func__, inode->i_ino, @@ -316,6 +318,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) } if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE || ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) { + set_sbi_flag(sbi, SBI_NEED_FSCK); f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported " "log cluster size: %u, run fsck to fix", __func__, inode->i_ino, -- 2.26.2