Message ID | 20201021062554.68132-19-wqu@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: add basic rw support for subpage sector size | expand |
On Wed, Oct 21, 2020 at 02:25:04PM +0800, Qu Wenruo wrote: > -#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". This should be moved to features.h instead of the duplicate definition. > + */ > +#define INLINE_EXTENT_BUFFER_PAGES (SZ_64K / PAGE_SIZE)
On Tue, Oct 27, 2020 at 12:16:32PM +0100, David Sterba wrote: > On Wed, Oct 21, 2020 at 02:25:04PM +0800, Qu Wenruo wrote: > > -#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". > > This should be moved to features.h instead of the duplicate definition. So features.h was some leftover in my tree, we don't have that file yet, this will need a cleanup first. I'll keep the patch in series so we can test it but it won't be in the final version I hope.
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 0d5d0581af06..6e33fa1645c3 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -5020,9 +5020,9 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start, /* * Sanity checks, currently the maximum is 64k covered by 16x 4k pages */ - BUILD_BUG_ON(BTRFS_MAX_METADATA_BLOCKSIZE - > MAX_INLINE_EXTENT_BUFFER_SIZE); - BUG_ON(len > MAX_INLINE_EXTENT_BUFFER_SIZE); + BUILD_BUG_ON(BTRFS_MAX_METADATA_BLOCKSIZE > + INLINE_EXTENT_BUFFER_PAGES * PAGE_SIZE); + BUG_ON(len > BTRFS_MAX_METADATA_BLOCKSIZE); #ifdef CONFIG_BTRFS_DEBUG eb->spinning_writers = 0; diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 3c9252b429e0..e588b3100ede 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) struct extent_buffer { u64 start; unsigned long len;
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> --- fs/btrfs/extent_io.c | 6 +++--- fs/btrfs/extent_io.h | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-)