diff mbox series

[06/16] xfs: remove the buffer allocation size in xfs_dir2_try_block_to_sf

Message ID 20240430124926.1775355-7-hch@lst.de (mailing list archive)
State Accepted, archived
Headers show
Series [01/16] xfs: allow non-empty forks in xfs_bmap_local_to_extents_empty | expand

Commit Message

Christoph Hellwig April 30, 2024, 12:49 p.m. UTC
We've already calculated the size of the short form directory in the
size variable when checking if it fits.  Use that for the temporary
buffer allocation instead of overallocating to the inode size.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_dir2_sf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Darrick J. Wong May 1, 2024, 9:17 p.m. UTC | #1
On Tue, Apr 30, 2024 at 02:49:16PM +0200, Christoph Hellwig wrote:
> We've already calculated the size of the short form directory in the
> size variable when checking if it fits.  Use that for the temporary
> buffer allocation instead of overallocating to the inode size.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Makes sense,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_dir2_sf.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> index fad3fd28175368..d02f1ddb1da92c 100644
> --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> @@ -281,11 +281,11 @@ xfs_dir2_try_block_to_sf(
>  	trace_xfs_dir2_block_to_sf(args);
>  
>  	/*
> -	 * Allocate a temporary destination buffer the size of the inode to
> -	 * format the data into.  Once we have formatted the data, we can free
> -	 * the block and copy the formatted data into the inode literal area.
> +	 * Allocate a temporary destination buffer to format the data into.
> +	 * Once we have formatted the data, we can free the block and copy the
> +	 * formatted data into the inode literal area.
>  	 */
> -	sfp = kmalloc(mp->m_sb.sb_inodesize, GFP_KERNEL | __GFP_NOFAIL);
> +	sfp = kmalloc(size, GFP_KERNEL | __GFP_NOFAIL);
>  	memcpy(sfp, &sfh, xfs_dir2_sf_hdr_size(sfh.i8count));
>  
>  	/*
> -- 
> 2.39.2
> 
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index fad3fd28175368..d02f1ddb1da92c 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -281,11 +281,11 @@  xfs_dir2_try_block_to_sf(
 	trace_xfs_dir2_block_to_sf(args);
 
 	/*
-	 * Allocate a temporary destination buffer the size of the inode to
-	 * format the data into.  Once we have formatted the data, we can free
-	 * the block and copy the formatted data into the inode literal area.
+	 * Allocate a temporary destination buffer to format the data into.
+	 * Once we have formatted the data, we can free the block and copy the
+	 * formatted data into the inode literal area.
 	 */
-	sfp = kmalloc(mp->m_sb.sb_inodesize, GFP_KERNEL | __GFP_NOFAIL);
+	sfp = kmalloc(size, GFP_KERNEL | __GFP_NOFAIL);
 	memcpy(sfp, &sfh, xfs_dir2_sf_hdr_size(sfh.i8count));
 
 	/*