Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3103318rwl; Thu, 13 Apr 2023 16:02:30 -0700 (PDT) X-Google-Smtp-Source: AKy350ZIemTtwX9jp6M+LXa9EaED8e1R62ANRgBmMrHFinan9MvwV3Bl1VQUufrlzPySJ0hqlHg0 X-Received: by 2002:a17:902:f552:b0:1a2:98b1:1ee2 with SMTP id h18-20020a170902f55200b001a298b11ee2mr750160plf.15.1681426950181; Thu, 13 Apr 2023 16:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681426950; cv=none; d=google.com; s=arc-20160816; b=MHZGFi9fTBtqy3lEqz+QE+0KD4t+1xE5Xk/y87dPZuAP9rNgIsuP/W/fjwLP8V1yeL xGJnIeyTkh8sRF/yLL0/sRORNWoVPxQ8c5ul/dsn6wCBTsOlfor0uNAiYbEvLNhtvJp8 /AmB8hjEl8VT+1xJ0HNfXLsEUiCjBkrwh+T88l/ODXxfK16ggHF2PeJz0c1F39bmB616 t9r5stH3t4mxsw7vhUnJ4lZs9zIlPYgEl53CYvRSHJK3WeE9BDNEBBRaXVQ3sHXa7br7 AZOVv6CkrdPk7UTVNHK0kJmpjLB3xoi74jlBwTgLLTgOlim1fQWzODjcwjtAwZzjD5mm Cd7w== 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:to:from:date:dkim-signature; bh=551suF2aP3jEpvFjtA3sWRHx9GL70pUk/yB3NhTNQ3s=; b=0jqO3qFeCepkortEuPIzlKB48Vdfo9jJx8rd2uufrFUrEgt4AaPMOVn5bJ1LKNJPva F4gddBQ1yAnX3CVWHQOpubgTOLgbKq/kKJzrLYPpPtO0JDkrTNZToixEhcOHiIu7bwiG XRhgwWcgBIhrl89eBBotxYLuohy4cHU+FP9EgJexhyMuZmaXIqs/Ie16Xghuu2VKUisa r9T2p9CTuzTiRrrhJWOXs2IWREl8zJYyPzf8NLSm44dZYi5Tfu5S7/kSriLeGKNFf9eq Fy/Sii9aT7rONPrj8nxSE2rUpLZvuI2+F6KOIOjCHANjTrM0MDkXRwfR6yccqY0igOEM pODQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tjAIfaZa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a17090a698200b002449259314esi5615024pjj.158.2023.04.13.16.02.15; Thu, 13 Apr 2023 16:02:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tjAIfaZa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229733AbjDMW5h (ORCPT + 99 others); Thu, 13 Apr 2023 18:57:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbjDMW5f (ORCPT ); Thu, 13 Apr 2023 18:57:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95C7810E5 for ; Thu, 13 Apr 2023 15:57:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 37C7F639A7 for ; Thu, 13 Apr 2023 22:57:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F824C433EF; Thu, 13 Apr 2023 22:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681426653; bh=x7b+Gqwia9nwQPurGo1PiKBlq7AFL1pSBWAxh/Cpgyg=; h=Date:From:To:Subject:References:In-Reply-To:From; b=tjAIfaZax4RCdqsATQy/LN/YWan6GFvPdNVaR55vDE//yQu0SVc61ZRRcz/stgFTC B/TNEk2Y6vvrxDoofcihPNmuznP3ESOOu+/qdhSfALB4QwgFeFZ56mG6bk8TPkzcuO KKhvkmWl5GjXKsRGvCf4FFaCVImtBPVJlJe/mmQDmH0EHmpEHUFL/Xnso28fl1Zu/m eWQa/wQOU2KUbAG7N0ORSZTd9tFavsXtTrlKbhYddjyRSp7clPhjAe4HCbq5E6p+Wt Yt5SYsoMrGxfmei10PO0o53VEphCKNZ6YE83SvgfVJV/WIz7Yr9fBW7Tw8y5mawn1a mJZkDA0CSPqJA== Date: Thu, 13 Apr 2023 15:57:31 -0700 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH v3] f2fs: relax sanity check if checkpoint is corrupted Message-ID: References: <20230407181539.4136580-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 1. extent_cache - let's drop the largest extent_cache 2. invalidate_block - don't show the warnings Signed-off-by: Jaegeuk Kim --- change log from v1: - cover f2fs_read_multi_pages fs/f2fs/checkpoint.c | 10 ++++++++++ fs/f2fs/data.c | 4 ++++ fs/f2fs/extent_cache.c | 22 +++++++++++++++------- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 448ecf5000b8..64b3860f50ee 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -152,6 +152,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr, se = get_seg_entry(sbi, segno); exist = f2fs_test_bit(offset, se->cur_valid_map); + + /* skip data, if we already have an error in checkpoint. */ + if (unlikely(f2fs_cp_error(sbi))) + return exist; + if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) { f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d", blkaddr, exist); @@ -202,6 +207,11 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, case DATA_GENERIC_ENHANCE_UPDATE: if (unlikely(blkaddr >= MAX_BLKADDR(sbi) || blkaddr < MAIN_BLKADDR(sbi))) { + + /* Skip to emit an error message. */ + if (unlikely(f2fs_cp_error(sbi))) + return false; + f2fs_warn(sbi, "access invalid blkaddr:%u", blkaddr); set_sbi_flag(sbi, SBI_NEED_FSCK); diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index f21e3aaa2474..8df225014304 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2237,6 +2237,10 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, if (ret) goto out; + if (unlikely(f2fs_cp_error(sbi))) { + ret = -EIO; + goto out_put_dnode; + } f2fs_bug_on(sbi, dn.data_blkaddr != COMPRESS_ADDR); skip_reading_dnode: diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index 9a8153895d20..bea6ab9d846a 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -23,18 +23,26 @@ bool sanity_check_extent_cache(struct inode *inode) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_inode_info *fi = F2FS_I(inode); + struct extent_tree *et = fi->extent_tree[EX_READ]; struct extent_info *ei; - if (!fi->extent_tree[EX_READ]) + if (!et) + return true; + + ei = &et->largest; + if (!ei->len) return true; - ei = &fi->extent_tree[EX_READ]->largest; + /* Let's drop, if checkpoint got corrupted. */ + if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG)) { + ei->len = 0; + et->largest_updated = true; + return true; + } - if (ei->len && - (!f2fs_is_valid_blkaddr(sbi, ei->blk, - DATA_GENERIC_ENHANCE) || - !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1, - DATA_GENERIC_ENHANCE))) { + if (!f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE) || + !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1, + DATA_GENERIC_ENHANCE)) { set_sbi_flag(sbi, SBI_NEED_FSCK); f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix", __func__, inode->i_ino, -- 2.40.0.634.g4ca3ef3211-goog