public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Zhiguo Niu <niuzhiguo84@gmail.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
	ke.wang@unisoc.com, linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, hongyu.jin@unisoc.com,
	Zhiguo Niu <zhiguo.niu@unisoc.com>
Subject: Re: [f2fs-dev] [PATCH v7] f2fs: unify the error handling of f2fs_is_valid_blkaddr
Date: Tue, 20 Feb 2024 14:13:56 +0800	[thread overview]
Message-ID: <c2bc04b6-be23-426f-ad6c-1d47dad7259b@kernel.org> (raw)
In-Reply-To: <CAHJ8P3+25FxdpqWNW53yyiLLG8J7LnMAeYr_DV3ARF9-3LCUUg@mail.gmail.com>

On 2024/2/20 13:34, Zhiguo Niu wrote:
> On Tue, Feb 20, 2024 at 10:36 AM Chao Yu <chao@kernel.org> wrote:
>>
>> On 2024/2/19 22:36, Chao Yu wrote:
>>>>>> Please think about how to optimize this, which is really ugly now
>> ---
>>    fs/f2fs/checkpoint.c | 12 ++++++++----
>>    1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
>> index 87b7c988c8ca..089c26b80be3 100644
>> --- a/fs/f2fs/checkpoint.c
>> +++ b/fs/f2fs/checkpoint.c
>> @@ -135,7 +135,7 @@ struct page *f2fs_get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index)
>>    }
>>
>>    static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
>> -                                                       int type)
>> +                                               int type, bool *record_error)
>>    {
>>          struct seg_entry *se;
>>          unsigned int segno, offset;
>> @@ -160,6 +160,7 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
>>                           blkaddr, exist);
>>                  set_sbi_flag(sbi, SBI_NEED_FSCK);
>>                  dump_stack();
>> +               *record_error = true;
>>          }
>>
>>          return exist;
>> @@ -209,10 +210,13 @@ 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))
>> +                       bool record_error = false;
>> +
>> +                       valid = __is_bitmap_valid(sbi, blkaddr, type,
>> +                                                       &record_error);
>> +                       if (!valid || record_error)
> if   type == DATA_GENERIC_ENHANCE_UPDATE && bitmap check invalid,  it
> is a OK case, but !valid
> will goto do error handling.

Yes, it looks we need to remove !valid condition to avoid error handling,
and assign record_error correctly inside __is_bitmap_valid() for all the
cases.

> I think do f2fs_handle_error in __is_bitmap_valid is a good way.

Let me revise the diff patch for comments.

Thanks,

> 
>>                                  goto err;
>> +                       return valid;
>>                  }
>>                  break;
>>          case META_GENERIC:
>> --
>> 2.40.1
>>

  reply	other threads:[~2024-02-20  6:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05  3:30 [PATCH v7] f2fs: unify the error handling of f2fs_is_valid_blkaddr Zhiguo Niu
2024-02-05  3:47 ` Chao Yu
2024-02-06  3:32   ` Jaegeuk Kim
2024-02-06  3:36     ` Chao Yu
2024-02-06 23:38       ` Zhiguo Niu
2024-02-19  3:46     ` Chao Yu
2024-02-19 11:19       ` Zhiguo Niu
2024-02-19 14:36         ` Chao Yu
2024-02-20  2:36           ` [f2fs-dev] " Chao Yu
2024-02-20  5:34             ` Zhiguo Niu
2024-02-20  6:13               ` Chao Yu [this message]
2024-02-20  6:32               ` Chao Yu
     [not found]                 ` <CAHJ8P3J8WUAxOrG91id+sKKt7ndLnETdbzz6Zy7haoC9qfT0tg@mail.gmail.com>
2024-02-20  7:58                   ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c2bc04b6-be23-426f-ad6c-1d47dad7259b@kernel.org \
    --to=chao@kernel.org \
    --cc=hongyu.jin@unisoc.com \
    --cc=jaegeuk@kernel.org \
    --cc=ke.wang@unisoc.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=niuzhiguo84@gmail.com \
    --cc=zhiguo.niu@unisoc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox