From: David Sterba <dsterba@suse.cz>
To: Naohiro Aota <naota@elisp.net>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: zoned: fix bitops api misuse
Date: Thu, 20 Apr 2023 15:24:30 +0200 [thread overview]
Message-ID: <20230420131743.GW19619@suse.cz> (raw)
In-Reply-To: <ghiglpjvgkvtdwpkl2h73b6gqlyfh6cl3m4b3uv3rhv5tmhyxq@2esoibq7emjk>
On Thu, Apr 20, 2023 at 01:14:30PM +0900, Naohiro Aota wrote:
> On Thu, Apr 20, 2023 at 12:58:14PM +0900, Naohiro Aota wrote:
> > On Wed, Apr 19, 2023 at 01:24:56AM +0200, David Sterba wrote:
> > > On Tue, Apr 18, 2023 at 05:45:24PM +0900, Naohiro Aota wrote:
> > > > From: Naohiro Aota <naohiro.aota@wdc.com>
> > > >
> > > > find_next_bit and find_next_zero_bit take @size as the second parameter and
> > > > @offset as the third parameter. They are specified opposite in
> > > > btrfs_ensure_empty_zones(). Thanks to the later loop, it never failed to
> > > > detect the empty zones. Fix them and (maybe) return the result a bit
> > > > faster.
> > > >
> > > > Fixes: 1cd6121f2a38 ("btrfs: zoned: implement zoned chunk allocator")
> > > > CC: stable@vger.kernel.org # 5.15+
> > > > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> > > > ---
> > > > fs/btrfs/zoned.c | 6 +++---
> > > > 1 file changed, 3 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> > > > index 2b160fda7301..55bde1336d81 100644
> > > > --- a/fs/btrfs/zoned.c
> > > > +++ b/fs/btrfs/zoned.c
> > > > @@ -1171,12 +1171,12 @@ int btrfs_ensure_empty_zones(struct btrfs_device *device, u64 start, u64 size)
> > > > return -ERANGE;
> > > >
> > > > /* All the zones are conventional */
> > > > - if (find_next_bit(zinfo->seq_zones, begin, end) == end)
> > > > + if (find_next_bit(zinfo->seq_zones, end, begin) == end)
> > >
> > > End is defined as "end = (start + size) >> shift", and the 2nd parameter
> > > of find_next_bit is supposed to be 'size'. Shouldn't it be "size >>
> > > shift"?
> >
> > Not so. The argument "size" represents the size of the allocation range,
> > which is to be confirmed as empty. OTOH, find_next_bit()'s "size" (the 2nd
> > parameter) represents the size of an entire bitmap, not the number of bits to
> > be tested.
>
> BTW, I found the same logic is implemented in subpage.c as
> bitmap_test_range_all_{set,zero}. So, it might worth moving them to
> somewhere (misc.h?) and use them here.
Good idea, please send it as a separate patch. Thanks.
prev parent reply other threads:[~2023-04-20 13:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 8:45 [PATCH] btrfs: zoned: fix bitops api misuse Naohiro Aota
2023-04-18 23:24 ` David Sterba
2023-04-20 3:58 ` Naohiro Aota
2023-04-20 4:14 ` Naohiro Aota
2023-04-20 13:24 ` David Sterba [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=20230420131743.GW19619@suse.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=naota@elisp.net \
/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