浏览代码

xfs: pass bmapi flags through to bmap_del_extent

Pass BMAPI_ flags from bunmapi into bmap_del_extent and extend
BMAPI_REMAP (which means "don't touch the allocator or the quota
accounting") to apply to bunmapi as well.  This will be used to
implement the unmap operation, which will be used by swapext.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Darrick J. Wong 8 年之前
父节点
当前提交
4847acf868
共有 2 个文件被更改,包括 8 次插入4 次删除
  1. 5 4
      fs/xfs/libxfs/xfs_bmap.c
  2. 3 0
      fs/xfs/libxfs/xfs_bmap.h

+ 5 - 4
fs/xfs/libxfs/xfs_bmap.c

@@ -4765,7 +4765,8 @@ xfs_bmap_del_extent(
 	xfs_btree_cur_t		*cur,	/* if null, not a btree */
 	xfs_btree_cur_t		*cur,	/* if null, not a btree */
 	xfs_bmbt_irec_t		*del,	/* data to remove from extents */
 	xfs_bmbt_irec_t		*del,	/* data to remove from extents */
 	int			*logflagsp, /* inode logging flags */
 	int			*logflagsp, /* inode logging flags */
-	int			whichfork) /* data or attr fork */
+	int			whichfork, /* data or attr fork */
+	int			bflags)	/* bmapi flags */
 {
 {
 	xfs_filblks_t		da_new;	/* new delay-alloc indirect blocks */
 	xfs_filblks_t		da_new;	/* new delay-alloc indirect blocks */
 	xfs_filblks_t		da_old;	/* old delay-alloc indirect blocks */
 	xfs_filblks_t		da_old;	/* old delay-alloc indirect blocks */
@@ -5057,7 +5058,7 @@ 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 && !(bflags & XFS_BMAPI_REMAP)) {
 		if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
 		if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
 			error = xfs_refcount_decrease_extent(mp, dfops, del);
 			error = xfs_refcount_decrease_extent(mp, dfops, del);
 			if (error)
 			if (error)
@@ -5075,7 +5076,7 @@ xfs_bmap_del_extent(
 	/*
 	/*
 	 * Adjust quota data.
 	 * Adjust quota data.
 	 */
 	 */
-	if (qfield)
+	if (qfield && !(bflags & XFS_BMAPI_REMAP))
 		xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks);
 		xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks);
 
 
 	/*
 	/*
@@ -5400,7 +5401,7 @@ xfs_bunmapi(
 			cur->bc_private.b.flags &= ~XFS_BTCUR_BPRV_WASDEL;
 			cur->bc_private.b.flags &= ~XFS_BTCUR_BPRV_WASDEL;
 
 
 		error = xfs_bmap_del_extent(ip, tp, &lastx, dfops, cur, &del,
 		error = xfs_bmap_del_extent(ip, tp, &lastx, dfops, cur, &del,
-				&tmp_logflags, whichfork);
+				&tmp_logflags, whichfork, flags);
 		logflags |= tmp_logflags;
 		logflags |= tmp_logflags;
 		if (error)
 		if (error)
 			goto error0;
 			goto error0;

+ 3 - 0
fs/xfs/libxfs/xfs_bmap.h

@@ -101,6 +101,9 @@ struct xfs_extent_free_item
  * Map the inode offset to the block given in ap->firstblock.  Primarily
  * Map the inode offset to the block given in ap->firstblock.  Primarily
  * used for reflink.  The range must be in a hole, and this flag cannot be
  * used for reflink.  The range must be in a hole, and this flag cannot be
  * turned on with PREALLOC or CONVERT, and cannot be used on the attr fork.
  * turned on with PREALLOC or CONVERT, and cannot be used on the attr fork.
+ *
+ * For bunmapi, this flag unmaps the range without adjusting quota, reducing
+ * refcount, or freeing the blocks.
  */
  */
 #define XFS_BMAPI_REMAP		0x100
 #define XFS_BMAPI_REMAP		0x100