cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements
@ 2014-02-17 14:47 Andrew Price
  2014-02-17 14:47 ` [Cluster-devel] [PATCH 2/4] gfs2-utils: Ensure sb_uuid uses are guarded Andrew Price
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Andrew Price @ 2014-02-17 14:47 UTC (permalink / raw)
  To: cluster-devel.redhat.com

build_sb was creating the sb, setting its fields from an sdp and then
writing it, and also zeroing the gap before the sb on the device in a
block-by-block way using buffer_heads.

This patch splits the build_sb function into lgfs2_sb_init and
lgfs2_sb_write which operate on gfs2_sb structures instead of gfs2_sbds.
lgfs2_sb_write now uses pwritev to zero the initial blocks and write the
sb to an fd.

get_random_bytes has been moved into structures.c and made static as
only lgfs2_sb_init now uses it.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/convert/gfs2_convert.c |   3 +-
 gfs2/edit/hexedit.c         |   3 +-
 gfs2/fsck/initialize.c      |  14 +++---
 gfs2/libgfs2/libgfs2.h      |   8 +--
 gfs2/libgfs2/misc.c         |  45 -----------------
 gfs2/libgfs2/ondisk.c       |   9 ++--
 gfs2/libgfs2/structures.c   | 120 +++++++++++++++++++++++++++++++++-----------
 gfs2/libgfs2/super.c        |  12 -----
 gfs2/mkfs/main_mkfs.c       |  32 ++++++++----
 9 files changed, 132 insertions(+), 114 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 55db4fa..7a7d4df 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2323,7 +2323,8 @@ int main(int argc, char **argv)
 		bh = bread(&sb2, sb2.sb_addr);
 		sb2.sd_sb.sb_fs_format = GFS2_FORMAT_FS;
 		sb2.sd_sb.sb_multihost_format = GFS2_FORMAT_MULTI;
-		gfs2_sb_out(&sb2.sd_sb, bh);
+		gfs2_sb_out(&sb2.sd_sb, bh->b_data);
+		bmodified(bh);
 		brelse(bh);
 
 		error = fsync(sb2.device_fd);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 738dc4e..ffbf075 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2150,7 +2150,8 @@ static void process_field(const char *field, const char *nstr)
 				gfs2_sb_assigns(&lsb, field, nstr);
 			else
 				gfs2_sb_assignval(&lsb, field, newval);
-			gfs2_sb_out(&lsb, rbh);
+			gfs2_sb_out(&lsb, rbh->b_data);
+			bmodified(rbh);
 			if (!termlines)
 				gfs2_sb_printval(&lsb, field);
 		} else {
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 5758607..0f33aa6 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -60,7 +60,7 @@ static int block_mounters(struct gfs2_sbd *sdp, int block_em)
 		}
 	}
 
-	if (write_sb(sdp)) {
+	if (lgfs2_sb_write(&sdp->sd_sb, sdp->device_fd, sdp->bsize)) {
 		stack;
 		return -1;
 	}
@@ -1130,7 +1130,6 @@ static int sb_repair(struct gfs2_sbd *sdp)
 {
 	uint64_t half;
 	uint32_t known_bsize = 0;
-	unsigned char uuid[16];
 	int error = 0;
 
 	memset(&fix_md, 0, sizeof(fix_md));
@@ -1205,9 +1204,8 @@ static int sb_repair(struct gfs2_sbd *sdp)
 		}
 	}
 	/* Step 3 - Rebuild the lock protocol and file system table name */
-	strcpy(sdp->lockproto, GFS2_DEFAULT_LOCKPROTO);
-	strcpy(sdp->locktable, "unknown");
 	if (query(_("Okay to fix the GFS2 superblock? (y/n)"))) {
+		struct gfs2_sb sb;
 		log_info(_("Found system master directory at: 0x%llx\n"),
 			 sdp->sd_sb.sb_master_dir.no_addr);
 		sdp->master_dir = lgfs2_inode_read(sdp,
@@ -1226,8 +1224,12 @@ static int sb_repair(struct gfs2_sbd *sdp)
 			log_crit(_("Error reading root inode: %s\n"), strerror(errno));
 			return -1;
 		}
-		get_random_bytes(uuid, sizeof(uuid));
-		build_sb(sdp, uuid);
+		lgfs2_sb_init(&sb, sdp->bsize);
+		strcpy(sb.sb_lockproto, GFS2_DEFAULT_LOCKPROTO);
+		strcpy(sb.sb_locktable, "unknown");
+		sb.sb_master_dir = sdp->master_dir->i_di.di_num;
+		sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
+		lgfs2_sb_write(&sb, sdp->device_fd, sdp->bsize);
 		inode_put(&sdp->md.rooti);
 		inode_put(&sdp->master_dir);
 		sb_fixed = 1;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index cc65003..6372128 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -719,7 +719,6 @@ extern int dir_exists(const char *dir);
 extern int mount_gfs2_meta(struct gfs2_sbd *sdp);
 extern void cleanup_metafs(struct gfs2_sbd *sdp);
 extern int is_fsname(char *name);
-extern void get_random_bytes(void *buf, int nbytes);
 
 /* recovery.c */
 extern void gfs2_replay_incr_blk(struct gfs2_inode *ip, unsigned int *blk);
@@ -753,7 +752,8 @@ static inline unsigned int rgrp_size(struct rgrp_tree *rgrp)
 
 /* structures.c */
 extern int build_master(struct gfs2_sbd *sdp);
-extern void build_sb(struct gfs2_sbd *sdp, const unsigned char *uuid);
+extern void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize);
+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);
 extern int build_jindex(struct gfs2_sbd *sdp);
@@ -789,14 +789,14 @@ extern void print_it(const char *label, const char *fmt, const char *fmt2, ...)
 /* Translation functions */
 
 extern void gfs2_inum_in(struct gfs2_inum *no, char *buf);
-extern void gfs2_inum_out(struct gfs2_inum *no, char *buf);
+extern void gfs2_inum_out(const struct gfs2_inum *no, char *buf);
 extern void gfs2_meta_header_in(struct gfs2_meta_header *mh,
 				struct gfs2_buffer_head *bh);
 extern void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf);
 extern void gfs2_meta_header_out_bh(const struct gfs2_meta_header *mh,
                                     struct gfs2_buffer_head *bh);
 extern void gfs2_sb_in(struct gfs2_sb *sb, struct gfs2_buffer_head *bh);
-extern void gfs2_sb_out(struct gfs2_sb *sb, struct gfs2_buffer_head *bh);
+extern void gfs2_sb_out(const struct gfs2_sb *sb, char *buf);
 extern void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf);
 extern void gfs2_rindex_out(struct gfs2_rindex *ri, char *buf);
 extern void gfs2_rgrp_in(struct gfs2_rgrp *rg, struct gfs2_buffer_head *bh);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index d34b8a5..4cdd6e0 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -17,7 +17,6 @@
 #include <dirent.h>
 #include <sys/sysmacros.h>
 #include <mntent.h>
-#include <sys/time.h>
 #include <signal.h>
 
 #include "libgfs2.h"
@@ -276,47 +275,3 @@ void cleanup_metafs(struct gfs2_sbd *sdp)
 	sigaction(SIGUSR2, &sa, NULL);
 	metafs_interrupted = 0;
 }
-
-/*
- * get_random_bytes - Generate a series of random bytes using /dev/urandom.
- *
- * Modified from original code in gen_uuid.c in e2fsprogs/lib
- */
-void get_random_bytes(void *buf, int nbytes)
-{
-	int i, n = nbytes, fd;
-	int lose_counter = 0;
-	unsigned char *cp = (unsigned char *) buf;
-	struct timeval	tv;
-
-	gettimeofday(&tv, 0);
-	fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
-	srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
-	/* Crank the random number generator a few times */
-	gettimeofday(&tv, 0);
-	for (i = (tv.tv_sec ^ tv.tv_usec) & 0x1F; i > 0; i--)
-		rand();
-	if (fd >= 0) {
-		while (n > 0) {
-			i = read(fd, cp, n);
-			if (i <= 0) {
-				if (lose_counter++ > 16)
-					break;
-				continue;
-			}
-			n -= i;
-			cp += i;
-			lose_counter = 0;
-		}
-		close(fd);
-	}
-
-	/*
-	 * We do this all the time, but this is the only source of
-	 * randomness if /dev/random/urandom is out to lunch.
-	 */
-	for (cp = buf, i = 0; i < nbytes; i++)
-		*cp++ ^= (rand() >> 7) & 0xFF;
-
-	return;
-}
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 4baacc7..43618bc 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -48,7 +48,7 @@ void gfs2_inum_in(struct gfs2_inum *no, char *buf)
 	CPIN_64(no, str, no_addr);
 }
 
-void gfs2_inum_out(struct gfs2_inum *no, char *buf)
+void gfs2_inum_out(const struct gfs2_inum *no, char *buf)
 {
 	struct gfs2_inum *str = (struct gfs2_inum *)buf;
 
@@ -124,11 +124,11 @@ void gfs2_sb_in(struct gfs2_sb *sb, struct gfs2_buffer_head *bh)
 #endif
 }
 
-void gfs2_sb_out(struct gfs2_sb *sb, struct gfs2_buffer_head *bh)
+void gfs2_sb_out(const struct gfs2_sb *sb, char *buf)
 {
-	struct gfs2_sb *str = (struct gfs2_sb *)bh->b_data;
+	struct gfs2_sb *str = (struct gfs2_sb *)buf;
 
-	gfs2_meta_header_out_bh(&sb->sb_header, bh);
+	gfs2_meta_header_out(&sb->sb_header, buf);
 
 	CPOUT_32(sb, str, sb_fs_format);
 	CPOUT_32(sb, str, sb_multihost_format);
@@ -144,7 +144,6 @@ void gfs2_sb_out(struct gfs2_sb *sb, struct gfs2_buffer_head *bh)
 #ifdef GFS2_HAS_UUID
 	memcpy(str->sb_uuid, sb->sb_uuid, 16);
 #endif
-	bmodified(bh);
 }
 
 const char *str_uuid(const unsigned char *uuid)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 030974b..2cc9a98 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -11,6 +11,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <linux/types.h>
+#include <sys/time.h>
 
 #include "libgfs2.h"
 
@@ -41,43 +42,102 @@ int build_master(struct gfs2_sbd *sdp)
 	return 0;
 }
 
-void build_sb(struct gfs2_sbd *sdp, const unsigned char *uuid)
+#ifdef GFS2_HAS_UUID
+/**
+ * Generate a series of random bytes using /dev/urandom.
+ * Modified from original code in gen_uuid.c in e2fsprogs/lib
+ */
+static void get_random_bytes(void *buf, int nbytes)
 {
-	unsigned int x;
-	struct gfs2_buffer_head *bh;
-	struct gfs2_sb sb;
-
-	/* Zero out the beginning of the device up to the superblock */
-	for (x = 0; x < sdp->sb_addr; x++) {
-		bh = bget(sdp, x);
-		memset(bh->b_data, 0, sdp->bsize);
-		bmodified(bh);
-		brelse(bh);
+	int i, n = nbytes, fd;
+	int lose_counter = 0;
+	unsigned char *cp = (unsigned char *) buf;
+	struct timeval	tv;
+
+	gettimeofday(&tv, 0);
+	fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
+	srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
+	/* Crank the random number generator a few times */
+	gettimeofday(&tv, 0);
+	for (i = (tv.tv_sec ^ tv.tv_usec) & 0x1F; i > 0; i--)
+		rand();
+	if (fd >= 0) {
+		while (n > 0) {
+			i = read(fd, cp, n);
+			if (i <= 0) {
+				if (lose_counter++ > 16)
+					break;
+				continue;
+			}
+			n -= i;
+			cp += i;
+			lose_counter = 0;
+		}
+		close(fd);
 	}
 
-	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_multihost_format = GFS2_FORMAT_MULTI;
-	sb.sb_bsize = sdp->bsize;
-	sb.sb_bsize_shift = ffs(sdp->bsize) - 1;
-	sb.sb_master_dir = sdp->master_dir->i_di.di_num;
-	sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
-	strcpy(sb.sb_lockproto, sdp->lockproto);
-	strcpy(sb.sb_locktable, sdp->locktable);
+	/*
+	 * We do this all the time, but this is the only source of
+	 * randomness if /dev/random/urandom is out to lunch.
+	 */
+	for (cp = buf, i = 0; i < nbytes; i++)
+		*cp++ ^= (rand() >> 7) & 0xFF;
+
+	return;
+}
+#endif
+
+/**
+ * Initialise a gfs2_sb structure with sensible defaults.
+ */
+void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize)
+{
+	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_multihost_format = GFS2_FORMAT_MULTI;
+	sb->sb_bsize = bsize;
+	sb->sb_bsize_shift = ffs(bsize) - 1;
 #ifdef GFS2_HAS_UUID
-	memcpy(sb.sb_uuid, uuid, sizeof(sb.sb_uuid));
+	get_random_bytes(&sb->sb_uuid, sizeof(sb->sb_uuid));
 #endif
-	bh = bget(sdp, sdp->sb_addr);
-	gfs2_sb_out(&sb, bh);
-	brelse(bh);
+}
 
-	if (sdp->debug) {
-		printf("\nSuper Block:\n");
-		gfs2_sb_print(&sb);
+int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize)
+{
+	int i, err = -1;
+	struct iovec *iov;
+	const size_t sb_addr = GFS2_SB_ADDR * GFS2_BASIC_BLOCK / bsize;
+	const size_t len = sb_addr + 1;
+
+	/* We only need 2 blocks: one for zeroing and a second for the superblock */
+	char *buf = calloc(2, bsize);
+	if (buf == NULL)
+		return -1;
+
+	iov = malloc(len * sizeof(*iov));
+	if (iov == NULL)
+		goto out_buf;
+
+	for (i = 0; i < len; i++) {
+		iov[i].iov_base = buf;
+		iov[i].iov_len = bsize;
 	}
+
+	gfs2_sb_out(sb, buf + bsize);
+	iov[sb_addr].iov_base = buf + bsize;
+
+	if (pwritev(fd, iov, len, 0) < (len * bsize))
+		goto out_iov;
+
+	err = 0;
+out_iov:
+	free(iov);
+out_buf:
+	free(buf);
+	return err;
 }
 
 int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index d074236..b956366 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -309,15 +309,3 @@ int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet)
 
 	return __ri_update(sdp, fd, rgcount, &sane, quiet);
 }
-
-int write_sb(struct gfs2_sbd *sbp)
-{
-	struct gfs2_buffer_head *bh;
-
-	bh = bread(sbp, GFS2_SB_ADDR >> sbp->sd_fsb2bb_shift);
-	gfs2_sb_out(&sbp->sd_sb, bh);
-	brelse(bh);
-	fsync(sbp->device_fd); /* make sure the change gets to disk ASAP */
-	return 0;
-}
-
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 0d84064..8bd396a 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -569,8 +569,8 @@ static void print_results(struct gfs2_sbd *sdp, uint64_t real_device_size,
 	       (unsigned long long)sdp->fssize, _("blocks"));
 	printf("%-27s%u\n", _("Journals:"), sdp->md.journals);
 	printf("%-27s%llu\n", _("Resource groups:"), (unsigned long long)sdp->rgrps);
-	printf("%-27s\"%s\"\n", _("Locking protocol:"), sdp->lockproto);
-	printf("%-27s\"%s\"\n", _("Lock table:"), sdp->locktable);
+	printf("%-27s\"%s\"\n", _("Locking protocol:"), opts->lockproto);
+	printf("%-27s\"%s\"\n", _("Lock table:"), opts->locktable);
 	/* Translators: "UUID" = universally unique identifier. */
 	printf("%-27s%s\n", _("UUID:"), str_uuid(uuid));
 }
@@ -701,8 +701,6 @@ static void sbd_init(struct gfs2_sbd *sdp, struct mkfs_opts *opts, struct mkfs_d
 		/* TODO: Check if the fssize is too small, somehow */
 		sdp->device.length = opts->fssize;
 	}
-	strcpy(sdp->lockproto, opts->lockproto);
-	strcpy(sdp->locktable, opts->locktable);
 }
 
 static int probe_contents(struct mkfs_dev *dev)
@@ -791,11 +789,11 @@ static void open_dev(const char *path, struct mkfs_dev *dev)
 void main_mkfs(int argc, char *argv[])
 {
 	struct gfs2_sbd sbd;
+	struct gfs2_sb sb;
 	struct mkfs_opts opts;
 	struct mkfs_dev dev;
 	lgfs2_rgrps_t rgs;
 	int error;
-	unsigned char uuid[16];
 	unsigned bsize;
 
 	opts_init(&opts);
@@ -810,15 +808,16 @@ void main_mkfs(int argc, char *argv[])
 	}
 
 	sbd_init(&sbd, &opts, &dev, bsize);
+	lgfs2_sb_init(&sb, bsize);
 	if (opts.debug) {
 		printf(_("File system options:\n"));
 		printf("  bsize = %u\n", sbd.bsize);
 		printf("  qcsize = %u\n", sbd.qcsize);
 		printf("  jsize = %u\n", sbd.jsize);
 		printf("  journals = %u\n", sbd.md.journals);
-		printf("  proto = %s\n", sbd.lockproto);
+		printf("  proto = %s\n", opts.lockproto);
+		printf("  table = %s\n", opts.locktable);
 		printf("  rgsize = %u\n", sbd.rgsize);
-		printf("  table = %s\n", sbd.locktable);
 		printf("  fssize = %"PRIu64"\n", opts.fssize);
 		printf("  sunit = %lu\n", opts.sunit);
 		printf("  swidth = %lu\n", opts.swidth);
@@ -838,8 +837,13 @@ void main_mkfs(int argc, char *argv[])
 		exit(1);
 	}
 	sbd.rgtree.osi_node = lgfs2_rgrps_root(rgs); // Temporary
+
 	build_root(&sbd);
+	sb.sb_root_dir = sbd.md.rooti->i_di.di_num;
+
 	build_master(&sbd);
+	sb.sb_master_dir = sbd.master_dir->i_di.di_num;
+
 	error = build_jindex(&sbd);
 	if (error) {
 		fprintf(stderr, _("Error building '%s': %s\n"), "jindex", strerror(errno));
@@ -872,8 +876,9 @@ void main_mkfs(int argc, char *argv[])
 		fprintf(stderr, _("Error building '%s': %s\n"), "quota", strerror(errno));
 		exit(EXIT_FAILURE);
 	}
-	get_random_bytes(uuid, sizeof(uuid));
-	build_sb(&sbd, uuid);
+
+	strcpy(sb.sb_lockproto, opts.lockproto);
+	strcpy(sb.sb_locktable, opts.locktable);
 
 	do_init_inum(&sbd);
 	do_init_statfs(&sbd);
@@ -884,6 +889,13 @@ void main_mkfs(int argc, char *argv[])
 	inode_put(&sbd.md.statfs);
 
 	gfs2_rgrp_free(&sbd.rgtree);
+
+	error = lgfs2_sb_write(&sb, dev.fd, sbd.bsize);
+	if (error) {
+		perror(_("Failed to write superblock\n"));
+		exit(EXIT_FAILURE);
+	}
+
 	error = fsync(dev.fd);
 	if (error){
 		perror(opts.device);
@@ -897,5 +909,5 @@ void main_mkfs(int argc, char *argv[])
 	}
 
 	if (!opts.quiet)
-		print_results(&sbd, dev.size, &opts, uuid);
+		print_results(&sbd, dev.size, &opts, sb.sb_uuid);
 }
-- 
1.8.5.3



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

* [Cluster-devel] [PATCH 2/4] gfs2-utils: Ensure sb_uuid uses are guarded
  2014-02-17 14:47 [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Andrew Price
@ 2014-02-17 14:47 ` Andrew Price
  2014-02-17 14:47 ` [Cluster-devel] [PATCH 3/4] libgfs2: Add support for new leaf hint fields Andrew Price
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Andrew Price @ 2014-02-17 14:47 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Guard uses of sb_uuid with #ifdef GFS2_HAS_UUID

Tweak print_results() in mkfs.gfs2 to accept the gfs2_sb which we
conditionally print the uuid from, instead of the gfs2_sbd.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/hexedit.c   |  5 ++++-
 gfs2/mkfs/main_mkfs.c | 27 ++++++++++++++-------------
 gfs2/tune/super.c     |  5 +++--
 3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index ffbf075..1ed4755 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -104,10 +104,12 @@ static int gfs2_sb_printval(struct gfs2_sb *lsb, const char *strfield)
 	checkprints(strfield, lsb, sb_locktable);
 	checkprint(strfield, lsb, __pad3.no_addr);
 	checkprint(strfield, lsb, __pad4.no_addr);
+#ifdef GFS2_HAS_UUID
 	if (strcmp(strfield, "sb_uuid") == 0) {
 		printf("%s\n", str_uuid(lsb->sb_uuid));
 		return 0;
 	}
+#endif
 
 	return -1;
 }
@@ -135,8 +137,9 @@ static int gfs2_sb_assigns(struct gfs2_sb *lsb, const char *strfield,
 {
 	checkassigns(strfield, lsb, sb_lockproto, val);
 	checkassigns(strfield, lsb, sb_locktable, val);
+#ifdef GFS2_HAS_UUID
 	checkassigns(strfield, lsb, sb_uuid, val);
-
+#endif
 	return -1;
 }
 
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 8bd396a..32da585 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -555,24 +555,25 @@ static void opts_check(struct mkfs_opts *opts)
 	}
 }
 
-static void print_results(struct gfs2_sbd *sdp, uint64_t real_device_size,
-                          struct mkfs_opts *opts, unsigned char uuid[16])
+static void print_results(struct gfs2_sb *sb, struct mkfs_dev *dev, struct mkfs_opts *opts,
+                          uint64_t rgrps, uint64_t fssize)
 {
 	printf("%-27s%s\n", _("Device:"), opts->device);
-	printf("%-27s%u\n", _("Block size:"), sdp->bsize);
-	printf("%-27s%.2f %s (%llu %s)\n", _("Device size:"),
+	printf("%-27s%u\n", _("Block size:"), sb->sb_bsize);
+	printf("%-27s%.2f %s (%"PRIu64" %s)\n", _("Device size:"),
 	       /* Translators: "GB" here means "gigabytes" */
-	       real_device_size / ((float)(1 << 30)), _("GB"),
-	       (unsigned long long)real_device_size / sdp->bsize, _("blocks"));
-	printf("%-27s%.2f %s (%llu %s)\n", _("Filesystem size:"),
-	       sdp->fssize / ((float)(1 << 30)) * sdp->bsize, _("GB"),
-	       (unsigned long long)sdp->fssize, _("blocks"));
-	printf("%-27s%u\n", _("Journals:"), sdp->md.journals);
-	printf("%-27s%llu\n", _("Resource groups:"), (unsigned long long)sdp->rgrps);
+	       (dev->size / ((float)(1 << 30))), _("GB"),
+	       (dev->size / sb->sb_bsize), _("blocks"));
+	printf("%-27s%.2f %s (%"PRIu64" %s)\n", _("Filesystem size:"),
+	       (fssize / ((float)(1 << 30)) * sb->sb_bsize), _("GB"), fssize, _("blocks"));
+	printf("%-27s%u\n", _("Journals:"), opts->journals);
+	printf("%-27s%"PRIu64"\n", _("Resource groups:"), rgrps);
 	printf("%-27s\"%s\"\n", _("Locking protocol:"), opts->lockproto);
 	printf("%-27s\"%s\"\n", _("Lock table:"), opts->locktable);
+#ifdef GFS2_HAS_UUID
 	/* Translators: "UUID" = universally unique identifier. */
-	printf("%-27s%s\n", _("UUID:"), str_uuid(uuid));
+	printf("%-27s%s\n", _("UUID:"), str_uuid(sb->sb_uuid));
+#endif
 }
 
 static void warn_of_destruction(const char *path)
@@ -909,5 +910,5 @@ void main_mkfs(int argc, char *argv[])
 	}
 
 	if (!opts.quiet)
-		print_results(&sbd, dev.size, &opts, sb.sb_uuid);
+		print_results(&sb, &dev, &opts, sbd.rgrps, sbd.fssize);
 }
diff --git a/gfs2/tune/super.c b/gfs2/tune/super.c
index cc34990..cbd0026 100644
--- a/gfs2/tune/super.c
+++ b/gfs2/tune/super.c
@@ -124,8 +124,9 @@ static int is_gfs2(const struct tunegfs2 *tfs)
 int print_super(const struct tunegfs2 *tfs)
 {
 	printf(_("File system volume name: %s\n"), tfs->sb->sb_locktable);
-	if (is_gfs2(tfs))
-		printf(_("File system UUID: %s\n"), uuid2str(tfs->sb->sb_uuid));
+#ifdef GFS2_HAS_UUID
+	printf(_("File system UUID: %s\n"), uuid2str(tfs->sb->sb_uuid));
+#endif
 	printf( _("File system magic number: 0x%X\n"), be32_to_cpu(tfs->sb->sb_header.mh_magic));
 	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));
-- 
1.8.5.3



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

* [Cluster-devel] [PATCH 3/4] libgfs2: Add support for new leaf hint fields
  2014-02-17 14:47 [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Andrew Price
  2014-02-17 14:47 ` [Cluster-devel] [PATCH 2/4] gfs2-utils: Ensure sb_uuid uses are guarded Andrew Price
@ 2014-02-17 14:47 ` Andrew Price
  2014-02-18 10:36   ` Steven Whitehouse
  2014-02-17 14:48 ` [Cluster-devel] [PATCH 4/4] mkfs.gfs2: Remove a dead structure Andrew Price
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Andrew Price @ 2014-02-17 14:47 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Kernel commit 01bcb0de introduces new gfs2_leaf fields. This patch adds
support for those fields to libgfs2, conditional upon them being
discovered in the configure stage. Includes meta.c changes by Steve
Whitehouse.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 configure.ac          | 10 ++++------
 gfs2/edit/extended.c  | 20 ++++++++++++++++----
 gfs2/edit/gfs2hex.c   |  9 ++-------
 gfs2/edit/hexedit.c   | 14 ++++++++++++++
 gfs2/edit/hexedit.h   |  5 +----
 gfs2/fsck/metawalk.c  |  2 +-
 gfs2/libgfs2/fs_ops.c | 11 +++++++++--
 gfs2/libgfs2/meta.c   |  8 ++++++++
 gfs2/libgfs2/ondisk.c | 26 +++++++++++++++++++++++---
 9 files changed, 78 insertions(+), 27 deletions(-)

diff --git a/configure.ac b/configure.ac
index 628d85e..80310be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,12 +116,10 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h mnt
 AC_CHECK_HEADERS([linux/dlmconstants.h linux/limits.h linux/types.h linux/netlink.h linux/fs.h],,
 		 [AC_MSG_ERROR([Unable to find all required kernel headers.])])
 
-AC_CHECK_HEADERS([linux/gfs2_ondisk.h],
-		 [AC_CHECK_MEMBERS([struct gfs2_sb.sb_uuid],,
-			[AC_MSG_ERROR([Unable to find gfs2 uuid support in your headers.
-Please update your kernel headers to a more recent version])],
-			[#include <linux/gfs2_ondisk.h>])],
-		 [AC_MSG_ERROR([Unable to find required kernel headers.])])
+AC_CHECK_HEADER([linux/gfs2_ondisk.h], [], [AC_MSG_ERROR([Unable to find linux/gfs2_ondisk.h])])
+AC_CHECK_MEMBER([struct gfs2_sb.sb_uuid], [], [], [[#include <linux/gfs2_ondisk.h>]])
+AC_CHECK_MEMBER([struct gfs2_leaf.lf_inode],[AC_DEFINE([GFS2_HAS_LEAF_HINTS],[],[Leaf block hints])],
+                [], [[#include <linux/gfs2_ondisk.h>]])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_INLINE
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index ac1e5d7..793ef6b 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -296,8 +296,18 @@ static void print_inode_type(__be16 de_type)
 	}
 }
 
+#ifdef GFS2_HAS_LEAF_HINTS
+#define LEAF_HINT_FMTS "lf_inode: 0x%"PRIx64", lf_dist: %"PRIu32", " \
+                       "lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "
+#define LEAF_HINT_FIELDS(lp) lp->lf_inode, lp->lf_dist, lp->lf_nsec, lp->lf_sec,
+#else
+#define LEAF_HINT_FMTS
+#define LEAF_HINT_FIELDS(lp)
+#endif
+
 static int display_leaf(struct iinfo *ind)
 {
+	struct gfs2_leaf *leaf = &ind->ii[0].lf;
 	int start_line, total_dirents = start_row[dmode];
 	int d;
 
@@ -305,11 +315,13 @@ static int display_leaf(struct iinfo *ind)
 	if (gfs2_struct_type == GFS2_METATYPE_SB)
 		print_gfs2("The superblock has 2 directories");
 	else
-		print_gfs2("Directory block: lf_depth:%d, lf_entries:%d,"
+		print_gfs2("Directory block: lf_depth:%d, lf_entries:%d, "
+		           LEAF_HINT_FMTS
 			   "fmt:%d next=0x%llx (%d dirents).",
-			   ind->ii[0].lf_depth, ind->ii[0].lf_entries,
-			   ind->ii[0].lf_dirent_format,
-			   ind->ii[0].lf_next,
+			   leaf->lf_depth, leaf->lf_entries,
+		           LEAF_HINT_FIELDS(leaf)
+			   leaf->lf_dirent_format,
+			   leaf->lf_next,
 			   ind->ii[0].dirents);
 
 	start_line = line;
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 8544bbd..979aee0 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -322,17 +322,12 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
 {
 	int x, i;
 	struct gfs2_dirent de;
-	struct gfs2_leaf leaf;
 	struct gfs2_buffer_head tbh; /* kludge */
 
 	x = 0;
 	memset(indir, 0, sizeof(*indir));
 	tbh.b_data = dlebuf;
-	gfs2_leaf_in(&leaf, &tbh);
-	indir->ii[0].lf_depth = leaf.lf_depth;
-	indir->ii[0].lf_entries = leaf.lf_entries;
-	indir->ii[0].lf_dirent_format = leaf.lf_dirent_format;
-	indir->ii[0].lf_next = leaf.lf_next;
+	gfs2_leaf_in(&indir->ii[0].lf, &tbh);
 	/* Directory Entries: */
 	for (i = sizeof(struct gfs2_leaf); i < sbd.bsize;
 	     i += de.de_rec_len) {
@@ -353,7 +348,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
 		if (de.de_rec_len <= sizeof(struct gfs2_dirent))
 			break;
 	}
-	return leaf.lf_next;
+	return indir->ii[0].lf.lf_next;
 }
 
 static void do_eattr_extended(struct gfs2_buffer_head *ebh)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 1ed4755..cf57ec8 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -219,7 +219,15 @@ static int gfs2_leaf_printval(struct gfs2_leaf *lf, const char *strfield)
 	checkprint(strfield, lf, lf_entries);
 	checkprint(strfield, lf, lf_dirent_format);
 	checkprint(strfield, lf, lf_next);
+#ifdef GFS2_HAS_LEAF_HINTS
+	checkprint(strfield, lf, lf_inode);
+	checkprint(strfield, lf, lf_dist);
+	checkprint(strfield, lf, lf_nsec);
+	checkprint(strfield, lf, lf_sec);
+	checkprints(strfield, lf, lf_reserved2);
+#else
 	checkprints(strfield, lf, lf_reserved);
+#endif
 
 	return -1;
 }
@@ -231,6 +239,12 @@ static int gfs2_leaf_assignval(struct gfs2_leaf *lf, const char *strfield,
 	checkassign(strfield, lf, lf_entries, value);
 	checkassign(strfield, lf, lf_dirent_format, value);
 	checkassign(strfield, lf, lf_next, value);
+#ifdef GFS2_HAS_LEAF_HINTS
+	checkassign(strfield, lf, lf_inode, value);
+	checkassign(strfield, lf, lf_dist, value);
+	checkassign(strfield, lf, lf_nsec, value);
+	checkassign(strfield, lf, lf_sec, value);
+#endif
 
 	return -1;
 }
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 21cf70a..7615242 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -79,10 +79,7 @@ struct indirect_info {
 	int height;
 	uint64_t block;
 	uint32_t dirents;
-	uint16_t lf_depth;
-	uint16_t lf_entries;
-	uint32_t lf_dirent_format;
-	uint64_t lf_next;
+	struct gfs2_leaf lf;
 	struct metapath mp;
 	struct gfs2_dirents dirent[64];
 };
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index b9b4154..15cba56 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -657,7 +657,6 @@ static void dir_leaf_reada(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize)
 static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
 {
 	int error = 0;
-	struct gfs2_leaf leaf;
 	unsigned hsize = (1 << ip->i_di.di_depth);
 	uint64_t leaf_no, leaf_next;
 	uint64_t first_ok_leaf, orig_di_blocks;
@@ -767,6 +766,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
 
 		chained_leaf = 0;
 		do {
+			struct gfs2_leaf leaf;
 			if (fsck_abort) {
 				free(tbl);
 				posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_NORMAL);
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index e00bd1f..f59f014 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -941,6 +941,9 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
 	oleaf->lf_depth = cpu_to_be16(oleaf->lf_depth);
 	nleaf->lf_depth = oleaf->lf_depth;
 
+#ifdef GFS2_HAS_LEAF_HINTS
+	nleaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+#endif
 	dip->i_di.di_blocks++;
 	bmodified(dip->i_bh);
 
@@ -1124,7 +1127,9 @@ restart:
 				nleaf = (struct gfs2_leaf *)nbh->b_data;
 				nleaf->lf_depth = leaf->lf_depth;
 				nleaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
-
+#ifdef GFS2_HAS_LEAF_HINTS
+				nleaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+#endif
 				err = dirent_alloc(dip, nbh, len, &dent);
 				if (err)
 					return err;
@@ -1175,7 +1180,9 @@ static void dir_make_exhash(struct gfs2_inode *dip)
 	leaf = (struct gfs2_leaf *)bh->b_data;
 	leaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
 	leaf->lf_entries = cpu_to_be16(dip->i_di.di_entries);
-
+#ifdef GFS2_HAS_LEAF_HINTS
+	leaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+#endif
 	buffer_copy_tail(sdp, bh, sizeof(struct gfs2_leaf),
 			 dip->i_bh, sizeof(struct gfs2_dinode));
 
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index 94be823..4305393 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -317,7 +317,15 @@ F(lf_depth)
 F(lf_entries)
 F(lf_dirent_format)
 F(lf_next)
+#ifdef GFS2_HAS_LEAF_HINTS
+FP(lf_inode, .points_to = (1 << LGFS2_MT_GFS2_DINODE))
+F(lf_dist)
+F(lf_nsec, .flags = LGFS2_MFF_NSECS)
+F(lf_sec, .flags = LGFS2_MFF_SECS)
+RF(lf_reserved2)
+#else
 RF(lf_reserved)
+#endif
 };
 
 #undef STRUCT
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 43618bc..dcc537e 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -433,8 +433,15 @@ void gfs2_leaf_in(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
 	CPIN_16(lf, str, lf_entries);
 	CPIN_32(lf, str, lf_dirent_format);
 	CPIN_64(lf, str, lf_next);
-
+#ifdef GFS2_HAS_LEAF_HINTS
+	CPIN_64(lf, str, lf_inode);
+	CPIN_32(lf, str, lf_dist);
+	CPIN_32(lf, str, lf_nsec);
+	CPIN_64(lf, str, lf_sec);
+	CPIN_08(lf, str, lf_reserved2, 40);
+#else
 	CPIN_08(lf, str, lf_reserved, 32);
+#endif
 }
 
 void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
@@ -446,8 +453,15 @@ void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
 	CPOUT_16(lf, str, lf_entries);
 	CPOUT_32(lf, str, lf_dirent_format);
 	CPOUT_64(lf, str, lf_next);
-
-	CPOUT_08(lf, str, lf_reserved, 32);
+#ifdef GFS2_HAS_LEAF_HINTS
+	CPOUT_64(lf, str, lf_inode);
+	CPOUT_32(lf, str, lf_dist);
+	CPOUT_32(lf, str, lf_nsec);
+	CPOUT_64(lf, str, lf_sec);
+	CPOUT_08(lf, str, lf_reserved2, 40);
+#else
+	CPOUT_08(lf, str, lf_reserved, 64);
+#endif
 	bmodified(bh);
 }
 
@@ -458,6 +472,12 @@ void gfs2_leaf_print(struct gfs2_leaf *lf)
 	pv(lf, lf_entries, "%u", "0x%x");
 	pv(lf, lf_dirent_format, "%u", "0x%x");
 	pv(lf, lf_next, "%llu", "0x%llx");
+#ifdef GFS2_HAS_LEAF_HINTS
+	pv(lf, lf_inode, "%llu", "0x%llx");
+	pv(lf, lf_dist, "%u", "0x%x");
+	pv(lf, lf_nsec, "%u", "0x%x");
+	pv(lf, lf_sec, "%llu", "0x%llx");
+#endif
 }
 
 void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf)
-- 
1.8.5.3



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

* [Cluster-devel] [PATCH 4/4] mkfs.gfs2: Remove a dead structure
  2014-02-17 14:47 [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Andrew Price
  2014-02-17 14:47 ` [Cluster-devel] [PATCH 2/4] gfs2-utils: Ensure sb_uuid uses are guarded Andrew Price
  2014-02-17 14:47 ` [Cluster-devel] [PATCH 3/4] libgfs2: Add support for new leaf hint fields Andrew Price
@ 2014-02-17 14:48 ` Andrew Price
  2014-02-17 15:12 ` [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Bob Peterson
  2014-02-25  3:15 ` [Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update Abhijith Das
  4 siblings, 0 replies; 9+ messages in thread
From: Andrew Price @ 2014-02-17 14:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com

struct mkfs_rgs has not been used since the new rgrp functions were
added to libgfs2. Remove it.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/mkfs/main_mkfs.c | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 32da585..e58de68 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -151,25 +151,6 @@ struct mkfs_dev {
 	unsigned int got_topol:1;
 };
 
-/**
- * A representation of the state of resource group calculation. Allows mkfs to create
- * resource groups at any point instead of creating them all in one batch.
- */
-struct mkfs_rgs {
-	struct osi_root *root;
-	uint64_t nextaddr;
-	unsigned bsize;
-	unsigned long align;
-	unsigned long align_off;
-	unsigned long curr_offset;
-	uint64_t maxrgsz;
-	uint64_t minrgsz;
-	uint64_t devlen;
-	uint64_t rgsize;
-	uint64_t count;
-	uint64_t blks_total;
-};
-
 static void opts_init(struct mkfs_opts *opts)
 {
 	memset(opts, 0, sizeof(*opts));
-- 
1.8.5.3



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

* [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements
  2014-02-17 14:47 [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Andrew Price
                   ` (2 preceding siblings ...)
  2014-02-17 14:48 ` [Cluster-devel] [PATCH 4/4] mkfs.gfs2: Remove a dead structure Andrew Price
@ 2014-02-17 15:12 ` Bob Peterson
  2014-02-25  3:15 ` [Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update Abhijith Das
  4 siblings, 0 replies; 9+ messages in thread
From: Bob Peterson @ 2014-02-17 15:12 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
| build_sb was creating the sb, setting its fields from an sdp and then
| writing it, and also zeroing the gap before the sb on the device in a
| block-by-block way using buffer_heads.
| 
| This patch splits the build_sb function into lgfs2_sb_init and
| lgfs2_sb_write which operate on gfs2_sb structures instead of gfs2_sbds.
| lgfs2_sb_write now uses pwritev to zero the initial blocks and write the
| sb to an fd.
| 
| get_random_bytes has been moved into structures.c and made static as
| only lgfs2_sb_init now uses it.
| 
| Signed-off-by: Andrew Price <anprice@redhat.com>
| ---

Hi,

All four patches look good to me. ACK.

Bob Peterson
Red Hat File Systems



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

* [Cluster-devel] [PATCH 3/4] libgfs2: Add support for new leaf hint fields
  2014-02-17 14:47 ` [Cluster-devel] [PATCH 3/4] libgfs2: Add support for new leaf hint fields Andrew Price
@ 2014-02-18 10:36   ` Steven Whitehouse
  2014-02-18 11:02     ` Andrew Price
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Whitehouse @ 2014-02-18 10:36 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On Mon, 2014-02-17 at 14:47 +0000, Andrew Price wrote:
> Kernel commit 01bcb0de introduces new gfs2_leaf fields. This patch adds
> support for those fields to libgfs2, conditional upon them being
> discovered in the configure stage. Includes meta.c changes by Steve
> Whitehouse.
> 
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>  configure.ac          | 10 ++++------
>  gfs2/edit/extended.c  | 20 ++++++++++++++++----
>  gfs2/edit/gfs2hex.c   |  9 ++-------
>  gfs2/edit/hexedit.c   | 14 ++++++++++++++
>  gfs2/edit/hexedit.h   |  5 +----
>  gfs2/fsck/metawalk.c  |  2 +-
>  gfs2/libgfs2/fs_ops.c | 11 +++++++++--
>  gfs2/libgfs2/meta.c   |  8 ++++++++
>  gfs2/libgfs2/ondisk.c | 26 +++++++++++++++++++++++---
>  9 files changed, 78 insertions(+), 27 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 628d85e..80310be 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -116,12 +116,10 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h mnt
>  AC_CHECK_HEADERS([linux/dlmconstants.h linux/limits.h linux/types.h linux/netlink.h linux/fs.h],,
>  		 [AC_MSG_ERROR([Unable to find all required kernel headers.])])
>  
> -AC_CHECK_HEADERS([linux/gfs2_ondisk.h],
> -		 [AC_CHECK_MEMBERS([struct gfs2_sb.sb_uuid],,
> -			[AC_MSG_ERROR([Unable to find gfs2 uuid support in your headers.
> -Please update your kernel headers to a more recent version])],
> -			[#include <linux/gfs2_ondisk.h>])],
> -		 [AC_MSG_ERROR([Unable to find required kernel headers.])])
> +AC_CHECK_HEADER([linux/gfs2_ondisk.h], [], [AC_MSG_ERROR([Unable to find linux/gfs2_ondisk.h])])
> +AC_CHECK_MEMBER([struct gfs2_sb.sb_uuid], [], [], [[#include <linux/gfs2_ondisk.h>]])
> +AC_CHECK_MEMBER([struct gfs2_leaf.lf_inode],[AC_DEFINE([GFS2_HAS_LEAF_HINTS],[],[Leaf block hints])],
> +                [], [[#include <linux/gfs2_ondisk.h>]])
>  
>  # Checks for typedefs, structures, and compiler characteristics.
>  AC_C_INLINE
> diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
> index ac1e5d7..793ef6b 100644
> --- a/gfs2/edit/extended.c
> +++ b/gfs2/edit/extended.c
> @@ -296,8 +296,18 @@ static void print_inode_type(__be16 de_type)
>  	}
>  }
>  
> +#ifdef GFS2_HAS_LEAF_HINTS
> +#define LEAF_HINT_FMTS "lf_inode: 0x%"PRIx64", lf_dist: %"PRIu32", " \
> +                       "lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "
> +#define LEAF_HINT_FIELDS(lp) lp->lf_inode, lp->lf_dist, lp->lf_nsec, lp->lf_sec,
> +#else
> +#define LEAF_HINT_FMTS
> +#define LEAF_HINT_FIELDS(lp)
> +#endif
> +
>  static int display_leaf(struct iinfo *ind)
>  {
> +	struct gfs2_leaf *leaf = &ind->ii[0].lf;
>  	int start_line, total_dirents = start_row[dmode];
>  	int d;
>  
> @@ -305,11 +315,13 @@ static int display_leaf(struct iinfo *ind)
>  	if (gfs2_struct_type == GFS2_METATYPE_SB)
>  		print_gfs2("The superblock has 2 directories");
>  	else
> -		print_gfs2("Directory block: lf_depth:%d, lf_entries:%d,"
> +		print_gfs2("Directory block: lf_depth:%d, lf_entries:%d, "
> +		           LEAF_HINT_FMTS
>  			   "fmt:%d next=0x%llx (%d dirents).",
> -			   ind->ii[0].lf_depth, ind->ii[0].lf_entries,
> -			   ind->ii[0].lf_dirent_format,
> -			   ind->ii[0].lf_next,
> +			   leaf->lf_depth, leaf->lf_entries,
> +		           LEAF_HINT_FIELDS(leaf)
> +			   leaf->lf_dirent_format,
> +			   leaf->lf_next,
>  			   ind->ii[0].dirents);
Hmm. It should be possible to use the metadata description to print out
any arbitrary data structure without needing to reference the fields in
the structure directly, so that this kind of thing shouldn't be
required.

>  
>  	start_line = line;
> diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
> index 8544bbd..979aee0 100644
> --- a/gfs2/edit/gfs2hex.c
> +++ b/gfs2/edit/gfs2hex.c
> @@ -322,17 +322,12 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
>  {
>  	int x, i;
>  	struct gfs2_dirent de;
> -	struct gfs2_leaf leaf;
>  	struct gfs2_buffer_head tbh; /* kludge */
>  
>  	x = 0;
>  	memset(indir, 0, sizeof(*indir));
>  	tbh.b_data = dlebuf;
> -	gfs2_leaf_in(&leaf, &tbh);
> -	indir->ii[0].lf_depth = leaf.lf_depth;
> -	indir->ii[0].lf_entries = leaf.lf_entries;
> -	indir->ii[0].lf_dirent_format = leaf.lf_dirent_format;
> -	indir->ii[0].lf_next = leaf.lf_next;
> +	gfs2_leaf_in(&indir->ii[0].lf, &tbh);
>  	/* Directory Entries: */
>  	for (i = sizeof(struct gfs2_leaf); i < sbd.bsize;
>  	     i += de.de_rec_len) {
> @@ -353,7 +348,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
>  		if (de.de_rec_len <= sizeof(struct gfs2_dirent))
>  			break;
>  	}
> -	return leaf.lf_next;
> +	return indir->ii[0].lf.lf_next;
>  }
>  
>  static void do_eattr_extended(struct gfs2_buffer_head *ebh)
> diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
> index 1ed4755..cf57ec8 100644
> --- a/gfs2/edit/hexedit.c
> +++ b/gfs2/edit/hexedit.c
> @@ -219,7 +219,15 @@ static int gfs2_leaf_printval(struct gfs2_leaf *lf, const char *strfield)
>  	checkprint(strfield, lf, lf_entries);
>  	checkprint(strfield, lf, lf_dirent_format);
>  	checkprint(strfield, lf, lf_next);
> +#ifdef GFS2_HAS_LEAF_HINTS
> +	checkprint(strfield, lf, lf_inode);
> +	checkprint(strfield, lf, lf_dist);
> +	checkprint(strfield, lf, lf_nsec);
> +	checkprint(strfield, lf, lf_sec);
> +	checkprints(strfield, lf, lf_reserved2);
> +#else
>  	checkprints(strfield, lf, lf_reserved);
> +#endif
Likewise here as well,

Steve.




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

* [Cluster-devel] [PATCH 3/4] libgfs2: Add support for new leaf hint fields
  2014-02-18 10:36   ` Steven Whitehouse
@ 2014-02-18 11:02     ` Andrew Price
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Price @ 2014-02-18 11:02 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 18/02/14 10:36, Steven Whitehouse wrote:
> Hi,
>
> On Mon, 2014-02-17 at 14:47 +0000, Andrew Price wrote:
>> Kernel commit 01bcb0de introduces new gfs2_leaf fields. This patch adds
>> support for those fields to libgfs2, conditional upon them being
>> discovered in the configure stage. Includes meta.c changes by Steve
>> Whitehouse.
>>
>> Signed-off-by: Andrew Price <anprice@redhat.com>
>> ---
>>   configure.ac          | 10 ++++------
>>   gfs2/edit/extended.c  | 20 ++++++++++++++++----
>>   gfs2/edit/gfs2hex.c   |  9 ++-------
>>   gfs2/edit/hexedit.c   | 14 ++++++++++++++
>>   gfs2/edit/hexedit.h   |  5 +----
>>   gfs2/fsck/metawalk.c  |  2 +-
>>   gfs2/libgfs2/fs_ops.c | 11 +++++++++--
>>   gfs2/libgfs2/meta.c   |  8 ++++++++
>>   gfs2/libgfs2/ondisk.c | 26 +++++++++++++++++++++++---
>>   9 files changed, 78 insertions(+), 27 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 628d85e..80310be 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -116,12 +116,10 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h mnt
>>   AC_CHECK_HEADERS([linux/dlmconstants.h linux/limits.h linux/types.h linux/netlink.h linux/fs.h],,
>>   		 [AC_MSG_ERROR([Unable to find all required kernel headers.])])
>>
>> -AC_CHECK_HEADERS([linux/gfs2_ondisk.h],
>> -		 [AC_CHECK_MEMBERS([struct gfs2_sb.sb_uuid],,
>> -			[AC_MSG_ERROR([Unable to find gfs2 uuid support in your headers.
>> -Please update your kernel headers to a more recent version])],
>> -			[#include <linux/gfs2_ondisk.h>])],
>> -		 [AC_MSG_ERROR([Unable to find required kernel headers.])])
>> +AC_CHECK_HEADER([linux/gfs2_ondisk.h], [], [AC_MSG_ERROR([Unable to find linux/gfs2_ondisk.h])])
>> +AC_CHECK_MEMBER([struct gfs2_sb.sb_uuid], [], [], [[#include <linux/gfs2_ondisk.h>]])
>> +AC_CHECK_MEMBER([struct gfs2_leaf.lf_inode],[AC_DEFINE([GFS2_HAS_LEAF_HINTS],[],[Leaf block hints])],
>> +                [], [[#include <linux/gfs2_ondisk.h>]])
>>
>>   # Checks for typedefs, structures, and compiler characteristics.
>>   AC_C_INLINE
>> diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
>> index ac1e5d7..793ef6b 100644
>> --- a/gfs2/edit/extended.c
>> +++ b/gfs2/edit/extended.c
>> @@ -296,8 +296,18 @@ static void print_inode_type(__be16 de_type)
>>   	}
>>   }
>>
>> +#ifdef GFS2_HAS_LEAF_HINTS
>> +#define LEAF_HINT_FMTS "lf_inode: 0x%"PRIx64", lf_dist: %"PRIu32", " \
>> +                       "lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "
>> +#define LEAF_HINT_FIELDS(lp) lp->lf_inode, lp->lf_dist, lp->lf_nsec, lp->lf_sec,
>> +#else
>> +#define LEAF_HINT_FMTS
>> +#define LEAF_HINT_FIELDS(lp)
>> +#endif
>> +
>>   static int display_leaf(struct iinfo *ind)
>>   {
>> +	struct gfs2_leaf *leaf = &ind->ii[0].lf;
>>   	int start_line, total_dirents = start_row[dmode];
>>   	int d;
>>
>> @@ -305,11 +315,13 @@ static int display_leaf(struct iinfo *ind)
>>   	if (gfs2_struct_type == GFS2_METATYPE_SB)
>>   		print_gfs2("The superblock has 2 directories");
>>   	else
>> -		print_gfs2("Directory block: lf_depth:%d, lf_entries:%d,"
>> +		print_gfs2("Directory block: lf_depth:%d, lf_entries:%d, "
>> +		           LEAF_HINT_FMTS
>>   			   "fmt:%d next=0x%llx (%d dirents).",
>> -			   ind->ii[0].lf_depth, ind->ii[0].lf_entries,
>> -			   ind->ii[0].lf_dirent_format,
>> -			   ind->ii[0].lf_next,
>> +			   leaf->lf_depth, leaf->lf_entries,
>> +		           LEAF_HINT_FIELDS(leaf)
>> +			   leaf->lf_dirent_format,
>> +			   leaf->lf_next,
>>   			   ind->ii[0].dirents);
> Hmm. It should be possible to use the metadata description to print out
> any arbitrary data structure without needing to reference the fields in
> the structure directly, so that this kind of thing shouldn't be
> required.

Yes, that's true of a lot of parts of the code and I've been planning to 
take care of it all at once by adding generic printing or 'tostring' 
functions to libgfs2. What I haven't decided yet is whether we need to 
store format strings ("%s" etc.) for each field in the metadata 
description or whether we can just use something like the field_print 
function in libgfs2/lang.c, which is slightly hacky:

static int field_print(const struct gfs2_buffer_head *bh, const struct 
lgfs2_metadata *mtype,
                       const struct lgfs2_metafield *field)
{
         const char *fieldp = (char *)bh->iov.iov_base + field->offset;

         printf("%s\t%"PRIu64"\t%u\t%u\t%s\t", mtype->name, 
bh->b_blocknr, field->offset, field->length, field->name);
         if (field->flags & LGFS2_MFF_UUID) {
                 printf("'%s'\n", str_uuid((const unsigned char *)fieldp));
         } else if (field->flags & LGFS2_MFF_STRING) {
                 printf("'%s'\n", fieldp);
         } else {
                 switch(field->length) {
                 case 1:
                         printf("%"PRIu8"\n", *(uint8_t *)fieldp);
                         break;
                 case 2:
                         printf("%"PRIu16"\n", be16_to_cpu(*(uint16_t 
*)fieldp));
                         break;
                 case 4:
                         printf("%"PRIu32"\n", be32_to_cpu(*(uint32_t 
*)fieldp));
                         break;
                 case 8:
                         printf("%"PRIu64"\n", be64_to_cpu(*(uint64_t 
*)fieldp));
                         break;
                 default:
                         // "Reserved" field so just print 0
                         printf("0\n");
                         return 1;
                 }
         }
         return 0;
}

Andy

>
>>
>>   	start_line = line;
>> diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
>> index 8544bbd..979aee0 100644
>> --- a/gfs2/edit/gfs2hex.c
>> +++ b/gfs2/edit/gfs2hex.c
>> @@ -322,17 +322,12 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
>>   {
>>   	int x, i;
>>   	struct gfs2_dirent de;
>> -	struct gfs2_leaf leaf;
>>   	struct gfs2_buffer_head tbh; /* kludge */
>>
>>   	x = 0;
>>   	memset(indir, 0, sizeof(*indir));
>>   	tbh.b_data = dlebuf;
>> -	gfs2_leaf_in(&leaf, &tbh);
>> -	indir->ii[0].lf_depth = leaf.lf_depth;
>> -	indir->ii[0].lf_entries = leaf.lf_entries;
>> -	indir->ii[0].lf_dirent_format = leaf.lf_dirent_format;
>> -	indir->ii[0].lf_next = leaf.lf_next;
>> +	gfs2_leaf_in(&indir->ii[0].lf, &tbh);
>>   	/* Directory Entries: */
>>   	for (i = sizeof(struct gfs2_leaf); i < sbd.bsize;
>>   	     i += de.de_rec_len) {
>> @@ -353,7 +348,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
>>   		if (de.de_rec_len <= sizeof(struct gfs2_dirent))
>>   			break;
>>   	}
>> -	return leaf.lf_next;
>> +	return indir->ii[0].lf.lf_next;
>>   }
>>
>>   static void do_eattr_extended(struct gfs2_buffer_head *ebh)
>> diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
>> index 1ed4755..cf57ec8 100644
>> --- a/gfs2/edit/hexedit.c
>> +++ b/gfs2/edit/hexedit.c
>> @@ -219,7 +219,15 @@ static int gfs2_leaf_printval(struct gfs2_leaf *lf, const char *strfield)
>>   	checkprint(strfield, lf, lf_entries);
>>   	checkprint(strfield, lf, lf_dirent_format);
>>   	checkprint(strfield, lf, lf_next);
>> +#ifdef GFS2_HAS_LEAF_HINTS
>> +	checkprint(strfield, lf, lf_inode);
>> +	checkprint(strfield, lf, lf_dist);
>> +	checkprint(strfield, lf, lf_nsec);
>> +	checkprint(strfield, lf, lf_sec);
>> +	checkprints(strfield, lf, lf_reserved2);
>> +#else
>>   	checkprints(strfield, lf, lf_reserved);
>> +#endif
> Likewise here as well,
>
> Steve.
>
>



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

* [Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update
  2014-02-17 14:47 [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Andrew Price
                   ` (3 preceding siblings ...)
  2014-02-17 15:12 ` [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Bob Peterson
@ 2014-02-25  3:15 ` Abhijith Das
  2014-02-25 12:20   ` Andrew Price
  4 siblings, 1 reply; 9+ messages in thread
From: Abhijith Das @ 2014-02-25  3:15 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Since the gfs2_sb structure doesn't contain all the gfs1 fields,
updating using lgfs2_sb_write overwrites some gfs1 fields with
zeros and breaks the filesystem.

We need to update only the gfs2_sb fields and leave the rest as-is.

Signed-off-by: Abhi Das <adas@redhat.com>

diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 0f33aa6..cf45a5c 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -60,6 +60,9 @@ static int block_mounters(struct gfs2_sbd *sdp, int block_em)
 		}
 	}
 
+	if (sdp->gfs1)
+		return lgfs2_sb_update(sdp);
+
 	if (lgfs2_sb_write(&sdp->sd_sb, sdp->device_fd, sdp->bsize)) {
 		stack;
 		return -1;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 6372128..a20e369 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -754,6 +754,7 @@ static inline unsigned int rgrp_size(struct rgrp_tree *rgrp)
 extern int build_master(struct gfs2_sbd *sdp);
 extern void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize);
 extern int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize);
+extern int lgfs2_sb_update(struct gfs2_sbd *sbp);
 extern int build_journal(struct gfs2_sbd *sdp, int j,
 			 struct gfs2_inode *jindex);
 extern int build_jindex(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 2cc9a98..641d875 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -105,6 +105,17 @@ void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize)
 #endif
 }
 
+int lgfs2_sb_update(struct gfs2_sbd *sbp)
+{
+	struct gfs2_buffer_head *bh;
+
+	bh = bread(sbp, GFS2_SB_ADDR >> sbp->sd_fsb2bb_shift);
+	gfs2_sb_out(&sbp->sd_sb, bh->b_data);
+	brelse(bh);
+	fsync(sbp->device_fd); /* make sure the change gets to disk ASAP */
+	return 0;
+}
+
 int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize)
 {
 	int i, err = -1;



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

* [Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update
  2014-02-25  3:15 ` [Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update Abhijith Das
@ 2014-02-25 12:20   ` Andrew Price
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Price @ 2014-02-25 12:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi Abhi,

On Mon, Feb 24, 2014 at 10:15:15PM -0500, Abhijith Das wrote:
> Since the gfs2_sb structure doesn't contain all the gfs1 fields,
> updating using lgfs2_sb_write overwrites some gfs1 fields with
> zeros and breaks the filesystem.
> 
> We need to update only the gfs2_sb fields and leave the rest as-is.
> 
> Signed-off-by: Abhi Das <adas@redhat.com>
> 
> diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
> index 0f33aa6..cf45a5c 100644
> --- a/gfs2/fsck/initialize.c
> +++ b/gfs2/fsck/initialize.c
> @@ -60,6 +60,9 @@ static int block_mounters(struct gfs2_sbd *sdp, int block_em)
>  		}
>  	}
>  
> +	if (sdp->gfs1)
> +		return lgfs2_sb_update(sdp);
> +
>  	if (lgfs2_sb_write(&sdp->sd_sb, sdp->device_fd, sdp->bsize)) {
>  		stack;
>  		return -1;
> diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
> index 6372128..a20e369 100644
> --- a/gfs2/libgfs2/libgfs2.h
> +++ b/gfs2/libgfs2/libgfs2.h
> @@ -754,6 +754,7 @@ static inline unsigned int rgrp_size(struct rgrp_tree *rgrp)
>  extern int build_master(struct gfs2_sbd *sdp);
>  extern void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize);
>  extern int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize);
> +extern int lgfs2_sb_update(struct gfs2_sbd *sbp);
>  extern int build_journal(struct gfs2_sbd *sdp, int j,
>  			 struct gfs2_inode *jindex);
>  extern int build_jindex(struct gfs2_sbd *sdp);
> diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
> index 2cc9a98..641d875 100644
> --- a/gfs2/libgfs2/structures.c
> +++ b/gfs2/libgfs2/structures.c
> @@ -105,6 +105,17 @@ void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize)
>  #endif
>  }
>  
> +int lgfs2_sb_update(struct gfs2_sbd *sbp)
> +{
> +	struct gfs2_buffer_head *bh;
> +
> +	bh = bread(sbp, GFS2_SB_ADDR >> sbp->sd_fsb2bb_shift);

Perhaps it should return non-zero if bh == NULL. bread() is one of those cases where libgfs2 still calls exit() in an error path but that's going to change at some point (I promise!).

> +	gfs2_sb_out(&sbp->sd_sb, bh->b_data);

I think a bmodified(bh); might be needed here too. I've been slowing pushing the gfs2_buffer_head usage out of ondisk.c and the long term plan is to replace them entirely but until then we'll need to set them modified explicitly in some cases.

Cheers,
Andy

> +	brelse(bh);
> +	fsync(sbp->device_fd); /* make sure the change gets to disk ASAP */
> +	return 0;
> +}
> +
>  int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize)
>  {
>  	int i, err = -1;
> 



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

end of thread, other threads:[~2014-02-25 12:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-17 14:47 [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Andrew Price
2014-02-17 14:47 ` [Cluster-devel] [PATCH 2/4] gfs2-utils: Ensure sb_uuid uses are guarded Andrew Price
2014-02-17 14:47 ` [Cluster-devel] [PATCH 3/4] libgfs2: Add support for new leaf hint fields Andrew Price
2014-02-18 10:36   ` Steven Whitehouse
2014-02-18 11:02     ` Andrew Price
2014-02-17 14:48 ` [Cluster-devel] [PATCH 4/4] mkfs.gfs2: Remove a dead structure Andrew Price
2014-02-17 15:12 ` [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Bob Peterson
2014-02-25  3:15 ` [Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update Abhijith Das
2014-02-25 12:20   ` Andrew Price

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).