diff mbox series

btrfs: fix wrong sizeof in btrfs_do_encoded_write

Message ID 20241015113736.1006573-1-maharmstone@fb.com (mailing list archive)
State New, archived
Headers show
Series btrfs: fix wrong sizeof in btrfs_do_encoded_write | expand

Commit Message

Mark Harmstone Oct. 15, 2024, 11:37 a.m. UTC
btrfs_do_encoded_write was converted to use folios in 400b172b8cdc, but
we're still allocating based on sizeof(struct page *) rather than
sizeof(struct folio *).

Signed-off-by: Mark Harmstone <maharmstone@fb.com>
---
 fs/btrfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Boris Burkov Oct. 15, 2024, 8:57 p.m. UTC | #1
On Tue, Oct 15, 2024 at 12:37:29PM +0100, Mark Harmstone wrote:
> btrfs_do_encoded_write was converted to use folios in 400b172b8cdc, but
> we're still allocating based on sizeof(struct page *) rather than
> sizeof(struct folio *).
> 
> Signed-off-by: Mark Harmstone <maharmstone@fb.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
>  fs/btrfs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 5618ca02934a..5bffc2c77718 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -9495,7 +9495,7 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
>  	 */
>  	disk_num_bytes = ALIGN(orig_count, fs_info->sectorsize);
>  	nr_folios = DIV_ROUND_UP(disk_num_bytes, PAGE_SIZE);
> -	folios = kvcalloc(nr_folios, sizeof(struct page *), GFP_KERNEL_ACCOUNT);
> +	folios = kvcalloc(nr_folios, sizeof(struct folio *), GFP_KERNEL_ACCOUNT);
>  	if (!folios)
>  		return -ENOMEM;
>  	for (i = 0; i < nr_folios; i++) {
> -- 
> 2.44.2
>
David Sterba Oct. 16, 2024, 12:27 a.m. UTC | #2
On Tue, Oct 15, 2024 at 12:37:29PM +0100, Mark Harmstone wrote:
> btrfs_do_encoded_write was converted to use folios in 400b172b8cdc, but
> we're still allocating based on sizeof(struct page *) rather than
> sizeof(struct folio *).

It's wrong that we should use folio, but both are a sizeof of a pointer,
so it's not wrong in the functionality sense.

> Signed-off-by: Mark Harmstone <maharmstone@fb.com>

Reviewed-by: David Sterba <dsterba@suse.com>
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5618ca02934a..5bffc2c77718 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9495,7 +9495,7 @@  ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
 	 */
 	disk_num_bytes = ALIGN(orig_count, fs_info->sectorsize);
 	nr_folios = DIV_ROUND_UP(disk_num_bytes, PAGE_SIZE);
-	folios = kvcalloc(nr_folios, sizeof(struct page *), GFP_KERNEL_ACCOUNT);
+	folios = kvcalloc(nr_folios, sizeof(struct folio *), GFP_KERNEL_ACCOUNT);
 	if (!folios)
 		return -ENOMEM;
 	for (i = 0; i < nr_folios; i++) {