Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1581516rdb; Mon, 19 Feb 2024 23:58:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVaRG4kOez3y2OXRd/9C4WyXIiA9gshjRlyzkEFs5F/GP17vGpWm49W2QLVXYZDQvqFTlVEMv6k317KbEafDSuQKLKxE5HFmwpJGSVE2g== X-Google-Smtp-Source: AGHT+IEv5X+DkduxgqffhCbK5N5mCShdhkkl2S6G5BJuevABUOM2eQfYzEwsBeKHD6aJQnFA415K X-Received: by 2002:a17:906:288b:b0:a3e:8333:d0b2 with SMTP id o11-20020a170906288b00b00a3e8333d0b2mr2803061ejd.23.1708415893276; Mon, 19 Feb 2024 23:58:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708415893; cv=pass; d=google.com; s=arc-20160816; b=zlWtlWotlwm4Sf2EQIdMnWNWizqU/RTvY76oh1dj0MtbMWzPFdiAgw3ZlyLoBv95Im 5rUAW2+b2LRKc4N6ot3hHZyPHzrqjxHPjKi8ScpufBMzT0P0dL469QsPcD7LLBGiVykp kPEKN+Y1wXOahlx29jOqv1uxQ2Ejikul0uYeD+FVjAPQtqHuk/4Et3g6AsNUnkD28ay5 ctBCCWWrpz5PW4jYkTUCrwrHXItZCmKew/hY1WqQXZzRNzx4IMZgd843AQ6La5ujrXFU ZlyBIkdvCKhraQPqdAa9E0la+RswMEbmN7masErbK5nZYMc3+uBDgwa6v/Kif+meF+4q 3Jkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Vd5DUm3oLPeYvExyKrLEOYIzybYkrU2C3ctnd34PWyM=; fh=w2kvI/0mdQM8yTBZ7531irUan64dFf3R9bUB31ELAjA=; b=be8l9LdHJKMKOTJD75WM1O6gpJgszUyUdltYXSTI45sb9pR8Nf5lbF/HqIXxNjct46 Phf0LlaHMw0nhwYxeZDvgxZed6A/J+sj1jEe6zlIEWX1fe8FjROQGNOxsoNzHeiT5pmu coqPVD18KDk1UE/mr51MUafIGGG5YJrnAiA7wIJEuJ2yJmH9JXli6H9tD2PEOEMX9Myz yYE7XzE1p42cFUh0wwtJhXaHSGgk+5dpzsmvlqC8TxhtJM3bw5XD4290eZxWMMDVnV39 I5eTPKHUnJ53mCfJ6ZbkQr2kagrzR5MabUijFGTfHUPGnM9ltDAMZCUQn2BHHfqAwuUA xzUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XwJcZBhj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72501-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72501-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z23-20020a170906715700b00a3ef7c1d647si419623ejj.818.2024.02.19.23.58.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 23:58:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72501-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XwJcZBhj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72501-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72501-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 065351F22C35 for ; Tue, 20 Feb 2024 07:58:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52A4B5BAF4; Tue, 20 Feb 2024 07:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XwJcZBhj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DDBF5A780 for ; Tue, 20 Feb 2024 07:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708415885; cv=none; b=tSiqjRxHlGThWsWcLxxl1cLlDseTUyzKp3lK0qs/+GtCon/049ucg0lxnyevVsu7KyNqeFLyGXJl8dZLxCosTyHrDTh8QHGTYEtXDUyQSYS7rRlBHm/fdTwo1o9qW7ae5iuNTfJc6gfKsGk7/HrvuaDsJ/wS6cHR7xAXSxyNZxM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708415885; c=relaxed/simple; bh=SKdSzd9Om3ss7aelGSZx7GlrCUSOV8sg/VeHoK4NhKs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=V8pyhJ/ZvvDYt5b0AFUVcCp+6lFZrV22Fr4OIA7MHw5nykiB51dpFi6P4NVT0WS3XlJMsjJO/nwJKWxNj88OBwq+//IudVdMlhrGbNJ/RucwNbehdy/7ospitSqqxvvxF3QAzdq6YfJpzyVwmrbrwc4KoudrqMR2sbUc94evVuE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XwJcZBhj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 609A0C433C7; Tue, 20 Feb 2024 07:58:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708415885; bh=SKdSzd9Om3ss7aelGSZx7GlrCUSOV8sg/VeHoK4NhKs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=XwJcZBhjVpfemPFNDSUdBoAOjVkwklq3JUgMim0sXvHVJ+Mv1Im9O/KiFpwe1fdwz Eq4oInUe8QG9haUl3w08iSZ7KN8KTEFJg3wJwC97s77T+q4fRB7TLD3/udIjlQuUR4 bCUzLUNFZXm9h89Z5HB+25+HlG2Kjn1S2kwrdcl4ZM6H/0HufS4+esymXeA890Fmeb QMngvObDXjjWXBttrI8poxzR2Y/UPnPO6SZyzZYif9DgJ1wDmoJcNjQCP8X7ezE2rn TXfFCOaz9Vvrzuv8wXFXUt++qaOazsDR/sWqUB5PXAKNLN5Ja5SWMphcQoAc2iqVFu TDHtG++ulF0jw== Message-ID: <5bf29cb0-96a6-4100-8755-750215d31ab6@kernel.org> Date: Tue, 20 Feb 2024 15:58:00 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [f2fs-dev] [PATCH v7] f2fs: unify the error handling of f2fs_is_valid_blkaddr Content-Language: en-US To: Zhiguo Niu Cc: Jaegeuk Kim , ke.wang@unisoc.com, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, hongyu.jin@unisoc.com, Zhiguo Niu References: <1707103845-17220-1-git-send-email-zhiguo.niu@unisoc.com> <6f01fe1b-d580-4a2a-adc5-7eb3baebeb7a@kernel.org> <17c9e85a-54b6-4e1c-b95f-262c771b0f1d@kernel.org> <4bcf0a1c-b21d-4735-bf57-b78439a65df5@kernel.org> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/2/20 15:45, Zhiguo Niu wrote: > > > On Tue, Feb 20, 2024 at 2:32 PM Chao Yu > wrote: > > > > On 2024/2/20 13:34, Zhiguo Niu wrote: > > > I think do f2fs_handle_error in __is_bitmap_valid is a good way. > > > > Like this? > > > > --- > >   fs/f2fs/checkpoint.c | 28 ++++++++++++++-------------- > >   1 file changed, 14 insertions(+), 14 deletions(-) > > > > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c > > index 87b7c988c8ca..b8a7e83eb4e0 100644 > > --- a/fs/f2fs/checkpoint.c > > +++ b/fs/f2fs/checkpoint.c > > @@ -155,21 +155,24 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr, > >                 return exist; > > > >         if ((exist && type == DATA_GENERIC_ENHANCE_UPDATE) || > > -               (!exist && type == DATA_GENERIC_ENHANCE)) { > > -               f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d", > > -                        blkaddr, exist); > > -               set_sbi_flag(sbi, SBI_NEED_FSCK); > > -               dump_stack(); > > -       } > > - > > +               (!exist && type == DATA_GENERIC_ENHANCE)) > > +               goto out_err; > > +       if (!exist && type != DATA_GENERIC_ENHANCE_UPDATE) > > +               goto out_handle; > > +       return exist; > > +out_err: > > +       f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d", > > +                blkaddr, exist); > > +       set_sbi_flag(sbi, SBI_NEED_FSCK); > > +       dump_stack(); > > +out_handle: > > +       f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR); > >         return exist; > >   } > > > >   static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, > >                                         block_t blkaddr, int type) > >   { > > -       bool valid = false; > > - > >         switch (type) { > >         case META_NAT: > >                 break; > > @@ -209,10 +212,7 @@ static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, > >                         dump_stack(); > >                         goto err; > >                 } else { > > -                       valid = __is_bitmap_valid(sbi, blkaddr, type); > > -                       if ((!valid && type != DATA_GENERIC_ENHANCE_UPDATE) || > > -                               (valid && type == DATA_GENERIC_ENHANCE_UPDATE)) > > -                               goto err; > > +                       return __is_bitmap_valid(sbi, blkaddr, type); > >                 } > >                 break; > >         case META_GENERIC: > > @@ -227,7 +227,7 @@ static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, > >         return true; > >   err: > >         f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR); > > -       return valid; > > +       return false; > I think it's OK. > Do we need to wait for Jaegeuk Kim’s suggestion or should I update the new patch  version first????? > thanks! I guess we'd better to wait for Jaegeuk's comments. Thanks, > >   } > > > >   bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, > > -- > > 2.40.1 > > > >