Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1205093rwl; Fri, 7 Apr 2023 11:35:23 -0700 (PDT) X-Google-Smtp-Source: AKy350ZU/9W+F5BqO0C9xiP01MwY1JwmDwZvLQU8wpPYNe2avtQvVrV7ZjHYYUM4KRcyszkTUytg X-Received: by 2002:a05:6402:7c3:b0:4fb:b09e:4c8b with SMTP id u3-20020a05640207c300b004fbb09e4c8bmr3069560edy.37.1680892522837; Fri, 07 Apr 2023 11:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680892522; cv=none; d=google.com; s=arc-20160816; b=p0gmUhIj+F3F1+1bOcGVdwfDUJ/ZgNRbQZ52taDgSKhwi3dC4IdsiakzCcUHSRWru/ myAmcA/lQUDRvC3fIQsyJbaacM7USJpzz2ZHIO6lO7+mAhneAdr+MBCBwJrsbeK4Bul5 itin8+dJmvSCkkXoyzB/j09P3mHyCs3E7fVpXgMQDTGvg0KdQNqq0oFg6LhThb5tjtug W8AMCaSAvpTn4oiZKOjgWeFfKCoaRGFsrbU3RKFZ7xep/wUzBtYwyen8ZliO8/o+mT9h Dfqd2h4OFxMPxljs4tKhtKwGwziBOW/wjil55gvu20oqZ/43VJqjJZ7G3KsQYmsoxrN9 /tvw== 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:dkim-signature; bh=BpFIudOkMb0Vfa8UEv4ibnPdy5QtCUoJsj01ogMe6hQ=; b=jPEUnujb/w7+4JU2HlBKi/t1DU6fhqT9pqHXmXckRBBiufexQgjWzk1DoBPXkoysvD t+u5mCTniC54sLDtJ8m7JuaFSBF0uXPRgBR7gF2xceCaY9GX46YIY9pLcARzOMRpDNUH j87PLdUaKyi/CSo0SR08GqB8CeGtApAonWvgcuek6JmcGhWKOEWn2k9N3riExfMngp01 WWcwh1fspVzW+4ortcE75m5/dly4wVxAaDyqSj6jAXVXpY9dNDFHUS7cg2qeUyBlt4zm /DV3x3IqvaDphDsfxxoJpEFay/ZQ6hvQWS2zpo/6aL3K8jKpN9NUr4hZUif/bynLYCYt U8xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XZSmTYiL; 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 l13-20020aa7cacd000000b0050477cb61ecsi2232847edt.82.2023.04.07.11.34.57; Fri, 07 Apr 2023 11:35:22 -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=XZSmTYiL; 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 S231473AbjDGSPp (ORCPT + 99 others); Fri, 7 Apr 2023 14:15:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231129AbjDGSPn (ORCPT ); Fri, 7 Apr 2023 14:15:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB4BAF0D for ; Fri, 7 Apr 2023 11:15:41 -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 441A16501B for ; Fri, 7 Apr 2023 18:15:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BA6BC433EF; Fri, 7 Apr 2023 18:15:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680891340; bh=R5IaRXJ/Qg+3iB9RW4lmo1YHb1AE43YUn4zUM2xxs5Q=; h=From:To:Cc:Subject:Date:From; b=XZSmTYiLruss9ev7G0liNfXg96G6RieiR1TRsz+uc4Yy2YHHH5b+rLEm+1YnER5f+ Yc+n0589V28eQQt+G3JCEmMCFgmA35Qe0ArA8rhK3Do//6bXQr7JK/wOPndJrXAu0O aweOd1uGbGOkxOl9jk7Vqffx6peJUeGxsxYMLuk+uMw/lySagLuw0xxC4rhEGdSlhn vaqP/MsxalJx2qMggmJ7xVZgdMrqnS1OFSIYg23IJRmY5ByQoEMa47/QhXTY0xk7Gd ukFNpLvAtdz4yqSPjveFQoGohvyAj2h1PPdT0TqXSfkgKE7hoTswm7S/plXvUaGvoi 8U7vcNLMHOooQ== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH] f2fs: relax sanity check if checkpoint is corrupted Date: Fri, 7 Apr 2023 11:15:39 -0700 Message-Id: <20230407181539.4136580-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 --- fs/f2fs/checkpoint.c | 5 +++++ fs/f2fs/extent_cache.c | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 5774076d7ca3..73ae4e85e70d 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, if we already have an error in checkpoint. */ + if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG)) + return exist; + if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) { f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d", blkaddr, exist); 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.577.gac1e443424-goog