Commit 7644bd98 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: teach xfs_bmapi_remap to accept some bmapi flags

Teach xfs_bmapi_remap how to map in unwritten extent and to skip rmap
updates.  This enables us to rebuild real and unwritten extents from the
rmapbt.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 7cf199ba
...@@ -4543,7 +4543,10 @@ xfs_bmapi_remap( ...@@ -4543,7 +4543,10 @@ xfs_bmapi_remap(
ASSERT(len > 0); ASSERT(len > 0);
ASSERT(len <= (xfs_filblks_t)MAXEXTLEN); ASSERT(len <= (xfs_filblks_t)MAXEXTLEN);
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
ASSERT(!(flags & ~(XFS_BMAPI_ATTRFORK))); ASSERT(!(flags & ~(XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC |
XFS_BMAPI_NORMAP)));
ASSERT((flags & (XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC)) !=
(XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC));
if (unlikely(XFS_TEST_ERROR( if (unlikely(XFS_TEST_ERROR(
(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&
...@@ -4581,7 +4584,10 @@ xfs_bmapi_remap( ...@@ -4581,7 +4584,10 @@ xfs_bmapi_remap(
got.br_startoff = bno; got.br_startoff = bno;
got.br_startblock = startblock; got.br_startblock = startblock;
got.br_blockcount = len; got.br_blockcount = len;
got.br_state = XFS_EXT_NORM; if (flags & XFS_BMAPI_PREALLOC)
got.br_state = XFS_EXT_UNWRITTEN;
else
got.br_state = XFS_EXT_NORM;
error = xfs_bmap_add_extent_hole_real(tp, ip, whichfork, &icur, error = xfs_bmap_add_extent_hole_real(tp, ip, whichfork, &icur,
&cur, &got, &firstblock, dfops, &logflags, flags); &cur, &got, &firstblock, dfops, &logflags, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment