Skip to content

Commit 4847acf

Browse files
committed
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>
1 parent f65306e commit 4847acf

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,7 +4765,8 @@ xfs_bmap_del_extent(
47654765
xfs_btree_cur_t *cur, /* if null, not a btree */
47664766
xfs_bmbt_irec_t *del, /* data to remove from extents */
47674767
int *logflagsp, /* inode logging flags */
4768-
int whichfork) /* data or attr fork */
4768+
int whichfork, /* data or attr fork */
4769+
int bflags) /* bmapi flags */
47694770
{
47704771
xfs_filblks_t da_new; /* new delay-alloc indirect blocks */
47714772
xfs_filblks_t da_old; /* old delay-alloc indirect blocks */
@@ -5057,7 +5058,7 @@ xfs_bmap_del_extent(
50575058
/*
50585059
* If we need to, add to list of extents to delete.
50595060
*/
5060-
if (do_fx) {
5061+
if (do_fx && !(bflags & XFS_BMAPI_REMAP)) {
50615062
if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
50625063
error = xfs_refcount_decrease_extent(mp, dfops, del);
50635064
if (error)
@@ -5075,7 +5076,7 @@ xfs_bmap_del_extent(
50755076
/*
50765077
* Adjust quota data.
50775078
*/
5078-
if (qfield)
5079+
if (qfield && !(bflags & XFS_BMAPI_REMAP))
50795080
xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks);
50805081

50815082
/*
@@ -5400,7 +5401,7 @@ xfs_bunmapi(
54005401
cur->bc_private.b.flags &= ~XFS_BTCUR_BPRV_WASDEL;
54015402

54025403
error = xfs_bmap_del_extent(ip, tp, &lastx, dfops, cur, &del,
5403-
&tmp_logflags, whichfork);
5404+
&tmp_logflags, whichfork, flags);
54045405
logflags |= tmp_logflags;
54055406
if (error)
54065407
goto error0;

fs/xfs/libxfs/xfs_bmap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ struct xfs_extent_free_item
101101
* Map the inode offset to the block given in ap->firstblock. Primarily
102102
* used for reflink. The range must be in a hole, and this flag cannot be
103103
* turned on with PREALLOC or CONVERT, and cannot be used on the attr fork.
104+
*
105+
* For bunmapi, this flag unmaps the range without adjusting quota, reducing
106+
* refcount, or freeing the blocks.
104107
*/
105108
#define XFS_BMAPI_REMAP 0x100
106109

0 commit comments

Comments
 (0)