Skip to content

Commit 95eb308

Browse files
committed
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: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 08daa3c commit 95eb308

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,10 +2005,13 @@ xfs_bmap_add_extent_delay_real(
20052005
ASSERT(0);
20062006
}
20072007

2008-
/* add reverse mapping */
2009-
error = xfs_rmap_map_extent(mp, bma->dfops, bma->ip, whichfork, new);
2010-
if (error)
2011-
goto done;
2008+
/* add reverse mapping unless caller opted out */
2009+
if (!(bma->flags & XFS_BMAPI_NORMAP)) {
2010+
error = xfs_rmap_map_extent(mp, bma->dfops, bma->ip,
2011+
whichfork, new);
2012+
if (error)
2013+
goto done;
2014+
}
20122015

20132016
/* convert to a btree if necessary */
20142017
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
@@ -2672,7 +2675,8 @@ xfs_bmap_add_extent_hole_real(
26722675
struct xfs_bmbt_irec *new,
26732676
xfs_fsblock_t *first,
26742677
struct xfs_defer_ops *dfops,
2675-
int *logflagsp)
2678+
int *logflagsp,
2679+
int flags)
26762680
{
26772681
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
26782682
struct xfs_mount *mp = ip->i_mount;
@@ -2849,10 +2853,12 @@ xfs_bmap_add_extent_hole_real(
28492853
break;
28502854
}
28512855

2852-
/* add reverse mapping */
2853-
error = xfs_rmap_map_extent(mp, dfops, ip, whichfork, new);
2854-
if (error)
2855-
goto done;
2856+
/* add reverse mapping unless caller opted out */
2857+
if (!(flags & XFS_BMAPI_NORMAP)) {
2858+
error = xfs_rmap_map_extent(mp, dfops, ip, whichfork, new);
2859+
if (error)
2860+
goto done;
2861+
}
28562862

28572863
/* convert to a btree if necessary */
28582864
if (xfs_bmap_needs_btree(ip, whichfork)) {
@@ -4127,7 +4133,8 @@ xfs_bmapi_allocate(
41274133
else
41284134
error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip,
41294135
whichfork, &bma->icur, &bma->cur, &bma->got,
4130-
bma->firstblock, bma->dfops, &bma->logflags);
4136+
bma->firstblock, bma->dfops, &bma->logflags,
4137+
bma->flags);
41314138

41324139
bma->logflags |= tmp_logflags;
41334140
if (error)
@@ -4573,7 +4580,7 @@ xfs_bmapi_remap(
45734580
got.br_state = XFS_EXT_NORM;
45744581

45754582
error = xfs_bmap_add_extent_hole_real(tp, ip, XFS_DATA_FORK, &icur,
4576-
&cur, &got, &firstblock, dfops, &logflags);
4583+
&cur, &got, &firstblock, dfops, &logflags, 0);
45774584
if (error)
45784585
goto error0;
45794586

fs/xfs/libxfs/xfs_bmap.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ struct xfs_extent_free_item
120120
/* Skip online discard of freed extents */
121121
#define XFS_BMAPI_NODISCARD 0x1000
122122

123+
/* Do not update the rmap btree. Used for reconstructing bmbt from rmapbt. */
124+
#define XFS_BMAPI_NORMAP 0x2000
125+
123126
#define XFS_BMAPI_FLAGS \
124127
{ XFS_BMAPI_ENTIRE, "ENTIRE" }, \
125128
{ XFS_BMAPI_METADATA, "METADATA" }, \
@@ -133,7 +136,8 @@ struct xfs_extent_free_item
133136
{ XFS_BMAPI_COWFORK, "COWFORK" }, \
134137
{ XFS_BMAPI_DELALLOC, "DELALLOC" }, \
135138
{ XFS_BMAPI_CONVERT_ONLY, "CONVERT_ONLY" }, \
136-
{ XFS_BMAPI_NODISCARD, "NODISCARD" }
139+
{ XFS_BMAPI_NODISCARD, "NODISCARD" }, \
140+
{ XFS_BMAPI_NORMAP, "NORMAP" }
137141

138142

139143
static inline int xfs_bmapi_aflag(int w)

0 commit comments

Comments
 (0)