Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3225989rwl; Thu, 13 Apr 2023 18:20:06 -0700 (PDT) X-Google-Smtp-Source: AKy350b3spq9YeEGix4YRaNIy9KgnUF3vxyAc8xXCOkyAgD9ZLoYrhSgFs0/rVhDOnfWxmpHVxlP X-Received: by 2002:a17:902:e748:b0:1a6:7570:5368 with SMTP id p8-20020a170902e74800b001a675705368mr835155plf.19.1681435206036; Thu, 13 Apr 2023 18:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681435206; cv=none; d=google.com; s=arc-20160816; b=C55weDDtdjyKhPwVXuYNEME79BqVG/O21ys1cTG2N3FkVqtNzb8Ga5UYhBZdtqEKL+ BXKN9TBMk7Nrl2xi82N/YxytTUkB3etnvyLcYdaDUqACZ/1IpP9wruEOsffhgHCMB2Om YI0YqSKTb6K81DiMYB937AAkkWKV0sxJ79WNDNZ+0Ls3kLDi6HOo2VdFDVnHU+aRCMsh OaU64FTc+KGxmxPQd8BrBnmnh3LRaDZ+xzyHOR+oGYLDpNMheyc6xiNGI6+s6fmLCpo2 N1O4rOMUWkBkk04h5YflKo124C05zgM9elbvuqoJhvW/Vh8TRwEtIbxbIc0uL7zQnVcb 00KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=rSpoj5UqM4hBtoQ/OM+hiWV88Sord4Iu7w33wlTHFQM=; b=x9qZ9KGVFpR68bV8uH3uMZ0G2JPB7zeFeU1ZvIHVE3dUbekGKXOT9whM+bWYXW/zF8 b0WHu4Hnei9VI4AvI/+d/s790kvy2g2hteLiCT2kYKf6kQ57so1JzO+MuFWGIHy0um7g 4iihuRie6UBuLNLCccmn30kJtBkAuUXub/GC0NfgPekl+SI4Chyl7Dt+36SsO1PFg+2v GzkDDM+tZLJ/D2jDjbRG0A5joVvoiJ6CZ+OVwoFKPADRqQQ6R38Fj2CdffEyHYd9JV4m njD87spf5f+Q7FF2nBdfXwYhThaSC8JQLtHhx29fzsRDpvnjFAx/DODRGFr9nQnx0z+A 9jdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ShgZ2Hz3; 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 m1-20020a170902db0100b001a656596b9esi3493917plx.608.2023.04.13.18.19.52; Thu, 13 Apr 2023 18:20:06 -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=ShgZ2Hz3; 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 S229484AbjDNBTE (ORCPT + 99 others); Thu, 13 Apr 2023 21:19:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjDNBTC (ORCPT ); Thu, 13 Apr 2023 21:19:02 -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 0C2212D5F for ; Thu, 13 Apr 2023 18:19:00 -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 871C963BB4 for ; Fri, 14 Apr 2023 01:19:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA50CC433D2; Fri, 14 Apr 2023 01:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681435139; bh=GpyqswlkR5WgrTmui+S0AaHMMIflP1m47uRsisRn0N8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ShgZ2Hz3viX7fEiwFXbfXEECNWNK4RBYOS83qbbUxpdPNS93Dt2xOlHESUPGZGC// JvfNDB+AfGphfTPIILlzD23Wo3p65QyMmDBP5PPQvgj9Bu0zqroC0l0TIATtNVHB55 7gEBRjiGKQPqI8jZztu9HPVtZeTg0jtfzL/IlZHImvNxM8KRVk5/Je2c6GnrYLPWIx eryiiQ10XyLT97bBBZD7/Sv/cXXt/P+qIl5rPnt/AaJS177GieGs22grSdIRUhtVsX KOmpYpTLYsZwJHGQntdFFbBHkoYU4RIhp0ohMqOEt8juzOck3g0JQpofG9mDK1zGHm oXN5pvFBi8/lw== Message-ID: <9e77c30c-0770-6cb7-cb75-2e22bc52b8d2@kernel.org> Date: Fri, 14 Apr 2023 09:18:56 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [f2fs-dev] [PATCH v2] f2fs: relax sanity check if checkpoint is corrupted Content-Language: en-US To: Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20230407181539.4136580-1-jaegeuk@kernel.org> <82ecc91f-a739-4744-29da-227daf5e45a2@kernel.org> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 On 2023/4/13 23:52, Jaegeuk Kim wrote: > On 04/13, Chao Yu wrote: >> On 2023/4/13 0:17, Jaegeuk Kim wrote: >>> 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: >>> - add one more case to skip the error message >>> >>> fs/f2fs/checkpoint.c | 10 ++++++++++ >>> fs/f2fs/extent_cache.c | 22 +++++++++++++++------- >>> 2 files changed, 25 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/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; >> >> Thsi field indicates whether it is needed to update largest extent into >> inode page, since cp_error is unrecoverable, it seems we don't needed to >> update it. > > Intention is to avoid any assumption like that, but sync the same logic when > updating this. Sure, fine to me. Reviewed-by: Chao Yu Thanks, > >> >> Thanks, >> >>> + 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,