public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Sun YangKai <sunk67188@gmail.com>,
	linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v3] btrfs: remove nonzero lowest level handling in btrfs_search_forward()
Date: Mon, 19 May 2025 15:00:23 +0930	[thread overview]
Message-ID: <cb99de5d-5800-45d7-a6b2-d58f364799e1@suse.com> (raw)
In-Reply-To: <5890818.DvuYhMxLoT@saltykitkat>



在 2025/5/19 10:01, Sun YangKai 写道:
>> 在 2025/5/19 09:07, Sun YangKai 写道:
>> [...]
>>
>>> Thank you for your reply. I'll fix it and split this into smaller patches.
>>
>> I don't think you need to split, unless you really have a strong reason
>> to do extra refactor.
>>
>> Something like this will be enough (not yet tested):
>>
>> ```
>> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
>> index a2e7979372cc..ca63e0dad499 100644
>> --- a/fs/btrfs/ctree.c
>> +++ b/fs/btrfs/ctree.c
>> @@ -4615,6 +4615,7 @@ int btrfs_search_forward(struct btrfs_root *root,
>> struct btrfs_key *min_key,
>>           int keep_locks = path->keep_locks;
>>
>>           ASSERT(!path->nowait);
>> +       ASSERT(path->lowest_level == 0);
>>           path->keep_locks = 1;
>>    again:
>>           cur = btrfs_read_lock_root_node(root);
>> @@ -4637,7 +4638,7 @@ int btrfs_search_forward(struct btrfs_root *root,
>> struct btrfs_key *min_key,
>>                   }
>>
>>                   /* at the lowest level, we're done, setup the path and
>> exit */
>> -               if (level == path->lowest_level) {
>> +               if (level == 0) {
>>                           if (slot >= nritems)
>>                                   goto find_next_key;
>>                           ret = 0;
>> @@ -4678,12 +4679,6 @@ int btrfs_search_forward(struct btrfs_root *root,
>> struct btrfs_key *min_key,
>>                                   goto out;
>>                           }
>>                   }
>> -               if (level == path->lowest_level) {
>> -                       ret = 0;
>> -                       /* Save our key for returning back. */
>> -                       btrfs_node_key_to_cpu(cur, min_key, slot);
>> -                       goto out;
>> -               }
>>                   cur = btrfs_read_node_slot(cur, slot);
>>                   if (IS_ERR(cur)) {
>>                           ret = PTR_ERR(cur);
>> ```
> 
> Yep! This is exactly what I want. Actually I was doing changes with different
> purposes so that make things totally messed up :(
And this one is now properly tested too.

Thanks,
Qu

      parent reply	other threads:[~2025-05-19  5:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22 12:56 [PATCH v2] btrfs: fix nonzero lowest level handling in btrfs_search_forward() Sun YangKai
2025-04-29  6:57 ` Sun YangKai
2025-04-29 15:27   ` David Sterba
     [not found]     ` <6048084.MhkbZ0Pkbq@saltykitkat>
2025-05-17 13:33       ` Sun YangKai
2025-05-17 13:47         ` [PATCH v3] btrfs: remove " Sun YangKai
2025-05-18 11:25           ` Qu Wenruo
     [not found]         ` <12674804.O9o76ZdvQC@saltykitkat>
     [not found]           ` <4d02fad5-07b2-47b6-9e18-30f45bc67163@suse.com>
     [not found]             ` <5890818.DvuYhMxLoT@saltykitkat>
2025-05-19  5:30               ` Qu Wenruo [this message]

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=cb99de5d-5800-45d7-a6b2-d58f364799e1@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sunk67188@gmail.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