Re: [PATCH v2 03/19] btrfs: calculate inline extent buffer page size based on page size

Qu Wenruo
2020-09-15T10:05:26Z

On 2020/9/15 下午4:35, Nikolay Borisov wrote:
>
>
> On 15.09.20 г. 8:35 ч., Qu Wenruo wrote:
>> Btrfs only support 64K as max node size, thus for 4K page system, we
>> would have at most 16 pages for one extent buffer.
>>
>> For a system using 64K page size, we would really have just one
>> single page.
>>
>> While we always use 16 pages for extent_buffer::pages[], this means for
>> systems using 64K pages, we are wasting memory for the 15 pages which
>> will never be utilized.
>>
>> So this patch will change how the extent_buffer::pages[] array size is
>> calclulated, now it will be calculated using
>> BTRFS_MAX_METADATA_BLOCKSIZE and PAGE_SIZE.
>>
>> For systems using 4K page size, it will stay 16 pages.
>> For systems using 64K page size, it will be just 1 page.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
>
> <snip>
>
>> diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
>> index 00a88f2eb5ab..d511890702cc 100644
>> --- a/fs/btrfs/extent_io.h
>> +++ b/fs/btrfs/extent_io.h
>> @@ -85,9 +85,11 @@ struct extent_io_ops {
>> int mirror);
>> };
>>
>> -
>> -#define INLINE_EXTENT_BUFFER_PAGES 16
>> -#define MAX_INLINE_EXTENT_BUFFER_SIZE (INLINE_EXTENT_BUFFER_PAGES * PAGE_SIZE)
>> +/*
>> + * The SZ_64K is BTRFS_MAX_METADATA_BLOCKSIZE, here just to avoid circle
>> + * including "ctree.h".
>> + */
>> +#define INLINE_EXTENT_BUFFER_PAGES (SZ_64K / PAGE_SIZE)
>
> nit: Instead of doing this it would be better if this define is simply
> moved next to BTRFS_MAX_METADATA_BLOCKSIZE so that every define relating
> to eb's are clustered together.

It would be better to only define the macro in extent buffer context.

We have put too many things into ctree.h so that we hit such problem in
the first place.

Thanks,
Qu
>
>> struct extent_buffer {
>> u64 start;
>> unsigned long len;
>>