Commit 95eb308c authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: add BMAPI_NORMAP flag to perform block remapping without updating rmapbt

Add a new flag, XFS_BMAPI_NORMAP, which will perform file block
remapping without updating the rmapbt.  This will be used by the repair
code to reconstruct bmbts from the rmapbt, in which case we don't want
the rmapbt update.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 08daa3cc
...@@ -2005,10 +2005,13 @@ xfs_bmap_add_extent_delay_real( ...@@ -2005,10 +2005,13 @@ xfs_bmap_add_extent_delay_real(
ASSERT(0); ASSERT(0);
} }
/* add reverse mapping */ /* add reverse mapping unless caller opted out */
error = xfs_rmap_map_extent(mp, bma->dfops, bma->ip, whichfork, new); if (!(bma->flags & XFS_BMAPI_NORMAP)) {
error = xfs_rmap_map_extent(mp, bma->dfops, bma->ip,
whichfork, new);
if (error) if (error)
goto done; goto done;
}
/* convert to a btree if necessary */ /* convert to a btree if necessary */
if (xfs_bmap_needs_btree(bma->ip, whichfork)) { if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
...@@ -2672,7 +2675,8 @@ xfs_bmap_add_extent_hole_real( ...@@ -2672,7 +2675,8 @@ xfs_bmap_add_extent_hole_real(
struct xfs_bmbt_irec *new, struct xfs_bmbt_irec *new,
xfs_fsblock_t *first, xfs_fsblock_t *first,
struct xfs_defer_ops *dfops, struct xfs_defer_ops *dfops,
int *logflagsp) int *logflagsp,
int flags)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
...@@ -2849,10 +2853,12 @@ xfs_bmap_add_extent_hole_real( ...@@ -2849,10 +2853,12 @@ xfs_bmap_add_extent_hole_real(
break; break;
} }
/* add reverse mapping */ /* add reverse mapping unless caller opted out */
if (!(flags & XFS_BMAPI_NORMAP)) {
error = xfs_rmap_map_extent(mp, dfops, ip, whichfork, new); error = xfs_rmap_map_extent(mp, dfops, ip, whichfork, new);
if (error) if (error)
goto done; goto done;
}
/* convert to a btree if necessary */ /* convert to a btree if necessary */
if (xfs_bmap_needs_btree(ip, whichfork)) { if (xfs_bmap_needs_btree(ip, whichfork)) {
...@@ -4127,7 +4133,8 @@ xfs_bmapi_allocate( ...@@ -4127,7 +4133,8 @@ xfs_bmapi_allocate(
else else
error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip,
whichfork, &bma->icur, &bma->cur, &bma->got, whichfork, &bma->icur, &bma->cur, &bma->got,
bma->firstblock, bma->dfops, &bma->logflags); bma->firstblock, bma->dfops, &bma->logflags,
bma->flags);
bma->logflags |= tmp_logflags; bma->logflags |= tmp_logflags;
if (error) if (error)
...@@ -4573,7 +4580,7 @@ xfs_bmapi_remap( ...@@ -4573,7 +4580,7 @@ xfs_bmapi_remap(
got.br_state = XFS_EXT_NORM; got.br_state = XFS_EXT_NORM;
error = xfs_bmap_add_extent_hole_real(tp, ip, XFS_DATA_FORK, &icur, error = xfs_bmap_add_extent_hole_real(tp, ip, XFS_DATA_FORK, &icur,
&cur, &got, &firstblock, dfops, &logflags); &cur, &got, &firstblock, dfops, &logflags, 0);
if (error) if (error)
goto error0; goto error0;
......
...@@ -120,6 +120,9 @@ struct xfs_extent_free_item ...@@ -120,6 +120,9 @@ struct xfs_extent_free_item
/* Skip online discard of freed extents */ /* Skip online discard of freed extents */
#define XFS_BMAPI_NODISCARD 0x1000 #define XFS_BMAPI_NODISCARD 0x1000
/* Do not update the rmap btree. Used for reconstructing bmbt from rmapbt. */
#define XFS_BMAPI_NORMAP 0x2000
#define XFS_BMAPI_FLAGS \ #define XFS_BMAPI_FLAGS \
{ XFS_BMAPI_ENTIRE, "ENTIRE" }, \ { XFS_BMAPI_ENTIRE, "ENTIRE" }, \
{ XFS_BMAPI_METADATA, "METADATA" }, \ { XFS_BMAPI_METADATA, "METADATA" }, \
...@@ -133,7 +136,8 @@ struct xfs_extent_free_item ...@@ -133,7 +136,8 @@ struct xfs_extent_free_item
{ XFS_BMAPI_COWFORK, "COWFORK" }, \ { XFS_BMAPI_COWFORK, "COWFORK" }, \
{ XFS_BMAPI_DELALLOC, "DELALLOC" }, \ { XFS_BMAPI_DELALLOC, "DELALLOC" }, \
{ XFS_BMAPI_CONVERT_ONLY, "CONVERT_ONLY" }, \ { XFS_BMAPI_CONVERT_ONLY, "CONVERT_ONLY" }, \
{ XFS_BMAPI_NODISCARD, "NODISCARD" } { XFS_BMAPI_NODISCARD, "NODISCARD" }, \
{ XFS_BMAPI_NORMAP, "NORMAP" }
static inline int xfs_bmapi_aflag(int w) static inline int xfs_bmapi_aflag(int w)
......
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