diff options
author | Christoph Hellwig <hch@lst.de> | 2017-11-16 22:11:35 -0600 |
---|---|---|
committer | Eric Sandeen <sandeen@redhat.com> | 2017-11-16 22:11:35 -0600 |
commit | 8e87c8847a2933650fb288b5f32d1141e7694860 (patch) | |
tree | 38c0f66e6428abd7259e0539b85ad13a846f33c1 | |
parent | 9788e059ce7c64ae5d7618e6e088625af2e335e2 (diff) | |
download | xfsprogs-dev-8e87c8847a2933650fb288b5f32d1141e7694860.tar.gz |
xfs: simplify xfs_reflink_convert_cow
Source kernel commit: b121459c7a56d2fb5a8ca6727bf9f87982738b01
Instead of looking up extents to convert and calling xfs_bmapi_write on
each of them just let xfs_bmapi_write handle the full range. To make
this robust add a new XFS_BMAPI_CONVERT_ONLY that only converts ranges
and never allocates blocks.
[darrick: shorten the stringified CONVERT_ONLY trace flag]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r-- | libxfs/xfs_bmap.c | 3 | ||||
-rw-r--r-- | libxfs/xfs_bmap.h | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 0821397e48..3d1bfa9a08 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -4322,7 +4322,8 @@ xfs_bmapi_write( * First, deal with the hole before the allocated space * that we found, if any. */ - if (need_alloc || wasdelay) { + if ((need_alloc || wasdelay) && + !(flags & XFS_BMAPI_CONVERT_ONLY)) { bma.eof = eof; bma.conv = !!(flags & XFS_BMAPI_CONVERT); bma.wasdel = wasdelay; diff --git a/libxfs/xfs_bmap.h b/libxfs/xfs_bmap.h index b6a395949d..e36d75799c 100644 --- a/libxfs/xfs_bmap.h +++ b/libxfs/xfs_bmap.h @@ -113,6 +113,9 @@ struct xfs_extent_free_item /* Only convert delalloc space, don't allocate entirely new extents */ #define XFS_BMAPI_DELALLOC 0x400 +/* Only convert unwritten extents, don't allocate new blocks */ +#define XFS_BMAPI_CONVERT_ONLY 0x800 + #define XFS_BMAPI_FLAGS \ { XFS_BMAPI_ENTIRE, "ENTIRE" }, \ { XFS_BMAPI_METADATA, "METADATA" }, \ @@ -124,7 +127,8 @@ struct xfs_extent_free_item { XFS_BMAPI_ZERO, "ZERO" }, \ { XFS_BMAPI_REMAP, "REMAP" }, \ { XFS_BMAPI_COWFORK, "COWFORK" }, \ - { XFS_BMAPI_DELALLOC, "DELALLOC" } + { XFS_BMAPI_DELALLOC, "DELALLOC" }, \ + { XFS_BMAPI_CONVERT_ONLY, "CONVERT_ONLY" } static inline int xfs_bmapi_aflag(int w) |