Skip to contentSkip to conversation

libgfs2: Import gfs2_ondisk.h

PATCH New Andrew Price 3 participants 9 messages Apr 9, 2019 – Nov 8, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libgfs2: Import gfs2_ondisk.h

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.

---
 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
configure.ac +0 -16
index 0c1b0192..51e0cc0a 100644
@@ -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
gfs2/convert/gfs2_convert.c +1 -2
index 9cf97b65..558a935d 100644
@@ -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"
gfs2/edit/extended.c +14 -27

116 lines not on this page · raw message

gfs2/edit/gfs2hex.c +6 -13
index 62d5cab5..49607294 100644
@@ -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
 }
 
 /**
gfs2/edit/hexedit.c +1 -2
index f015828c..5c4910fe 100644
@@ -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"
gfs2/edit/hexedit.h +1 -1
index d2992d8e..8b2338e6 100644
@@ -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"
gfs2/edit/journal.c +6 -7
index 6364761f..f45b4e7b 100644
@@ -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,
gfs2/edit/savemeta.c +1 -2
index 04f1221f..c895e1ec 100644
@@ -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>
 
gfs2/fsck/fs_recovery.c +14 -16
index 677abd75..5834cc9e 100644
@@ -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);
gfs2/fsck/initialize.c +24 -26

141 lines not on this page · raw message

gfs2/fsck/lost_n_found.c +6 -6
index 4d5d52c8..1c196a72 100644
@@ -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;
gfs2/fsck/pass1.c +1 -1
index 3c2f74fa..84ff9d9b 100644
@@ -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,
gfs2/fsck/pass2.c +1 -1
index 763e39a9..e707a108 100644
@@ -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;
gfs2/fsck/rgrepair.c +12 -17
index 2f145903..134ae940 100644
@@ -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;
gfs2/include/gfs2_ondisk.h new file +535 -0

535 lines not on this page · raw message

gfs2/libgfs2/buf.c +0 -1
index 92cd393d..aec778a5 100644
@@ -11,7 +11,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
-#include <linux/types.h>
 
 #include "libgfs2.h"
 
gfs2/libgfs2/device_geometry.c +0 -1
index 1303f11b..72f9c7e4 100644
@@ -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"
gfs2/libgfs2/fs_geometry.c +0 -1
index df8a13a9..09504c51 100644
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include <linux/types.h>
 #include "libgfs2.h"
 #include "config.h"
 
gfs2/libgfs2/fs_ops.c +0 -7
index 7e87e435..cbf6de88 100644
@@ -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));
 
gfs2/libgfs2/gfs1.c +1 -2
index b91cce5e..1fee25c9 100644
@@ -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"
gfs2/libgfs2/lang.c +1 -10
index 62ad2ab7..c56091f1 100644
@@ -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 {
gfs2/libgfs2/libgfs2.h +50 -53

177 lines not on this page · raw message

gfs2/libgfs2/meta.c +1 -30
index 1da74146..42325077 100644
@@ -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 {
gfs2/libgfs2/ondisk.c +86 -175

466 lines not on this page · raw message

gfs2/libgfs2/recovery.c +0 -2
index 06f81116..bc446cfe 100644
@@ -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 */
gfs2/libgfs2/rgrp.c +0 -8
index 3cdaccae..e1748a4c 100644
@@ -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;
gfs2/libgfs2/structures.c +1 -21
index c84701d4..f05e7f2d 100644
@@ -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);
 
gfs2/mkfs/gfs2_mkfs.h +1 -1
index 75f70e6a..5f358354 100644
@@ -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"
 
gfs2/mkfs/main_grow.c +0 -1
index ad80a8d9..7e56d2cd 100644
@@ -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>
gfs2/mkfs/main_jadd.c +0 -7
index efe91e30..2a64f390 100644
@@ -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);
gfs2/mkfs/main_mkfs.c +3 -11
index 7aeae695..d65aafd7 100644
@@ -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)
gfs2/tune/super.c +3 -15
index f4b7d85b..73af0bb3 100644
@@ -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)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 libgfs2: Import gfs2_ondisk.h

Quoted 5 lines · Andrew Price

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.

Quoted 7 lines

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..

#2 lore raw

PATCH 1/1 libgfs2: Import gfs2_ondisk.h

Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Andrew Price

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.:

Quoted 6 lines
Quoted 4 lines

:%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.

Quoted 2 lines

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.

Quoted 3 lines

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

#3 lore raw

PATCH 1/1 libgfs2: Import gfs2_ondisk.h

Hi,

Quoted 23 lines · Andrew Price
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Andrew Price

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.:

Quoted 6 lines
Quoted 4 lines

:%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.

Quoted 8 lines
Quoted 2 lines

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.

Quoted 11 lines
Quoted 4 lines

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.

#4 lore raw

PATCH 1/1 libgfs2: Import gfs2_ondisk.h

Quoted 4 lines · Steven Whitehouse

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).

#5 lore raw

PATCH 1/1 libgfs2: Import gfs2_ondisk.h

Revisiting this...

Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Steven Whitehouse

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

#6 lore raw

PATCH 1/1 libgfs2: Import gfs2_ondisk.h

In reply to Steven Whitehouse
Quoted 29 lines · Steven Whitehouse

Hi,

Quoted 26 lines · Andrew Price
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Andrew Price

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.:

Quoted 6 lines
Quoted 4 lines

:%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.

Quoted 2 lines

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

Quoted 8 lines
Quoted 5 lines

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.

Quoted 3 lines

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

#7 lore raw

PATCH 1/1 libgfs2: Import gfs2_ondisk.h

Hi,

Quoted 38 lines · Andrew Price
Quoted 35 lines · Steven Whitehouse

Hi,

Quoted 31 lines · Andrew Price
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Andrew Price

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.:

Quoted 6 lines
Quoted 4 lines

:%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.

Quoted 2 lines

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.

Quoted 9 lines
Quoted 2 lines

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.

#8 lore raw

PATCH 1/1 libgfs2: Import gfs2_ondisk.h

Quoted 21 lines · Steven Whitehouse
Quoted 10 lines · Andrew Price
Quoted 2 lines · Steven Whitehouse

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.

Quoted 7 lines

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