From patchwork Wed Dec 20 17:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13500403 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F02604777A for ; Wed, 20 Dec 2023 17:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ueyDWLvF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B941FC433C8; Wed, 20 Dec 2023 17:14:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703092473; bh=UKMhh4vUQ5+mlvx3PX22RA/0F31AJ/mw5lFiem5eTyE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ueyDWLvF6lTJwShUAVCULrNBpYvmkkTuuBrWWYmOY85byk5iB2NL+Z4FI/T6kYrlc xu3mAvjBNHwBywV8G1v7llmh2bM+TXlpl8R4sIFSloRGA86K6dDYvfb3EFZCmOkdFQ o4h70V2io/oQpoeIjBe98AKYC2mpw2Ju9CgrZuQkccW3XrsZQfm3MJQ9YaLBLKY72t O2UPWnLYR1bhtWqufSLMPq3h4o3kq322dVVvodC2COcNdqxlSKxodQpX2Un7qAfg3/ 1M2jruOAY2+EWfkX3EWlYHYBp79L47vhoNlyzT4eJGFvsZ6ggtfRZ9I9ftGY5vQ7jS iDZ/eFsNa+w7g== Date: Wed, 20 Dec 2023 09:14:33 -0800 Subject: [PATCH 1/4] xfs_io: set exitcode = 1 on parsing errors in scrub/repair command From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170309219094.1608142.4865155109436063528.stgit@frogsfrogsfrogs> In-Reply-To: <170309219080.1608142.737701463093437769.stgit@frogsfrogsfrogs> References: <170309219080.1608142.737701463093437769.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Set exitcode to 1 if there is an error parsing the CLI arguments to the scrub or repair commands, like we do most other places in xfs_io. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- io/scrub.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/io/scrub.c b/io/scrub.c index fc22ba49..8b3bdd77 100644 --- a/io/scrub.c +++ b/io/scrub.c @@ -103,11 +103,14 @@ parse_args( while ((c = getopt(argc, argv, "")) != EOF) { switch (c) { default: + exitcode = 1; return command_usage(cmdinfo); } } - if (optind > argc - 1) + if (optind > argc - 1) { + exitcode = 1; return command_usage(cmdinfo); + } for (i = 0, d = xfrog_scrubbers; i < XFS_SCRUB_TYPE_NR; i++, d++) { if (strcmp(d->name, argv[optind]) == 0) { @@ -117,6 +120,7 @@ parse_args( } if (type < 0) { printf(_("Unknown type '%s'.\n"), argv[optind]); + exitcode = 1; return command_usage(cmdinfo); } optind++; @@ -132,19 +136,22 @@ parse_args( fprintf(stderr, _("Bad inode number '%s'.\n"), argv[optind]); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } control2 = strtoul(argv[optind + 1], &p, 0); if (*p != '\0') { fprintf(stderr, _("Bad generation number '%s'.\n"), argv[optind + 1]); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } } else { fprintf(stderr, _("Must specify inode number and generation.\n")); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } break; case XFROG_SCRUB_TYPE_AGHEADER: @@ -152,13 +159,15 @@ parse_args( if (optind != argc - 1) { fprintf(stderr, _("Must specify one AG number.\n")); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } control = strtoul(argv[optind], &p, 0); if (*p != '\0') { fprintf(stderr, _("Bad AG number '%s'.\n"), argv[optind]); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } break; case XFROG_SCRUB_TYPE_FS: @@ -166,7 +175,8 @@ parse_args( if (optind != argc) { fprintf(stderr, _("No parameters allowed.\n")); - return 0; + exitcode = 1; + return command_usage(cmdinfo); } break; default: From patchwork Wed Dec 20 17:14:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13500404 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FA0B47787 for ; Wed, 20 Dec 2023 17:14:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ernGT/6g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64A19C433C7; Wed, 20 Dec 2023 17:14:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703092489; bh=gZHG9gFNGDYJOMfHUNWI/dOFGVtRgNuxNifk+/8yYvA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ernGT/6gjwdjP5KPgiAK4q1wWorgX8NJTlRclXZIc7EDaM5vpSKhMBCC6nHjfbSWH 1Iua3ITvsKGgZbH557PDs4rYlbBhTMbx87UcT+hbxV2x5qci+AhquFNrFfhd7AcM4o yT9Iz57MpzrmAGbYdSWOPCzF0B4amQjDEdUYH7+EoNu8azAB74fJUEV4rnEK3MOwOs DMZ1Mgbs+vMd7OtCe9KvXFpmC7Q013eT6bnuy84RKShhMF9npB1zTqvXXmSM8rmisf D2mSEJ21DDVtvFhg9JsgdnF73VIUu5+tv8nk3lGwWMjtSSIyo/8VhGDd7IjM+xHrWV CHwfyCDrB/G0Q== Date: Wed, 20 Dec 2023 09:14:48 -0800 Subject: [PATCH 2/4] xfs_io: collapse trivial helpers From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170309219107.1608142.4643674100831010643.stgit@frogsfrogsfrogs> In-Reply-To: <170309219080.1608142.737701463093437769.stgit@frogsfrogsfrogs> References: <170309219080.1608142.737701463093437769.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Simply the call chain by having parse_args set the scrub ioctl parameters in the caller's object. The parse_args callers can then invoke the ioctl directly, eliminating one function and one indirect call. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- io/scrub.c | 124 +++++++++++++++++++----------------------------------------- 1 file changed, 40 insertions(+), 84 deletions(-) diff --git a/io/scrub.c b/io/scrub.c index 8b3bdd77..238d9240 100644 --- a/io/scrub.c +++ b/io/scrub.c @@ -41,57 +41,12 @@ scrub_help(void) printf("\n"); } -static void -scrub_ioctl( - int fd, - int type, - uint64_t control, - uint32_t control2) -{ - struct xfs_scrub_metadata meta; - const struct xfrog_scrub_descr *sc; - int error; - - sc = &xfrog_scrubbers[type]; - memset(&meta, 0, sizeof(meta)); - meta.sm_type = type; - switch (sc->type) { - case XFROG_SCRUB_TYPE_AGHEADER: - case XFROG_SCRUB_TYPE_PERAG: - meta.sm_agno = control; - break; - case XFROG_SCRUB_TYPE_INODE: - meta.sm_ino = control; - meta.sm_gen = control2; - break; - case XFROG_SCRUB_TYPE_NONE: - case XFROG_SCRUB_TYPE_FS: - /* no control parameters */ - break; - } - meta.sm_flags = 0; - - error = ioctl(fd, XFS_IOC_SCRUB_METADATA, &meta); - if (error) - perror("scrub"); - if (meta.sm_flags & XFS_SCRUB_OFLAG_CORRUPT) - printf(_("Corruption detected.\n")); - if (meta.sm_flags & XFS_SCRUB_OFLAG_PREEN) - printf(_("Optimization possible.\n")); - if (meta.sm_flags & XFS_SCRUB_OFLAG_XFAIL) - printf(_("Cross-referencing failed.\n")); - if (meta.sm_flags & XFS_SCRUB_OFLAG_XCORRUPT) - printf(_("Corruption detected during cross-referencing.\n")); - if (meta.sm_flags & XFS_SCRUB_OFLAG_INCOMPLETE) - printf(_("Scan was not complete.\n")); -} - static int parse_args( int argc, char **argv, - struct cmdinfo *cmdinfo, - void (*fn)(int, int, uint64_t, uint32_t)) + const struct cmdinfo *cmdinfo, + struct xfs_scrub_metadata *meta) { char *p; int type = -1; @@ -100,6 +55,7 @@ parse_args( uint32_t control2 = 0; const struct xfrog_scrub_descr *d = NULL; + memset(meta, 0, sizeof(struct xfs_scrub_metadata)); while ((c = getopt(argc, argv, "")) != EOF) { switch (c) { default: @@ -125,6 +81,8 @@ parse_args( } optind++; + meta->sm_type = type; + switch (d->type) { case XFROG_SCRUB_TYPE_INODE: if (optind == argc) { @@ -153,6 +111,8 @@ parse_args( exitcode = 1; return command_usage(cmdinfo); } + meta->sm_ino = control; + meta->sm_gen = control2; break; case XFROG_SCRUB_TYPE_AGHEADER: case XFROG_SCRUB_TYPE_PERAG: @@ -169,6 +129,7 @@ parse_args( exitcode = 1; return command_usage(cmdinfo); } + meta->sm_agno = control; break; case XFROG_SCRUB_TYPE_FS: case XFROG_SCRUB_TYPE_NONE: @@ -178,13 +139,12 @@ parse_args( exitcode = 1; return command_usage(cmdinfo); } + /* no control parameters */ break; default: ASSERT(0); break; } - fn(file->fd, type, control, control2); - return 0; } @@ -193,7 +153,27 @@ scrub_f( int argc, char **argv) { - return parse_args(argc, argv, &scrub_cmd, scrub_ioctl); + struct xfs_scrub_metadata meta; + int error; + + error = parse_args(argc, argv, &scrub_cmd, &meta); + if (error) + return error; + + error = ioctl(file->fd, XFS_IOC_SCRUB_METADATA, &meta); + if (error) + perror("scrub"); + if (meta.sm_flags & XFS_SCRUB_OFLAG_CORRUPT) + printf(_("Corruption detected.\n")); + if (meta.sm_flags & XFS_SCRUB_OFLAG_PREEN) + printf(_("Optimization possible.\n")); + if (meta.sm_flags & XFS_SCRUB_OFLAG_XFAIL) + printf(_("Cross-referencing failed.\n")); + if (meta.sm_flags & XFS_SCRUB_OFLAG_XCORRUPT) + printf(_("Corruption detected during cross-referencing.\n")); + if (meta.sm_flags & XFS_SCRUB_OFLAG_INCOMPLETE) + printf(_("Scan was not complete.\n")); + return 0; } void @@ -236,37 +216,20 @@ repair_help(void) printf("\n"); } -static void -repair_ioctl( - int fd, - int type, - uint64_t control, - uint32_t control2) +static int +repair_f( + int argc, + char **argv) { struct xfs_scrub_metadata meta; - const struct xfrog_scrub_descr *sc; int error; - sc = &xfrog_scrubbers[type]; - memset(&meta, 0, sizeof(meta)); - meta.sm_type = type; - switch (sc->type) { - case XFROG_SCRUB_TYPE_AGHEADER: - case XFROG_SCRUB_TYPE_PERAG: - meta.sm_agno = control; - break; - case XFROG_SCRUB_TYPE_INODE: - meta.sm_ino = control; - meta.sm_gen = control2; - break; - case XFROG_SCRUB_TYPE_NONE: - case XFROG_SCRUB_TYPE_FS: - /* no control parameters */ - break; - } - meta.sm_flags = XFS_SCRUB_IFLAG_REPAIR; + error = parse_args(argc, argv, &repair_cmd, &meta); + if (error) + return error; + meta.sm_flags |= XFS_SCRUB_IFLAG_REPAIR; - error = ioctl(fd, XFS_IOC_SCRUB_METADATA, &meta); + error = ioctl(file->fd, XFS_IOC_SCRUB_METADATA, &meta); if (error) perror("repair"); if (meta.sm_flags & XFS_SCRUB_OFLAG_CORRUPT) @@ -281,14 +244,7 @@ repair_ioctl( printf(_("Repair was not complete.\n")); if (meta.sm_flags & XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED) printf(_("Metadata did not need repair or optimization.\n")); -} - -static int -repair_f( - int argc, - char **argv) -{ - return parse_args(argc, argv, &repair_cmd, repair_ioctl); + return 0; } void From patchwork Wed Dec 20 17:15:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13500405 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 361D34776B for ; Wed, 20 Dec 2023 17:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DnLfbRxt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F337FC433C7; Wed, 20 Dec 2023 17:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703092505; bh=CHCl/zMNcMr3PiLIAfk3i8JhfwnPwjrznk09LJEW9UE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=DnLfbRxtEqJA2uQ2Dns+n1MbCWwMA8MDWrNXcZgg/HtuYLRWkba+56qsk6MDt4gMG zvD7bSJJvKbc+hJm/y0KTv1VAt1mkWHvYovAJgtBX9Eadq+eRbH4jpeDinhZE8h/FY ZQRFbQz+j8M408xa//9972bEsQw/OmZyWhyHVAXQYxlWwXdEnoSVHoRrBevrHM3p8s FudB1mQQcHt5/jimXCmQPnyWrRh7KWAt1ppfRiAhZoxhjJjbnueXy/3QpXHrqGPDuS +2Re9UqGSRXEmMPlGanaHzk8l49BiZZvSzof28WSVYkjBBKRTHzD1vX6n2M1SFz0M/ ydIYP4taI78uQ== Date: Wed, 20 Dec 2023 09:15:04 -0800 Subject: [PATCH 3/4] xfs_io: extract contorl number parsing routines From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170309219120.1608142.14150492359425333052.stgit@frogsfrogsfrogs> In-Reply-To: <170309219080.1608142.737701463093437769.stgit@frogsfrogsfrogs> References: <170309219080.1608142.737701463093437769.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Break out the parts of parse_args that extract control numbers from the CLI arguments, so that the function isn't as long. This isn't all that exciting now, but the scrub vectorization speedups will introduce a new ioctl. For the new command that comes with that, we'll want the control number parsing helpers. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- io/scrub.c | 128 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 43 deletions(-) diff --git a/io/scrub.c b/io/scrub.c index 238d9240..cde788fb 100644 --- a/io/scrub.c +++ b/io/scrub.c @@ -41,6 +41,87 @@ scrub_help(void) printf("\n"); } +static bool +parse_inode( + int argc, + char **argv, + int optind, + __u64 *ino, + __u32 *gen) +{ + char *p; + unsigned long long control; + unsigned long control2; + + if (optind == argc) { + *ino = 0; + *gen = 0; + return true; + } + + if (optind != argc - 2) { + fprintf(stderr, + _("Must specify inode number and generation.\n")); + return false; + } + + control = strtoull(argv[optind], &p, 0); + if (*p != '\0') { + fprintf(stderr, _("Bad inode number '%s'.\n"), + argv[optind]); + return false; + } + control2 = strtoul(argv[optind + 1], &p, 0); + if (*p != '\0') { + fprintf(stderr, _("Bad generation number '%s'.\n"), + argv[optind + 1]); + return false; + } + + *ino = control; + *gen = control2; + return true; +} + +static bool +parse_agno( + int argc, + char **argv, + int optind, + __u32 *agno) +{ + char *p; + unsigned long control; + + if (optind != argc - 1) { + fprintf(stderr, _("Must specify one AG number.\n")); + return false; + } + + control = strtoul(argv[optind], &p, 0); + if (*p != '\0') { + fprintf(stderr, _("Bad AG number '%s'.\n"), argv[optind]); + return false; + } + + *agno = control; + return true; +} + +static bool +parse_none( + int argc, + int optind) +{ + if (optind != argc) { + fprintf(stderr, _("No parameters allowed.\n")); + return false; + } + + /* no control parameters */ + return true; +} + static int parse_args( int argc, @@ -48,11 +129,8 @@ parse_args( const struct cmdinfo *cmdinfo, struct xfs_scrub_metadata *meta) { - char *p; int type = -1; int i, c; - uint64_t control = 0; - uint32_t control2 = 0; const struct xfrog_scrub_descr *d = NULL; memset(meta, 0, sizeof(struct xfs_scrub_metadata)); @@ -85,61 +163,25 @@ parse_args( switch (d->type) { case XFROG_SCRUB_TYPE_INODE: - if (optind == argc) { - control = 0; - control2 = 0; - } else if (optind == argc - 2) { - control = strtoull(argv[optind], &p, 0); - if (*p != '\0') { - fprintf(stderr, - _("Bad inode number '%s'.\n"), - argv[optind]); - exitcode = 1; - return command_usage(cmdinfo); - } - control2 = strtoul(argv[optind + 1], &p, 0); - if (*p != '\0') { - fprintf(stderr, - _("Bad generation number '%s'.\n"), - argv[optind + 1]); - exitcode = 1; - return command_usage(cmdinfo); - } - } else { - fprintf(stderr, - _("Must specify inode number and generation.\n")); + if (!parse_inode(argc, argv, optind, &meta->sm_ino, + &meta->sm_gen)) { exitcode = 1; return command_usage(cmdinfo); } - meta->sm_ino = control; - meta->sm_gen = control2; break; case XFROG_SCRUB_TYPE_AGHEADER: case XFROG_SCRUB_TYPE_PERAG: - if (optind != argc - 1) { - fprintf(stderr, - _("Must specify one AG number.\n")); + if (!parse_agno(argc, argv, optind, &meta->sm_agno)) { exitcode = 1; return command_usage(cmdinfo); } - control = strtoul(argv[optind], &p, 0); - if (*p != '\0') { - fprintf(stderr, - _("Bad AG number '%s'.\n"), argv[optind]); - exitcode = 1; - return command_usage(cmdinfo); - } - meta->sm_agno = control; break; case XFROG_SCRUB_TYPE_FS: case XFROG_SCRUB_TYPE_NONE: - if (optind != argc) { - fprintf(stderr, - _("No parameters allowed.\n")); + if (!parse_none(argc, optind)) { exitcode = 1; return command_usage(cmdinfo); } - /* no control parameters */ break; default: ASSERT(0); From patchwork Wed Dec 20 17:15:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13500406 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0258847789 for ; Wed, 20 Dec 2023 17:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q5rTouIF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 933C4C433C8; Wed, 20 Dec 2023 17:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703092520; bh=4ZnHxdmIN4pNizR4EjfnFMU2oEkYnIPvXX17Ls+58Uo=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Q5rTouIFK5hNRdR+NvpE2fsFwuNl/hvApfP0IBrg/Hv+6HE+zMC5dahYrJQYuk6BN ZF//Q7Jo91TJoLoUWVGOXeNnWjEhdRmCm/Em3qwPTMpZonR1zqDTtteOa60NThXD7e nXxY8tWIe5ZjmBPpCejlVuPYoqFIzPjzcMJcIOzTLJaiHgAIHyvuJLhUnX4VglSyr1 jFM7V2YB8RtYj6I2v5gvJntvZoY4bkJDJNqK2t/ps58m6YveG7JvFiPYSDWYEZdzr6 HDcvdsNYT0n+9jO1lFrvDCee3u81NMJANTdnlpzTMKZqKXdR3Ts96a5mIKdWhRhyRw ewRBCebrLlSxg== Date: Wed, 20 Dec 2023 09:15:20 -0800 Subject: [PATCH 4/4] xfs_io: support passing the FORCE_REBUILD flag to online repair From: "Darrick J. Wong" To: djwong@kernel.org, cem@kernel.org Cc: Carlos Maiolino , Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <170309219133.1608142.1654531129225506927.stgit@frogsfrogsfrogs> In-Reply-To: <170309219080.1608142.737701463093437769.stgit@frogsfrogsfrogs> References: <170309219080.1608142.737701463093437769.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong 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 Reviewed-by: Carlos Maiolino Reviewed-by: Christoph Hellwig --- io/scrub.c | 11 +++++++++-- man/man8/xfs_io.8 | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/io/scrub.c b/io/scrub.c index cde788fb..403b3a72 100644 --- a/io/scrub.c +++ b/io/scrub.c @@ -131,11 +131,15 @@ parse_args( { int type = -1; int i, c; + uint32_t flags = 0; const struct xfrog_scrub_descr *d = NULL; memset(meta, 0, sizeof(struct xfs_scrub_metadata)); - 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: exitcode = 1; return command_usage(cmdinfo); @@ -160,6 +164,7 @@ parse_args( optind++; meta->sm_type = type; + meta->sm_flags = flags; switch (d->type) { case XFROG_SCRUB_TYPE_INODE: @@ -248,11 +253,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"); diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8 index ef7087b3..d46dc369 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