From: Nikolay Borisov <nborisov@suse.com>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>, Qu Wenruo <wqu@suse.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] btrfs: subpage: pack all subpage bitmaps into a larger bitmap
Date: Mon, 16 Aug 2021 17:27:33 +0300 [thread overview]
Message-ID: <892a4b32-a2f9-56f4-17b8-a494c287dfc8@suse.com> (raw)
In-Reply-To: <417cfed7-e7c6-8c51-254b-7a76533b96c8@gmx.com>
On 16.08.21 г. 16:41, Qu Wenruo wrote:
>
>
> On 2021/8/16 下午6:26, Nikolay Borisov wrote:
>>
>>
>> On 16.08.21 г. 9:00, 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
>>> restore the bitmap.
>>> And will be able to support 128K page size in the future.
>>>
<snip>
>>
>> offtopic: Instead of having a bunch of those checks can't we replace
>> them with ASSERTS and ensure that the decision whether we do subpage or
>> not is taken at a higher level ?
>
> Nope, in this particular call site, btrfs_alloc_subpage() can be called
> with regular page size.
>
> I guess it's better to rename this function like btrfs_prepare_page()?
There are currently 2 callers:
btrfs_attach_subpage - this one only calls it iff sectorsize != alloc_subage
alloc_extent_buffer - here it's called unconditionally but that can
easily be rectified with an if(subpage) check
<snip>
>> 2 argument of find_next_zero_bit is 'size' which would be nbits as it
>> expects the size to be in bits , not start + nbit. Every logical bitmap
>> in ->bitmaps is defined by [start, nbits] no ? Unfortunately there is a
>> discrepancy between the order of documentation and the order of actual
>> arguments in the definition of this function....
>
> IT'S A TRAP!
>
> Paramater 2 (@size) is the total size of the search range, it should be
> larger than the 3rd parameter.
It's not even that it's the end index of the bit we are looking for. I.e
if we want to check bits 20-29 we'd pass 20 as start, and 29 as size ...
This is fucked, but it is what it is. I guess the documentation of the
bits function is dodgy...
<snip>
next prev parent reply other threads:[~2021-08-16 14:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 6:00 [PATCH 0/2] btrfs: subpage: pack all subpage bitmaps into a larger bitmap Qu Wenruo
2021-08-16 6:00 ` [PATCH 1/2] btrfs: introduce btrfs_subpage_bitmap_info Qu Wenruo
2021-08-16 9:28 ` Nikolay Borisov
2021-08-16 10:12 ` Qu Wenruo
2021-08-16 10:17 ` David Sterba
2021-08-16 6:00 ` [PATCH 2/2] btrfs: subpage: pack all subpage bitmaps into a larger bitmap Qu Wenruo
2021-08-16 10:26 ` Nikolay Borisov
2021-08-16 13:41 ` Qu Wenruo
2021-08-16 14:27 ` Nikolay Borisov [this message]
2021-08-16 23:18 ` Qu Wenruo
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=892a4b32-a2f9-56f4-17b8-a494c287dfc8@suse.com \
--to=nborisov@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.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