From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 4/4] btrfs: subpage: pack all subpage bitmaps into a larger bitmap
Date: Mon, 23 Aug 2021 19:00:26 +0200 [thread overview]
Message-ID: <20210823170026.GI5047@twin.jikos.cz> (raw)
In-Reply-To: <9599db38-cff8-fac5-c6db-ec1d53beeed3@suse.com>
On Tue, Aug 17, 2021 at 04:43:56PM +0300, Nikolay Borisov wrote:
>
>
> On 17.08.21 г. 12:38, Qu Wenruo wrote:
> > Currently we use u16 bitmap to make 4k sectorsize work for 64K page
> > size.
> >
> > But this u16 bitmap is not large enough to contain larger page size like
> > 128K, nor is space efficient for 16K page size.
> >
> > To handle both cases, here we pack all subpage bitmaps into a larger
> > bitmap, now btrfs_subpage::bitmaps[] will be the ultimate bitmap for
> > subpage usage.
> >
> > Each sub-bitmap will has its start bit number recorded in
> > btrfs_subpage_info::*_start, and its bitmap length will be recorded in
> > btrfs_subpage_info::bitmap_nr_bits.
> >
> > All subpage bitmap operations will be converted from using direct u16
> > operations to bitmap operations, with above *_start calculated.
> >
> > For 64K page size with 4K sectorsize, this should not cause much
> > difference.
> >
> > While for 16K page size, we will only need 1 unsigned long (u32) to
> > store all the bitmaps, which saves quite some space.
> >
> > Furthermore, this allows us to support larger page size like 128K and
> > 258K.
> >
> > Signed-off-by: Qu Wenruo <wqu@suse.com>
>
> <snip>
>
> > +#define GANG_LOOKUP_SIZE 16
> > static struct extent_buffer *get_next_extent_buffer(
> > struct btrfs_fs_info *fs_info, struct page *page, u64 bytenr)
> > {
> > - struct extent_buffer *gang[BTRFS_SUBPAGE_BITMAP_SIZE];
> > + struct extent_buffer *gang[GANG_LOOKUP_SIZE];
> > struct extent_buffer *found = NULL;
> > u64 page_start = page_offset(page);
> > - int ret;
> > - int i;
> > + u64 cur = page_start;
> >
> > ASSERT(in_range(bytenr, page_start, PAGE_SIZE));
> > - ASSERT(PAGE_SIZE / fs_info->nodesize <= BTRFS_SUBPAGE_BITMAP_SIZE);
> > lockdep_assert_held(&fs_info->buffer_lock);
> >
> > - ret = radix_tree_gang_lookup(&fs_info->buffer_radix, (void **)gang,
> > - bytenr >> fs_info->sectorsize_bits,
> > - PAGE_SIZE / fs_info->nodesize);
> > - for (i = 0; i < ret; i++) {
> > - /* Already beyond page end */
> > - if (gang[i]->start >= page_start + PAGE_SIZE)
> > - break;
> > - /* Found one */
> > - if (gang[i]->start >= bytenr) {
> > - found = gang[i];
> > - break;
> > + while (cur < page_start + PAGE_SIZE) {
> > + int ret;
> > + int i;
> > +
> > + ret = radix_tree_gang_lookup(&fs_info->buffer_radix,
> > + (void **)gang, cur >> fs_info->sectorsize_bits,
> > + min_t(unsigned int, GANG_LOOKUP_SIZE,
> > + PAGE_SIZE / fs_info->nodesize));
> > + if (ret == 0)
> > + goto out;
> > + for (i = 0; i < ret; i++) {
> > + /* Already beyond page end */
> > + if (gang[i]->start >= page_start + PAGE_SIZE)
>
> nit: this could be rewritten as (in_range(gang[i]->start, page_start,
> PAGE_SIZE)
Yes it could though I won't do that myself as it touches the logic and
code flow so I don't count it as trivial fixups I usually do. I'll fold
a fixup if you or Qu send it.
next prev parent reply other threads:[~2021-08-23 17:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 9:38 [PATCH v2 0/2] btrfs: subpage: pack all subpage bitmaps into a larger bitmap Qu Wenruo
2021-08-17 9:38 ` [PATCH v2 1/4] btrfs: only call btrfs_alloc_subpage() when sectorsize is smaller than PAGE_SIZE Qu Wenruo
2021-08-17 9:38 ` [PATCH v2 2/4] btrfs: make btrfs_alloc_subpage() to return struct btrfs_subpage * directly Qu Wenruo
2021-08-17 9:38 ` [PATCH v2 3/4] btrfs: introduce btrfs_subpage_bitmap_info Qu Wenruo
2021-08-17 10:11 ` Nikolay Borisov
2021-08-23 16:45 ` David Sterba
2021-08-30 14:28 ` Nikolay Borisov
2021-08-23 16:41 ` David Sterba
2021-08-23 23:15 ` Qu Wenruo
2021-08-17 9:38 ` [PATCH v2 4/4] btrfs: subpage: pack all subpage bitmaps into a larger bitmap Qu Wenruo
2021-08-17 13:43 ` Nikolay Borisov
2021-08-23 17:00 ` David Sterba [this message]
2021-08-23 16:57 ` David Sterba
2021-08-23 23:16 ` Qu Wenruo
2021-08-24 14:20 ` David Sterba
2021-08-17 13:44 ` [PATCH v2 0/2] " Nikolay Borisov
2021-08-23 17:05 ` David Sterba
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=20210823170026.GI5047@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
--cc=wqu@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