xfs: upgrade filesystem features
authorDarrick J. Wong <djwong@kernel.org>
Wed, 7 Aug 2024 22:54:58 +0000 (15:54 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 14 Aug 2024 03:08:27 +0000 (20:08 -0700)
Add the ability to upgrade *some* filesystem features.  Note that you'll
have to run online fsck immediately afterwards to build metadata!

XXX DO NOT MERGE

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
io/scrub.c
libxfs/xfs_fs.h
man/man8/xfs_io.8

index a137f402b94d4884d81002fdeb498089b2e1b542..c84647dfabed9a695bc54373f4ff9e81158e56e3 100644 (file)
@@ -19,6 +19,7 @@
 static struct cmdinfo scrub_cmd;
 static struct cmdinfo repair_cmd;
 static const struct cmdinfo scrubv_cmd;
+static const struct cmdinfo addfeature_cmd;
 
 static void
 scrub_help(void)
@@ -356,6 +357,7 @@ scrub_init(void)
 
        add_command(&scrub_cmd);
        add_command(&scrubv_cmd);
+       add_command(&addfeature_cmd);
 }
 
 static void
@@ -730,3 +732,67 @@ static const struct cmdinfo scrubv_cmd = {
        .oneline        = N_("vectored metadata scrub"),
        .help           = scrubv_help,
 };
+
+static void
+addfeature_help(void)
+{
+       printf(_(
+"\n"
+" Upgrade the feature set of the mounted filesystem.\n"
+"\n"
+"Supported features: bigtime, inobtcount, nrext64, exchange.\n"));
+}
+
+static int
+addfeature_f(
+       int             argc,
+       char            **argv)
+{
+       __u64           flags = 0;
+       int             c;
+       int             error;
+
+       while ((c = getopt(argc, argv, "")) != EOF) {
+               switch (c) {
+               default:
+                       addfeature_help();
+                       return 0;
+               }
+       }
+
+       for (c = optind; c < argc; c++) {
+               if (!strcmp(argv[c], "bigtime"))
+                       flags |= XFS_FSOP_GEOM_FLAGS_BIGTIME;
+               else if (!strcmp(argv[c], "inobtcount"))
+                       flags |= XFS_FSOP_GEOM_FLAGS_INOBTCNT;
+               else if (!strcmp(argv[c], "nrext64"))
+                       flags |= XFS_FSOP_GEOM_FLAGS_NREXT64;
+               else if (!strcmp(argv[c], "exchange"))
+                       flags |= XFS_FSOP_GEOM_FLAGS_EXCHANGE_RANGE;
+               else {
+                       addfeature_help();
+                       return 1;
+               }
+       }
+
+       if (!expert) {
+               printf(_("addfeature requires expert mode.\n"));
+               return 1;
+       }
+
+       error = ioctl(file->fd, XFS_IOC_ADDFEATURE, &flags);
+       if (error)
+               perror("addfeature");
+
+       return 0;
+}
+
+static const struct cmdinfo addfeature_cmd = {
+       .name           = "addfeature",
+       .cfunc          = addfeature_f,
+       .argmin         = -1,
+       .argmax         = -1,
+       .flags          = CMD_NOMAP_OK,
+       .oneline        = N_("add filesystem features"),
+       .help           = addfeature_help,
+};
index 2c302cf30762da4035033f3bce718a2e38f21e57..b1962c18295470193e791db5dc2b4b2977d1f30c 100644 (file)
@@ -1151,6 +1151,7 @@ struct xfs_health_monitor {
 #define XFS_IOC_GETFSREFCOUNTS _IOWR('X', 66, struct xfs_getfsrefs_head)
 #define XFS_IOC_MAP_FREESP     _IOW ('X', 67, struct xfs_map_freesp)
 #define XFS_IOC_HEALTH_MONITOR _IOW ('X', 68, struct xfs_health_monitor)
+#define XFS_IOC_ADDFEATURE     _IOW ('X', 69, __u64)
 
 /*
  * ioctl commands that replace IRIX syssgi()'s
index dcf97b2a9452c2ac9814cbcfd9b98b633a8bd447..283aff731d2156a8ef23f77b890a43eec050a1b2 100644 (file)
@@ -1258,6 +1258,18 @@ If 1, set the NOALLOC flag.
 .PD
 .RE
 
+.TP
+.BI "addfeature [ " features " ]"
+Upgrade the mounted filesystem feature set.
+The only supported features are:
+.BR bigtime ,
+.BR inobtcount ,
+.BR nrext64 ,
+and
+.BR exchange .
+.PD
+.RE
+
 .TP
 .BI "bulkstat [ \-a " agno " ] [ \-d ] [ \-e " endino " ] [ \-m ] [ \-n " batchsize " ] [ \-q ] [ \-s " startino " ] [ \-v " version" ]
 Display raw stat information about a bunch of inodes in an XFS filesystem.