]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_io: support scrubbing rtgroup metadata paths
authorDarrick J. Wong <djwong@kernel.org>
Thu, 21 Nov 2024 00:24:39 +0000 (16:24 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 24 Dec 2024 02:01:34 +0000 (18:01 -0800)
Support scrubbing the metadata directory path of an rtgroup metadata
file.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
io/scrub.c
man/man8/xfs_io.8

index 99c24d9550243c084e4b6763ef00a2db2bf70802..a137f402b94d4884d81002fdeb498089b2e1b542 100644 (file)
@@ -136,21 +136,23 @@ parse_metapath(
        int             argc,
        char            **argv,
        int             optind,
-       __u64           *ino)
+       __u64           *ino,
+       __u32           *group)
 {
        char            *p;
        unsigned long long control;
+       unsigned long   control2 = 0;
        int             i;
 
-       if (optind != argc - 1) {
+       if (optind != argc - 1 && optind != argc - 2) {
                fprintf(stderr, _("Must specify metapath number.\n"));
                return false;
        }
 
        for (i = 0; i < XFS_SCRUB_METAPATH_NR; i++) {
                if (!strcmp(argv[optind], xfrog_metapaths[i].name)) {
-                       *ino = i;
-                       return true;
+                       control = i;
+                       goto find_group;
                }
        }
 
@@ -161,7 +163,32 @@ parse_metapath(
                return false;
        }
 
+find_group:
+       if (xfrog_metapaths[control].group == XFROG_SCRUB_GROUP_RTGROUP) {
+               if (optind == argc - 1) {
+                       fprintf(stderr,
+_("%s: Metapath requires a group number.\n"),
+                                       xfrog_metapaths[*ino].name);
+                       return false;
+               }
+               control2 = strtoul(argv[optind + 1], &p, 0);
+               if (*p != '\0') {
+                       fprintf(stderr,
+ _("Bad group number '%s'.\n"),
+                               argv[optind + 1]);
+                       return false;
+               }
+       } else {
+               if (optind == argc - 2) {
+                       fprintf(stderr,
+_("%s: Metapath does not take a second argument.\n"),
+                                       xfrog_metapaths[*ino].name);
+                       return false;
+               }
+       }
+
        *ino = control;
+       *group = control2;
        return true;
 }
 
@@ -237,7 +264,8 @@ parse_args(
 
        switch (d->group) {
        case XFROG_SCRUB_GROUP_METAPATH:
-               if (!parse_metapath(argc, argv, optind, &meta->sm_ino)) {
+               if (!parse_metapath(argc, argv, optind, &meta->sm_ino,
+                                                       &meta->sm_agno)) {
                        exitcode = 1;
                        return command_usage(cmdinfo);
                }
@@ -582,7 +610,8 @@ scrubv_f(
 
        switch (group) {
        case XFROG_SCRUB_GROUP_METAPATH:
-               if (!parse_metapath(argc, argv, optind, &scrubv.head.svh_ino)) {
+               if (!parse_metapath(argc, argv, optind, &scrubv.head.svh_ino,
+                                   &scrubv.head.svh_agno)) {
                        exitcode = 1;
                        return command_usage(&scrubv_cmd);
                }
index 6775b0a273e5aa57e3434ceed2a5cffcf2834a8b..4673b071901c285a573f6d029ba051ac7386ff63 100644 (file)
@@ -1425,7 +1425,7 @@ Currently supported versions are 1 and 5.
 .RE
 .PD
 .TP
-.BI "scrub " type " [ " agnumber " | " rgnumber " | " "ino" " " "gen" " | " metapath " ]"
+.BI "scrub " type " [ " agnumber " | " rgnumber " | " "ino" " " "gen" " | " metapath " [ " rgnumber " ] ]"
 Scrub internal XFS filesystem metadata.  The
 .BI type
 parameter specifies which type of metadata to scrub.
@@ -1434,6 +1434,7 @@ For realtime group metadata, one rtgroup number must be specified.
 For file metadata, the scrub is applied to the open file unless the
 inode number and generation number are specified.
 For metapath, the name of a file or a raw number must be specified.
+If the metapath file is a per-rtgroup file, the group number must be specified.
 .RE
 .PD
 .TP