From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: "Guan-Chun.Wu" <409411716@gms.tku.edu.tw>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: btree: fix merge logic to use btree_last() return value
Date: Tue, 26 Aug 2025 00:54:25 +0800 [thread overview]
Message-ID: <aKyVQRG9k/CboNRn@visitorckw-System-Product-Name> (raw)
In-Reply-To: <20250822085851.566303-1-409411716@gms.tku.edu.tw>
Hi Guan-Chun,
On Fri, Aug 22, 2025 at 04:58:51PM +0800, Guan-Chun.Wu wrote:
> Previously btree_merge() called btree_last() only to test existence,
> then performed an extra btree_lookup() to fetch the value. This patch
> changes it to directly use the value returned by btree_last(), avoiding
> redundant lookups and simplifying the merge loop.
The code change itself looks correct.
However, the subject line gives the impression that this patch fixes a
bug, while it actually just simplifies the logic. Could you consider
updating the subject to better reflect the nature of the change?
BTW, it seems that only the qla2xxx SCSI driver uses the btree
library, and that driver doesn't actually call btree_merge(). So in
practice, this function is unused in the kernel. Should we consider
removing it entirely?
>
> Signed-off-by: Guan-Chun.Wu <409411716@gms.tku.edu.tw>
Is the dot in your real name intentional?
Regards,
Kuan-Wei
> ---
> lib/btree.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/btree.c b/lib/btree.c
> index bb81d3393ac5..9c80c0c7bba8 100644
> --- a/lib/btree.c
> +++ b/lib/btree.c
> @@ -653,9 +653,9 @@ int btree_merge(struct btree_head *target, struct btree_head *victim,
> * walks to remove a single object from the victim.
> */
> for (;;) {
> - if (!btree_last(victim, geo, key))
> + val = btree_last(victim, geo, key);
> + if (!val)
> break;
> - val = btree_lookup(victim, geo, key);
> err = btree_insert(target, geo, key, val, gfp);
> if (err)
> return err;
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2025-08-25 16:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 8:58 Guan-Chun.Wu
2025-08-25 16:54 ` Kuan-Wei Chiu [this message]
2025-08-26 16:08 ` Guan-Chun Wu
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=aKyVQRG9k/CboNRn@visitorckw-System-Product-Name \
--to=visitorckw@gmail.com \
--cc=409411716@gms.tku.edu.tw \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®