From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, cem@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 1/3] xfs_io: support passing the FORCE_REBUILD flag to online repair
Date: Mon, 25 Sep 2023 14:58:49 -0700 [thread overview]
Message-ID: <169567912995.2320149.4634874093845147114.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <169567912436.2320149.9404820627184014976.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
Add CLI options to the scrubv and repair commands so that the user can
pass FORCE_REBUILD to force the kernel to rebuild metadata.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
io/scrub.c | 24 ++++++++++++++++--------
man/man8/xfs_io.8 | 3 +++
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/io/scrub.c b/io/scrub.c
index fc22ba49f8b..dbdedf10099 100644
--- a/io/scrub.c
+++ b/io/scrub.c
@@ -46,7 +46,8 @@ scrub_ioctl(
int fd,
int type,
uint64_t control,
- uint32_t control2)
+ uint32_t control2,
+ uint32_t flags)
{
struct xfs_scrub_metadata meta;
const struct xfrog_scrub_descr *sc;
@@ -69,7 +70,7 @@ scrub_ioctl(
/* no control parameters */
break;
}
- meta.sm_flags = 0;
+ meta.sm_flags = flags;
error = ioctl(fd, XFS_IOC_SCRUB_METADATA, &meta);
if (error)
@@ -91,17 +92,21 @@ parse_args(
int argc,
char **argv,
struct cmdinfo *cmdinfo,
- void (*fn)(int, int, uint64_t, uint32_t))
+ void (*fn)(int, int, uint64_t, uint32_t, uint32_t))
{
char *p;
int type = -1;
int i, c;
uint64_t control = 0;
uint32_t control2 = 0;
+ uint32_t flags = 0;
const struct xfrog_scrub_descr *d = NULL;
- while ((c = getopt(argc, argv, "")) != EOF) {
+ while ((c = getopt(argc, argv, "R")) != EOF) {
switch (c) {
+ case 'R':
+ flags |= XFS_SCRUB_IFLAG_FORCE_REBUILD;
+ break;
default:
return command_usage(cmdinfo);
}
@@ -173,7 +178,7 @@ parse_args(
ASSERT(0);
break;
}
- fn(file->fd, type, control, control2);
+ fn(file->fd, type, control, control2, flags);
return 0;
}
@@ -216,11 +221,13 @@ repair_help(void)
" or (optionally) take an inode number and generation number to act upon as\n"
" the second and third parameters.\n"
"\n"
+" Flags are -R to force rebuilding metadata.\n"
+"\n"
" Example:\n"
" 'repair inobt 3' - repairs the inode btree in AG 3.\n"
" 'repair bmapbtd 128 13525' - repairs the extent map of inode 128 gen 13525.\n"
"\n"
-" Known metadata repairs types are:"));
+" Known metadata repair types are:"));
for (i = 0, d = xfrog_scrubbers; i < XFS_SCRUB_TYPE_NR; i++, d++)
printf(" %s", d->name);
printf("\n");
@@ -231,7 +238,8 @@ repair_ioctl(
int fd,
int type,
uint64_t control,
- uint32_t control2)
+ uint32_t control2,
+ uint32_t flags)
{
struct xfs_scrub_metadata meta;
const struct xfrog_scrub_descr *sc;
@@ -254,7 +262,7 @@ repair_ioctl(
/* no control parameters */
break;
}
- meta.sm_flags = XFS_SCRUB_IFLAG_REPAIR;
+ meta.sm_flags = flags | XFS_SCRUB_IFLAG_REPAIR;
error = ioctl(fd, XFS_IOC_SCRUB_METADATA, &meta);
if (error)
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index ef7087b3d09..d46dc369a06 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -1340,6 +1340,9 @@ parameter specifies which type of metadata to repair.
For AG metadata, one AG number must be specified.
For file metadata, the repair is applied to the open file unless the
inode number and generation number are specified.
+The
+.B -R
+option can be specified to force rebuilding of a metadata structure.
.TP
.BI "label" " " "[ -c | -s " label " ] "
On filesystems that support online label manipulation, get, set, or clear the
next prev parent reply other threads:[~2023-09-25 21:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <iq6M2jOFTA7tpkemhj2B-jYNUxbdZWyn_T3zy7D3OK-XjdJMLzOaQp_x201-WWr0NRp1s5vaAspRGyQm7l2hqQ==@protonmail.internalid>
2023-09-25 21:58 ` [PATCHSET v26.2 0/3] xfsprogs: force rebuilding of metadata Darrick J. Wong
2023-09-25 21:58 ` Darrick J. Wong [this message]
2023-09-25 21:58 ` [PATCH 2/3] xfs_scrub: don't retry unsupported optimizations Darrick J. Wong
2023-09-25 21:59 ` [PATCH 3/3] xfs_scrub: try to use XFS_SCRUB_IFLAG_FORCE_REBUILD Darrick J. Wong
2023-10-03 11:33 ` [PATCHSET v26.2 0/3] xfsprogs: force rebuilding of metadata Carlos Maiolino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=169567912995.2320149.4634874093845147114.stgit@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox