All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support
@ 2021-01-07 13:42 Andrew Price
  2021-01-07 13:42 ` [Cluster-devel] [PATCH 1/3] mkfs.gfs2: Add extended option for specifying format version Andrew Price
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andrew Price @ 2021-01-07 13:42 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This patch set prepares gfs2-utils for supporting fs format 1802, which is intended to enable trusted.* xattrs and enable rgrplvb by default. mkfs.gfs2 still creates filesystems with format 1801 by default.

Andrew Price (3):
  mkfs.gfs2: Add extended option for specifying format version
  fsck.gfs2: Enable checking of format 1802
  tunegfs2: Add support for fs format versions

 gfs2/fsck/fsck.h          |  2 +-
 gfs2/fsck/initialize.c    |  2 +-
 gfs2/fsck/pass1.c         | 12 ++++++++++--
 gfs2/libgfs2/libgfs2.h    |  6 +++++-
 gfs2/libgfs2/structures.c |  4 ++--
 gfs2/man/mkfs.gfs2.8      |  3 +++
 gfs2/man/tunegfs2.8       |  5 +++++
 gfs2/mkfs/main_mkfs.c     | 26 +++++++++++++++++++++++++-
 gfs2/tune/Makefile.am     |  3 ++-
 gfs2/tune/main.c          | 18 +++++++++++++-----
 gfs2/tune/super.c         | 20 ++++++++++++++++++++
 gfs2/tune/tunegfs2.h      |  5 +++--
 tests/Makefile.am         |  3 ++-
 tests/fsck.at             |  4 +++-
 tests/mkfs.at             | 10 ++++++++++
 tests/testsuite.at        |  1 +
 tests/tune.at             | 17 +++++++++++++++++
 17 files changed, 123 insertions(+), 18 deletions(-)
 create mode 100644 tests/tune.at

-- 
2.29.2



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH 1/3] mkfs.gfs2: Add extended option for specifying format version
  2021-01-07 13:42 [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support Andrew Price
@ 2021-01-07 13:42 ` Andrew Price
  2021-01-07 13:42 ` [Cluster-devel] [PATCH 2/3] fsck.gfs2: Enable checking of format 1802 Andrew Price
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Price @ 2021-01-07 13:42 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Add -o format=<number> to allow testing of newer format versions. The
default value is taken from GFS2_FORMAT_FS in the
include/linux/gfs2_ondisk.h kernel header.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/fsck/initialize.c    |  2 +-
 gfs2/libgfs2/libgfs2.h    |  5 ++++-
 gfs2/libgfs2/structures.c |  4 ++--
 gfs2/man/mkfs.gfs2.8      |  3 +++
 gfs2/mkfs/main_mkfs.c     | 26 +++++++++++++++++++++++++-
 tests/mkfs.at             | 10 ++++++++++
 6 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index ecda56e2..b5bcecfa 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -1291,7 +1291,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
 			log_crit(_("Error reading root inode: %s\n"), strerror(errno));
 			return -1;
 		}
-		lgfs2_sb_init(&sb, sdp->bsize);
+		lgfs2_sb_init(&sb, sdp->bsize, GFS2_FORMAT_FS);
 		strcpy(sb.sb_lockproto, GFS2_DEFAULT_LOCKPROTO);
 		strcpy(sb.sb_locktable, "unknown");
 		sb.sb_master_dir = sdp->master_dir->i_di.di_num;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index e815b5d7..6973c6f3 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -325,6 +325,9 @@ struct metapath {
 #define GFS2_MIN_RGSIZE             (32)
 #define GFS2_MAX_RGSIZE             (2048)
 
+#define LGFS2_FS_FORMAT_MIN (1801)
+#define LGFS2_FS_FORMAT_MAX (1802)
+
 /* meta.c */
 extern const struct lgfs2_metadata lgfs2_metadata[];
 extern const unsigned lgfs2_metadata_size;
@@ -676,7 +679,7 @@ static inline unsigned int rgrp_size(struct rgrp_tree *rgrp)
 
 /* structures.c */
 extern int build_master(struct gfs2_sbd *sdp);
-extern void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize);
+extern void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize, unsigned format);
 extern int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize);
 extern int build_journal(struct gfs2_sbd *sdp, int j,
 			 struct gfs2_inode *jindex);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 5cc2dd01..79095efc 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -53,13 +53,13 @@ int build_master(struct gfs2_sbd *sdp)
 /**
  * Initialise a gfs2_sb structure with sensible defaults.
  */
-void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize)
+void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize, unsigned format)
 {
 	memset(sb, 0, sizeof(struct gfs2_sb));
 	sb->sb_header.mh_magic = GFS2_MAGIC;
 	sb->sb_header.mh_type = GFS2_METATYPE_SB;
 	sb->sb_header.mh_format = GFS2_FORMAT_SB;
-	sb->sb_fs_format = GFS2_FORMAT_FS;
+	sb->sb_fs_format = format;
 	sb->sb_multihost_format = GFS2_FORMAT_MULTI;
 	sb->sb_bsize = bsize;
 	sb->sb_bsize_shift = ffs(bsize) - 1;
diff --git a/gfs2/man/mkfs.gfs2.8 b/gfs2/man/mkfs.gfs2.8
index 35e355a5..58742dea 100644
--- a/gfs2/man/mkfs.gfs2.8
+++ b/gfs2/man/mkfs.gfs2.8
@@ -86,6 +86,9 @@ probing the device or specified with the
 and
 .I sunit
 extended options.
+.TP
+.BI format= <number>
+Set the filesystem format version. Testing only.
 .RE
 .TP
 \fB-p\fP \fIprotocol\fR
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 17643e59..5e34ca1f 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -81,6 +81,7 @@ static void print_ext_opts(void)
 		"swidth=N",  _("Specify the stripe width of the device, overriding probed values"),
 		"sunit=N", _("Specify the stripe unit of the device, overriding probed values"),
 		"align=[0|1]", _("Disable or enable alignment of resource groups"),
+		"format=N", _("Specify the format version number"),
 		NULL, NULL
 	};
 	printf(_("Extended options:\n"));
@@ -118,6 +119,7 @@ struct mkfs_opts {
 	unsigned rgsize;
 	unsigned long sunit;
 	unsigned long swidth;
+	unsigned format;
 	uint64_t fssize;
 	int journals;
 	const char *lockproto;
@@ -137,6 +139,7 @@ struct mkfs_opts {
 	unsigned got_locktable:1;
 	unsigned got_device:1;
 	unsigned got_topol:1;
+	unsigned got_format:1;
 
 	unsigned override:1;
 	unsigned quiet:1;
@@ -158,6 +161,7 @@ static void opts_init(struct mkfs_opts *opts)
 	opts->locktable = "";
 	opts->confirm = 1;
 	opts->align = 1;
+	opts->format = GFS2_FORMAT_FS;
 }
 
 struct gfs2_inum *mkfs_journals = NULL;
@@ -290,6 +294,22 @@ static int parse_topology(struct mkfs_opts *opts, char *str)
 	return 0;
 }
 
+static int parse_format(struct mkfs_opts *opts, char *str)
+{
+	unsigned long ln;
+
+	if (parse_ulong(opts, "format", str, &ln) != 0)
+		return -1;
+
+	if (ln < LGFS2_FS_FORMAT_MIN || ln > LGFS2_FS_FORMAT_MAX) {
+		fprintf(stderr, _("Invalid filesystem format: %s\n"), str);
+		return -1;
+	}
+	opts->format = ln;
+	opts->got_format = 1;
+	return 0;
+}
+
 static int opt_parse_extended(char *str, struct mkfs_opts *opts)
 {
 	char *opt;
@@ -316,6 +336,9 @@ static int opt_parse_extended(char *str, struct mkfs_opts *opts)
 				return -1;
 			opts->got_topol = (opts->dev.logical_sector_size != 0 &&
 	                                   opts->dev.physical_sector_size != 0);
+		} else if (strcmp("format", key) == 0) {
+			if (parse_format(opts, val) != 0)
+				return -1;
 		} else if (strcmp("help", key) == 0) {
 			print_ext_opts();
 			return 1;
@@ -1129,7 +1152,7 @@ int main(int argc, char *argv[])
 
 	if (sbd_init(&sbd, &opts, bsize) != 0)
 		exit(-1);
-	lgfs2_sb_init(&sb, bsize);
+	lgfs2_sb_init(&sb, bsize, opts.format);
 	if (opts.debug) {
 		printf(_("File system options:\n"));
 		printf("  bsize = %u\n", sbd.bsize);
@@ -1142,6 +1165,7 @@ int main(int argc, char *argv[])
 		printf("  fssize = %"PRIu64"\n", opts.fssize);
 		printf("  sunit = %lu\n", opts.sunit);
 		printf("  swidth = %lu\n", opts.swidth);
+		printf("  format = %u\n", opts.format);
 	}
 	rgs = rgs_init(&opts, &sbd);
 	if (rgs == NULL)
diff --git a/tests/mkfs.at b/tests/mkfs.at
index 73cdfee6..6d6d3bd1 100644
--- a/tests/mkfs.at
+++ b/tests/mkfs.at
@@ -31,6 +31,16 @@ AT_CHECK([$GFS_MKFS -p lock_nolock -c 0 $GFS_TGT], 255, [ignore], [ignore])
 AT_CHECK([$GFS_MKFS -p lock_nolock -c 65 $GFS_TGT], 255, [ignore], [ignore])
 AT_CLEANUP
 
+AT_SETUP([Format version validation])
+AT_KEYWORDS(mkfs.gfs2 mkfs)
+AT_CHECK([$GFS_MKFS -p lock_nolock -o format=-1 $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -o format=0 $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -o format=1800 $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -o format=1801 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -o format=1802 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -o format=1803 $GFS_TGT], 255, [ignore], [ignore])
+AT_CLEANUP
+
 AT_SETUP([Locking protocols])
 AT_KEYWORDS(mkfs.gfs2 mkfs)
 GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock $GFS_TGT])
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH 2/3] fsck.gfs2: Enable checking of format 1802
  2021-01-07 13:42 [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support Andrew Price
  2021-01-07 13:42 ` [Cluster-devel] [PATCH 1/3] mkfs.gfs2: Add extended option for specifying format version Andrew Price
@ 2021-01-07 13:42 ` Andrew Price
  2021-01-07 13:42 ` [Cluster-devel] [PATCH 3/3] tunegfs2: Add support for fs format versions Andrew Price
  2021-01-12 14:22 ` [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support Andrew Price
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Price @ 2021-01-07 13:42 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Format 1802 introduces trusted.* xattrs with type 4. Since the
gfs2_ondisk.h kernel header may not match the booted kernel the validity
check is now hard coded.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/fsck/fsck.h  |  2 +-
 gfs2/fsck/pass1.c | 12 ++++++++++--
 tests/fsck.at     |  4 +++-
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 877448c3..13dd7b37 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -4,7 +4,7 @@
 #include "libgfs2.h"
 #include "osi_tree.h"
 
-#define FSCK_MAX_FORMAT (1801)
+#define FSCK_MAX_FORMAT (1802)
 
 #define FSCK_HASH_SHIFT         (13)
 #define FSCK_HASH_SIZE          (1 << FSCK_HASH_SHIFT)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index e6aec43e..88fc4dc4 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -998,6 +998,14 @@ static int ask_remove_eattr_entry(struct gfs2_sbd *sdp,
 	return 1;
 }
 
+static int eatype_max(unsigned fs_format)
+{
+	int max = 4;
+	if (fs_format < 1802)
+		max = 3;
+	return max;
+}
+
 static int check_eattr_entries(struct gfs2_inode *ip,
 			       struct gfs2_buffer_head *leaf_bh,
 			       struct gfs2_ea_header *ea_hdr,
@@ -1038,11 +1046,11 @@ static int check_eattr_entries(struct gfs2_inode *ip,
 	strncpy(ea_name, (char *)ea_hdr + sizeof(struct gfs2_ea_header),
 		ea_hdr->ea_name_len);
 
-	if (!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
+	if (ea_hdr->ea_type > eatype_max(sdp->sd_sb.sb_fs_format) &&
 	   ((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
 		/* Skip invalid entry */
 		log_err(_("EA (%s) type is invalid (%d > %d).\n"),
-			ea_name, ea_hdr->ea_type, GFS2_EATYPE_LAST);
+			ea_name, ea_hdr->ea_type, eatype_max(sdp->sd_sb.sb_fs_format));
 		return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
 					      ea_hdr_prev, 0, 0);
 	}
diff --git a/tests/fsck.at b/tests/fsck.at
index fab28a50..727108f4 100644
--- a/tests/fsck.at
+++ b/tests/fsck.at
@@ -59,11 +59,13 @@ AT_SETUP([gfs2 format versions])
 AT_KEYWORDS(fsck.gfs2 fsck)
 GFS_TGT_REGEN
 AT_CHECK([mkfs.gfs2 -O -p lock_nolock ${GFS_TGT}], 0, [ignore], [ignore])
-AT_CHECK(GFS_RUN_OR_SKIP([echo "set sb { sb_fs_format: 1802 }" | gfs2l ${GFS_TGT}]), 0, [ignore], [ignore])
+AT_CHECK(GFS_RUN_OR_SKIP([echo "set sb { sb_fs_format: 1803 }" | gfs2l ${GFS_TGT}]), 0, [ignore], [ignore])
 # Unsupported format, FSCK_USAGE == 16
 AT_CHECK([fsck.gfs2 -y $GFS_TGT], 16, [ignore], [ignore])
 # Format out of range
 AT_CHECK(GFS_RUN_OR_SKIP([echo "set sb { sb_fs_format: 4242 }" | gfs2l ${GFS_TGT}]), 0, [ignore], [ignore])
 AT_CHECK([fsck.gfs2 -y $GFS_TGT], 1, [ignore], [ignore])
 AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([mkfs.gfs2 -O -p lock_nolock -o format=1802 ${GFS_TGT}], 0, [ignore], [ignore])
+AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])
 AT_CLEANUP
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH 3/3] tunegfs2: Add support for fs format versions
  2021-01-07 13:42 [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support Andrew Price
  2021-01-07 13:42 ` [Cluster-devel] [PATCH 1/3] mkfs.gfs2: Add extended option for specifying format version Andrew Price
  2021-01-07 13:42 ` [Cluster-devel] [PATCH 2/3] fsck.gfs2: Enable checking of format 1802 Andrew Price
@ 2021-01-07 13:42 ` Andrew Price
  2021-01-12 14:22 ` [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support Andrew Price
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Price @ 2021-01-07 13:42 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Add a new -r option to change sb_fs_format.  Only increasing the number
is supported. New tests added.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/libgfs2.h |  1 +
 gfs2/man/tunegfs2.8    |  5 +++++
 gfs2/tune/Makefile.am  |  3 ++-
 gfs2/tune/main.c       | 18 +++++++++++++-----
 gfs2/tune/super.c      | 20 ++++++++++++++++++++
 gfs2/tune/tunegfs2.h   |  5 +++--
 tests/Makefile.am      |  3 ++-
 tests/testsuite.at     |  1 +
 tests/tune.at          | 17 +++++++++++++++++
 9 files changed, 64 insertions(+), 9 deletions(-)
 create mode 100644 tests/tune.at

diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 6973c6f3..1f64b59e 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -327,6 +327,7 @@ struct metapath {
 
 #define LGFS2_FS_FORMAT_MIN (1801)
 #define LGFS2_FS_FORMAT_MAX (1802)
+#define LGFS2_FS_FORMAT_VALID(n) ((n) >= LGFS2_FS_FORMAT_MIN && (n) <= LGFS2_FS_FORMAT_MAX)
 
 /* meta.c */
 extern const struct lgfs2_metadata lgfs2_metadata[];
diff --git a/gfs2/man/tunegfs2.8 b/gfs2/man/tunegfs2.8
index c4446f44..660bf962 100644
--- a/gfs2/man/tunegfs2.8
+++ b/gfs2/man/tunegfs2.8
@@ -53,6 +53,11 @@ Set the filesystem UUID
 
 Print out the information on the version of the tool.
 
+.TP
+\fB-r\fP \fI<version>\fR
+
+Set the filesystem format version.
+
 .SH SEE ALSO
 
 \fBgfs2\fP(5)
diff --git a/gfs2/tune/Makefile.am b/gfs2/tune/Makefile.am
index b03f609a..6c4bbe1f 100644
--- a/gfs2/tune/Makefile.am
+++ b/gfs2/tune/Makefile.am
@@ -10,10 +10,11 @@ tunegfs2_SOURCES = \
 tunegfs2_CPPFLAGS = \
 	-D_FILE_OFFSET_BITS=64 \
 	-I$(top_srcdir)/gfs2/include \
-	-I$(top_srcdir)/group/include
+	-I$(top_srcdir)/gfs2/libgfs2
 tunegfs2_CFLAGS = \
 	$(uuid_CFLAGS)
 tunegfs2_LDADD = \
+	$(top_builddir)/gfs2/libgfs2/libgfs2.la \
 	$(uuid_LIBS)
 
 if HAVE_CHECK
diff --git a/gfs2/tune/main.c b/gfs2/tune/main.c
index 93f0f60c..d5998071 100644
--- a/gfs2/tune/main.c
+++ b/gfs2/tune/main.c
@@ -52,9 +52,9 @@ static void parse_mount_options(char *arg)
 
 static void usage(char *name)
 {
-	printf("%s %s [-hlV] [-L <%s>] [-U <%s>] [-o <%s>] <%s>\n",
+	printf("%s %s [-hlV] [-L <%s>] [-U <%s>] [-o <%s>] [-r <%s>] <%s>\n",
 	       _("Usage:"), basename(name), _("label"), _("UUID"),
-	       _("mount options"), _("device"));
+	       _("mount options"), _("version"), _("device"));
 }
 
 static void version(void)
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
 	int c, status;
 
 	memset(tfs, 0, sizeof(struct tunegfs2));
-	while((c = getopt(argc, argv, "hL:U:lo:V")) != -1) {
+	while((c = getopt(argc, argv, "hL:U:lo:Vr:")) != -1) {
 		switch(c) {
 		case 'h':
 			usage(argv[0]);
@@ -90,6 +90,10 @@ int main(int argc, char **argv)
 		case 'V':
 			version();
 			return 0;
+		case 'r':
+			tfs->opt_format = 1;
+			tfs->format = optarg;
+			break;
 		default:
 			fprintf(stderr, _("Invalid option: %c\n"), c);
 			usage(argv[0]);
@@ -145,9 +149,13 @@ int main(int argc, char **argv)
 		if (status)
 			goto out;
 	}
-
+	if (tfs->opt_format) {
+		status = change_format(tfs, tfs->format);
+		if (status)
+			goto out;
+	}
 	if (tfs->opt_label || tfs->opt_uuid || tfs->opt_table ||
-	    tfs->opt_proto) {
+	    tfs->opt_proto || tfs->opt_format) {
 		status = write_super(tfs);
 		if (status)
 			goto out;
diff --git a/gfs2/tune/super.c b/gfs2/tune/super.c
index f4b7d85b..c3029fd1 100644
--- a/gfs2/tune/super.c
+++ b/gfs2/tune/super.c
@@ -12,6 +12,7 @@
 #define _(String) gettext(String)
 #include <linux_endian.h>
 #include <linux/gfs2_ondisk.h>
+#include <libgfs2.h>
 #include "tunegfs2.h"
 
 #ifdef GFS2_HAS_UUID
@@ -64,6 +65,7 @@ int print_super(const struct tunegfs2 *tfs)
 	}
 #endif
 	printf( _("File system magic number: 0x%X\n"), be32_to_cpu(tfs->sb->sb_header.mh_magic));
+	printf(_("File system format version: %"PRIu32"\n"), be32_to_cpu(tfs->sb->sb_fs_format));
 	printf(_("Block size: %d\n"), be32_to_cpu(tfs->sb->sb_bsize));
 	printf(_("Block shift: %d\n"), be32_to_cpu(tfs->sb->sb_bsize_shift));
 	printf(_("Root inode: %llu\n"), (unsigned long long)be64_to_cpu(tfs->sb->sb_root_dir.no_addr));
@@ -150,3 +152,21 @@ int change_locktable(struct tunegfs2 *tfs, const char *locktable)
 	return 0;
 }
 
+int change_format(struct tunegfs2 *tfs, const char *format)
+{
+	char *end;
+	long ln;
+
+	errno = 0;
+	ln = strtol(format, &end, 10);
+	if (errno || end == format || !LGFS2_FS_FORMAT_VALID(ln)) {
+		fprintf(stderr, _("Invalid format option '%s'\n"), format);
+		return EX_DATAERR;
+	}
+	if (ln < be32_to_cpu(tfs->sb->sb_fs_format)) {
+		fprintf(stderr, _("Regressing the filesystem format is not supported\n"));
+		return EX_DATAERR;
+	}
+	tfs->sb->sb_fs_format = cpu_to_be32(ln);
+	return 0;
+}
diff --git a/gfs2/tune/tunegfs2.h b/gfs2/tune/tunegfs2.h
index 3b28c58e..98c99696 100644
--- a/gfs2/tune/tunegfs2.h
+++ b/gfs2/tune/tunegfs2.h
@@ -1,8 +1,6 @@
 #ifndef __GFS2_TUNE_DOT_H__
 #define __GFS2_TUNE_DOT_H__
 
-#define GFS2_DEFAULT_BSIZE	4096
-
 struct tunegfs2 {
 	char *devicename;
 	int fd;
@@ -13,11 +11,13 @@ struct tunegfs2 {
 	char *table;
 	char *proto;
 	char *mount_options;
+	char *format;
 	int opt_list;
 	int opt_label;
 	int opt_uuid;
 	int opt_proto;
 	int opt_table;
+	int opt_format;
 };
 
 extern int print_super(const struct tunegfs2 *);
@@ -26,6 +26,7 @@ extern int write_super(const struct tunegfs2 *);
 extern int change_uuid(struct tunegfs2 *, const char *uuid);
 extern int change_lockproto(struct tunegfs2 *, const char *label);
 extern int change_locktable(struct tunegfs2 *, const char *label);
+extern int change_format(struct tunegfs2 *, const char *format);
 
 #endif
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 11d848cd..9109cf39 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -52,7 +52,8 @@ TESTSUITE_AT = \
 	testsuite.at \
 	mkfs.at \
 	fsck.at \
-	edit.at
+	edit.at \
+	tune.at
 
 TESTSUITE = testsuite
 
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 98102183..1c1dc9e5 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -51,3 +51,4 @@ AT_COLOR_TESTS
 m4_include([mkfs.at])
 m4_include([fsck.at])
 m4_include([edit.at])
+m4_include([tune.at])
diff --git a/tests/tune.at b/tests/tune.at
new file mode 100644
index 00000000..b0158034
--- /dev/null
+++ b/tests/tune.at
@@ -0,0 +1,17 @@
+AT_TESTED([tunegfs2])
+AT_BANNER([tunegfs2 tests])
+
+AT_SETUP([Format version])
+AT_KEYWORDS(tunegfs2 tune)
+AT_CHECK([$GFS_MKFS -p lock_nolock -o format=1802 $GFS_TGT], 0, [ignore], [ignore])
+# Exit code 65 == EX_DATAERR (sysexits.h)
+AT_CHECK([tunegfs2 -r 0 $GFS_TGT], 65, [ignore], [ignore])
+# Regress not supported
+AT_CHECK([tunegfs2 -r 1801 $GFS_TGT], 65, [ignore], [ignore])
+# Format 1803 does not exist
+AT_CHECK([tunegfs2 -r 1803 $GFS_TGT], 65, [ignore], [ignore])
+# Normal version bump
+AT_CHECK([$GFS_MKFS -p lock_nolock -o format=1801 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([tunegfs2 -r 1802 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])
+AT_CLEANUP
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support
  2021-01-07 13:42 [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support Andrew Price
                   ` (2 preceding siblings ...)
  2021-01-07 13:42 ` [Cluster-devel] [PATCH 3/3] tunegfs2: Add support for fs format versions Andrew Price
@ 2021-01-12 14:22 ` Andrew Price
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Price @ 2021-01-12 14:22 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 07/01/2021 13:42, Andrew Price wrote:
> This patch set prepares gfs2-utils for supporting fs format 1802, which is intended to enable trusted.* xattrs and enable rgrplvb by default. mkfs.gfs2 still creates filesystems with format 1801 by default.
> 
> Andrew Price (3):
>    mkfs.gfs2: Add extended option for specifying format version
>    fsck.gfs2: Enable checking of format 1802
>    tunegfs2: Add support for fs format versions

I've pushed these patches to gfs2-utils/master to ease testing the 
kernel patches. mkfs.gfs2 will continue to create format 1801 
filesystems by default until gfs2_ondisk.h kernel header is updated, but 
format 1802 can be tested using 'mkfs.gfs2 -o format=1802 ...' or 
'tunegfs2 -r 1802 ...' for existing filesystems (subsequent downgrading 
is not supported).

Andy



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-12 14:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 13:42 [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support Andrew Price
2021-01-07 13:42 ` [Cluster-devel] [PATCH 1/3] mkfs.gfs2: Add extended option for specifying format version Andrew Price
2021-01-07 13:42 ` [Cluster-devel] [PATCH 2/3] fsck.gfs2: Enable checking of format 1802 Andrew Price
2021-01-07 13:42 ` [Cluster-devel] [PATCH 3/3] tunegfs2: Add support for fs format versions Andrew Price
2021-01-12 14:22 ` [Cluster-devel] [PATCH 0/3] gfs2-utils: New fs format version support Andrew Price

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.