diff mbox series

[2/5] btrfs: remove the PAGE_SIZE usage inside inline extent reads

Message ID 2e9629067938c31bb59c34655456909c4d00e183.1740043233.git.wqu@suse.com (mailing list archive)
State New
Headers show
Series btrfs: prepare for larger folios support | expand

Commit Message

Qu Wenruo Feb. 20, 2025, 9:22 a.m. UTC
The inline extent ram size should never exceed btrfs block size, there
is no need to clamp the size against PAGE_SIZE.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Johannes Thumshirn Feb. 21, 2025, 11:37 a.m. UTC | #1
On 20.02.25 10:25, Qu Wenruo wrote:
> The inline extent ram size should never exceed btrfs block size, there
> is no need to clamp the size against PAGE_SIZE.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>   fs/btrfs/inode.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 3af74f3c5d75..d9ca92d1b927 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -6784,7 +6784,7 @@ static noinline int uncompress_inline(struct btrfs_path *path,
>   
>   	read_extent_buffer(leaf, tmp, ptr, inline_size);
>   
> -	max_size = min_t(unsigned long, PAGE_SIZE, max_size);
> +	max_size = min_t(unsigned long, sectorsize, max_size);
>   	ret = btrfs_decompress(compress_type, tmp, folio, 0, inline_size,
>   			       max_size);
>   
> @@ -6820,7 +6820,7 @@ static int read_inline_extent(struct btrfs_fs_info *fs_info,
>   	if (btrfs_file_extent_compression(path->nodes[0], fi) != BTRFS_COMPRESS_NONE)
>   		return uncompress_inline(path, folio, fi);
>   
> -	copy_size = min_t(u64, PAGE_SIZE,
> +	copy_size = min_t(u64, sectorsize,
>   			  btrfs_file_extent_ram_bytes(path->nodes[0], fi));
>   	kaddr = kmap_local_folio(folio, 0);
>   	read_extent_buffer(path->nodes[0], kaddr,


That'll make it compile:

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f94b80d4433d..f64869fad466 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6788,6 +6788,7 @@ static noinline int uncompress_inline(struct btrfs_path *path,
  {
         int ret;
         struct extent_buffer *leaf = path->nodes[0];
+       u32 sectorsize = leaf->fs_info->sectorsize;
         char *tmp;
         size_t max_size;
         unsigned long inline_size;
@@ -6825,6 +6826,7 @@ static noinline int uncompress_inline(struct btrfs_path *path,
  static int read_inline_extent(struct btrfs_path *path, struct folio *folio)
  {
         struct btrfs_file_extent_item *fi;
+       u32 sectorsize;
         void *kaddr;
         size_t copy_size;

@@ -6832,6 +6834,7 @@ static int read_inline_extent(struct btrfs_path *path, struct folio *folio)
                 return 0;

         ASSERT(folio_pos(folio) == 0);
+       sectorsize = folio_to_fs_info(folio)->sectorsize;

         fi = btrfs_item_ptr(path->nodes[0], path->slots[0],
                             struct btrfs_file_extent_item);
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3af74f3c5d75..d9ca92d1b927 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6784,7 +6784,7 @@  static noinline int uncompress_inline(struct btrfs_path *path,
 
 	read_extent_buffer(leaf, tmp, ptr, inline_size);
 
-	max_size = min_t(unsigned long, PAGE_SIZE, max_size);
+	max_size = min_t(unsigned long, sectorsize, max_size);
 	ret = btrfs_decompress(compress_type, tmp, folio, 0, inline_size,
 			       max_size);
 
@@ -6820,7 +6820,7 @@  static int read_inline_extent(struct btrfs_fs_info *fs_info,
 	if (btrfs_file_extent_compression(path->nodes[0], fi) != BTRFS_COMPRESS_NONE)
 		return uncompress_inline(path, folio, fi);
 
-	copy_size = min_t(u64, PAGE_SIZE,
+	copy_size = min_t(u64, sectorsize,
 			  btrfs_file_extent_ram_bytes(path->nodes[0], fi));
 	kaddr = kmap_local_folio(folio, 0);
 	read_extent_buffer(path->nodes[0], kaddr,