summaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_bmap.c
diff options
context:
space:
mode:
authorDarrick J. Wong2016-10-03 18:11:23 +0200
committerDarrick J. Wong2016-10-03 18:11:23 +0200
commit62aab20f08758b1b171a73a54e0c72dd12beb980 (patch)
treede89fe822091706cb1da1fbb3166a3b976b8d348 /fs/xfs/libxfs/xfs_bmap.c
parentxfs: connect refcount adjust functions to upper layers (diff)
downloadkernel-qcow2-linux-62aab20f08758b1b171a73a54e0c72dd12beb980.tar.gz
kernel-qcow2-linux-62aab20f08758b1b171a73a54e0c72dd12beb980.tar.xz
kernel-qcow2-linux-62aab20f08758b1b171a73a54e0c72dd12beb980.zip
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: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/libxfs/xfs_bmap.c')
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 9d7f61d36645..907d7b8df7bb 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -48,6 +48,7 @@
#include "xfs_filestream.h"
#include "xfs_rmap.h"
#include "xfs_ag_resv.h"
+#include "xfs_refcount.h"
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 (do_fx)
- xfs_bmap_add_free(mp, dfops, del->br_startblock,
- del->br_blockcount, NULL);
+ 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,
+ del->br_blockcount, NULL);
+ }
+
/*
* Adjust inode # blocks in the file.
*/