Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62aab20f authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: adjust refcount when unmapping file blocks



When we're unmapping blocks from a reflinked file, decrease the
refcount of the affected blocks and free the extents that are no
longer in use.

Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 33ba6129
Loading
Loading
Loading
Loading
+11 −3
Original line number Original line Diff line number Diff line
@@ -48,6 +48,7 @@
#include "xfs_filestream.h"
#include "xfs_filestream.h"
#include "xfs_rmap.h"
#include "xfs_rmap.h"
#include "xfs_ag_resv.h"
#include "xfs_ag_resv.h"
#include "xfs_refcount.h"




kmem_zone_t		*xfs_bmap_free_item_zone;
kmem_zone_t		*xfs_bmap_free_item_zone;
@@ -4988,9 +4989,16 @@ xfs_bmap_del_extent(
	/*
	/*
	 * If we need to, add to list of extents to delete.
	 * If we need to, add to list of extents to delete.
	 */
	 */
	if (do_fx)
	if (do_fx) {
		if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
			error = xfs_refcount_decrease_extent(mp, dfops, del);
			if (error)
				goto done;
		} else
			xfs_bmap_add_free(mp, dfops, del->br_startblock,
			xfs_bmap_add_free(mp, dfops, del->br_startblock,
					del->br_blockcount, NULL);
					del->br_blockcount, NULL);
	}

	/*
	/*
	 * Adjust inode # blocks in the file.
	 * Adjust inode # blocks in the file.
	 */
	 */