From: Gabriel Niebler <gniebler@suse.com>
To: Nikolay Borisov <nborisov@suse.com>,
linux-btrfs@vger.kernel.org, dsterba@suse.com
Subject: Re: [PATCH v2] btrfs: Turn fs_info member buffer_radix into XArray
Date: Mon, 2 May 2022 09:20:47 +0200 [thread overview]
Message-ID: <8a28fb76-0d20-a1c1-7e2f-5cbb87313ed1@suse.com> (raw)
In-Reply-To: <20220429183932.GF18596@twin.jikos.cz>
Am 29.04.22 um 20:39 schrieb David Sterba:
> On Fri, Apr 29, 2022 at 05:14:15PM +0300, Nikolay Borisov wrote:
>>> - cur = gang[ret - 1]->start + gang[ret - 1]->len;
>>> }
>>
>> nit: The body of the loop can be turned into:
>>
>> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
>> index da3d9dc186cd..7c1d5fec59dd 100644
>> --- a/fs/btrfs/extent_io.c
>> +++ b/fs/btrfs/extent_io.c
>> @@ -7318,16 +7318,13 @@ static struct extent_buffer *get_next_extent_buffer(
>>
>> xa_for_each_start(&fs_info->extent_buffers, index, eb,
>> page_start >> fs_info->sectorsize_bits) {
>> - if (eb->start >= page_start + PAGE_SIZE)
>> + if (in_range(eb->start, page_start, PAGE_SIZE))
>> + return eb;
>> + else if (eb->start >= page_start + PAGE_SIZE)
>> /* Already beyond page end */
>> - break;
>> - if (eb->start >= bytenr) {
>> - /* Found one */
>> - found = eb;
>> - break;
>> - }
>> + return NULL;
>> }
>> - return found;
>> + return NULL;
>> }
>>
>>
>> That is use the in_range macro to detect when we have an eb between
>> page_start and page_start + PAGE_SIZE in which case we can directly
>> return it, and the in_range is self-documenting. And directly return
>> NULL in case of eb->start going beyond the current page and in case we
>> didn't find anything. David, what do you think?
>
> I like it and folded to the patch, thanks. The variable 'found' becomes
> unused so removed as well.
Nice! I didn't know there was such a macro - learned something again.
Thank you both!
prev parent reply other threads:[~2022-05-02 7:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-21 15:45 [PATCH v2] btrfs: Turn fs_info member buffer_radix into XArray Gabriel Niebler
2022-04-22 20:32 ` David Sterba
2022-04-29 14:14 ` Nikolay Borisov
2022-04-29 18:39 ` David Sterba
2022-05-02 7:20 ` Gabriel Niebler [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=8a28fb76-0d20-a1c1-7e2f-5cbb87313ed1@suse.com \
--to=gniebler@suse.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.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