All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h
@ 2019-04-09  9:41 Andrew Price
  2019-04-09 12:03 ` Christoph Hellwig
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Price @ 2019-04-09  9:41 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Give gfs2-utils its own copy of gfs2_ondisk.h which uses userspace
types. This allows us to always support the latest ondisk structures and
obsoletes a lot of #ifdef GFS2_HAS_<FEATURE> blocks and configure.ac
checks.

gfs2_ondisk.h was changed simply by search-and-replace of the kernel int
types with the uintN_t, i.e.:

:%s/__u\(8\|16\|32\|64\)/uint\1_t/g
:%s/__be\(64\|32\|16\|8\)/uint\1_t/g

and the linux/types.h include replaced with stdint.h

A bunch of format strings were updated to use PRI* from inttypes.h to
fix issues where the kernel types were typedef'd to long long and the
userspace types are just long, for instance, despite being the same
width on x86_64.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 configure.ac                   |  16 -
 gfs2/convert/gfs2_convert.c    |   3 +-
 gfs2/edit/extended.c           |  41 +--
 gfs2/edit/gfs2hex.c            |  19 +-
 gfs2/edit/hexedit.c            |   3 +-
 gfs2/edit/hexedit.h            |   2 +-
 gfs2/edit/journal.c            |  13 +-
 gfs2/edit/savemeta.c           |   3 +-
 gfs2/fsck/fs_recovery.c        |  30 +-
 gfs2/fsck/initialize.c         |  50 ++-
 gfs2/fsck/lost_n_found.c       |  12 +-
 gfs2/fsck/pass1.c              |   2 +-
 gfs2/fsck/pass2.c              |   2 +-
 gfs2/fsck/rgrepair.c           |  29 +-
 gfs2/include/gfs2_ondisk.h     | 535 +++++++++++++++++++++++++++++++++
 gfs2/libgfs2/buf.c             |   1 -
 gfs2/libgfs2/device_geometry.c |   1 -
 gfs2/libgfs2/fs_geometry.c     |   1 -
 gfs2/libgfs2/fs_ops.c          |   7 -
 gfs2/libgfs2/gfs1.c            |   3 +-
 gfs2/libgfs2/lang.c            |  11 +-
 gfs2/libgfs2/libgfs2.h         | 103 +++----
 gfs2/libgfs2/meta.c            |  31 +-
 gfs2/libgfs2/ondisk.c          | 261 ++++++----------
 gfs2/libgfs2/recovery.c        |   2 -
 gfs2/libgfs2/rgrp.c            |   8 -
 gfs2/libgfs2/structures.c      |  22 +-
 gfs2/mkfs/gfs2_mkfs.h          |   2 +-
 gfs2/mkfs/main_grow.c          |   1 -
 gfs2/mkfs/main_jadd.c          |   7 -
 gfs2/mkfs/main_mkfs.c          |  14 +-
 gfs2/tune/super.c              |  18 +-
 32 files changed, 770 insertions(+), 483 deletions(-)
 create mode 100644 gfs2/include/gfs2_ondisk.h

diff --git a/configure.ac b/configure.ac
index 0c1b0192..51e0cc0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,23 +126,7 @@ AC_SUBST([udevdir], [$with_udevdir])
 # Checks for header files.
 AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h mntent.h stddef.h sys/file.h sys/ioctl.h sys/mount.h sys/time.h sys/vfs.h syslog.h termios.h])
 AC_CHECK_HEADER([linux/fs.h], [], [AC_MSG_ERROR([Unable to find linux/fs.h])])
-AC_CHECK_HEADER([linux/types.h], [], [AC_MSG_ERROR([Unable to find linux/types.h])])
 AC_CHECK_HEADER([linux/limits.h], [], [AC_MSG_ERROR([Unable to find linux/limits.h])])
-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], [sb_has_uuid=yes], [sb_has_uuid=no],
-                [[#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>]])
-AC_CHECK_MEMBER([struct gfs2_dirent.de_rahead],[AC_DEFINE([GFS2_HAS_DE_RAHEAD],[],[Dirent readahead field])],
-                [], [[#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>]])
-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>]])
-AC_CHECK_MEMBER([struct gfs2_log_header.lh_crc],[AC_DEFINE([GFS2_HAS_LH_V2],[],[v2 log header format])],
-                [], [[#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
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 9cf97b65..558a935d 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -28,8 +28,7 @@
 #include <locale.h>
 #define _(String) gettext(String)
 
-#include <linux/types.h>
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 #include <logging.h>
 #include "osi_list.h"
 #include "copyright.cf"
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index d24d7550..c46e522e 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -6,7 +6,6 @@
 #include <string.h>
 #include <inttypes.h>
 #include <sys/types.h>
-#include <linux/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -19,7 +18,7 @@
 #include <sys/mount.h>
 #include <dirent.h>
 
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 #include "copyright.cf"
 
 #include "hexedit.h"
@@ -233,7 +232,7 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
 	return 0;
 }
 
-static void print_inode_type(__be16 de_type)
+static void print_inode_type(uint16_t de_type)
 {
 	if (sbd.gfs1) {
 		switch(de_type) {
@@ -298,15 +297,6 @@ static void print_inode_type(__be16 de_type)
 	}
 }
 
-#ifdef GFS2_HAS_LEAF_HINTS
-#define LEAF_HINT_FMTS "lf_inode: 0x%llx, lf_dist: %u, " \
-                       "lf_nsec: %u, lf_sec: %llu, "
-#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;
@@ -318,10 +308,11 @@ static int display_leaf(struct iinfo *ind)
 		print_gfs2("The superblock has 2 directories");
 	else
 		print_gfs2("Directory block: lf_depth:%d, lf_entries:%d, "
-		           LEAF_HINT_FMTS
-			   "fmt:%d next=0x%llx (%d dirents).",
+		       "lf_inode: 0x%"PRIx64", lf_dist: %u, lf_nsec: %u, "
+		       "lf_sec: %"PRIu64", fmt:%d next=0x%"PRIx64" (%d dirents).",
 			   leaf->lf_depth, leaf->lf_entries,
-		           LEAF_HINT_FIELDS(leaf)
+		           leaf->lf_inode, leaf->lf_dist,
+		           leaf->lf_nsec, leaf->lf_sec,
 			   leaf->lf_dirent_format,
 			   leaf->lf_next,
 			   ind->ii[0].dirents);
@@ -344,18 +335,14 @@ static int display_leaf(struct iinfo *ind)
 					strcpy(edit_fmt, "%llx");
 				}
 			}
-			print_gfs2("%d/%d [%08x] %lld/%"PRId64" (0x%llx/0x%"PRIx64") +%u: ",
+			print_gfs2("%d/%d [%08x] %"PRId64"/%"PRId64" (0x%"PRIx64"/0x%"PRIx64") +%"PRIu16": ",
 				   total_dirents, d + 1,
 				   ind->ii[0].dirent[d].dirent.de_hash,
 				   ind->ii[0].dirent[d].dirent.de_inum.no_formal_ino,
 				   ind->ii[0].dirent[d].block,
 				   ind->ii[0].dirent[d].dirent.de_inum.no_formal_ino,
 				   ind->ii[0].dirent[d].block,
-#ifdef GFS2_HAS_DE_RAHEAD
-				   (unsigned int)ind->ii[0].dirent[d].dirent.de_rahead
-#else
-				   0
-#endif
+				   ind->ii[0].dirent[d].dirent.de_rahead
 			);
 		}
 		print_inode_type(ind->ii[0].dirent[d].dirent.de_type);
@@ -453,7 +440,7 @@ static int print_gfs_jindex(struct gfs2_inode *dij)
 	char jbuf[sizeof(struct gfs_jindex)];
 
 	start_line = line;
-	print_gfs2("Journal index entries found: %lld.",
+	print_gfs2("Journal index entries found: %"PRIu64".",
 		   dij->i_di.di_size / sizeof(struct gfs_jindex));
 	eol(0);
 	lines_per_row[dmode] = 4;
@@ -495,7 +482,7 @@ static int print_gfs2_jindex(void)
 		if (strncmp(indirect->ii[0].dirent[d].filename, "journal", 7))
 			continue;
 		ip = lgfs2_inode_read(&sbd, indirect->ii[0].dirent[d].block);
-		print_gfs2("%s: 0x%-5"PRIx64" %lldMB ",
+		print_gfs2("%s: 0x%-5"PRIx64" %"PRIu64"MB ",
 			   indirect->ii[0].dirent[d].filename,
 			   indirect->ii[0].dirent[d].block,
 			   ip->i_di.di_size / 1048576);
@@ -522,7 +509,7 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
 	char highlighted_addr[32];
 
 	start_line = line;
-	print_gfs2("RG index entries found: %lld.", dip->i_di.di_size /
+	print_gfs2("RG index entries found: %"PRIu64".", dip->i_di.di_size /
 		   sizeof(struct gfs2_rindex));
 	eol(0);
 	lines_per_row[dmode] = 6;
@@ -548,7 +535,7 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
 			}
 			print_gfs2("RG #%d", print_entry_ndx);
 			if (!print_rindex)
-				print_gfs2(" located at: %llu (0x%llx)",
+				print_gfs2(" located at: %"PRIu64" (0x%"PRIx64")",
 					   ri.ri_addr, ri.ri_addr);
 			eol(0);
 			if (edit_row[dmode] == print_entry_ndx)
@@ -627,10 +614,10 @@ static int print_quota(struct gfs2_inode *diq)
 {
 	struct gfs2_quota qbuf, q;
 	int i, error;
-	
+
 	print_gfs2("quota file contents:");
 	eol(0);
-	print_gfs2("quota entries found: %lld.", diq->i_di.di_size / sizeof(q));
+	print_gfs2("quota entries found: %"PRIu64".", diq->i_di.di_size / sizeof(q));
 	eol(0);
 	for (i=0; ; i++) {
 		error = gfs2_readi(diq, (void *)&qbuf, i * sizeof(q), sizeof(qbuf));
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 62d5cab5..49607294 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -5,24 +5,21 @@
 #include <string.h>
 #include <inttypes.h>
 #include <sys/types.h>
-#include <linux/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
 #include <curses.h>
+#include <uuid.h>
 
 #include "hexedit.h"
 
 #define WANT_GFS_CONVERSION_FUNCTIONS
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 
 #include "extended.h"
 #include "gfs2hex.h"
 #include "libgfs2.h"
-#ifdef GFS2_HAS_UUID
-#include <uuid.h>
-#endif
 
 #define pv(struct, member, fmt, fmt2) do {				\
 		print_it("  "#member, fmt, fmt2, struct->member);	\
@@ -381,10 +378,10 @@ static void gfs2_inum_print2(const char *title,struct gfs2_inum *no)
 	}
 	else
 		printf("  %s:",title);
-	pv2(no, no_formal_ino, "%llu", "0x%llx");
+	pv2(no, no_formal_ino, "%"PRIu64, "0x%"PRIx64);
 	if (!termlines)
 		printf("        addr:");
-	pv2(no, no_addr, "%llu", "0x%llx");
+	pv2(no, no_addr, "%"PRIu64, "0x%"PRIx64);
 }
 
 /**
@@ -393,6 +390,8 @@ static void gfs2_inum_print2(const char *title,struct gfs2_inum *no)
  */
 static void gfs2_sb_print2(struct gfs2_sb *sbp2)
 {
+	char readable_uuid[36+1];
+
 	gfs2_meta_header_print(&sbp2->sb_header);
 
 	pv(sbp2, sb_fs_format, "%u", "0x%x");
@@ -417,14 +416,8 @@ static void gfs2_sb_print2(struct gfs2_sb *sbp2)
 		gfs2_inum_print2("quota ino ", &gfs1_quota_di);
 		gfs2_inum_print2("license   ", &gfs1_license_di);
 	}
-#ifdef GFS2_HAS_UUID
-	{
-	char readable_uuid[36+1];
-
 	uuid_unparse(sbp2->sb_uuid, readable_uuid);
 	print_it("  sb_uuid", "%s", NULL, readable_uuid);
-	}
-#endif
 }
 
 /**
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index f015828c..5c4910fe 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -6,7 +6,6 @@
 #include <string.h>
 #include <inttypes.h>
 #include <sys/types.h>
-#include <linux/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -19,7 +18,7 @@
 #include <sys/mount.h>
 #include <dirent.h>
 
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 #include "copyright.cf"
 
 #include "hexedit.h"
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index d2992d8e..8b2338e6 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -4,7 +4,7 @@
 #include <sys/types.h>
 #include <inttypes.h>
 #include <limits.h>
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 #include <string.h>
 
 #include "libgfs2.h"
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 6364761f..f45b4e7b 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -6,7 +6,6 @@
 #include <string.h>
 #include <inttypes.h>
 #include <sys/types.h>
-#include <linux/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -19,7 +18,7 @@
 #include <sys/mount.h>
 #include <dirent.h>
 
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 #include "copyright.cf"
 
 #include "hexedit.h"
@@ -531,8 +530,8 @@ void dump_journal(const char *journal, int tblk)
 			uint64_t o;
 			int bmap = 0;
 
-			print_gfs2("rgd: 0x%llx for 0x%x, ", rgd->ri.ri_addr,
-				   rgd->ri.ri_length);
+			print_gfs2("rgd: 0x%"PRIx64" for 0x%"PRIx32", ",
+			           rgd->ri.ri_addr, rgd->ri.ri_length);
 			o = tblk - rgd->ri.ri_data0;
 			if (o >= (rgd->bits->bi_start +
 				  rgd->bits->bi_len) * (uint64_t)GFS2_NBBY)
@@ -591,8 +590,8 @@ void dump_journal(const char *journal, int tblk)
 				check_journal_wrap(lh1.lh_sequence,
 						   &highest_seq);
 				print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log header: "
-					   "Flags:%x, Seq: 0x%llx, 1st: 0x%llx, "
-					   "tail: 0x%llx, last: 0x%llx",
+					   "Flags:%x, Seq: 0x%"PRIx64", 1st: 0x%"PRIx64", "
+					   "tail: 0x%"PRIx64", last: 0x%"PRIx64"",
 					   abs_block, jb + wrappt,
 					   lh1.lh_flags, lh1.lh_sequence,
 					   lh1.lh_first, lh1.lh_tail,
@@ -607,7 +606,7 @@ void dump_journal(const char *journal, int tblk)
 						dummy_bh.b_data, lh_flags_field,
 						(dmode == HEX_MODE));
 				print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log header: Seq"
-					   ": 0x%llx, tail: 0x%x, blk: 0x%x [%s]",
+					   ": 0x%"PRIx64", tail: 0x%x, blk: 0x%x [%s]",
 					   abs_block, ((jb + wrappt) % j_size)
 					   / sbd.bsize, lh.lh_sequence,
 					   lh.lh_tail, lh.lh_blkno,
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 04f1221f..c895e1ec 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -7,7 +7,6 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <sys/types.h>
-#include <linux/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -17,7 +16,7 @@
 #include <sys/ioctl.h>
 #include <limits.h>
 #include <sys/time.h>
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 #include <zlib.h>
 #include <time.h>
 
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 677abd75..5834cc9e 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -121,7 +121,7 @@ static void refresh_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
 }
 
 static int buf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
-				struct gfs2_log_descriptor *ld, __be64 *ptr,
+				struct gfs2_log_descriptor *ld, uint64_t *ptr,
 				int pass)
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
@@ -188,7 +188,7 @@ static int buf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
 }
 
 static int revoke_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
-				   struct gfs2_log_descriptor *ld, __be64 *ptr,
+				   struct gfs2_log_descriptor *ld, uint64_t *ptr,
 				   int pass)
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
@@ -215,7 +215,7 @@ static int revoke_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
 				continue;
 		}
 		while (offset + sizeof(uint64_t) <= sdp->sd_sb.sb_bsize) {
-			blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset));
+			blkno = be64_to_cpu(*(uint64_t *)(bh->b_data + offset));
 			log_info( _("Journal replay processing revoke for "
 				    "block #%lld (0x%llx) for journal+0x%x\n"),
 				  (unsigned long long)blkno,
@@ -242,7 +242,7 @@ static int revoke_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
 
 static int databuf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
 				    struct gfs2_log_descriptor *ld,
-				    __be64 *ptr, int pass)
+				    uint64_t *ptr, int pass)
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
 	unsigned int blks = be32_to_cpu(ld->ld_data1);
@@ -283,7 +283,7 @@ static int databuf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
 
 		/* Unescape */
 		if (esc) {
-			__be32 *eptr = (__be32 *)bh_ip->b_data;
+			uint32_t *eptr = (uint32_t *)bh_ip->b_data;
 			*eptr = cpu_to_be32(GFS2_MAGIC);
 		}
 
@@ -315,10 +315,10 @@ static int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
 	struct gfs2_log_descriptor *ld;
 	int error = 0;
 	uint32_t length;
-	__be64 *ptr;
+	uint64_t *ptr;
 	unsigned int offset = sizeof(struct gfs2_log_descriptor);
-	offset += sizeof(__be64) - 1;
-	offset &= ~(sizeof(__be64) - 1);
+	offset += sizeof(uint64_t) - 1;
+	offset &= ~(sizeof(uint64_t) - 1);
 
 	while (start != end) {
 		uint32_t check_magic;
@@ -360,7 +360,7 @@ static int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
 			brelse(bh);
 			return -EIO;
 		}
-		ptr = (__be64 *)(bh->b_data + offset);
+		ptr = (uint64_t *)(bh->b_data + offset);
 		error = databuf_lo_scan_elements(ip, start, ld, ptr, pass);
 		if (error) {
 			bmodified(bh);
@@ -429,19 +429,17 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
 			prev_seq = lh.lh_sequence;
 			continue;
 		}
-		log_err( _("Journal block %u (0x%x): sequence no. 0x%llx "
-			   "out of order.\n"), blk, blk, lh.lh_sequence);
-		log_info( _("Low: 0x%llx, High: 0x%llx, Prev: 0x%llx\n"),
-			  (unsigned long long)lowest_seq,
-			  (unsigned long long)highest_seq,
-			  (unsigned long long)prev_seq);
+		log_err(_("Journal block %"PRIu32" (0x%"PRIx32"): sequence no. "
+		          "0x%"PRIx64" out of order.\n"), blk, blk, lh.lh_sequence);
+		log_info(_("Low: 0x%"PRIx64", High: 0x%"PRIx64", Prev: 0x%"PRIx64"\n"),
+		         lowest_seq, highest_seq, prev_seq);
 		seq_errors++;
 		if (!fix)
 			continue;
 		highest_seq++;
 		lh.lh_sequence = highest_seq;
 		prev_seq = lh.lh_sequence;
-		log_warn( _("Renumbering it as 0x%llx\n"), lh.lh_sequence);
+		log_warn(_("Renumbering it as 0x%"PRIx64"\n"), lh.lh_sequence);
 		block_map(ip, blk, &new, &dblock, NULL, FALSE);
 		bh = bread(ip->i_sbd, dblock);
 		gfs2_log_header_out(&lh, bh->b_data);
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index d1c620af..603884eb 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -925,7 +925,7 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
 	if (di->di_num.no_formal_ino == 2) {
 		if (sdp->sd_sb.sb_master_dir.no_addr)
 			return;
-		log_warn(_("Found system master directory at: 0x%llx.\n"),
+		log_warn(_("Found system master directory at: 0x%"PRIx64".\n"),
 			 di->di_num.no_addr);
 		sdp->sd_sb.sb_master_dir.no_addr = di->di_num.no_addr;
 		return;
@@ -940,7 +940,7 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
 	     (di->di_size % sizeof(struct gfs_jindex) == 0))) {
 		if (fix_md.jiinode || is_journal_copy(ip, bh))
 			goto out_discard_ip;
-		log_warn(_("Found system jindex file at: 0x%llx\n"),
+		log_warn(_("Found system jindex file at: 0x%"PRIx64"\n"),
 			 di->di_num.no_addr);
 		fix_md.jiinode = ip;
 	} else if (!sdp->gfs1 && is_dir(di, sdp->gfs1)) {
@@ -954,8 +954,8 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
 			}
 			fix_md.jiinode = child_ip;
 			sdp->sd_sb.sb_master_dir.no_addr = di->di_num.no_addr;
-			log_warn(_("Found system master directory at: "
-				   "0x%llx\n"), di->di_num.no_addr);
+			log_warn(_("Found system master directory at: 0x%"PRIx64"\n"),
+			         di->di_num.no_addr);
 			return;
 		}
 
@@ -966,39 +966,38 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
 			inode_put(&child_ip);
 			if (fix_md.pinode || is_journal_copy(ip, bh))
 				goto out_discard_ip;
-			log_warn(_("Found system per_node directory at: "
-				   "0x%llx\n"), ip->i_di.di_num.no_addr);
+			log_warn(_("Found system per_node directory at: 0x%"PRIx64"\n"),
+			         ip->i_di.di_num.no_addr);
 			fix_md.pinode = ip;
 			error = dir_search(ip, "..", 2, NULL, &inum);
 			if (!error && inum.no_addr) {
 				sdp->sd_sb.sb_master_dir.no_addr =
 					inum.no_addr;
-				log_warn(_("From per_node\'s \'..\' I "
-					   "backtracked the master directory "
-					   "to: 0x%llx\n"), inum.no_addr);
+				log_warn(_("Found master directory from per_node/.. "
+					   "at 0x%"PRIx64"\n"), inum.no_addr);
 			}
 			return;
 		}
-		log_debug(_("Unknown system directory at block 0x%llx\n"),
+		log_debug(_("Unknown system directory at block 0x%"PRIx64"\n"),
 			  di->di_num.no_addr);
 		goto out_discard_ip;
 	} else if (!sdp->gfs1 && di->di_size == 8) {
 		if (fix_md.inum || is_journal_copy(ip, bh))
 			goto out_discard_ip;
 		fix_md.inum = ip;
-		log_warn(_("Found system inum file at: 0x%llx\n"),
+		log_warn(_("Found system inum file at: 0x%"PRIx64"\n"),
 			 di->di_num.no_addr);
 	} else if (di->di_size == 24) {
 		if (fix_md.statfs || is_journal_copy(ip, bh))
 			goto out_discard_ip;
 		fix_md.statfs = ip;
-		log_warn(_("Found system statfs file at: 0x%llx\n"),
+		log_warn(_("Found system statfs file at: 0x%"PRIx64"\n"),
 			 di->di_num.no_addr);
 	} else if ((di->di_size % 96) == 0) {
 		if (fix_md.riinode || is_journal_copy(ip, bh))
 			goto out_discard_ip;
 		fix_md.riinode = ip;
-		log_warn(_("Found system rindex file at: 0x%llx\n"),
+		log_warn(_("Found system rindex file at: 0x%"PRIx64"\n"),
 			 di->di_num.no_addr);
 	} else if (!fix_md.qinode && di->di_size >= 176 &&
 		   di->di_num.no_formal_ino >= 12 &&
@@ -1006,7 +1005,7 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
 		if (is_journal_copy(ip, bh))
 			goto out_discard_ip;
 		fix_md.qinode = ip;
-		log_warn(_("Found system quota file at: 0x%llx\n"),
+		log_warn(_("Found system quota file at: 0x%"PRIx64"\n"),
 			 di->di_num.no_addr);
 	} else {
 out_discard_ip:
@@ -1034,17 +1033,17 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
 		struct gfs2_buffer_head *root_bh;
 
 		if (di->di_num.no_addr == bh->b_blocknr) {
-			log_warn(_("Found the root directory at: 0x%llx.\n"),
+			log_warn(_("Found the root directory at: 0x%"PRIx64".\n"),
 				 di->di_num.no_addr);
 			sdp->sd_sb.sb_root_dir.no_addr = di->di_num.no_addr;
 			return;
 		}
-		log_warn(_("The root dinode should be at block 0x%llx but it "
+		log_warn(_("The root dinode should be at block 0x%"PRIx64" but it "
 			   "seems to be destroyed.\n"),
-			 (unsigned long long)di->di_num.no_addr);
+		         di->di_num.no_addr);
 		log_warn(_("Found a copy of the root directory in a journal "
-			   "at block: 0x%llx.\n"),
-			 (unsigned long long)bh->b_blocknr);
+			   "at block: 0x%"PRIx64".\n"),
+		         bh->b_blocknr);
 		if (!query(_("Do you want to replace the root dinode from the "
 			     "copy? (y/n)"))) {
 			log_err(_("Damaged root dinode not fixed.\n"));
@@ -1066,10 +1065,9 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
 		gfs2_lookupi(ip, "..", 2, &parent_ip);
 		if (parent_ip && parent_ip->i_di.di_num.no_addr ==
 		    ip->i_di.di_num.no_addr) {
-			log_warn(_("Found the root directory at: 0x%llx\n"),
+			log_warn(_("Found the root directory at: 0x%"PRIx64"\n"),
 				 ip->i_di.di_num.no_addr);
-			sdp->sd_sb.sb_root_dir.no_addr =
-				ip->i_di.di_num.no_addr;
+			sdp->sd_sb.sb_root_dir.no_addr = ip->i_di.di_num.no_addr;
 			inode_put(&parent_ip);
 			inode_put(&ip);
 			return;
@@ -1082,8 +1080,8 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
 	error = dir_search(ip, "..", 2, NULL, &inum);
 	if (!error && inum.no_addr && inum.no_addr < possible_root) {
 			possible_root = inum.no_addr;
-			log_debug(_("Found a possible root at: 0x%llx\n"),
-				  (unsigned long long)possible_root);
+			log_debug(_("Found a possible root at: 0x%"PRIx64"\n"),
+			          possible_root);
 	}
 	inode_put(&ip);
 }
@@ -1272,7 +1270,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
 	/* Step 3 - Rebuild the lock protocol and file system table name */
 	if (query(_("Okay to fix the GFS2 superblock? (y/n)"))) {
 		struct gfs2_sb sb;
-		log_info(_("Found system master directory at: 0x%llx\n"),
+		log_info(_("Found system master directory at: 0x%"PRIx64"\n"),
 			 sdp->sd_sb.sb_master_dir.no_addr);
 		sdp->master_dir = lgfs2_inode_read(sdp,
 					     sdp->sd_sb.sb_master_dir.no_addr);
@@ -1282,7 +1280,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
 		}
 		sdp->master_dir->i_di.di_num.no_addr =
 			sdp->sd_sb.sb_master_dir.no_addr;
-		log_info(_("Found the root directory at: 0x%llx\n"),
+		log_info(_("Found the root directory at: 0x%"PRIx64"\n"),
 			 sdp->sd_sb.sb_root_dir.no_addr);
 		sdp->md.rooti = lgfs2_inode_read(sdp,
 					   sdp->sd_sb.sb_root_dir.no_addr);
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 4d5d52c8..1c196a72 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -61,11 +61,11 @@ static void add_dotdot(struct gfs2_inode *ip)
 			  bmodified(dip->i_bh);
 			}
 		} else {
-			log_debug(_("Directory (0x%llx)'s link to parent "
-				    "(0x%llx) had a formal inode discrepancy: "
-				    "was 0x%llx, expected 0x%llx\n"),
-				  (unsigned long long)ip->i_di.di_num.no_addr,
-				  (unsigned long long)di->dotdot_parent.no_addr,
+			log_debug(_("Directory (0x%"PRIx64")'s link to parent "
+				    "(0x%"PRIx64") had a formal inode discrepancy: "
+				    "was 0x%"PRIx64", expected 0x%"PRIx64"\n"),
+				  ip->i_di.di_num.no_addr,
+				  di->dotdot_parent.no_addr,
 				  di->dotdot_parent.no_formal_ino,
 				  dip->i_di.di_num.no_formal_ino);
 			log_debug(_("The parent directory was not changed.\n"));
@@ -176,7 +176,7 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
  */
 int add_inode_to_lf(struct gfs2_inode *ip){
 	char tmp_name[256];
-	__be32 inode_type;
+	uint32_t inode_type;
 	struct gfs2_sbd *sdp = ip->i_sbd;
 	int err = 0;
 	uint32_t mode;
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 3c2f74fa..84ff9d9b 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -2197,7 +2197,7 @@ int pass1(struct gfs2_sbd *sdp)
 				 (unsigned long long)rg_count);
 		rgd = (struct rgrp_tree *)n;
 		for (i = 0; i < rgd->ri.ri_length; i++) {
-			log_debug( _("rgrp block %lld (0x%llx) "
+			log_debug(_("rgrp block %"PRIu64" (0x%"PRIx64") "
 				     "is now marked as 'rgrp data'\n"),
 				   rgd->ri.ri_addr + i, rgd->ri.ri_addr + i);
 			if (gfs2_blockmap_set(bl, rgd->ri.ri_addr + i,
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 763e39a9..e707a108 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1945,7 +1945,7 @@ static int check_pernode_for(int x, struct gfs2_inode *pernode, const char *fn,
 	else if (multiple && (ip->i_di.di_size % filelen))
 		valid_size = 0;
 	if (!valid_size) {
-		log_err(_("System file %s has an invalid size. Is %llu, "
+		log_err(_("System file %s has an invalid size. Is %"PRIu64", "
 			  "should be %llu.\n"), fn, ip->i_di.di_size, filelen);
 		if (!query( _("Rebuild the system file? (y/n) ")))
 			goto out_good;
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 2f145903..134ae940 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -414,11 +414,10 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
 			rgrp_dist++;
 		}
 		if (found) {
-			log_info( _("rgrp found at 0x%llx, length=%d, "
-				    "used=%llu, free=%d\n"),
+			log_info(_("rgrp found at 0x%"PRIx64", length=%d, "
+			           "used=%"PRIu64", free=%"PRIu32"\n"),
 				  prevrgd->ri.ri_addr, length,
-				  (unsigned long long)used_blocks,
-				  free_blocks);
+				  used_blocks, free_blocks);
 			break;
 		}
 	}
@@ -688,11 +687,10 @@ static int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs,
 	for (n = osi_first(&sdp->rgcalc), rgi = 0; n; n = next, rgi++) {
 		next = osi_next(n);
 		calc_rgd = (struct rgrp_tree *)n;
-                log_debug("%d: 0x%llx / %x / 0x%llx"
+                log_debug("%d: 0x%"PRIx64" / %x / 0x%"PRIx64
 			  " / 0x%x / 0x%x\n", rgi + 1,
-			  (unsigned long long)calc_rgd->ri.ri_addr,
-			  calc_rgd->ri.ri_length,
-			  calc_rgd->ri.ri_data0, calc_rgd->ri.ri_data, 
+			  calc_rgd->ri.ri_addr, calc_rgd->ri.ri_length,
+			  calc_rgd->ri.ri_data0, calc_rgd->ri.ri_data,
 			  calc_rgd->ri.ri_bitbytes);
         }
 	*num_rgs = number_of_rgs;
@@ -1085,16 +1083,14 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count, int *sane)
 		if (actual->ri.ri_addr < expected->ri.ri_addr) {
 			n = next;
 			discrepancies++;
-			log_info(_("%d addr: 0x%llx < 0x%llx * mismatch\n"),
-				 rg + 1, actual->ri.ri_addr,
-				 expected->ri.ri_addr);
+			log_info(_("%d addr: 0x%"PRIx64" < 0x%"PRIx64" * mismatch\n"),
+			         rg + 1, actual->ri.ri_addr, expected->ri.ri_addr);
 			continue;
 		} else if (expected->ri.ri_addr < actual->ri.ri_addr) {
 			e = enext;
 			discrepancies++;
-			log_info(_("%d addr: 0x%llx > 0x%llx * mismatch\n"),
-				 rg + 1, actual->ri.ri_addr,
-				 expected->ri.ri_addr);
+			log_info(_("%d addr: 0x%"PRIx64" > 0x%"PRIx64" * mismatch\n"),
+			         rg + 1, actual->ri.ri_addr, expected->ri.ri_addr);
 			continue;
 		}
 		if (!ri_equal(actual->ri, expected->ri, ri_length) ||
@@ -1102,9 +1098,8 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count, int *sane)
 		    !ri_equal(actual->ri, expected->ri, ri_data) ||
 		    !ri_equal(actual->ri, expected->ri, ri_bitbytes)) {
 			discrepancies++;
-			log_info(_("%d addr: 0x%llx 0x%llx * has mismatch\n"),
-				 rg + 1, actual->ri.ri_addr,
-				 expected->ri.ri_addr);
+			log_info(_("%d addr: 0x%"PRIx64" 0x%"PRIx64" * has mismatch\n"),
+			         rg + 1, actual->ri.ri_addr, expected->ri.ri_addr);
 		}
 		n = next;
 		e = enext;
diff --git a/gfs2/include/gfs2_ondisk.h b/gfs2/include/gfs2_ondisk.h
new file mode 100644
index 00000000..0a5a37fa
--- /dev/null
+++ b/gfs2/include/gfs2_ondisk.h
@@ -0,0 +1,535 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
+ * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
+#ifndef __GFS2_ONDISK_DOT_H__
+#define __GFS2_ONDISK_DOT_H__
+
+#include <stdint.h>
+
+#define GFS2_MAGIC		0x01161970
+#define GFS2_BASIC_BLOCK	512
+#define GFS2_BASIC_BLOCK_SHIFT	9
+
+/* Lock numbers of the LM_TYPE_NONDISK type */
+
+#define GFS2_MOUNT_LOCK		0
+#define GFS2_LIVE_LOCK		1
+#define GFS2_FREEZE_LOCK	2
+#define GFS2_RENAME_LOCK	3
+#define GFS2_CONTROL_LOCK	4
+#define GFS2_MOUNTED_LOCK	5
+
+/* Format numbers for various metadata types */
+
+#define GFS2_FORMAT_NONE	0
+#define GFS2_FORMAT_SB		100
+#define GFS2_FORMAT_RG		200
+#define GFS2_FORMAT_RB		300
+#define GFS2_FORMAT_DI		400
+#define GFS2_FORMAT_IN		500
+#define GFS2_FORMAT_LF		600
+#define GFS2_FORMAT_JD		700
+#define GFS2_FORMAT_LH		800
+#define GFS2_FORMAT_LD		900
+#define GFS2_FORMAT_LB		1000
+#define GFS2_FORMAT_EA		1600
+#define GFS2_FORMAT_ED		1700
+#define GFS2_FORMAT_QC		1400
+/* These are format numbers for entities contained in files */
+#define GFS2_FORMAT_RI		1100
+#define GFS2_FORMAT_DE		1200
+#define GFS2_FORMAT_QU		1500
+/* These are part of the superblock */
+#define GFS2_FORMAT_FS		1801
+#define GFS2_FORMAT_MULTI	1900
+
+/*
+ * An on-disk inode number
+ */
+
+struct gfs2_inum {
+	uint64_t no_formal_ino;
+	uint64_t no_addr;
+};
+
+/*
+ * Generic metadata head structure
+ * Every inplace buffer logged in the journal must start with this.
+ */
+
+#define GFS2_METATYPE_NONE	0
+#define GFS2_METATYPE_SB	1
+#define GFS2_METATYPE_RG	2
+#define GFS2_METATYPE_RB	3
+#define GFS2_METATYPE_DI	4
+#define GFS2_METATYPE_IN	5
+#define GFS2_METATYPE_LF	6
+#define GFS2_METATYPE_JD	7
+#define GFS2_METATYPE_LH	8
+#define GFS2_METATYPE_LD	9
+#define GFS2_METATYPE_LB	12
+#define GFS2_METATYPE_EA	10
+#define GFS2_METATYPE_ED	11
+#define GFS2_METATYPE_QC	14
+
+struct gfs2_meta_header {
+	uint32_t mh_magic;
+	uint32_t mh_type;
+	uint64_t __pad0;		/* Was generation number in gfs1 */
+	uint32_t mh_format;
+	/* This union is to keep userspace happy */
+	union {
+		uint32_t mh_jid;		/* Was incarnation number in gfs1 */
+		uint32_t __pad1;
+	};
+};
+
+/*
+ * super-block structure
+ *
+ * It's probably good if SIZEOF_SB <= GFS2_BASIC_BLOCK (512 bytes)
+ *
+ * Order is important, need to be able to read old superblocks to do on-disk
+ * version upgrades.
+ */
+
+/* Address of superblock in GFS2 basic blocks */
+#define GFS2_SB_ADDR		128
+
+/* The lock number for the superblock (must be zero) */
+#define GFS2_SB_LOCK		0
+
+/* Requirement:  GFS2_LOCKNAME_LEN % 8 == 0
+   Includes: the fencing zero@the end */
+#define GFS2_LOCKNAME_LEN	64
+
+struct gfs2_sb {
+	struct gfs2_meta_header sb_header;
+
+	uint32_t sb_fs_format;
+	uint32_t sb_multihost_format;
+	uint32_t  __pad0;	/* Was superblock flags in gfs1 */
+
+	uint32_t sb_bsize;
+	uint32_t sb_bsize_shift;
+	uint32_t __pad1;	/* Was journal segment size in gfs1 */
+
+	struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */
+	struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */
+	struct gfs2_inum sb_root_dir;
+
+	char sb_lockproto[GFS2_LOCKNAME_LEN];
+	char sb_locktable[GFS2_LOCKNAME_LEN];
+
+	struct gfs2_inum __pad3; /* Was quota inode in gfs1 */
+	struct gfs2_inum __pad4; /* Was licence inode in gfs1 */
+#define GFS2_HAS_UUID 1
+	uint8_t sb_uuid[16]; /* The UUID, maybe 0 for backwards compat */
+};
+
+/*
+ * resource index structure
+ */
+
+struct gfs2_rindex {
+	uint64_t ri_addr;	/* grp block disk address */
+	uint32_t ri_length;	/* length of rgrp header in fs blocks */
+	uint32_t __pad;
+
+	uint64_t ri_data0;	/* first data location */
+	uint32_t ri_data;	/* num of data blocks in rgrp */
+
+	uint32_t ri_bitbytes;	/* number of bytes in data bitmaps */
+
+	uint8_t ri_reserved[64];
+};
+
+/*
+ * resource group header structure
+ */
+
+/* Number of blocks per byte in rgrp */
+#define GFS2_NBBY		4
+#define GFS2_BIT_SIZE		2
+#define GFS2_BIT_MASK		0x00000003
+
+#define GFS2_BLKST_FREE		0
+#define GFS2_BLKST_USED		1
+#define GFS2_BLKST_UNLINKED	2
+#define GFS2_BLKST_DINODE	3
+
+#define GFS2_RGF_JOURNAL	0x00000001
+#define GFS2_RGF_METAONLY	0x00000002
+#define GFS2_RGF_DATAONLY	0x00000004
+#define GFS2_RGF_NOALLOC	0x00000008
+#define GFS2_RGF_TRIMMED	0x00000010
+
+struct gfs2_rgrp_lvb {
+	uint32_t rl_magic;
+	uint32_t rl_flags;
+	uint32_t rl_free;
+	uint32_t rl_dinodes;
+	uint64_t rl_igeneration;
+	uint32_t rl_unlinked;
+	uint32_t __pad;
+};
+
+struct gfs2_rgrp {
+	struct gfs2_meta_header rg_header;
+
+	uint32_t rg_flags;
+	uint32_t rg_free;
+	uint32_t rg_dinodes;
+	union {
+		uint32_t __pad;
+		uint32_t rg_skip; /* Distance to the next rgrp in fs blocks */
+	};
+	uint64_t rg_igeneration;
+	/* The following 3 fields are duplicated from gfs2_rindex to reduce
+	   reliance on the rindex */
+	uint64_t rg_data0;     /* First data location */
+	uint32_t rg_data;      /* Number of data blocks in rgrp */
+	uint32_t rg_bitbytes;  /* Number of bytes in data bitmaps */
+	uint32_t rg_crc;       /* crc32 of the structure with this field 0 */
+
+	uint8_t rg_reserved[60]; /* Several fields from gfs1 now reserved */
+};
+
+/*
+ * quota structure
+ */
+
+struct gfs2_quota {
+	uint64_t qu_limit;
+	uint64_t qu_warn;
+	uint64_t qu_value;
+	uint8_t qu_reserved[64];
+};
+
+/*
+ * dinode structure
+ */
+
+#define GFS2_MAX_META_HEIGHT	10
+#define GFS2_DIR_MAX_DEPTH	17
+
+#define DT2IF(dt) (((dt) << 12) & S_IFMT)
+#define IF2DT(sif) (((sif) & S_IFMT) >> 12)
+
+enum {
+	gfs2fl_Jdata		= 0,
+	gfs2fl_ExHash		= 1,
+	gfs2fl_Unused		= 2,
+	gfs2fl_EaIndirect	= 3,
+	gfs2fl_Directio		= 4,
+	gfs2fl_Immutable	= 5,
+	gfs2fl_AppendOnly	= 6,
+	gfs2fl_NoAtime		= 7,
+	gfs2fl_Sync		= 8,
+	gfs2fl_System		= 9,
+	gfs2fl_TopLevel		= 10,
+	gfs2fl_TruncInProg	= 29,
+	gfs2fl_InheritDirectio	= 30,
+	gfs2fl_InheritJdata	= 31,
+};
+
+/* Dinode flags */
+#define GFS2_DIF_JDATA			0x00000001
+#define GFS2_DIF_EXHASH			0x00000002
+#define GFS2_DIF_UNUSED			0x00000004  /* only in gfs1 */
+#define GFS2_DIF_EA_INDIRECT		0x00000008
+#define GFS2_DIF_DIRECTIO		0x00000010
+#define GFS2_DIF_IMMUTABLE		0x00000020
+#define GFS2_DIF_APPENDONLY		0x00000040
+#define GFS2_DIF_NOATIME		0x00000080
+#define GFS2_DIF_SYNC			0x00000100
+#define GFS2_DIF_SYSTEM			0x00000200 /* New in gfs2 */
+#define GFS2_DIF_TOPDIR			0x00000400 /* New in gfs2 */
+#define GFS2_DIF_TRUNC_IN_PROG		0x20000000 /* New in gfs2 */
+#define GFS2_DIF_INHERIT_DIRECTIO	0x40000000 /* only in gfs1 */
+#define GFS2_DIF_INHERIT_JDATA		0x80000000
+
+struct gfs2_dinode {
+	struct gfs2_meta_header di_header;
+
+	struct gfs2_inum di_num;
+
+	uint32_t di_mode;	/* mode of file */
+	uint32_t di_uid;	/* owner's user id */
+	uint32_t di_gid;	/* owner's group id */
+	uint32_t di_nlink;	/* number of links to this file */
+	uint64_t di_size;	/* number of bytes in file */
+	uint64_t di_blocks;	/* number of blocks in file */
+	uint64_t di_atime;	/* time last accessed */
+	uint64_t di_mtime;	/* time last modified */
+	uint64_t di_ctime;	/* time last changed */
+	uint32_t di_major;	/* device major number */
+	uint32_t di_minor;	/* device minor number */
+
+	/* This section varies from gfs1. Padding added to align with
+         * remainder of dinode
+	 */
+	uint64_t di_goal_meta;	/* rgrp to alloc from next */
+	uint64_t di_goal_data;	/* data block goal */
+	uint64_t di_generation;	/* generation number for NFS */
+
+	uint32_t di_flags;	/* GFS2_DIF_... */
+	uint32_t di_payload_format;  /* GFS2_FORMAT_... */
+	uint16_t __pad1;	/* Was ditype in gfs1 */
+	uint16_t di_height;	/* height of metadata */
+	uint32_t __pad2;	/* Unused incarnation number from gfs1 */
+
+	/* These only apply to directories  */
+	uint16_t __pad3;	/* Padding */
+	uint16_t di_depth;	/* Number of bits in the table */
+	uint32_t di_entries;	/* The number of entries in the directory */
+
+	struct gfs2_inum __pad4; /* Unused even in current gfs1 */
+
+	uint64_t di_eattr;	/* extended attribute block number */
+	uint32_t di_atime_nsec;   /* nsec portion of atime */
+	uint32_t di_mtime_nsec;   /* nsec portion of mtime */
+	uint32_t di_ctime_nsec;   /* nsec portion of ctime */
+
+	uint8_t di_reserved[44];
+};
+
+/*
+ * directory structure - many of these per directory file
+ */
+
+#define GFS2_FNAMESIZE		255
+#define GFS2_DIRENT_SIZE(name_len) ((sizeof(struct gfs2_dirent) + (name_len) + 7) & ~7)
+#define GFS2_MIN_DIRENT_SIZE (GFS2_DIRENT_SIZE(1))
+
+
+struct gfs2_dirent {
+	struct gfs2_inum de_inum;
+	uint32_t de_hash;
+	uint16_t de_rec_len;
+	uint16_t de_name_len;
+	uint16_t de_type;
+	uint16_t de_rahead;
+	union {
+		uint8_t __pad[12];
+		struct {
+			uint32_t de_cookie; /* ondisk value not used */
+			uint8_t pad3[8];
+		};
+	};
+};
+
+/*
+ * Header of leaf directory nodes
+ */
+
+struct gfs2_leaf {
+	struct gfs2_meta_header lf_header;
+
+	uint16_t lf_depth;		/* Depth of leaf */
+	uint16_t lf_entries;		/* Number of dirents in leaf */
+	uint32_t lf_dirent_format;	/* Format of the dirents */
+	uint64_t lf_next;			/* Next leaf, if overflow */
+
+	union {
+		uint8_t lf_reserved[64];
+		struct {
+			uint64_t lf_inode;	/* Dir inode number */
+			uint32_t lf_dist;		/* Dist from inode on chain */
+			uint32_t lf_nsec;		/* Last ins/del usecs */
+			uint64_t lf_sec;		/* Last ins/del in secs */
+			uint8_t lf_reserved2[40];
+		};
+	};
+};
+
+/*
+ * Extended attribute header format
+ *
+ * This works in a similar way to dirents. There is a fixed size header
+ * followed by a variable length section made up of the name and the
+ * associated data. In the case of a "stuffed" entry, the value is
+ * inline directly after the name, the ea_num_ptrs entry will be
+ * zero in that case. For non-"stuffed" entries, there will be
+ * a set of pointers (aligned to 8 byte boundary) to the block(s)
+ * containing the value.
+ *
+ * The blocks containing the values and the blocks containing the
+ * extended attribute headers themselves all start with the common
+ * metadata header. Each inode, if it has extended attributes, will
+ * have either a single block containing the extended attribute headers
+ * or a single indirect block pointing to blocks containing the
+ * extended attribute headers.
+ *
+ * The maximum size of the data part of an extended attribute is 64k
+ * so the number of blocks required depends upon block size. Since the
+ * block size also determines the number of pointers in an indirect
+ * block, its a fairly complicated calculation to work out the maximum
+ * number of blocks that an inode may have relating to extended attributes.
+ *
+ */
+
+#define GFS2_EA_MAX_NAME_LEN	255
+#define GFS2_EA_MAX_DATA_LEN	65536
+
+#define GFS2_EATYPE_UNUSED	0
+#define GFS2_EATYPE_USR		1
+#define GFS2_EATYPE_SYS		2
+#define GFS2_EATYPE_SECURITY	3
+
+#define GFS2_EATYPE_LAST	3
+#define GFS2_EATYPE_VALID(x)	((x) <= GFS2_EATYPE_LAST)
+
+#define GFS2_EAFLAG_LAST	0x01	/* last ea in block */
+
+struct gfs2_ea_header {
+	uint32_t ea_rec_len;
+	uint32_t ea_data_len;
+	uint8_t ea_name_len;	/* no NULL pointer after the string */
+	uint8_t ea_type;		/* GFS2_EATYPE_... */
+	uint8_t ea_flags;		/* GFS2_EAFLAG_... */
+	uint8_t ea_num_ptrs;
+	uint32_t __pad;
+};
+
+/*
+ * Log header structure
+ */
+
+#define GFS2_LOG_HEAD_UNMOUNT		0x00000001 /* log is clean */
+#define GFS2_LOG_HEAD_FLUSH_NORMAL	0x00000002 /* normal log flush */
+#define GFS2_LOG_HEAD_FLUSH_SYNC	0x00000004 /* Sync log flush */
+#define GFS2_LOG_HEAD_FLUSH_SHUTDOWN	0x00000008 /* Shutdown log flush */
+#define GFS2_LOG_HEAD_FLUSH_FREEZE	0x00000010 /* Freeze flush */
+#define GFS2_LOG_HEAD_RECOVERY		0x00000020 /* Journal recovery */
+#define GFS2_LOG_HEAD_USERSPACE		0x80000000 /* Written by gfs2-utils */
+
+/* Log flush callers */
+#define GFS2_LFC_SHUTDOWN		0x00000100
+#define GFS2_LFC_JDATA_WPAGES		0x00000200
+#define GFS2_LFC_SET_FLAGS		0x00000400
+#define GFS2_LFC_AIL_EMPTY_GL		0x00000800
+#define GFS2_LFC_AIL_FLUSH		0x00001000
+#define GFS2_LFC_RGRP_GO_SYNC		0x00002000
+#define GFS2_LFC_INODE_GO_SYNC		0x00004000
+#define GFS2_LFC_INODE_GO_INVAL		0x00008000
+#define GFS2_LFC_FREEZE_GO_SYNC		0x00010000
+#define GFS2_LFC_KILL_SB		0x00020000
+#define GFS2_LFC_DO_SYNC		0x00040000
+#define GFS2_LFC_INPLACE_RESERVE	0x00080000
+#define GFS2_LFC_WRITE_INODE		0x00100000
+#define GFS2_LFC_MAKE_FS_RO		0x00200000
+#define GFS2_LFC_SYNC_FS		0x00400000
+#define GFS2_LFC_EVICT_INODE		0x00800000
+#define GFS2_LFC_TRANS_END		0x01000000
+#define GFS2_LFC_LOGD_JFLUSH_REQD	0x02000000
+#define GFS2_LFC_LOGD_AIL_FLUSH_REQD	0x04000000
+
+#define LH_V1_SIZE (offsetofend(struct gfs2_log_header, lh_hash))
+
+struct gfs2_log_header {
+	struct gfs2_meta_header lh_header;
+
+	uint64_t lh_sequence;	/* Sequence number of this transaction */
+	uint32_t lh_flags;	/* GFS2_LOG_HEAD_... */
+	uint32_t lh_tail;		/* Block number of log tail */
+	uint32_t lh_blkno;
+	uint32_t lh_hash;		/* crc up to here with this field 0 */
+
+	/* Version 2 additional fields start here */
+	uint32_t lh_crc;		/* crc32c from lh_nsec to end of block */
+	uint32_t lh_nsec;		/* Nanoseconds of timestamp */
+	uint64_t lh_sec;		/* Seconds of timestamp */
+	uint64_t lh_addr;		/* Block addr of this log header (absolute) */
+	uint64_t lh_jinode;	/* Journal inode number */
+	uint64_t lh_statfs_addr;	/* Local statfs inode number */
+	uint64_t lh_quota_addr;	/* Local quota change inode number */
+
+	/* Statfs local changes (i.e. diff from global statfs) */
+	uint64_t lh_local_total;
+	uint64_t lh_local_free;
+	uint64_t lh_local_dinodes;
+};
+
+/*
+ * Log type descriptor
+ */
+
+#define GFS2_LOG_DESC_METADATA	300
+/* ld_data1 is the number of metadata blocks in the descriptor.
+   ld_data2 is unused. */
+
+#define GFS2_LOG_DESC_REVOKE	301
+/* ld_data1 is the number of revoke blocks in the descriptor.
+   ld_data2 is unused. */
+
+#define GFS2_LOG_DESC_JDATA	302
+/* ld_data1 is the number of data blocks in the descriptor.
+   ld_data2 is unused. */
+
+struct gfs2_log_descriptor {
+	struct gfs2_meta_header ld_header;
+
+	uint32_t ld_type;		/* GFS2_LOG_DESC_... */
+	uint32_t ld_length;	/* Number of buffers in this chunk */
+	uint32_t ld_data1;	/* descriptor-specific field */
+	uint32_t ld_data2;	/* descriptor-specific field */
+
+	uint8_t ld_reserved[32];
+};
+
+/*
+ * Inum Range
+ * Describe a range of formal inode numbers allocated to
+ * one machine to assign to inodes.
+ */
+
+#define GFS2_INUM_QUANTUM	1048576
+
+struct gfs2_inum_range {
+	uint64_t ir_start;
+	uint64_t ir_length;
+};
+
+/*
+ * Statfs change
+ * Describes an change to the pool of free and allocated
+ * blocks.
+ */
+
+struct gfs2_statfs_change {
+	uint64_t sc_total;
+	uint64_t sc_free;
+	uint64_t sc_dinodes;
+};
+
+/*
+ * Quota change
+ * Describes an allocation change for a particular
+ * user or group.
+ */
+
+#define GFS2_QCF_USER		0x00000001
+
+struct gfs2_quota_change {
+	uint64_t qc_change;
+	uint32_t qc_flags;	/* GFS2_QCF_... */
+	uint32_t qc_id;
+};
+
+struct gfs2_quota_lvb {
+        uint32_t qb_magic;
+        uint32_t __pad;
+        uint64_t qb_limit;      /* Hard limit of # blocks to alloc */
+        uint64_t qb_warn;       /* Warn user when alloc is above this # */
+        uint64_t qb_value;       /* Current # blocks allocated */
+};
+
+#endif /* __GFS2_ONDISK_DOT_H__ */
diff --git a/gfs2/libgfs2/buf.c b/gfs2/libgfs2/buf.c
index 92cd393d..aec778a5 100644
--- a/gfs2/libgfs2/buf.c
+++ b/gfs2/libgfs2/buf.c
@@ -11,7 +11,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
-#include <linux/types.h>
 
 #include "libgfs2.h"
 
diff --git a/gfs2/libgfs2/device_geometry.c b/gfs2/libgfs2/device_geometry.c
index 1303f11b..72f9c7e4 100644
--- a/gfs2/libgfs2/device_geometry.c
+++ b/gfs2/libgfs2/device_geometry.c
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/ioctl.h>
-#include <linux/types.h>
 #include <linux/fs.h>
 
 #include "libgfs2.h"
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index df8a13a9..09504c51 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include <linux/types.h>
 #include "libgfs2.h"
 #include "config.h"
 
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 7e87e435..cbf6de88 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include <linux/types.h>
 #include "libgfs2.h"
 #include "rgrp.h"
 
@@ -1029,9 +1028,7 @@ 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);
 
@@ -1231,9 +1228,7 @@ 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;
@@ -1285,9 +1280,7 @@ 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/gfs1.c b/gfs2/libgfs2/gfs1.c
index b91cce5e..1fee25c9 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -10,8 +10,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <linux/types.h>
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 
 #include "osi_list.h"
 #include "libgfs2.h"
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 62ad2ab7..c56091f1 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -6,12 +6,10 @@
 #include <errno.h>
 #include <limits.h>
 #include <ctype.h>
+#include <uuid.h>
 
 #include "lang.h"
 #include "parser.h"
-#ifdef GFS2_HAS_UUID
-#include <uuid.h>
-#endif
 
 const char* ast_type_string[] = {
 	[AST_NONE] = "NONE",
@@ -315,14 +313,12 @@ static int field_print(const struct gfs2_buffer_head *bh, const struct lgfs2_met
 
 	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) {
-#ifdef GFS2_HAS_UUID
 		char readable_uuid[36+1];
 		uuid_t uuid;
 
 		memcpy(uuid, fieldp, sizeof(uuid_t));
 		uuid_unparse(uuid, readable_uuid);
 		printf("'%s'\n", readable_uuid);
-#endif
 	} else if (field->flags & LGFS2_MFF_STRING) {
 		printf("'%s'\n", fieldp);
 	} else {
@@ -450,7 +446,6 @@ static int ast_field_set(struct gfs2_buffer_head *bh, const struct lgfs2_metafie
 	int err = 0;
 
 	if (field->flags & LGFS2_MFF_UUID) {
-#ifdef GFS2_HAS_UUID
 		uuid_t uuid;
 
 		if (uuid_parse(val->ast_str, uuid) != 0) {
@@ -458,10 +453,6 @@ static int ast_field_set(struct gfs2_buffer_head *bh, const struct lgfs2_metafie
 			return AST_INTERP_INVAL;
 		}
 		err = lgfs2_field_assign(bh->b_data, field, uuid);
-#else
-		fprintf(stderr, "No UUID support\n");
-		err = 1;
-#endif
 	} else if (field->flags & LGFS2_MFF_STRING) {
 		err = lgfs2_field_assign(bh->b_data, field, val->ast_str);
 	} else {
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index f75ff1e0..ce84d831 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -8,13 +8,12 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/uio.h>
-#include <linux/types.h>
 #include <linux/limits.h>
 #include <endian.h>
 #include <byteswap.h>
 #include <mntent.h>
 
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 #include "osi_list.h"
 #include "osi_tree.h"
 
@@ -507,43 +506,43 @@ struct gfs_dinode {
 
 	struct gfs2_inum di_num; /* formal inode # and block address */
 
-	__be32 di_mode;	/* mode of file */
-	__be32 di_uid;	/* owner's user id */
-	__be32 di_gid;	/* owner's group id */
-	__be32 di_nlink;	/* number (qty) of links to this file */
-	__be64 di_size;	/* number (qty) of bytes in file */
-	__be64 di_blocks;	/* number (qty) of blocks in file */
-	__be64 di_atime;	/* time last accessed */
-	__be64 di_mtime;	/* time last modified */
-	__be64 di_ctime;	/* time last changed */
+	uint32_t di_mode;	/* mode of file */
+	uint32_t di_uid;	/* owner's user id */
+	uint32_t di_gid;	/* owner's group id */
+	uint32_t di_nlink;	/* number (qty) of links to this file */
+	uint64_t di_size;	/* number (qty) of bytes in file */
+	uint64_t di_blocks;	/* number (qty) of blocks in file */
+	uint64_t di_atime;	/* time last accessed */
+	uint64_t di_mtime;	/* time last modified */
+	uint64_t di_ctime;	/* time last changed */
 
 	/*  Non-zero only for character or block device nodes  */
-	__be32 di_major;	/* device major number */
-	__be32 di_minor;	/* device minor number */
+	uint32_t di_major;	/* device major number */
+	uint32_t di_minor;	/* device minor number */
 
 	/*  Block allocation strategy  */
-	__be64 di_rgrp;	/* dinode rgrp block number */
-	__be64 di_goal_rgrp;	/* rgrp to alloc from next */
-	__be32 di_goal_dblk;	/* data block goal */
-	__be32 di_goal_mblk;	/* metadata block goal */
+	uint64_t di_rgrp;	/* dinode rgrp block number */
+	uint64_t di_goal_rgrp;	/* rgrp to alloc from next */
+	uint32_t di_goal_dblk;	/* data block goal */
+	uint32_t di_goal_mblk;	/* metadata block goal */
 
-	__be32 di_flags;	/* GFS_DIF_... */
+	uint32_t di_flags;	/* GFS_DIF_... */
 
 	/*  struct gfs_rindex, struct gfs_jindex, or struct gfs_dirent */
-	__be32 di_payload_format;  /* GFS_FORMAT_... */
-	__be16 di_type;	/* GFS_FILE_... type of file */
-	__be16 di_height;	/* height of metadata (0 == stuffed) */
-	__be32 di_incarn;	/* incarnation (unused, see gfs_meta_header) */
-	__be16 di_pad;
+	uint32_t di_payload_format;  /* GFS_FORMAT_... */
+	uint16_t di_type;	/* GFS_FILE_... type of file */
+	uint16_t di_height;	/* height of metadata (0 == stuffed) */
+	uint32_t di_incarn;	/* incarnation (unused, see gfs_meta_header) */
+	uint16_t di_pad;
 
 	/*  These only apply to directories  */
-	__be16 di_depth;	/* Number of bits in the table */
-	__be32 di_entries;	/* The # (qty) of entries in the directory */
+	uint16_t di_depth;	/* Number of bits in the table */
+	uint32_t di_entries;	/* The # (qty) of entries in the directory */
 
 	/*  This formed an on-disk chain of unused dinodes  */
 	struct gfs2_inum di_next_unused;  /* used in old versions only */
 
-	__be64 di_eattr;	/* extended attribute block number */
+	uint64_t di_eattr;	/* extended attribute block number */
 
 	char di_reserved[56];
 };
@@ -553,13 +552,13 @@ struct gfs_sb {
 	    in order to support on-disk version upgrades */
 	struct gfs2_meta_header sb_header;
 
-	__be32 sb_fs_format;         /* GFS_FORMAT_FS (on-disk version) */
-	__be32 sb_multihost_format;  /* GFS_FORMAT_MULTI */
-	__be32 sb_flags;             /* ?? */
+	uint32_t sb_fs_format;         /* GFS_FORMAT_FS (on-disk version) */
+	uint32_t sb_multihost_format;  /* GFS_FORMAT_MULTI */
+	uint32_t sb_flags;             /* ?? */
 
-	__be32 sb_bsize;             /* fundamental FS block size in bytes */
-	__be32 sb_bsize_shift;       /* log2(sb_bsize) */
-	__be32 sb_seg_size;          /* Journal segment size in FS blocks */
+	uint32_t sb_bsize;             /* fundamental FS block size in bytes */
+	uint32_t sb_bsize_shift;       /* log2(sb_bsize) */
+	uint32_t sb_seg_size;          /* Journal segment size in FS blocks */
 
 	/* These special inodes do not appear in any on-disk directory. */
 	struct gfs2_inum sb_jindex_di;  /* journal index inode */
@@ -580,17 +579,17 @@ struct gfs_sb {
 struct gfs_rgrp {
 	struct gfs2_meta_header rg_header;
 
-	__be32 rg_flags;
-	__be32 rg_free;       /* Number (qty) of free data blocks */
+	uint32_t rg_flags;
+	uint32_t rg_free;       /* Number (qty) of free data blocks */
 
 	/* Dinodes are USEDMETA, but are handled separately from other METAs */
-	__be32 rg_useddi;     /* Number (qty) of dinodes (used or free) */
-	__be32 rg_freedi;     /* Number (qty) of unused (free) dinodes */
+	uint32_t rg_useddi;     /* Number (qty) of dinodes (used or free) */
+	uint32_t rg_freedi;     /* Number (qty) of unused (free) dinodes */
 	struct gfs2_inum rg_freedi_list; /* 1st block in chain of free dinodes */
 
 	/* These META statistics do not include dinodes (used or free) */
-	__be32 rg_usedmeta;   /* Number (qty) of used metadata blocks */
-	__be32 rg_freemeta;   /* Number (qty) of unused metadata blocks */
+	uint32_t rg_usedmeta;   /* Number (qty) of used metadata blocks */
+	uint32_t rg_freemeta;   /* Number (qty) of unused metadata blocks */
 
 	char rg_reserved[64];
 };
@@ -598,22 +597,22 @@ struct gfs_rgrp {
 struct gfs_log_header {
 	struct gfs2_meta_header lh_header;
 
-	__be32 lh_flags;      /* GFS_LOG_HEAD_... */
-	__be32 lh_pad;
+	uint32_t lh_flags;      /* GFS_LOG_HEAD_... */
+	uint32_t lh_pad;
 
-	__be64 lh_first;     /* Block number of first header in this trans */
-	__be64 lh_sequence;   /* Sequence number of this transaction */
+	uint64_t lh_first;     /* Block number of first header in this trans */
+	uint64_t lh_sequence;   /* Sequence number of this transaction */
 
-	__be64 lh_tail;       /* Block number of log tail */
-	__be64 lh_last_dump;  /* Block number of last dump */
+	uint64_t lh_tail;       /* Block number of log tail */
+	uint64_t lh_last_dump;  /* Block number of last dump */
 
 	uint8_t lh_reserved[64];
 };
 
 struct gfs_jindex {
-        __be64 ji_addr;       /* starting block of the journal */
-        __be32 ji_nsegment;   /* number (quantity) of segments in journal */
-        __be32 ji_pad;
+        uint64_t ji_addr;       /* starting block of the journal */
+        uint32_t ji_nsegment;   /* number (quantity) of segments in journal */
+        uint32_t ji_pad;
 
         uint8_t ji_reserved[64];
 };
@@ -621,10 +620,10 @@ struct gfs_jindex {
 struct gfs_log_descriptor {
 	struct gfs2_meta_header ld_header;
 
-	__be32 ld_type;       /* GFS_LOG_DESC_... Type of this log chunk */
-	__be32 ld_length;     /* Number of buffers in this chunk */
-	__be32 ld_data1;      /* descriptor-specific field */
-	__be32 ld_data2;      /* descriptor-specific field */
+	uint32_t ld_type;       /* GFS_LOG_DESC_... Type of this log chunk */
+	uint32_t ld_length;     /* Number of buffers in this chunk */
+	uint32_t ld_data1;      /* descriptor-specific field */
+	uint32_t ld_data2;      /* descriptor-specific field */
 	uint8_t ld_reserved[64];
 };
 
@@ -740,9 +739,7 @@ extern void gfs2_dirent_out(struct gfs2_dirent *de, char *buf);
 extern void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf);
 extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
 extern void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf);
-extern void gfs2_log_header_v1_in(struct gfs2_log_header *lh, char *buf);
 extern void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf);
-extern void gfs2_log_header_v1_out(struct gfs2_log_header *lh, char *buf);
 extern void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf);
 extern void gfs2_log_descriptor_in(struct gfs2_log_descriptor *ld, char *buf);
 extern void gfs2_log_descriptor_out(struct gfs2_log_descriptor *ld, char *buf);
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index 1da74146..42325077 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -1,12 +1,9 @@
 #include <stdint.h>
 #include <string.h>
+#include <uuid.h>
 #include "libgfs2.h"
 #include "clusterautoconfig.h"
 
-#ifdef GFS2_HAS_UUID
-#include <uuid.h>
-#endif
-
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 #define SYM(x) { x, #x, 0 },
 #define PREFIX_SYM(p,x) { p##x, #p #x, sizeof #p - 1 },
@@ -72,7 +69,6 @@ const unsigned lgfs2_di_flag_size = ARRAY_SIZE(lgfs2_di_flags);
 
 const struct lgfs2_symbolic lgfs2_lh_flags[] = {
 PREFIX_SYM(GFS2_LOG_HEAD_, UNMOUNT)
-#ifdef GFS2_HAS_LH_V2
 PREFIX_SYM(GFS2_LOG_HEAD_FLUSH_, NORMAL)
 PREFIX_SYM(GFS2_LOG_HEAD_FLUSH_, SYNC)
 PREFIX_SYM(GFS2_LOG_HEAD_FLUSH_, SHUTDOWN)
@@ -100,7 +96,6 @@ PREFIX_SYM(GFS2_LFC_, EVICT_INODE)
 PREFIX_SYM(GFS2_LFC_, TRANS_END)
 PREFIX_SYM(GFS2_LFC_, LOGD_JFLUSH_REQD)
 PREFIX_SYM(GFS2_LFC_, LOGD_AIL_FLUSH_REQD)
-#endif
 };
 
 const unsigned int lgfs2_lh_flag_size = ARRAY_SIZE(lgfs2_lh_flags);
@@ -183,9 +178,7 @@ F(sb_lockproto, .flags = LGFS2_MFF_STRING)
 F(sb_locktable, .flags = LGFS2_MFF_STRING)
 INR(__pad3, .points_to = (1 << LGFS2_MT_GFS2_DINODE))
 INR(__pad4, .points_to = (1 << LGFS2_MT_GFS2_DINODE))
-#ifdef GFS2_HAS_UUID
 F(sb_uuid, .flags = LGFS2_MFF_UUID)
-#endif
 };
 
 #undef STRUCT
@@ -230,18 +223,12 @@ 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)
-#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)
 F(rg_crc, .flags = LGFS2_MFF_CHECK)
-#endif
 RF(rg_reserved)
 };
 
@@ -363,15 +350,11 @@ 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
@@ -392,7 +375,6 @@ F(lh_flags, .flags = LGFS2_MFF_MASK, .symtab = lgfs2_lh_flags, .nsyms = ARRAY_SI
 F(lh_tail)
 F(lh_blkno)
 F(lh_hash, .flags = LGFS2_MFF_CHECK)
-#ifdef GFS2_HAS_LH_V2
 F(lh_crc, .flags = LGFS2_MFF_CHECK)
 F(lh_nsec, .flags = LGFS2_MFF_NSECS)
 F(lh_sec, .flags = LGFS2_MFF_SECS)
@@ -403,7 +385,6 @@ FP(lh_quota_addr, .points_to = (1 << LGFS2_MT_GFS2_DINODE))
 F(lh_local_total, .flags = LGFS2_MFF_FSBLOCKS)
 F(lh_local_free, .flags = LGFS2_MFF_FSBLOCKS)
 F(lh_local_dinodes, .flags = LGFS2_MFF_FSBLOCKS)
-#endif
 };
 
 #undef STRUCT
@@ -486,17 +467,9 @@ F(de_hash, .flags = LGFS2_MFF_CHECK)
 F(de_rec_len, .flags = LGFS2_MFF_BYTES)
 F(de_name_len, .flags = LGFS2_MFF_BYTES)
 F(de_type)
-#ifdef GFS2_HAS_DE_RAHEAD
 F(de_rahead)
-#ifdef GFS2_HAS_DE_COOKIE
 F(de_cookie)
 RF(pad3)
-#else
-RF(pad2)
-#endif /* GFS2_HAS_DE_COOKIE */
-#else
-RF(__pad)
-#endif /* GFS2_HAS_DE_RAHEAD */
 };
 
 #undef STRUCT
@@ -935,14 +908,12 @@ int lgfs2_field_str(char *str, const size_t size, const char *blk, const struct
 		return 1;
 
 	if (field->flags & LGFS2_MFF_UUID) {
-#ifdef GFS2_HAS_UUID
 		char readable_uuid[36+1];
 		uuid_t uuid;
 
 		memcpy(uuid, fieldp, sizeof(uuid_t));
 		uuid_unparse(uuid, readable_uuid);
 		snprintf(str, size, "%s", readable_uuid);
-#endif
 	} else if (field->flags & LGFS2_MFF_STRING) {
 		snprintf(str, size, "%s", fieldp);
 	} else {
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 648a9142..19e98db3 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -6,11 +6,8 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <ctype.h>
-#include <linux/types.h>
-#include "libgfs2.h"
-#ifdef GFS2_HAS_UUID
 #include <uuid.h>
-#endif
+#include "libgfs2.h"
 
 #define pv(struct, member, fmt, fmt2) do {				\
 		print_it("  "#member, fmt, fmt2, struct->member);	\
@@ -60,8 +57,8 @@ void gfs2_inum_out(const struct gfs2_inum *no, char *buf)
 
 void gfs2_inum_print(const struct gfs2_inum *no)
 {
-	pv(no, no_formal_ino, "%llu", "0x%llx");
-	pv(no, no_addr, "%llu", "0x%llx");
+	pv(no, no_formal_ino, "%"PRIu64, "0x%"PRIx64);
+	pv(no, no_addr, "%"PRIu64, "0x%"PRIx64);
 }
 
 void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf)
@@ -87,8 +84,8 @@ void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf)
 void gfs2_meta_header_print(const struct gfs2_meta_header *mh)
 {
 	pv(mh, mh_magic, "0x%08X", NULL);
-	pv(mh, mh_type, "%u", "0x%x");
-	pv(mh, mh_format, "%u", "0x%x");
+	pv(mh, mh_type, "%"PRIu32, "0x%"PRIx32);
+	pv(mh, mh_format, "%"PRIu32, "0x%"PRIx32);
 }
 
 void gfs2_sb_in(struct gfs2_sb *sb, char *buf)
@@ -113,9 +110,7 @@ void gfs2_sb_in(struct gfs2_sb *sb, char *buf)
 	gfs2_inum_in(&sb->__pad2, (char *)&str->__pad2); /* gfs rindex */
 	gfs2_inum_in(&sb->__pad3, (char *)&str->__pad3); /* gfs quota */
 	gfs2_inum_in(&sb->__pad4, (char *)&str->__pad4); /* gfs license */
-#ifdef GFS2_HAS_UUID
 	CPIN_08(sb, str, sb_uuid, sizeof(sb->sb_uuid));
-#endif
 }
 
 void gfs2_sb_out(const struct gfs2_sb *sb, char *buf)
@@ -140,20 +135,20 @@ void gfs2_sb_out(const struct gfs2_sb *sb, char *buf)
 	gfs2_inum_out(&sb->__pad2, (char *)&str->__pad2); /* gfs rindex */
 	gfs2_inum_out(&sb->__pad3, (char *)&str->__pad3); /* gfs quota */
 	gfs2_inum_out(&sb->__pad4, (char *)&str->__pad4); /* gfs license */
-#ifdef GFS2_HAS_UUID
 	memcpy(str->sb_uuid, sb->sb_uuid, 16);
-#endif
 }
 
 void gfs2_sb_print(const struct gfs2_sb *sb)
 {
+	char readable_uuid[36+1];
+
 	gfs2_meta_header_print(&sb->sb_header);
 
-	pv(sb, sb_fs_format, "%u", "0x%x");
-	pv(sb, sb_multihost_format, "%u", "0x%x");
+	pv(sb, sb_fs_format, "%"PRIu32, "0x%"PRIx32);
+	pv(sb, sb_multihost_format, "%"PRIu32, "0x%"PRIx32);
 
-	pv(sb, sb_bsize, "%u", "0x%x");
-	pv(sb, sb_bsize_shift, "%u", "0x%x");
+	pv(sb, sb_bsize, "%"PRIu32, "0x%"PRIx32);
+	pv(sb, sb_bsize_shift, "%"PRIu32, "0x%"PRIx32);
 
 	gfs2_inum_print(&sb->sb_master_dir);
 	gfs2_inum_print(&sb->sb_root_dir);
@@ -161,14 +156,8 @@ void gfs2_sb_print(const struct gfs2_sb *sb)
 	pv(sb, sb_lockproto, "%s", NULL);
 	pv(sb, sb_locktable, "%s", NULL);
 
-#ifdef GFS2_HAS_UUID
-	{
-	char readable_uuid[36+1];
-
 	uuid_unparse(sb->sb_uuid, readable_uuid);
 	print_it("  uuid", "%36s", NULL, readable_uuid);
-	}
-#endif
 }
 
 void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf)
@@ -202,13 +191,11 @@ void gfs2_rindex_out(const struct gfs2_rindex *ri, char *buf)
 
 void gfs2_rindex_print(const struct gfs2_rindex *ri)
 {
-	pv(ri, ri_addr, "%llu", "0x%llx");
-	pv(ri, ri_length, "%u", "0x%x");
-
-	pv(ri, ri_data0, "%llu", "0x%llx");
-	pv(ri, ri_data, "%u", "0x%x");
-
-	pv(ri, ri_bitbytes, "%u", "0x%x");
+	pv(ri, ri_addr, "%"PRIu64, "0x%"PRIx64);
+	pv(ri, ri_length, "%"PRIu32, "0x%"PRIx32);
+	pv(ri, ri_data0, "%"PRIu64, "0x%"PRIx64);
+	pv(ri, ri_data, "%"PRIu32, "0x%"PRIx32);
+	pv(ri, ri_bitbytes, "%"PRIu32, "0x%"PRIx32);
 }
 
 void gfs2_rgrp_in(struct gfs2_rgrp *rg, char *buf)
@@ -219,18 +206,12 @@ void gfs2_rgrp_in(struct gfs2_rgrp *rg, char *buf)
 	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);
-#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_32(rg, str, rg_crc);
-#endif
 	CPIN_08(rg, str, rg_reserved, sizeof(rg->rg_reserved));
 }
 
@@ -242,41 +223,27 @@ 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);
-#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, sizeof(rg->rg_reserved));
 	lgfs2_rgrp_crc_set(buf);
-#else
-	CPOUT_08(rg, str, rg_reserved, sizeof(rg->rg_reserved));
-#endif
 }
 
 void gfs2_rgrp_print(const struct gfs2_rgrp *rg)
 {
 	gfs2_meta_header_print(&rg->rg_header);
-	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");
-#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");
-	pv(rg, rg_crc, "%u", "0x%x");
-#endif
+	pv(rg, rg_flags, "%"PRIu32, "0x%"PRIx32);
+	pv(rg, rg_free, "%"PRIu32, "0x%"PRIx32);
+	pv(rg, rg_dinodes, "%"PRIu32, "0x%"PRIx32);
+	pv(rg, rg_skip, "%"PRIu32, "0x%"PRIx32);
+	pv(rg, rg_igeneration, "%"PRIu64, "0x%"PRIx64);
+	pv(rg, rg_data0, "%"PRIu64, "0x%"PRIx64);
+	pv(rg, rg_data, "%"PRIu32, "0x%"PRIx32);
+	pv(rg, rg_bitbytes, "%"PRIu32, "0x%"PRIx32);
+	pv(rg, rg_crc, "%"PRIu32, "0x%"PRIx32);
 }
 
 void gfs2_quota_in(struct gfs2_quota *qu, char *buf)
@@ -301,9 +268,9 @@ void gfs2_quota_out(struct gfs2_quota *qu, char *buf)
 
 void gfs2_quota_print(const struct gfs2_quota *qu)
 {
-	pv(qu, qu_limit, "%llu", "0x%llx");
-	pv(qu, qu_warn, "%llu", "0x%llx");
-	pv(qu, qu_value, "%lld", "0x%llx");
+	pv(qu, qu_limit, "%"PRIu64, "0x%"PRIx64);
+	pv(qu, qu_warn, "%"PRIu64, "0x%"PRIx64);
+	pv(qu, qu_value, "%"PRId64, "0x%"PRIx64);
 }
 
 void gfs2_dinode_in(struct gfs2_dinode *di, char *buf)
@@ -382,28 +349,27 @@ void gfs2_dinode_print(const struct gfs2_dinode *di)
 	gfs2_inum_print(&di->di_num);
 
 	pv(di, di_mode, "0%o", NULL);
-	pv(di, di_uid, "%u", "0x%x");
-	pv(di, di_gid, "%u", "0x%x");
-	pv(di, di_nlink, "%u", "0x%x");
-	pv(di, di_size, "%llu", "0x%llx");
-	pv(di, di_blocks, "%llu", "0x%llx");
-	pv(di, di_atime, "%lld", "0x%llx");
-	pv(di, di_mtime, "%lld", "0x%llx");
-	pv(di, di_ctime, "%lld", "0x%llx");
-	pv(di, di_major, "%u", "0x%llx");
-	pv(di, di_minor, "%u", "0x%llx");
-
-	pv(di, di_goal_meta, "%llu", "0x%llx");
-	pv(di, di_goal_data, "%llu", "0x%llx");
-
+	pv(di, di_uid, "%"PRIu32, "0x%"PRIx32);
+	pv(di, di_gid, "%"PRIu32, "0x%"PRIx32);
+	pv(di, di_nlink, "%"PRIu32, "0x%"PRIx32);
+	pv(di, di_size, "%"PRIu64, "0x%"PRIx64);
+	pv(di, di_blocks, "%"PRIu64, "0x%"PRIx64);
+	pv(di, di_atime, "%"PRId64, "0x%"PRIx64);
+	pv(di, di_mtime, "%"PRId64, "0x%"PRIx64);
+	pv(di, di_ctime, "%"PRId64, "0x%"PRIx64);
+	pv(di, di_major, "%"PRIu32, "0x%"PRIx32);
+	pv(di, di_minor, "%"PRIu32, "0x%"PRIx32);
+	pv(di, di_goal_meta, "%"PRIu64, "0x%"PRIx64);
+	pv(di, di_goal_data, "%"PRIu64, "0x%"PRIx64);
 	pv(di, di_flags, "0x%.8X", NULL);
-	pv(di, di_payload_format, "%u", "0x%x");
-	pv(di, di_height, "%u", "0x%x");
-
-	pv(di, di_depth, "%u", "0x%x");
-	pv(di, di_entries, "%u", "0x%x");
-
-	pv(di, di_eattr, "%llu", "0x%llx");
+	pv(di, di_payload_format, "%"PRIu32, "0x%"PRIx32);
+	pv(di, di_height, "%"PRIu16, "0x%"PRIx16);
+	pv(di, di_depth, "%"PRIu16, "0x%"PRIx16);
+	pv(di, di_entries, "%"PRIu32, "0x%"PRIx32);
+	pv(di, di_eattr, "%"PRIu64, "0x%"PRIx64);
+	pv(di, di_atime_nsec, "%"PRIu32, "0x%"PRIx32);
+	pv(di, di_mtime_nsec, "%"PRIu32, "0x%"PRIx32);
+	pv(di, di_ctime_nsec, "%"PRIu32, "0x%"PRIx32);
 }
 
 void gfs2_dirent_in(struct gfs2_dirent *de, char *buf)
@@ -415,17 +381,9 @@ void gfs2_dirent_in(struct gfs2_dirent *de, char *buf)
 	CPIN_16(de, str, de_rec_len);
 	CPIN_16(de, str, de_name_len);
 	CPIN_16(de, str, de_type);
-#ifdef GFS2_HAS_DE_RAHEAD
 	CPIN_16(de, str, de_rahead);
-#ifdef GFS2_HAS_DE_COOKIE
 	CPIN_32(de, str, de_cookie);
 	CPIN_08(de, str, pad3, 8);
-#else
-	CPIN_08(de, str, pad2, 12);
-#endif /* GFS2_HAS_DE_COOKIE */
-#else
-	CPIN_08(de, str, __pad, 14);
-#endif /* GFS2_HAS_DE_RAHEAD */
 }
 
 void gfs2_dirent_out(struct gfs2_dirent *de, char *buf)
@@ -437,17 +395,9 @@ void gfs2_dirent_out(struct gfs2_dirent *de, char *buf)
 	CPOUT_16(de, str, de_rec_len);
 	CPOUT_16(de, str, de_name_len);
 	CPOUT_16(de, str, de_type);
-#ifdef GFS2_HAS_DE_RAHEAD
 	CPOUT_16(de, str, de_rahead);
-#ifdef GFS2_HAS_DE_COOKIE
 	CPOUT_32(de, str, de_cookie);
 	CPOUT_08(de, str, pad3, 8);
-#else
-	CPOUT_08(de, str, pad2, 12);
-#endif /* GFS2_HAS_DE_COOKIE */
-#else
-	CPOUT_08(de, str, __pad, 14);
-#endif /* GFS2_HAS_DE_RAHEAD */
 }
 
 void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf)
@@ -459,15 +409,11 @@ void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf)
 	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, char *buf)
@@ -479,30 +425,24 @@ void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf)
 	CPOUT_16(lf, str, lf_entries);
 	CPOUT_32(lf, str, lf_dirent_format);
 	CPOUT_64(lf, str, lf_next);
-#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
 }
 
 void gfs2_leaf_print(const struct gfs2_leaf *lf)
 {
 	gfs2_meta_header_print(&lf->lf_header);
-	pv(lf, lf_depth, "%u", "0x%x");
-	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
+	pv(lf, lf_depth, "%"PRIu16, "0x%"PRIx16);
+	pv(lf, lf_entries, "%"PRIu16, "0x%"PRIx16);
+	pv(lf, lf_dirent_format, "%"PRIu32, "0x%"PRIx32);
+	pv(lf, lf_next, "%"PRIu64, "0x%"PRIx64);
+	pv(lf, lf_inode, "%"PRIu64, "0x%"PRIx64);
+	pv(lf, lf_dist, "%"PRIu32, "0x%"PRIx32);
+	pv(lf, lf_nsec, "%"PRIu32, "0x%"PRIx32);
+	pv(lf, lf_sec, "%"PRIu64, "0x%"PRIx64);
 }
 
 void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf)
@@ -521,19 +461,19 @@ void gfs2_ea_header_print(const struct gfs2_ea_header *ea, char *name)
 {
 	char buf[GFS2_EA_MAX_NAME_LEN + 1];
 
-	pv(ea, ea_rec_len, "%u", "0x%x");
-	pv(ea, ea_data_len, "%u", "0x%x");
-	pv(ea, ea_name_len, "%u", "0x%x");
-	pv(ea, ea_type, "%u", "0x%x");
-	pv(ea, ea_flags, "%u", "0x%x");
-	pv(ea, ea_num_ptrs, "%u", "0x%x");
+	pv(ea, ea_rec_len, "%"PRIu32, "0x%"PRIx32);
+	pv(ea, ea_data_len, "%"PRIu32, "0x%"PRIx32);
+	pv(ea, ea_name_len, "%"PRIu8, "0x%"PRIx8);
+	pv(ea, ea_type, "%"PRIu8, "0x%"PRIx8);
+	pv(ea, ea_flags, "%"PRIu8, "0x%"PRIx8);
+	pv(ea, ea_num_ptrs, "%"PRIu8, "0x%"PRIx8);
 
 	memset(buf, 0, GFS2_EA_MAX_NAME_LEN + 1);
 	memcpy(buf, name, ea->ea_name_len);
 	print_it("  name", "%s", NULL, buf);
 }
 
-void gfs2_log_header_v1_in(struct gfs2_log_header *lh, char *buf)
+void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf)
 {
 	struct gfs2_log_header *str = (struct gfs2_log_header *)buf;
 
@@ -543,15 +483,6 @@ void gfs2_log_header_v1_in(struct gfs2_log_header *lh, char *buf)
 	CPIN_32(lh, str, lh_tail);
 	CPIN_32(lh, str, lh_blkno);
 	CPIN_32(lh, str, lh_hash);
-}
-
-void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf)
-{
-	gfs2_log_header_v1_in(lh, buf);
-#ifdef GFS2_HAS_LH_V2
-	{
-	struct gfs2_log_header *str = (struct gfs2_log_header *)buf;
-
 	CPIN_32(lh, str, lh_crc);
 	CPIN_32(lh, str, lh_nsec);
 	CPIN_64(lh, str, lh_sec);
@@ -562,11 +493,9 @@ void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf)
 	CPIN_64(lh, str, lh_local_total);
 	CPIN_64(lh, str, lh_local_free);
 	CPIN_64(lh, str, lh_local_dinodes);
-	}
-#endif
 }
 
-void gfs2_log_header_v1_out(struct gfs2_log_header *lh, char *buf)
+void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf)
 {
 	struct gfs2_log_header *str = (struct gfs2_log_header *)buf;
 
@@ -576,15 +505,6 @@ void gfs2_log_header_v1_out(struct gfs2_log_header *lh, char *buf)
 	CPOUT_32(lh, str, lh_tail);
 	CPOUT_32(lh, str, lh_blkno);
 	CPOUT_32(lh, str, lh_hash);
-}
-
-void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf)
-{
-	gfs2_log_header_v1_out(lh, buf);
-#ifdef GFS2_HAS_LH_V2
-	{
-	struct gfs2_log_header *str = (struct gfs2_log_header *)buf;
-
 	CPOUT_32(lh, str, lh_crc);
 	CPOUT_32(lh, str, lh_nsec);
 	CPOUT_64(lh, str, lh_sec);
@@ -595,35 +515,26 @@ void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf)
 	CPOUT_64(lh, str, lh_local_total);
 	CPOUT_64(lh, str, lh_local_free);
 	CPOUT_64(lh, str, lh_local_dinodes);
-	}
-#endif
 }
 
-void gfs2_log_header_v1_print(const struct gfs2_log_header *lh)
+void gfs2_log_header_print(const struct gfs2_log_header *lh)
 {
 	gfs2_meta_header_print(&lh->lh_header);
-	pv(lh, lh_sequence, "%llu", "0x%llx");
+	pv(lh, lh_sequence, "%"PRIu64, "0x%"PRIx64);
 	pv(lh, lh_flags, "0x%.8X", NULL);
-	pv(lh, lh_tail, "%u", "0x%x");
-	pv(lh, lh_blkno, "%u", "0x%x");
+	pv(lh, lh_tail, "%"PRIu32, "0x%"PRIx32);
+	pv(lh, lh_blkno, "%"PRIu32, "0x%"PRIx32);
 	pv(lh, lh_hash, "0x%.8X", NULL);
-}
-
-void gfs2_log_header_print(const struct gfs2_log_header *lh)
-{
-	gfs2_log_header_v1_print(lh);
-#ifdef GFS2_HAS_LH_V2
 	pv(lh, lh_crc, "0x%.8X", NULL);
-	pv(lh, lh_nsec, "%u", "0x%x");
-	pv(lh, lh_sec, "%llu", "0x%llx");
-	pv(lh, lh_addr, "%llu", "0x%llx");
-	pv(lh, lh_jinode, "%llu", "0x%llx");
-	pv(lh, lh_statfs_addr, "%llu", "0x%llx");
-	pv(lh, lh_quota_addr, "%llu", "0x%llx");
-	pv(lh, lh_local_total, "%lld", "0x%llx");
-	pv(lh, lh_local_free, "%lld", "0x%llx");
-	pv(lh, lh_local_dinodes, "%lld", "0x%llx");
-#endif
+	pv(lh, lh_nsec, "%"PRIu32, "0x%"PRIx32);
+	pv(lh, lh_sec, "%"PRIu64, "0x%"PRIx64);
+	pv(lh, lh_addr, "%"PRIu64, "0x%"PRIx64);
+	pv(lh, lh_jinode, "%"PRIu64, "0x%"PRIx64);
+	pv(lh, lh_statfs_addr, "%"PRIu64, "0x%"PRIx64);
+	pv(lh, lh_quota_addr, "%"PRIu64, "0x%"PRIx64);
+	pv(lh, lh_local_total, "%"PRId64, "0x%"PRIx64);
+	pv(lh, lh_local_free, "%"PRId64, "0x%"PRIx64);
+	pv(lh, lh_local_dinodes, "%"PRId64, "0x%"PRIx64);
 }
 
 void gfs2_log_descriptor_in(struct gfs2_log_descriptor *ld, char *buf)
@@ -655,10 +566,10 @@ void gfs2_log_descriptor_out(struct gfs2_log_descriptor *ld, char *buf)
 void gfs2_log_descriptor_print(const struct gfs2_log_descriptor *ld)
 {
 	gfs2_meta_header_print(&ld->ld_header);
-	pv(ld, ld_type, "%u", "0x%x");
-	pv(ld, ld_length, "%u", "0x%x");
-	pv(ld, ld_data1, "%u", "0x%x");
-	pv(ld, ld_data2, "%u", "0x%x");
+	pv(ld, ld_type, "%"PRIu32, "0x%"PRIx32);
+	pv(ld, ld_length, "%"PRIu32, "0x%"PRIx32);
+	pv(ld, ld_data1, "%"PRIu32, "0x%"PRIx32);
+	pv(ld, ld_data2, "%"PRIu32, "0x%"PRIx32);
 }
 
 void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, char *buf)
@@ -681,9 +592,9 @@ void gfs2_statfs_change_out(struct gfs2_statfs_change *sc, char *buf)
 
 void gfs2_statfs_change_print(const struct gfs2_statfs_change *sc)
 {
-	pv(sc, sc_total, "%lld", "0x%llx");
-	pv(sc, sc_free, "%lld", "0x%llx");
-	pv(sc, sc_dinodes, "%lld", "0x%llx");
+	pv(sc, sc_total, "%"PRId64, "0x%"PRIx64);
+	pv(sc, sc_free, "%"PRId64, "0x%"PRIx64);
+	pv(sc, sc_dinodes, "%"PRId64, "0x%"PRIx64);
 }
 
 void gfs2_quota_change_in(struct gfs2_quota_change *qc, char *buf)
@@ -708,8 +619,8 @@ void gfs2_quota_change_out(struct gfs2_quota_change *qc, char *buf)
 
 void gfs2_quota_change_print(const struct gfs2_quota_change *qc)
 {
-	pv(qc, qc_change, "%lld", "0x%llx");
+	pv(qc, qc_change, "%"PRId64, "0x%"PRIx64);
 	pv(qc, qc_flags, "0x%.8X", NULL);
-	pv(qc, qc_id, "%u", "0x%x");
+	pv(qc, qc_id, "%"PRIu32, "0x%"PRIx32);
 }
 
diff --git a/gfs2/libgfs2/recovery.c b/gfs2/libgfs2/recovery.c
index 06f81116..bc446cfe 100644
--- a/gfs2/libgfs2/recovery.c
+++ b/gfs2/libgfs2/recovery.c
@@ -72,9 +72,7 @@ int get_log_header(struct gfs2_inode *ip, unsigned int blk,
 	crc = lgfs2_log_header_crc(bh->b_data, ip->i_sbd->bsize);
 	gfs2_log_header_in(&lh, bh->b_data);
 	brelse(bh);
-#ifdef GFS2_HAS_LH_V2
 	lh_crc = lh.lh_crc;
-#endif
 	if (error || lh.lh_blkno != blk || lh.lh_hash != hash)
 		return 1;
 	/* Don't check the crc if it's zero, as it is in pre-v2 log headers */
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index 3cdaccae..e1748a4c 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -164,7 +164,6 @@ void lgfs2_rgrp_bitbuf_free(lgfs2_rgrp_t rg)
 int lgfs2_rgrp_crc_check(char *buf)
 {
 	int ret = 0;
-#ifdef GFS2_HAS_RG_RI_FIELDS
 	struct gfs2_rgrp *rg = (struct gfs2_rgrp *)buf;
 	uint32_t crc = rg->rg_crc;
 
@@ -175,7 +174,6 @@ int lgfs2_rgrp_crc_check(char *buf)
 	if (be32_to_cpu(crc) != gfs2_disk_hash(buf, sizeof(struct gfs2_rgrp)))
 		ret = 1;
 	rg->rg_crc = crc;
-#endif
 	return ret;
 }
 
@@ -184,14 +182,12 @@ int lgfs2_rgrp_crc_check(char *buf)
  */
 void lgfs2_rgrp_crc_set(char *buf)
 {
-#ifdef GFS2_HAS_RG_RI_FIELDS
 	struct gfs2_rgrp *rg = (struct gfs2_rgrp *)buf;
 	uint32_t crc;
 
 	rg->rg_crc = 0;
 	crc = gfs2_disk_hash(buf, sizeof(struct gfs2_rgrp));
 	rg->rg_crc = cpu_to_be32(crc);
-#endif
 }
 
 /**
@@ -666,15 +662,11 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, ui
 	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
-#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;
 	rg->rg.rg_crc = 0;
-#endif
 	compute_bitmaps(rg, rgs->sdp->bsize);
 	rg->rgrps = rgs;
 	return rg;
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index c84701d4..f05e7f2d 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -10,17 +10,13 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
-#include <linux/types.h>
 #include <sys/time.h>
+#include <uuid.h>
 
 #include "libgfs2.h"
 #include "config.h"
 #include "crc32c.h"
 
-#ifdef GFS2_HAS_UUID
-#include <uuid.h>
-#endif
-
 int build_master(struct gfs2_sbd *sdp)
 {
 	struct gfs2_inum inum;
@@ -63,9 +59,7 @@ void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize)
 	sb->sb_multihost_format = GFS2_FORMAT_MULTI;
 	sb->sb_bsize = bsize;
 	sb->sb_bsize_shift = ffs(bsize) - 1;
-#ifdef GFS2_HAS_UUID
 	uuid_generate(sb->sb_uuid);
-#endif
 }
 
 int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize)
@@ -113,15 +107,11 @@ uint32_t lgfs2_log_header_hash(char *buf)
 
 uint32_t lgfs2_log_header_crc(char *buf, unsigned bsize)
 {
-#ifdef GFS2_HAS_LH_V2
 	/* lh_crc CRCs the rest of the block starting after lh_crc */
 	const off_t v1_end = offsetof(struct gfs2_log_header, lh_hash) + 4;
 	const unsigned char *lb = (const unsigned char *)buf;
 
 	return crc32c(~0, lb + v1_end + 4, bsize - v1_end - 4);
-#else
-	return 0;
-#endif
 }
 
 /**
@@ -141,7 +131,6 @@ int lgfs2_write_journal_data(struct gfs2_inode *ip)
 		.lh_tail = 0,
 		.lh_blkno = 0,
 		.lh_hash = 0,
-#ifdef GFS2_HAS_LH_V2
 		.lh_flags = GFS2_LOG_HEAD_UNMOUNT | GFS2_LOG_HEAD_USERSPACE,
 		.lh_crc = 0,
 		.lh_nsec = 0,
@@ -152,9 +141,6 @@ int lgfs2_write_journal_data(struct gfs2_inode *ip)
 		.lh_local_total = 0,
 		.lh_local_free = 0,
 		.lh_local_dinodes = 0,
-#else
-		.lh_flags = GFS2_LOG_HEAD_UNMOUNT,
-#endif
 	};
 	struct gfs2_buffer_head *bh;
 	struct gfs2_sbd *sdp = ip->i_sbd;
@@ -175,10 +161,8 @@ int lgfs2_write_journal_data(struct gfs2_inode *ip)
 		gfs2_log_header_out(&lh, bh->b_data);
 
 		buflh->lh_hash = cpu_to_be32(lgfs2_log_header_hash(bh->b_data));
-#ifdef GFS2_HAS_LH_V2
 		buflh->lh_addr = cpu_to_be64(bh->b_blocknr);
 		buflh->lh_crc = cpu_to_be32(lgfs2_log_header_crc(bh->b_data, sdp->bsize));
-#endif
 
 		if (bwrite(bh)) {
 			free(bh);
@@ -212,10 +196,8 @@ int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)
 	lh.lh_header.mh_type = GFS2_METATYPE_LH;
 	lh.lh_header.mh_format = GFS2_FORMAT_LH;
 	lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
-#ifdef GFS2_HAS_LH_V2
 	lh.lh_flags |= GFS2_LOG_HEAD_USERSPACE;
 	lh.lh_jinode = jnl->i_di.di_num.no_addr;
-#endif
 	for (x = 0; x < blocks; x++) {
 		struct gfs2_buffer_head *bh = get_file_buf(jnl, x, TRUE);
 		if (!bh)
@@ -235,11 +217,9 @@ int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)
 		gfs2_log_header_out(&lh, bh->b_data);
 		hash = lgfs2_log_header_hash(bh->b_data);
 		((struct gfs2_log_header *)bh->b_data)->lh_hash = cpu_to_be32(hash);
-#ifdef GFS2_HAS_LH_V2
 		((struct gfs2_log_header *)bh->b_data)->lh_addr = cpu_to_be64(bh->b_blocknr);
 		hash = lgfs2_log_header_crc(bh->b_data, bsize);
 		((struct gfs2_log_header *)bh->b_data)->lh_crc = cpu_to_be32(hash);
-#endif
 		bmodified(bh);
 		brelse(bh);
 
diff --git a/gfs2/mkfs/gfs2_mkfs.h b/gfs2/mkfs/gfs2_mkfs.h
index 75f70e6a..5f358354 100644
--- a/gfs2/mkfs/gfs2_mkfs.h
+++ b/gfs2/mkfs/gfs2_mkfs.h
@@ -2,7 +2,7 @@
 #define __GFS2_MKFS_DOT_H__
 
 #include <stdarg.h>
-#include <linux/gfs2_ondisk.h>
+#include <gfs2_ondisk.h>
 #include "osi_list.h"
 #include "copyright.cf"
 
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index ad80a8d9..7e56d2cd 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -15,7 +15,6 @@
 #include <time.h>
 #include <errno.h>
 #include <stdarg.h>
-#include <linux/types.h>
 #include <blkid.h>
 #include <libintl.h>
 #include <locale.h>
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index efe91e30..2a64f390 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -20,7 +20,6 @@
 #include <locale.h>
 #define _(String) gettext(String)
 
-#include <linux/types.h>
 #include <linux/fiemap.h>
 #include <linux/fs.h>
 #include "libgfs2.h"
@@ -425,7 +424,6 @@ close:
 	opts->orig_journals = existing_journals;
 }
 
-#ifdef GFS2_HAS_LH_V2
 static uint64_t find_block_address(int fd, off_t offset, unsigned bsize)
 {
 	struct {
@@ -446,7 +444,6 @@ static uint64_t find_block_address(int fd, off_t offset, unsigned bsize)
 	}
 	return fme.fe.fe_physical / bsize;
 }
-#endif
 
 static void add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
 {
@@ -482,10 +479,8 @@ static void add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
 		lh.lh_header.mh_type = GFS2_METATYPE_LH;
 		lh.lh_header.mh_format = GFS2_FORMAT_LH;
 		lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
-#ifdef GFS2_HAS_LH_V2
 		lh.lh_flags |= GFS2_LOG_HEAD_USERSPACE;
 		lh.lh_jinode = addr;
-#endif
 		for (x=0; x<blocks; x++) {
 			uint32_t hash;
 
@@ -494,12 +489,10 @@ static void add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
 			gfs2_log_header_out(&lh, buf);
 			hash = lgfs2_log_header_hash(buf);
 			((struct gfs2_log_header *)buf)->lh_hash = cpu_to_be32(hash);
-#ifdef GFS2_HAS_LH_V2
 			((struct gfs2_log_header *)buf)->lh_addr = cpu_to_be64(
 			                           find_block_address(fd, off, sdp->bsize));
 			hash = lgfs2_log_header_crc(buf, sdp->bsize);
 			((struct gfs2_log_header *)buf)->lh_crc = cpu_to_be32(hash);
-#endif
 			if (write(fd, buf, sdp->bsize) != sdp->bsize) {
 				perror("add_j");
 				exit(EXIT_FAILURE);
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 7aeae695..d65aafd7 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -22,18 +22,14 @@
 #include <limits.h>
 #include <blkid.h>
 #include <locale.h>
+#include <uuid.h>
 
 #define _(String) gettext(String)
 
-#include <linux/types.h>
 #include "libgfs2.h"
 #include "gfs2_mkfs.h"
 #include "progress.h"
 
-#ifdef GFS2_HAS_UUID
-#include <uuid.h>
-#endif
-
 static void print_usage(const char *prog_name)
 {
 	int i;
@@ -566,6 +562,8 @@ static void opts_check(struct mkfs_opts *opts)
 
 static void print_results(struct gfs2_sb *sb, struct mkfs_opts *opts, uint64_t rgrps, uint64_t fssize)
 {
+	char readable_uuid[36+1];
+
 	printf("%-27s%s\n", _("Device:"), opts->dev.path);
 	printf("%-27s%u\n", _("Block size:"), sb->sb_bsize);
 	printf("%-27s%.2f %s (%"PRIu64" %s)\n", _("Device size:"),
@@ -579,15 +577,9 @@ static void print_results(struct gfs2_sb *sb, struct mkfs_opts *opts, uint64_t r
 	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
-	{
-	char readable_uuid[36+1];
-
 	uuid_unparse(sb->sb_uuid, readable_uuid);
 	/* Translators: "UUID" = universally unique identifier. */
 	printf("%-27s%s\n", _("UUID:"), readable_uuid);
-	}
-#endif
 }
 
 static void warn_of_destruction(const char *path)
diff --git a/gfs2/tune/super.c b/gfs2/tune/super.c
index f4b7d85b..73af0bb3 100644
--- a/gfs2/tune/super.c
+++ b/gfs2/tune/super.c
@@ -11,12 +11,9 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 #include <linux_endian.h>
-#include <linux/gfs2_ondisk.h>
-#include "tunegfs2.h"
-
-#ifdef GFS2_HAS_UUID
+#include <gfs2_ondisk.h>
 #include <uuid.h>
-#endif
+#include "tunegfs2.h"
 
 int read_super(struct tunegfs2 *tfs)
 {
@@ -54,15 +51,11 @@ 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);
-#ifdef GFS2_HAS_UUID
-	{
 	char readable_uuid[36+1];
 
+	printf(_("File system volume name: %s\n"), tfs->sb->sb_locktable);
 	uuid_unparse(tfs->sb->sb_uuid, readable_uuid);
 	printf(_("File system UUID: %s\n"), readable_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));
@@ -88,7 +81,6 @@ int write_super(const struct tunegfs2 *tfs)
 
 int change_uuid(struct tunegfs2 *tfs, const char *str)
 {
-#ifdef GFS2_HAS_UUID
 	uuid_t uuid;
 	int status;
 
@@ -96,10 +88,6 @@ int change_uuid(struct tunegfs2 *tfs, const char *str)
 	if (status == 0)
 		uuid_copy(tfs->sb->sb_uuid, uuid);
 	return status;
-#else
-	fprintf(stderr, _("UUID support unavailable in this build\n"));
-	return 1;
-#endif
 }
 
 int change_lockproto(struct tunegfs2 *tfs, const char *lockproto)
-- 
2.20.1



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

* [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h
  2019-04-09  9:41 [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h Andrew Price
@ 2019-04-09 12:03 ` Christoph Hellwig
  2019-04-09 12:18   ` Andrew Price
  0 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2019-04-09 12:03 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Tue, Apr 09, 2019 at 10:41:53AM +0100, Andrew Price wrote:
> Give gfs2-utils its own copy of gfs2_ondisk.h which uses userspace
> types. This allows us to always support the latest ondisk structures and
> obsoletes a lot of #ifdef GFS2_HAS_<FEATURE> blocks and configure.ac
> checks.
> 
> gfs2_ondisk.h was changed simply by search-and-replace of the kernel int
> types with the uintN_t, i.e.:
> 
> :%s/__u\(8\|16\|32\|64\)/uint\1_t/g
> :%s/__be\(64\|32\|16\|8\)/uint\1_t/g
> 
> and the linux/types.h include replaced with stdint.h

Why?  At least the be types give you really useful type checking with
sparse, which can be trivially wired up in userspace as well.  Also
keeping the file 1:1 the same is going to make your life much easier
in the future..



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

* [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h
  2019-04-09 12:03 ` Christoph Hellwig
@ 2019-04-09 12:18   ` Andrew Price
  2019-04-09 12:21     ` Steven Whitehouse
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Price @ 2019-04-09 12:18 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 09/04/2019 13:03, Christoph Hellwig wrote:
> On Tue, Apr 09, 2019 at 10:41:53AM +0100, Andrew Price wrote:
>> Give gfs2-utils its own copy of gfs2_ondisk.h which uses userspace
>> types. This allows us to always support the latest ondisk structures and
>> obsoletes a lot of #ifdef GFS2_HAS_<FEATURE> blocks and configure.ac
>> checks.
>>
>> gfs2_ondisk.h was changed simply by search-and-replace of the kernel int
>> types with the uintN_t, i.e.:
>>
>> :%s/__u\(8\|16\|32\|64\)/uint\1_t/g
>> :%s/__be\(64\|32\|16\|8\)/uint\1_t/g
>>
>> and the linux/types.h include replaced with stdint.h
> 
> Why?

Because I'd like to be able to build gfs2-utils on FreeBSD one day. Plus 
we get the handy stuff in inttypes.h to use, Linux doesn't have that.

> At least the be types give you really useful type checking with
> sparse, which can be trivially wired up in userspace as well.

If you mean the bitwise annotations that only sparse checks, we're 
fairly safe in gfs2-utils in that anything represented by a struct is 
going to have been parsed through one of the libgfs2/ondisk.c functions 
so will be the right endianness. I run sparse over this code very rarely 
anyway.

> Also
> keeping the file 1:1 the same is going to make your life much easier
> in the future..

It's really no difficulty to run the above substitutions the next time 
the file changes, but gfs2_ondisk.h changes once in a blue moon anyway 
so the maintenance overhead is going to be tiny.

Andy



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

* [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h
  2019-04-09 12:18   ` Andrew Price
@ 2019-04-09 12:21     ` Steven Whitehouse
  2019-04-09 12:35       ` Christoph Hellwig
  2019-04-09 12:48       ` Andrew Price
  0 siblings, 2 replies; 9+ messages in thread
From: Steven Whitehouse @ 2019-04-09 12:21 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On 09/04/2019 13:18, Andrew Price wrote:
> On 09/04/2019 13:03, Christoph Hellwig wrote:
>> On Tue, Apr 09, 2019 at 10:41:53AM +0100, Andrew Price wrote:
>>> Give gfs2-utils its own copy of gfs2_ondisk.h which uses userspace
>>> types. This allows us to always support the latest ondisk structures 
>>> and
>>> obsoletes a lot of #ifdef GFS2_HAS_<FEATURE> blocks and configure.ac
>>> checks.
>>>
>>> gfs2_ondisk.h was changed simply by search-and-replace of the kernel 
>>> int
>>> types with the uintN_t, i.e.:
>>>
>>> :%s/__u\(8\|16\|32\|64\)/uint\1_t/g
>>> :%s/__be\(64\|32\|16\|8\)/uint\1_t/g
>>>
>>> and the linux/types.h include replaced with stdint.h
>>
>> Why?
>
> Because I'd like to be able to build gfs2-utils on FreeBSD one day. 
> Plus we get the handy stuff in inttypes.h to use, Linux doesn't have 
> that.
>
>> At least the be types give you really useful type checking with
>> sparse, which can be trivially wired up in userspace as well.
>
> If you mean the bitwise annotations that only sparse checks, we're 
> fairly safe in gfs2-utils in that anything represented by a struct is 
> going to have been parsed through one of the libgfs2/ondisk.c 
> functions so will be the right endianness. I run sparse over this code 
> very rarely anyway.

Those conversion functions are not sensible, thats why we got rid of 
them from the kernel code. It is better to have a set of types that have 
the endianess specified so that we can use sparse. Compile time checking 
is always a good plan where it is possible.


>
>> Also
>> keeping the file 1:1 the same is going to make your life much easier
>> in the future..
>
> It's really no difficulty to run the above substitutions the next time 
> the file changes, but gfs2_ondisk.h changes once in a blue moon anyway 
> so the maintenance overhead is going to be tiny.
>
> Andy
>
Thats true, but lets keep the ability to do endianess checks,

Steve.




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

* [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h
  2019-04-09 12:21     ` Steven Whitehouse
@ 2019-04-09 12:35       ` Christoph Hellwig
  2019-11-08  9:50         ` Andrew Price
  2019-04-09 12:48       ` Andrew Price
  1 sibling, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2019-04-09 12:35 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Tue, Apr 09, 2019 at 01:21:23PM +0100, Steven Whitehouse wrote:
> Those conversion functions are not sensible, thats why we got rid of them
> from the kernel code. It is better to have a set of types that have the
> endianess specified so that we can use sparse. Compile time checking is
> always a good plan where it is possible.

Yeah.  And <linux/types.h> vs inttypes.h is no argument either,
you can define the __be types based on the inttypes.h types (which
really are stdint.h ones anyway).



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

* [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h
  2019-04-09 12:21     ` Steven Whitehouse
  2019-04-09 12:35       ` Christoph Hellwig
@ 2019-04-09 12:48       ` Andrew Price
  2019-04-09 13:03         ` Steven Whitehouse
  1 sibling, 1 reply; 9+ messages in thread
From: Andrew Price @ 2019-04-09 12:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com



On 09/04/2019 13:21, Steven Whitehouse wrote:
> Hi,
> 
> On 09/04/2019 13:18, Andrew Price wrote:
>> On 09/04/2019 13:03, Christoph Hellwig wrote:
>>> On Tue, Apr 09, 2019 at 10:41:53AM +0100, Andrew Price wrote:
>>>> Give gfs2-utils its own copy of gfs2_ondisk.h which uses userspace
>>>> types. This allows us to always support the latest ondisk structures 
>>>> and
>>>> obsoletes a lot of #ifdef GFS2_HAS_<FEATURE> blocks and configure.ac
>>>> checks.
>>>>
>>>> gfs2_ondisk.h was changed simply by search-and-replace of the kernel 
>>>> int
>>>> types with the uintN_t, i.e.:
>>>>
>>>> :%s/__u\(8\|16\|32\|64\)/uint\1_t/g
>>>> :%s/__be\(64\|32\|16\|8\)/uint\1_t/g
>>>>
>>>> and the linux/types.h include replaced with stdint.h
>>>
>>> Why?
>>
>> Because I'd like to be able to build gfs2-utils on FreeBSD one day. 
>> Plus we get the handy stuff in inttypes.h to use, Linux doesn't have 
>> that.
>>
>>> At least the be types give you really useful type checking with
>>> sparse, which can be trivially wired up in userspace as well.
>>
>> If you mean the bitwise annotations that only sparse checks, we're 
>> fairly safe in gfs2-utils in that anything represented by a struct is 
>> going to have been parsed through one of the libgfs2/ondisk.c 
>> functions so will be the right endianness. I run sparse over this code 
>> very rarely anyway.
> 
> Those conversion functions are not sensible, thats why we got rid of 
> them from the kernel code. 

Is it the functions that aren't sensible or the use of the gfs2_ondisk.h 
structs as the containers for the native endian data? I'm not sure I get 
why the kernel functions like gfs2_dinode_in() are considered sensible 
and gfs2-utils' gfs2_dinode_in(), which does a similar thing but with a 
different struct, isn't sensible.

> It is better to have a set of types that have 
> the endianess specified so that we can use sparse. Compile time checking 
> is always a good plan where it is possible.

Okay, I'll add back the bitwise annotations through typedefs to stdint.h 
types in a new header but I don't want to name it linux/types.h to avoid 
picking up the wrong one, so I'll just change that #include in 
gfs2_ondisk.h.

Andy



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

* [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h
  2019-04-09 12:48       ` Andrew Price
@ 2019-04-09 13:03         ` Steven Whitehouse
  2019-04-09 13:14           ` Andrew Price
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Whitehouse @ 2019-04-09 13:03 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On 09/04/2019 13:48, Andrew Price wrote:
>
>
> On 09/04/2019 13:21, Steven Whitehouse wrote:
>> Hi,
>>
>> On 09/04/2019 13:18, Andrew Price wrote:
>>> On 09/04/2019 13:03, Christoph Hellwig wrote:
>>>> On Tue, Apr 09, 2019 at 10:41:53AM +0100, Andrew Price wrote:
>>>>> Give gfs2-utils its own copy of gfs2_ondisk.h which uses userspace
>>>>> types. This allows us to always support the latest ondisk 
>>>>> structures and
>>>>> obsoletes a lot of #ifdef GFS2_HAS_<FEATURE> blocks and configure.ac
>>>>> checks.
>>>>>
>>>>> gfs2_ondisk.h was changed simply by search-and-replace of the 
>>>>> kernel int
>>>>> types with the uintN_t, i.e.:
>>>>>
>>>>> :%s/__u\(8\|16\|32\|64\)/uint\1_t/g
>>>>> :%s/__be\(64\|32\|16\|8\)/uint\1_t/g
>>>>>
>>>>> and the linux/types.h include replaced with stdint.h
>>>>
>>>> Why?
>>>
>>> Because I'd like to be able to build gfs2-utils on FreeBSD one day. 
>>> Plus we get the handy stuff in inttypes.h to use, Linux doesn't have 
>>> that.
>>>
>>>> At least the be types give you really useful type checking with
>>>> sparse, which can be trivially wired up in userspace as well.
>>>
>>> If you mean the bitwise annotations that only sparse checks, we're 
>>> fairly safe in gfs2-utils in that anything represented by a struct 
>>> is going to have been parsed through one of the libgfs2/ondisk.c 
>>> functions so will be the right endianness. I run sparse over this 
>>> code very rarely anyway.
>>
>> Those conversion functions are not sensible, thats why we got rid of 
>> them from the kernel code. 
>
> Is it the functions that aren't sensible or the use of the 
> gfs2_ondisk.h structs as the containers for the native endian data? 
> I'm not sure I get why the kernel functions like gfs2_dinode_in() are 
> considered sensible and gfs2-utils' gfs2_dinode_in(), which does a 
> similar thing but with a different struct, isn't sensible.
>
Well in general we don't want to convert lots of fields in what is 
basically a copy. The inode, when it is read in is an exception to that 
mainly because we have to in order to make sure that the vfs level data 
is all up to date. Keeping the structs as containers is useful, so yes 
we want to retain that. In many cases though we only need a few fields 
from what can be quite large data structures, so in those cases we 
should read/update the fields that we care about for that particular 
operation, rather than converting the whole data structure each time. We 
got a fair speed up when we made that change in the kernel.

So generally I'd like to discourage the blanket conversion functions, 
though it is likely we'll need to retain a few of them, in favour of 
converting just the required fields at the point of use. This should be 
safe to do given that we have the ability to do compile time type 
checking - and lets try and include that in the tests that are always 
run before check in, to make sure that we don't land up with any 
mistakes. That would be a good addition to the tests I think,

Steve.




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

* [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h
  2019-04-09 13:03         ` Steven Whitehouse
@ 2019-04-09 13:14           ` Andrew Price
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Price @ 2019-04-09 13:14 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 09/04/2019 14:03, Steven Whitehouse wrote:
> On 09/04/2019 13:48, Andrew Price wrote:
>> On 09/04/2019 13:21, Steven Whitehouse wrote:
>>> Those conversion functions are not sensible, thats why we got rid of 
>>> them from the kernel code. 
>>
>> Is it the functions that aren't sensible or the use of the 
>> gfs2_ondisk.h structs as the containers for the native endian data? 
>> I'm not sure I get why the kernel functions like gfs2_dinode_in() are 
>> considered sensible and gfs2-utils' gfs2_dinode_in(), which does a 
>> similar thing but with a different struct, isn't sensible.
>>
> Well in general we don't want to convert lots of fields in what is 
> basically a copy. The inode, when it is read in is an exception to that 
> mainly because we have to in order to make sure that the vfs level data 
> is all up to date. Keeping the structs as containers is useful, so yes 
> we want to retain that. In many cases though we only need a few fields 
> from what can be quite large data structures, so in those cases we 
> should read/update the fields that we care about for that particular 
> operation, rather than converting the whole data structure each time. We 
> got a fair speed up when we made that change in the kernel.
> 
> So generally I'd like to discourage the blanket conversion functions, 
> though it is likely we'll need to retain a few of them, in favour of 
> converting just the required fields at the point of use. This should be 
> safe to do given that we have the ability to do compile time type 
> checking - and lets try and include that in the tests that are always 
> run before check in, to make sure that we don't land up with any 
> mistakes. That would be a good addition to the tests I think,

Ah ok, that makes sense to me, thanks for explaining. I'm sure we could 
speed up bits of gfs2-utils by taking that approach too.

Andy



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

* [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h
  2019-04-09 12:35       ` Christoph Hellwig
@ 2019-11-08  9:50         ` Andrew Price
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Price @ 2019-11-08  9:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Revisiting this...

On 09/04/2019 13:35, Christoph Hellwig wrote:
> On Tue, Apr 09, 2019 at 01:21:23PM +0100, Steven Whitehouse wrote:
>> Those conversion functions are not sensible, thats why we got rid of them
>> from the kernel code. It is better to have a set of types that have the
>> endianess specified so that we can use sparse. Compile time checking is
>> always a good plan where it is possible.
> 
> Yeah.  And <linux/types.h> vs inttypes.h is no argument either,
> you can define the __be types based on the inttypes.h types (which
> really are stdint.h ones anyway).

Linux's __be* type definitions are pulled in by standard headers (e.g. 
sys/stat.h via bits/statx.h -> linux/stat.h -> linux/types.h) so they 
can't be redefined in terms of stdint.h types, unfortunately. Even if 
that did work it could easily be broken outside of our control in the 
future, so that's another reason to leave the __be* types alone.

So I think the best we can do is define some new bitwise-annotated types 
based on stdint.h and change the imported gfs2_ondisk.h to use them.

Andy



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

end of thread, other threads:[~2019-11-08  9:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-09  9:41 [Cluster-devel] [PATCH] libgfs2: Import gfs2_ondisk.h Andrew Price
2019-04-09 12:03 ` Christoph Hellwig
2019-04-09 12:18   ` Andrew Price
2019-04-09 12:21     ` Steven Whitehouse
2019-04-09 12:35       ` Christoph Hellwig
2019-11-08  9:50         ` Andrew Price
2019-04-09 12:48       ` Andrew Price
2019-04-09 13:03         ` Steven Whitehouse
2019-04-09 13:14           ` 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.