diff options
author | Darrick J. Wong <djwong@kernel.org> | 2021-09-01 11:25:40 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2021-12-15 17:29:29 -0800 |
commit | bb3fa72be19cdab77e76e3ead6fe171b279e968e (patch) | |
tree | 62235a8c196baf9cd8ee23721cd8bf73219f2d3e /fs/xfs/scrub | |
parent | 9ce7cdaa061e17128626e0b880adfed00455931d (diff) |
xfs: allow userspace to rebuild metadata structuresdefrag-freespace_2021-12-15
Add a new (superuser-only) flag to the online metadata repair ioctl to
force it to rebuild structures, even if they're not broken. We will use
this to move metadata structures out of the way during a free space
defragmentation operation.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/scrub')
-rw-r--r-- | fs/xfs/scrub/scrub.c | 7 | ||||
-rw-r--r-- | fs/xfs/scrub/trace.h | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c index 104e27f0bc1c..882d60735648 100644 --- a/fs/xfs/scrub/scrub.c +++ b/fs/xfs/scrub/scrub.c @@ -464,6 +464,11 @@ xchk_validate_inputs( goto out; } + /* No rebuild without repair. */ + if ((sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) && + !(sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)) + return -EINVAL; + /* * We only want to repair read-write v5+ filesystems. Defer the check * for ops->repair until after our scrub confirms that we need to @@ -625,6 +630,8 @@ retry_op: /* Let debug users force us into the repair routines. */ if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) needs_fix = true; + if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) + needs_fix = true; /* * If userspace asked for a repair but it wasn't necessary, diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 80fcc76d9b69..1083ae5c5093 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -111,7 +111,8 @@ TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BARRIER); { XFS_SCRUB_OFLAG_WARNING, "warning" }, \ { XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED, "norepair" }, \ { XFS_SCRUB_IFLAG_FREEZE_OK, "freeze" }, \ - { XFS_SCRUB_IFLAG_RETAIN_INODES, "icache" } + { XFS_SCRUB_IFLAG_RETAIN_INODES, "icache" }, \ + { XFS_SCRUB_IFLAG_FORCE_REBUILD, "rebuild" } DECLARE_EVENT_CLASS(xchk_class, TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm, |