]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: add BMAPI_NORMAP flag to perform block remapping without updating rmapbt
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 28 Jun 2018 20:11:56 +0000 (15:11 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 28 Jun 2018 20:11:56 +0000 (15:11 -0500)
Source kernel commit: 95eb308caa0ff7c4a0a86053422934737e6e6dc7

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: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_bmap.c
libxfs/xfs_bmap.h

index f894aff909a62779d76b063ff9a63799728aafe4..ee3a13d33a6afb55ec5138b524cc4df1b21eced1 100644 (file)
@@ -1996,10 +1996,13 @@ xfs_bmap_add_extent_delay_real(
                ASSERT(0);
        }
 
-       /* add reverse mapping */
-       error = xfs_rmap_map_extent(mp, bma->dfops, bma->ip, whichfork, new);
-       if (error)
-               goto done;
+       /* add reverse mapping unless caller opted out */
+       if (!(bma->flags & XFS_BMAPI_NORMAP)) {
+               error = xfs_rmap_map_extent(mp, bma->dfops, bma->ip,
+                               whichfork, new);
+               if (error)
+                       goto done;
+       }
 
        /* convert to a btree if necessary */
        if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
@@ -2663,7 +2666,8 @@ xfs_bmap_add_extent_hole_real(
        struct xfs_bmbt_irec    *new,
        xfs_fsblock_t           *first,
        struct xfs_defer_ops    *dfops,
-       int                     *logflagsp)
+       int                     *logflagsp,
+       int                     flags)
 {
        struct xfs_ifork        *ifp = XFS_IFORK_PTR(ip, whichfork);
        struct xfs_mount        *mp = ip->i_mount;
@@ -2840,10 +2844,12 @@ xfs_bmap_add_extent_hole_real(
                break;
        }
 
-       /* add reverse mapping */
-       error = xfs_rmap_map_extent(mp, dfops, ip, whichfork, new);
-       if (error)
-               goto done;
+       /* add reverse mapping unless caller opted out */
+       if (!(flags & XFS_BMAPI_NORMAP)) {
+               error = xfs_rmap_map_extent(mp, dfops, ip, whichfork, new);
+               if (error)
+                       goto done;
+       }
 
        /* convert to a btree if necessary */
        if (xfs_bmap_needs_btree(ip, whichfork)) {
@@ -4118,7 +4124,8 @@ xfs_bmapi_allocate(
        else
                error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip,
                                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;
        if (error)
@@ -4564,7 +4571,7 @@ xfs_bmapi_remap(
        got.br_state = XFS_EXT_NORM;
 
        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)
                goto error0;
 
index 8d8946bfdd8cd6c30fc9bbb6619866721941acd4..c46b73d1cb5bbdc03843c5932a8dea78431a89b3 100644 (file)
@@ -120,6 +120,9 @@ struct xfs_extent_free_item
 /* Skip online discard of freed extents */
 #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 \
        { XFS_BMAPI_ENTIRE,     "ENTIRE" }, \
        { XFS_BMAPI_METADATA,   "METADATA" }, \
@@ -133,7 +136,8 @@ struct xfs_extent_free_item
        { XFS_BMAPI_COWFORK,    "COWFORK" }, \
        { XFS_BMAPI_DELALLOC,   "DELALLOC" }, \
        { 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)