Make use of the new ability to call xfs_bmap_local_to_extents_empty on a non-empty local fork to reuse the old inode fork data to build the leaf block to replace the local temporary buffer. Signed-off-by: Christoph Hellwig <hch@xxxxxx> --- fs/xfs/libxfs/xfs_attr_leaf.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index b9e98950eb3d81..d9285614d7c21b 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -942,24 +942,16 @@ xfs_attr_shortform_to_leaf( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; - struct xfs_ifork *ifp = &dp->i_af; - struct xfs_attr_sf_hdr *sf = ifp->if_data; + struct xfs_attr_sf_hdr *sf; struct xfs_attr_sf_entry *sfe; - int size = be16_to_cpu(sf->totsize); struct xfs_da_args nargs; - char *tmpbuffer; int error, i; xfs_dablk_t blkno; struct xfs_buf *bp; trace_xfs_attr_sf_to_leaf(args); - tmpbuffer = kmalloc(size, GFP_KERNEL | __GFP_NOFAIL); - memcpy(tmpbuffer, ifp->if_data, size); - sf = (struct xfs_attr_sf_hdr *)tmpbuffer; - - xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); - xfs_bmap_local_to_extents_empty(args->trans, dp, XFS_ATTR_FORK); + sf = xfs_bmap_local_to_extents_empty(args->trans, dp, XFS_ATTR_FORK); bp = NULL; error = xfs_da_grow_inode(args, &blkno); @@ -1003,7 +995,7 @@ xfs_attr_shortform_to_leaf( } error = 0; out: - kfree(tmpbuffer); + kfree(sf); return error; } -- 2.39.2