Skip to contentSkip to conversation

gfs2-utils: Add support for new resource group fields

PATCH Superseded Andrew Price 2 participants 10 messages Dec 8, 2017

lore
Share & tools
lore
#0 lore raw

v2 cover gfs2-utils: Add support for new resource group fields

These patches add basic support for the new fields in struct gfs2_rgrp as described in the previous posting.

v2: Modified lgfs2_rgrp_crc_check() to take just the rgrp buffer to avoid using potentially differing data from the struct gfs2_rgrp.

Andrew Price (8):
gfs2-utils configure: Check for rg_skip
libgfs2: Add rgrp_skip support
mkfs.gfs2: Pull place_journals() out of place_rgrps() mkfs.gfs2: Set the rg_skip field in new rgrps gfs2-utils configure: Check for rg_data0, rg_data and rg_bitbytes
libgfs2: Add support for rg_data0, rg_data and rg_bitbytes mkfs.gfs2: Set the rg_data0, rg_data and rg_bitbytes fields
libgfs2: Add support for rg_crc

 configure.ac             |  4 +++
 gfs2/libgfs2/libgfs2.h   |  4 ++-
 gfs2/libgfs2/meta.c      | 10 +++++++
 gfs2/libgfs2/ondisk.c    | 42 ++++++++++++++++++++++++++--
 gfs2/libgfs2/rgrp.c      | 71 ++++++++++++++++++++++++++++++++++++++++++------
 gfs2/mkfs/main_grow.c    |  9 ++++--
 gfs2/mkfs/main_mkfs.c    | 35 +++++++++++-------------
 tests/check_rgrp.c       |  2 +-
 tests/mkfs.at            | 32 ++++++++++++++++++++++
 tests/rgrifieldscheck.sh | 20 ++++++++++++++
 tests/rgskipcheck.sh     | 19 +++++++++++++
 11 files changed, 213 insertions(+), 35 deletions(-)
 create mode 100755 tests/rgrifieldscheck.sh
 create mode 100755 tests/rgskipcheck.sh
Signature · 1 line
2.13.6
#1 lore raw

PATCH v2 1/8 gfs2-utils configure: Check for rg_skip

Define GFS2_HAS_RG_SKIP if the new rg_skip field is found in struct gfs2_rgrp.

---
 configure.ac | 2 ++
 1 file changed, 2 insertions(+)
configure.ac +2 -0
index f1d83513..7f8bcca9 100644
@@ -137,6 +137,8 @@ AC_CHECK_MEMBER([struct gfs2_dirent.de_rahead],[AC_DEFINE([GFS2_HAS_DE_RAHEAD],[
                 [], [[#include <linux/gfs2_ondisk.h>]])
 AC_CHECK_MEMBER([struct gfs2_dirent.de_cookie],[AC_DEFINE([GFS2_HAS_DE_COOKIE],[],[Dirent cookie field])],
                 [], [[#include <linux/gfs2_ondisk.h>]])
+AC_CHECK_MEMBER([struct gfs2_rgrp.rg_skip],[AC_DEFINE([GFS2_HAS_RG_SKIP],[],[Next resource group pointer])],
+                [], [[#include <linux/gfs2_ondisk.h>]])
 
 # libuuid is only required if struct gfs2_sb.sb_uuid exists
 if test "$sb_has_uuid" = "yes" -a "$have_uuid" = "no"; then
Signature · 1 line
2.13.6
#2 lore raw

PATCH v2 2/8 libgfs2: Add rgrp_skip support

In reply to Andrew Price
---
 gfs2/libgfs2/meta.c   |  4 ++++
 gfs2/libgfs2/ondisk.c | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)
gfs2/libgfs2/meta.c +4 -0
index 500757d9..be91f0cc 100644
@@ -201,7 +201,11 @@ MH(rg_header)
 F(rg_flags)
 F(rg_free, .flags = LGFS2_MFF_FSBLOCKS)
 F(rg_dinodes, .flags = LGFS2_MFF_FSBLOCKS)
+#ifdef GFS2_HAS_RG_SKIP
+FP(rg_skip, .points_to = (1 << LGFS2_MT_GFS2_RGRP))
+#else
 RF(__pad)
+#endif
 F(rg_igeneration)
 RF(rg_reserved)
 };
gfs2/libgfs2/ondisk.c +18 -0
index acedd3ea..b5c62114 100644
@@ -227,6 +227,12 @@ void gfs2_rgrp_in(struct gfs2_rgrp *rg, struct gfs2_buffer_head *bh)
 	CPIN_32(rg, str, rg_flags);
 	CPIN_32(rg, str, rg_free);
 	CPIN_32(rg, str, rg_dinodes);
+#ifdef GFS2_HAS_RG_SKIP
+	CPIN_32(rg, str, rg_skip);
+#else
+	CPIN_32(rg, str, __pad);
+#endif
+	CPIN_64(rg, str, rg_igeneration);
 
 	CPIN_08(rg, str, rg_reserved, 80);
 }
@@ -239,6 +245,12 @@ void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf)
 	CPOUT_32(rg, str, rg_flags);
 	CPOUT_32(rg, str, rg_free);
 	CPOUT_32(rg, str, rg_dinodes);
+#ifdef GFS2_HAS_RG_SKIP
+	CPOUT_32(rg, str, rg_skip);
+#else
+	CPOUT_32(rg, str, __pad);
+#endif
+	CPOUT_64(rg, str, rg_igeneration);
 
 	CPOUT_08(rg, str, rg_reserved, 80);
 }
@@ -255,6 +267,12 @@ void gfs2_rgrp_print(const struct gfs2_rgrp *rg)
 	pv(rg, rg_flags, "%u", "0x%x");
 	pv(rg, rg_free, "%u", "0x%x");
 	pv(rg, rg_dinodes, "%u", "0x%x");
+#ifdef GFS2_HAS_RG_SKIP
+	pv(rg, rg_skip, "%u", "0x%x");
+#else
+	pv(rg, __pad, "%u", "0x%x");
+#endif
+	pv(rg, rg_igeneration, "%llu", "0x%llx");
 }
 
 void gfs2_quota_in(struct gfs2_quota *qu, char *buf)
Signature · 1 line
2.13.6
#3 lore raw

PATCH v2 3/8 mkfs.gfs2: Pull place_journals() out of place_rgrps()

In reply to Andrew Price

Removes some clutter from place_rgrps() and makes main() a little more informative.

---
 gfs2/mkfs/main_mkfs.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
gfs2/mkfs/main_mkfs.c +11 -15
index 2e08bc62..3b774115 100644
@@ -713,7 +713,6 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
 	uint32_t rgsize = lgfs2_rgsize_for_data(jfsize, sdp->bsize);
 	unsigned j;
 
-	/* Initialise a progress bar for resource group creation. */
 	gfs2_progress_init(&progress, opts->journals, _("Adding journals: "), opts->quiet);
 
 	/* We'll build the jindex later so remember where we put the journals */
@@ -728,7 +727,6 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
 		lgfs2_rgrp_t rg;
 		struct gfs2_inode in = {0};
 
-		/* Update progress bar for journal creation. */
 		gfs2_progress_update(&progress, (j + 1));
 
 		if (opts->debug)
@@ -783,26 +781,19 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
 	return 0;
 }
 
-static int place_rgrps(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_opts *opts)
+static int place_rgrps(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, uint64_t *rgaddr, struct mkfs_opts *opts)
 {
 	struct gfs2_progress_bar progress;
-	uint64_t rgaddr = lgfs2_rgrp_align_addr(rgs, sdp->sb_addr + 1);
 	uint32_t rgblks = ((opts->rgsize << 20) / sdp->bsize);
 	uint32_t rgnum;
 	int result;
 
-	result = place_journals(sdp, rgs, opts, &rgaddr);
-	if (result != 0)
-		return result;
-
-	rgnum = lgfs2_rgrps_plan(rgs, sdp->device.length - rgaddr, rgblks);
-
-	/* Initialise a progress bar for resource group creation (after journal creation). */
+	rgnum = lgfs2_rgrps_plan(rgs, sdp->device.length - *rgaddr, rgblks);
 	gfs2_progress_init(&progress, (rgnum + opts->journals), _("Building resource groups: "), opts->quiet);
 
 	while (1) {
 		lgfs2_rgrp_t rg;
-		result = add_rgrp(rgs, &rgaddr, 0, &rg);
+		result = add_rgrp(rgs, rgaddr, 0, &rg);
 		if (result > 0)
 			break;
 		else if (result < 0)
@@ -814,7 +805,6 @@ static int place_rgrps(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_opts
 			return result;
 		}
 
-		/* Update progress bar with resource group address. */
 		gfs2_progress_update(&progress, (sdp->rgrps));
 	}
 	gfs2_progress_close(&progress, _("Done\n"));
@@ -944,6 +934,7 @@ int main(int argc, char *argv[])
 	struct gfs2_sb sb;
 	struct mkfs_opts opts;
 	lgfs2_rgrps_t rgs;
+	uint64_t rgaddr;
 	int error;
 	unsigned bsize;
 
@@ -993,8 +984,13 @@ int main(int argc, char *argv[])
 		if (!opts.quiet)
 			printf("%s", _("Done\n"));
 	}
-
-	error = place_rgrps(&sbd, rgs, &opts);
+	rgaddr = lgfs2_rgrp_align_addr(rgs, sbd.sb_addr + 1);
+	error = place_journals(&sbd, rgs, &opts, &rgaddr);
+	if (error != 0) {
+		fprintf(stderr, _("Failed to create journals\n"));
+		exit(1);
+	}
+	error = place_rgrps(&sbd, rgs, &rgaddr, &opts);
 	if (error) {
 		fprintf(stderr, _("Failed to build resource groups\n"));
 		exit(1);
Signature · 1 line
2.13.6
#4 lore raw

PATCH v2 4/8 mkfs.gfs2: Set the rg_skip field in new rgrps

In reply to Andrew Price

This field is the difference between the block address of a rgrp and the next one. Includes a test to check the rg_skip field against the rindex.

---
 gfs2/libgfs2/libgfs2.h |  2 +-
 gfs2/libgfs2/rgrp.c    | 10 +++++++---
 gfs2/mkfs/main_grow.c  |  9 ++++++---
 gfs2/mkfs/main_mkfs.c  |  9 +++++----
 tests/check_rgrp.c     |  2 +-
 tests/mkfs.at          | 16 ++++++++++++++++
 tests/rgskipcheck.sh   | 19 +++++++++++++++++++
 7 files changed, 55 insertions(+), 12 deletions(-)
 create mode 100755 tests/rgskipcheck.sh
gfs2/libgfs2/libgfs2.h +1 -1
index 2e29d332..50dc3f56 100644
@@ -202,7 +202,7 @@ extern uint64_t lgfs2_rgrp_align_addr(const lgfs2_rgrps_t rgs, uint64_t addr);
 extern uint32_t lgfs2_rgrp_align_len(const lgfs2_rgrps_t rgs, uint32_t len);
 extern unsigned lgfs2_rgsize_for_data(uint64_t blksreq, unsigned bsize);
 extern uint32_t lgfs2_rgrps_plan(const lgfs2_rgrps_t rgs, uint64_t space, uint32_t tgtsize);
-extern lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry);
+extern lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, uint32_t rg_skip);
 extern int lgfs2_rgrp_bitbuf_alloc(lgfs2_rgrp_t rg);
 extern void lgfs2_rgrp_bitbuf_free(lgfs2_rgrp_t rg);
 extern int lgfs2_rgrp_write(int fd, lgfs2_rgrp_t rg);
gfs2/libgfs2/rgrp.c +7 -3
index bb0776aa..4a2b1973 100644
@@ -430,7 +430,7 @@ unsigned lgfs2_rindex_read_fd(int fd, lgfs2_rgrps_t rgs)
 			return 0;
 
 		gfs2_rindex_in(&ri, buf);
-		rg = lgfs2_rgrps_append(rgs, &ri);
+		rg = lgfs2_rgrps_append(rgs, &ri, 0);
 		if (rg == NULL)
 			return 0;
 		count++;
@@ -463,7 +463,7 @@ const struct gfs2_rindex *lgfs2_rindex_read_one(struct gfs2_inode *rip, lgfs2_rg
 		return NULL;
 
 	gfs2_rindex_in(&ri, buf);
-	rg = lgfs2_rgrps_append(rgs, &ri);
+	rg = lgfs2_rgrps_append(rgs, &ri, 0);
 	if (rg == NULL)
 		return NULL;
 
@@ -582,9 +582,10 @@ struct osi_node *lgfs2_rgrps_root(lgfs2_rgrps_t rgs)
  * Insert a new resource group after the last resource group in a set.
  * rgs: The set of resource groups
  * entry: The entry to be added
+ * rg_skip: The value to be used for this resource group's rg_skip field
  * Returns the new resource group on success or NULL on failure with errno set.
  */
-lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry)
+lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, uint32_t rg_skip)
 {
 	lgfs2_rgrp_t rg;
 	struct osi_node **link = &rgs->root.osi_node;
@@ -615,6 +616,9 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry)
 	rg->rg.rg_header.mh_type = GFS2_METATYPE_RG;
 	rg->rg.rg_header.mh_format = GFS2_FORMAT_RG;
 	rg->rg.rg_free = rg->ri.ri_data;
+#ifdef GFS2_HAS_RG_SKIP
+	rg->rg.rg_skip = rg_skip;
+#endif
 
 	compute_bitmaps(rg, rgs->sdp->bsize);
 	rg->rgrps = rgs;
gfs2/mkfs/main_grow.c +6 -3
index dbee4bc6..ad80a8d9 100644
@@ -213,14 +213,17 @@ static unsigned initialize_new_portion(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs)
 		int err = 0;
 		lgfs2_rgrp_t rg;
 		struct gfs2_rindex ri;
-		rgaddr = lgfs2_rindex_entry_new(rgs, &ri, rgaddr, 0);
-		if (rgaddr == 0)
+		uint64_t nextaddr;
+
+		nextaddr = lgfs2_rindex_entry_new(rgs, &ri, rgaddr, 0);
+		if (nextaddr == 0)
 			break;
-		rg = lgfs2_rgrps_append(rgs, &ri);
+		rg = lgfs2_rgrps_append(rgs, &ri, nextaddr - rgaddr);
 		if (rg == NULL) {
 			perror(_("Failed to create resource group"));
 			return 0;
 		}
+		rgaddr = nextaddr;
 		if (metafs_interrupted)
 			return 0;
 		if (!test)
gfs2/mkfs/main_mkfs.c +5 -4
index 3b774115..54ff2db6 100644
@@ -685,11 +685,12 @@ static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrp_t rg, int debug)
 static int add_rgrp(lgfs2_rgrps_t rgs, uint64_t *addr, uint32_t len, lgfs2_rgrp_t *rg)
 {
 	struct gfs2_rindex ri;
+	uint64_t nextaddr;
 
 	/* When we get to the end of the device, it's only an error if we have
 	   more structures left to write, i.e. when len is != 0. */
-	*addr = lgfs2_rindex_entry_new(rgs, &ri, *addr, len);
-	if (*addr == 0) {
+	nextaddr = lgfs2_rindex_entry_new(rgs, &ri, *addr, len);
+	if (nextaddr == 0) {
 		if (len != 0) {
 			perror(_("Failed to create resource group index entry"));
 			return -1;
@@ -697,12 +698,12 @@ static int add_rgrp(lgfs2_rgrps_t rgs, uint64_t *addr, uint32_t len, lgfs2_rgrp_
 			return 1;
 		}
 	}
-
-	*rg = lgfs2_rgrps_append(rgs, &ri);
+	*rg = lgfs2_rgrps_append(rgs, &ri, nextaddr - *addr);
 	if (*rg == NULL) {
 		perror(_("Failed to create resource group"));
 		return -1;
 	}
+	*addr = nextaddr;
 	return 0;
 }
 
tests/check_rgrp.c +1 -1
index ce22c387..0360d3c8 100644
@@ -31,7 +31,7 @@ static lgfs2_rgrps_t mockup_rgrp(void)
 	addr = lgfs2_rindex_entry_new(rgs, &ri, 16, rgsize);
 	ck_assert(addr != 0);
 
-	rg = lgfs2_rgrps_append(rgs, &ri);
+	rg = lgfs2_rgrps_append(rgs, &ri, 0);
 	fail_unless(rg != NULL);
 
 	for (i = 0; i < rg->ri.ri_length; i++) {
tests/mkfs.at +16 -0
index 274a81db..b90d55e2 100644
@@ -123,3 +123,19 @@ AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:512:65536:393216:512 $GFS_
 # Check rgrp alignment to minimum_io_size: 65536 / 4096 == 16
 AT_CHECK([gfs2_edit -p rindex $GFS_TGT | grep ri_addr | awk '{print $2, $2 % 16; if ($2 % 16 != 0) { exit 1 }}'], 0, [ignore], [ignore])
 AT_CLEANUP
+
+AT_SETUP([Values of rg_skip])
+AT_KEYWORDS(mkfs.gfs2 mkfs)
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 2048 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgskipcheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 1024 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgskipcheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 512 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgskipcheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 219 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgskipcheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 32 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgskipcheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:512:65536:393216:512 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgskipcheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CLEANUP
tests/rgskipcheck.sh new file +19 -0
new file mode 100755
index 00000000..4a8f93fe
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+dev=$1
+rgcount=$(gfs2_edit -p rgcount $dev | cut -f1 -d' ')
+prevaddr=$(gfs2_edit -p rg 0 $dev | grep ^RG | awk '{print $5}')
+prevskip=0
+for i in `seq 0 $(($rgcount - 1))`; do
+	addr=$(gfs2_edit -p rg $i $dev | grep ^RG | awk '{print $5}')
+	expected=$(($addr - $prevaddr))
+
+	if test $prevskip != $expected; then
+		echo "Bad rg_skip in rg $(($i - 1)): $prevskip (expected: $expected)" >&2
+		exit 1
+	fi
+
+	prevskip=$(gfs2_edit -p rg $i $dev | grep rg_skip | awk '{print $2}')
+	prevaddr=$addr
+done
+
Signature · 1 line
2.13.6
#5 lore raw

PATCH v2 5/8 gfs2-utils configure: Check for rg_data0, rg_data and rg_bitbytes

In reply to Andrew Price

Define GFS2_HAS_RG_RI_FIELDS if the new rg_data0 field is found in struct gfs2_rgrp. This implies that rg_data and rg_bitbytes are also present as they were added at the same time.

---
 configure.ac | 2 ++
 1 file changed, 2 insertions(+)
configure.ac +2 -0
index 7f8bcca9..4e8518cb 100644
@@ -139,6 +139,8 @@ AC_CHECK_MEMBER([struct gfs2_dirent.de_cookie],[AC_DEFINE([GFS2_HAS_DE_COOKIE],[
                 [], [[#include <linux/gfs2_ondisk.h>]])
 AC_CHECK_MEMBER([struct gfs2_rgrp.rg_skip],[AC_DEFINE([GFS2_HAS_RG_SKIP],[],[Next resource group pointer])],
                 [], [[#include <linux/gfs2_ondisk.h>]])
+AC_CHECK_MEMBER([struct gfs2_rgrp.rg_data0],[AC_DEFINE([GFS2_HAS_RG_RI_FIELDS],[],[Resource group fields duplicated from the rindex])],
+                [], [[#include <linux/gfs2_ondisk.h>]])
 
 # libuuid is only required if struct gfs2_sb.sb_uuid exists
 if test "$sb_has_uuid" = "yes" -a "$have_uuid" = "no"; then
Signature · 1 line
2.13.6
#6 lore raw

PATCH v2 6/8 libgfs2: Add support for rg_data0, rg_data and rg_bitbytes

In reply to Andrew Price
---
 gfs2/libgfs2/meta.c   |  5 +++++
 gfs2/libgfs2/ondisk.c | 21 +++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
gfs2/libgfs2/meta.c +5 -0
index be91f0cc..1b771f30 100644
@@ -207,6 +207,11 @@ FP(rg_skip, .points_to = (1 << LGFS2_MT_GFS2_RGRP))
 RF(__pad)
 #endif
 F(rg_igeneration)
+#ifdef GFS2_HAS_RG_RI_FIELDS
+FP(rg_data0, .points_to = ANY_GFS2_BLOCK|(1 << LGFS2_MT_FREE))
+F(rg_data, .flags = LGFS2_MFF_FSBLOCKS)
+F(rg_bitbytes, .flags = LGFS2_MFF_BYTES)
+#endif
 RF(rg_reserved)
 };
 
gfs2/libgfs2/ondisk.c +19 -2
index b5c62114..fd25a860 100644
@@ -233,8 +233,14 @@ void gfs2_rgrp_in(struct gfs2_rgrp *rg, struct gfs2_buffer_head *bh)
 	CPIN_32(rg, str, __pad);
 #endif
 	CPIN_64(rg, str, rg_igeneration);
-
+#ifdef GFS2_HAS_RG_RI_FIELDS
+	CPIN_64(rg, str, rg_data0);
+	CPIN_32(rg, str, rg_data);
+	CPIN_32(rg, str, rg_bitbytes);
+	CPIN_08(rg, str, rg_reserved, 64);
+#else
 	CPIN_08(rg, str, rg_reserved, 80);
+#endif
 }
 
 void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf)
@@ -251,8 +257,14 @@ void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf)
 	CPOUT_32(rg, str, __pad);
 #endif
 	CPOUT_64(rg, str, rg_igeneration);
-
+#ifdef GFS2_HAS_RG_RI_FIELDS
+	CPOUT_64(rg, str, rg_data0);
+	CPOUT_32(rg, str, rg_data);
+	CPOUT_32(rg, str, rg_bitbytes);
+	CPOUT_08(rg, str, rg_reserved, 64);
+#else
 	CPOUT_08(rg, str, rg_reserved, 80);
+#endif
 }
 
 void gfs2_rgrp_out_bh(const struct gfs2_rgrp *rg, struct gfs2_buffer_head *bh)
@@ -273,6 +285,11 @@ void gfs2_rgrp_print(const struct gfs2_rgrp *rg)
 	pv(rg, __pad, "%u", "0x%x");
 #endif
 	pv(rg, rg_igeneration, "%llu", "0x%llx");
+#ifdef GFS2_HAS_RG_RI_FIELDS
+	pv(rg, rg_data0, "%llu", "0x%llx");
+	pv(rg, rg_data, "%u", "0x%x");
+	pv(rg, rg_bitbytes, "%u", "0x%x");
+#endif
 }
 
 void gfs2_quota_in(struct gfs2_quota *qu, char *buf)
Signature · 1 line
2.13.6
#7 lore raw

PATCH v2 7/8 mkfs.gfs2: Set the rg_data0, rg_data and rg_bitbytes fields

In reply to Andrew Price

These fields are duplicated from the rindex entry associated with the rgrp in order to reduce dependency on the rindex.

---
 gfs2/libgfs2/rgrp.c      |  6 +++++-
 tests/mkfs.at            | 16 ++++++++++++++++
 tests/rgrifieldscheck.sh | 17 +++++++++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100755 tests/rgrifieldscheck.sh
gfs2/libgfs2/rgrp.c +5 -1
index 4a2b1973..17178bd9 100644
@@ -619,7 +619,11 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, ui
 #ifdef GFS2_HAS_RG_SKIP
 	rg->rg.rg_skip = rg_skip;
 #endif
-
+#ifdef GFS2_HAS_RG_RI_FIELDS
+	rg->rg.rg_data0 = rg->ri.ri_data0;
+	rg->rg.rg_data = rg->ri.ri_data;
+	rg->rg.rg_bitbytes = rg->ri.ri_bitbytes;
+#endif
 	compute_bitmaps(rg, rgs->sdp->bsize);
 	rg->rgrps = rgs;
 	return rg;
tests/mkfs.at +16 -0
index b90d55e2..be888171 100644
@@ -139,3 +139,19 @@ AT_CHECK([rgskipcheck.sh $GFS_TGT], 0, [ignore], [ignore])
 AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:512:65536:393216:512 $GFS_TGT], 0, [ignore], [ignore])
 AT_CHECK([rgskipcheck.sh $GFS_TGT], 0, [ignore], [ignore])
 AT_CLEANUP
+
+AT_SETUP([Values of rg_data0, rg_data, rg_bitbytes])
+AT_KEYWORDS(mkfs.gfs2 mkfs)
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 2048 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgrifieldscheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 1024 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgrifieldscheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 512 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgrifieldscheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 219 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgrifieldscheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 32 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgrifieldscheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:512:65536:393216:512 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([rgrifieldscheck.sh $GFS_TGT], 0, [ignore], [ignore])
+AT_CLEANUP
tests/rgrifieldscheck.sh new file +17 -0
new file mode 100755
index 00000000..c99470a9
@@ -0,0 +1,17 @@
+#!/bin/sh
+dev=$1
+i=0
+gfs2_edit -p rindex $dev | while read field rival unused
+do
+	test $field = ri_data0 -o $field = ri_data -o $field = ri_bitbytes || continue
+	rgfield=$(echo $field | sed 's/ri/rg/')
+	rgval=$(gfs2_edit -p rg $i $dev | grep " $rgfield " | awk '{print $2}')
+
+	if test "$rival" != "$rgval"
+	then
+		echo "Bad $rgfield in rg $i: $rgval (expected: $rival)" >&2
+		exit 1
+	fi
+
+	test $field = ri_bitbytes && let i++
+done
Signature · 1 line
2.13.6
#8 lore raw

PATCH v2 8/8 libgfs2: Add support for rg_crc

In reply to Andrew Price

This new field in the resource group headers is set on write and checked on read so that fsck.gfs2 now considers a resource group with a bad, non-zero crc to be corrupted. gfs2_grow, gfs2_edit, and mkfs.gfs2 all now support the rg_crc field, including save/restoremeta.

---
 gfs2/libgfs2/libgfs2.h   |  2 ++
 gfs2/libgfs2/meta.c      |  1 +
 gfs2/libgfs2/ondisk.c    |  7 ++++--
 gfs2/libgfs2/rgrp.c      | 55 +++++++++++++++++++++++++++++++++++++++++++-----
 tests/rgrifieldscheck.sh |  3 +++
 5 files changed, 61 insertions(+), 7 deletions(-)
gfs2/libgfs2/libgfs2.h +2 -0
index 50dc3f56..2221af88 100644
@@ -667,6 +667,8 @@ extern int clean_journal(struct gfs2_inode *ip, struct gfs2_log_header *head);
 /* rgrp.c */
 extern int gfs2_compute_bitstructs(const uint32_t bsize, struct rgrp_tree *rgd);
 extern struct rgrp_tree *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk);
+extern int lgfs2_rgrp_crc_check(char *buf);
+extern void lgfs2_rgrp_crc_set(char *buf);
 extern uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd);
 extern void gfs2_rgrp_relse(struct rgrp_tree *rgd);
 extern struct rgrp_tree *rgrp_insert(struct osi_root *rgtree,
gfs2/libgfs2/meta.c +1 -0
index 1b771f30..82c8c6be 100644
@@ -211,6 +211,7 @@ F(rg_igeneration)
 FP(rg_data0, .points_to = ANY_GFS2_BLOCK|(1 << LGFS2_MT_FREE))
 F(rg_data, .flags = LGFS2_MFF_FSBLOCKS)
 F(rg_bitbytes, .flags = LGFS2_MFF_BYTES)
+F(rg_crc, .flags = LGFS2_MFF_CHECK)
 #endif
 RF(rg_reserved)
 };
gfs2/libgfs2/ondisk.c +5 -2
index fd25a860..dfb99d14 100644
@@ -237,7 +237,8 @@ void gfs2_rgrp_in(struct gfs2_rgrp *rg, struct gfs2_buffer_head *bh)
 	CPIN_64(rg, str, rg_data0);
 	CPIN_32(rg, str, rg_data);
 	CPIN_32(rg, str, rg_bitbytes);
-	CPIN_08(rg, str, rg_reserved, 64);
+	CPIN_32(rg, str, rg_crc);
+	CPIN_08(rg, str, rg_reserved, 60);
 #else
 	CPIN_08(rg, str, rg_reserved, 80);
 #endif
@@ -261,7 +262,8 @@ void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf)
 	CPOUT_64(rg, str, rg_data0);
 	CPOUT_32(rg, str, rg_data);
 	CPOUT_32(rg, str, rg_bitbytes);
-	CPOUT_08(rg, str, rg_reserved, 64);
+	CPOUT_08(rg, str, rg_reserved, 60);
+	lgfs2_rgrp_crc_set(buf);
 #else
 	CPOUT_08(rg, str, rg_reserved, 80);
 #endif
@@ -289,6 +291,7 @@ void gfs2_rgrp_print(const struct gfs2_rgrp *rg)
 	pv(rg, rg_data0, "%llu", "0x%llx");
 	pv(rg, rg_data, "%u", "0x%x");
 	pv(rg, rg_bitbytes, "%u", "0x%x");
+	pv(rg, rg_crc, "%u", "0x%x");
 #endif
 }
 
gfs2/libgfs2/rgrp.c +50 -5

73 lines not on this page · raw message

tests/rgrifieldscheck.sh +3 -0
index c99470a9..85f6408e 100755
@@ -1,6 +1,9 @@
 #!/bin/sh
 dev=$1
 i=0
+gfs2_edit -p rg 0 $dev | grep rg_data0 > /dev/null 2>&1
+# New fields not present in /usr/include/linux/gfs2_ondisk.h
+test $? = 0 || exit 0
 gfs2_edit -p rindex $dev | while read field rival unused
 do
 	test $field = ri_data0 -o $field = ri_data -o $field = ri_bitbytes || continue
Signature · 1 line
2.13.6
#9 lore raw

v2 cover gfs2-utils: Add support for new resource group fields

In reply to Andrew Price

----- Original Message -----

| These patches add basic support for the new fields in struct gfs2_rgrp as
| described in the previous posting.
| 
| v2: Modified lgfs2_rgrp_crc_check() to take just the rgrp buffer to avoid
| using potentially differing data from the struct gfs2_rgrp.
| 
| Andrew Price (8):
|   gfs2-utils configure: Check for rg_skip
|   libgfs2: Add rgrp_skip support
|   mkfs.gfs2: Pull place_journals() out of place_rgrps()
|   mkfs.gfs2: Set the rg_skip field in new rgrps
|   gfs2-utils configure: Check for rg_data0, rg_data and rg_bitbytes
|   libgfs2: Add support for rg_data0, rg_data and rg_bitbytes
|   mkfs.gfs2: Set the rg_data0, rg_data and rg_bitbytes fields
|   libgfs2: Add support for rg_crc
| 
|  configure.ac             |  4 +++
|  gfs2/libgfs2/libgfs2.h   |  4 ++-
|  gfs2/libgfs2/meta.c      | 10 +++++++
|  gfs2/libgfs2/ondisk.c    | 42 ++++++++++++++++++++++++++--
|  gfs2/libgfs2/rgrp.c      | 71
|  ++++++++++++++++++++++++++++++++++++++++++------
|  gfs2/mkfs/main_grow.c    |  9 ++++--
|  gfs2/mkfs/main_mkfs.c    | 35 +++++++++++-------------
|  tests/check_rgrp.c       |  2 +-
|  tests/mkfs.at            | 32 ++++++++++++++++++++++
|  tests/rgrifieldscheck.sh | 20 ++++++++++++++
|  tests/rgskipcheck.sh     | 19 +++++++++++++
|  11 files changed, 213 insertions(+), 35 deletions(-)
|  create mode 100755 tests/rgrifieldscheck.sh
|  create mode 100755 tests/rgskipcheck.sh
| 
| --
| 2.13.6

Hi,

Series ACK

Bob Peterson
Red Hat File Systems