gfs2-utils: Import linux/gfs2_ondisk.h
v2 cover gfs2-utils: Import linux/gfs2_ondisk.h
v1: https://listman.redhat.com/archives/cluster-devel/2019-April/msg00021.html
My previous attempt at this did a search+replace to satisfy the field types in gfs2_ondisk.h, which was a little OTT. This attempt adds a linux/types.h that gfs2_ondisk.h will pick up instead of the kernel one.
Having our own gfs2_ondisk.h means that we can support new gfs2 features unconditionally and more easily experiment with on-disk changes; we can use the PRI* macros from inttypes.h for consistent string formatting (appease -Wformat) across architectures, and it gets us closer to being able to compile gfs2-utils on non-linux systems.
Andy
Andrew Price (8):
Import linux/gfs2_ondisk.h
Remove HAS_UUID conditionals
Remove GFS2_HAS_LEAF_HINTS conditionals
Remove GFS2_HAS_DE_RAHEAD/COOKIE conditionals
Remove GFS2_HAS_RG_SKIP conditionals
Remove GFS2_HAS_RG_RI_FIELDS conditionals
Remove GFS2_HAS_LH_V2 conditionals
Use PRI* when printing gfs2 structures
configure.ac | 25 +- gfs2/convert/gfs2_convert.c | 2 - gfs2/edit/extended.c | 54 ++-- gfs2/edit/gfs2hex.c | 45 ++- gfs2/edit/hexedit.c | 2 - gfs2/edit/hexedit.h | 1 - gfs2/edit/journal.c | 15 +- gfs2/edit/savemeta.c | 2 - gfs2/fsck/fs_recovery.c | 10 +- gfs2/fsck/initialize.c | 47 ++- gfs2/fsck/lost_n_found.c | 10 +- gfs2/fsck/pass1.c | 5 +- gfs2/fsck/pass2.c | 2 +- gfs2/fsck/rgrepair.c | 37 +-- gfs2/include/Makefile.am | 2 + gfs2/include/gfs2_ondisk.h | 542 +++++++++++++++++++++++++++++++++ gfs2/include/linux/types.h | 32 ++ gfs2/libgfs2/buf.c | 1 - gfs2/libgfs2/device_geometry.c | 1 - gfs2/libgfs2/fs_ops.c | 7 - gfs2/libgfs2/gfs1.c | 2 - gfs2/libgfs2/lang.c | 11 +- gfs2/libgfs2/libgfs2.h | 6 +- gfs2/libgfs2/meta.c | 27 +- gfs2/libgfs2/ondisk.c | 266 ++++++---------- gfs2/libgfs2/recovery.c | 2 - gfs2/libgfs2/rgrp.c | 8 - gfs2/libgfs2/structures.c | 24 +- gfs2/mkfs/gfs2_mkfs.h | 1 - gfs2/mkfs/main_grow.c | 1 - gfs2/mkfs/main_jadd.c | 10 +- gfs2/mkfs/main_mkfs.c | 17 +- gfs2/tune/super.c | 17 +- 33 files changed, 773 insertions(+), 461 deletions(-) create mode 100644 gfs2/include/gfs2_ondisk.h create mode 100644 gfs2/include/linux/types.h
Signature · 1 line
2.30.2
PATCH v2 1/8 Import linux/gfs2_ondisk.h
Give gfs2-utils its own copy of gfs2_ondisk.h. This allows us to always support the latest ondisk structures and obsoletes a lot of #ifdef GFS2_HAS_<FEATURE> blocks and configure.ac checks.
Provide the kernel int typedefs that gfs2_ondisk.h uses with our own linux/types.h, which uses standard userspace types but keeps the bitwise attribute tags that sparse uses.
Remove a bunch of unnecessary #include statements in the utils so that linux/gfs2_ondisk.h is never included and (our) linux/types.h is only ever included in libgfs2.h.
--- configure.ac | 2 - gfs2/convert/gfs2_convert.c | 2 - gfs2/edit/extended.c | 2 - gfs2/edit/gfs2hex.c | 5 - gfs2/edit/hexedit.c | 2 - gfs2/edit/hexedit.h | 1 - gfs2/edit/journal.c | 2 - gfs2/edit/savemeta.c | 2 - gfs2/include/Makefile.am | 2 + gfs2/include/gfs2_ondisk.h | 542 +++++++++++++++++++++++++++++++++ gfs2/include/linux/types.h | 32 ++ gfs2/libgfs2/buf.c | 1 - gfs2/libgfs2/device_geometry.c | 1 - gfs2/libgfs2/fs_ops.c | 1 - gfs2/libgfs2/gfs1.c | 2 - gfs2/libgfs2/libgfs2.h | 3 +- gfs2/libgfs2/ondisk.c | 1 - gfs2/libgfs2/structures.c | 1 - gfs2/mkfs/gfs2_mkfs.h | 1 - gfs2/mkfs/main_grow.c | 1 - gfs2/mkfs/main_jadd.c | 1 - gfs2/mkfs/main_mkfs.c | 1 - gfs2/tune/super.c | 1 - 23 files changed, 577 insertions(+), 32 deletions(-) create mode 100644 gfs2/include/gfs2_ondisk.h create mode 100644 gfs2/include/linux/types.h
configure.ac +0 -2
@@ -127,9 +127,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])],
gfs2/convert/gfs2_convert.c +0 -2
@@ -28,8 +28,6 @@#include <locale.h> #define _ (String) gettext(String) -#include <linux/types.h> -#include <linux/gfs2_ondisk.h> #include <logging.h> #include "osi_list.h" #include "copyright.cf"
gfs2/edit/extended.c +0 -2
@@ -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,6 @@#include <sys/mount.h> #include <dirent.h> -#include <linux/gfs2_ondisk.h> #include "copyright.cf" #include "hexedit.h"
gfs2/edit/gfs2hex.c +0 -5
@@ -5,7 +5,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>
@@ -13,10 +12,6 @@#include <curses.h> #include "hexedit.h" - -#define WANT_GFS_CONVERSION_FUNCTIONS -#include <linux/gfs2_ondisk.h> -#include "extended.h" #include "gfs2hex.h" #include "libgfs2.h"
gfs2/edit/hexedit.c +0 -2
@@ -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,6 @@#include <sys/mount.h> #include <dirent.h> -#include <linux/gfs2_ondisk.h> #include "copyright.cf" #include "hexedit.h"
gfs2/edit/hexedit.h +0 -1
@@ -4,7 +4,6 @@#include <sys/types.h> #include <inttypes.h> #include <limits.h> -#include <linux/gfs2_ondisk.h> #include <string.h> #include "libgfs2.h"
gfs2/edit/journal.c +0 -2
@@ -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,6 @@#include <sys/mount.h> #include <dirent.h> -#include <linux/gfs2_ondisk.h> #include "copyright.cf" #include "hexedit.h"
gfs2/edit/savemeta.c +0 -2
@@ -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,6 @@#include <sys/ioctl.h> #include <limits.h> #include <sys/time.h> -#include <linux/gfs2_ondisk.h> #include <zlib.h> #include <bzlib.h> #include <time.h>
gfs2/include/Makefile.am +2 -0
@@ -4,4 +4,6 @@ noinst_HEADERS = \ osi_list.h \ osi_tree.h \ linux_endian.h \ + gfs2_ondisk.h \ + linux/types.h \ logging.h
gfs2/include/gfs2_ondisk.h new file +542 -0
542 lines not on this page · raw message
gfs2/include/linux/types.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef LINUX_TYPES_H +#define LINUX_TYPES_H + +/* Satisfy gfs2_ondisk.h with userspace definitions of kernel types */ + +#include <stdint.h> + +#ifdef __CHECKER__ +#define __bitwise__ __attribute__((bitwise)) +#else +#define __bitwise__ +#endif +#define __bitwise __bitwise__ + +typedef uint8_t __u8 ; +typedef uint16_t __u16 ; +typedef uint32_t __u32 ; +typedef uint64_t __u64 ; + +typedef int8_t __s8 ; +typedef int16_t __s16 ; +typedef int32_t __s32 ; +typedef int64_t __s64 ; + +typedef __u16 __bitwise __le16 ; +typedef __u16 __bitwise __be16 ; +typedef __u32 __bitwise __le32 ; +typedef __u32 __bitwise __be32 ; +typedef __u64 __bitwise __le64 ; +typedef __u64 __bitwise __be64 ; + +#endif /* LINUX_TYPES_H */
gfs2/libgfs2/buf.c +0 -1
@@ -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
@@ -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_ops.c +0 -1
@@ -11,7 +11,6 @@#include <unistd.h> #include <errno.h> -#include <linux/types.h> #include "libgfs2.h" #include "rgrp.h"
gfs2/libgfs2/gfs1.c +0 -2
@@ -10,8 +10,6 @@#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> -#include <linux/types.h> -#include <linux/gfs2_ondisk.h> #include "osi_list.h" #include "libgfs2.h"
gfs2/libgfs2/libgfs2.h +1 -2
@@ -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"
gfs2/libgfs2/ondisk.c +0 -1
@@ -6,7 +6,6 @@#include <stdint.h> #include <inttypes.h> #include <ctype.h> -#include <linux/types.h> #include "libgfs2.h" #ifdef GFS2_HAS_UUID #include <uuid.h>
gfs2/libgfs2/structures.c +0 -1
@@ -10,7 +10,6 @@#include <fcntl.h> #include <unistd.h> #include <errno.h> -#include <linux/types.h> #include <sys/time.h> #include "libgfs2.h"
gfs2/mkfs/gfs2_mkfs.h +0 -1
@@ -2,7 +2,6 @@#define __GFS2_MKFS_DOT_H__#include <stdarg.h> -#include <linux/gfs2_ondisk.h> #include "osi_list.h" #include "copyright.cf"
gfs2/mkfs/main_grow.c +0 -1
@@ -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 -1
@@ -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"
gfs2/mkfs/main_mkfs.c +0 -1
@@ -25,7 +25,6 @@#define _ (String) gettext(String) -#include <linux/types.h> #include "libgfs2.h" #include "gfs2_mkfs.h" #include "progress.h"
gfs2/tune/super.c +0 -1
@@ -11,7 +11,6 @@#include <libintl.h> #define _ (String) gettext(String)#include <linux_endian.h> -#include <linux/gfs2_ondisk.h> #include <libgfs2.h> #include "tunegfs2.h"
Signature · 1 line
2.30.2
PATCH v2 1/8 Import linux/gfs2_ondisk.h
Andy,
gfs2/include/gfs2_ondisk.h
Quoted 5 lines · Andrew Price
gfs2/include/gfs2_ondisk.h new file +0
-0
any reason why this file shouldn't be at gfs2/include/linux/gfs2_ondisk.h?
Thanks,
Andreas
PATCH v2 1/8 Import linux/gfs2_ondisk.h
Quoted 10 lines · Andreas Gruenbacher
Andy,
gfs2/include/gfs2_ondisk.h
Quoted 5 lines · Andrew Price
gfs2/include/gfs2_ondisk.h new file +0
-0any reason why this file shouldn't be at
gfs2/include/linux/gfs2_ondisk.h?
I didn't feel it was needed, but it does have the benefit of making sure we're not picking up the system linux/gfs2_ondisk.h when we #include <gfs2_ondisk.h> and it shows clearly that we're not trying to.
Andy
PATCH v2 1/8 Import linux/gfs2_ondisk.h
Quoted 12 lines · Andrew Price
Quoted 10 lines · Andreas Gruenbacher
Andy,
gfs2/include/gfs2_ondisk.h
Quoted 5 lines · Andrew Price
gfs2/include/gfs2_ondisk.h new file +0
-0any reason why this file shouldn't be at
gfs2/include/linux/gfs2_ondisk.h?
Quoted 3 lines
I didn't feel it was needed, but it does have the benefit of making sure we're not picking up the system
linux/gfs2_ondisk.hwhen we #include <gfs2_ondisk.h> and it shows clearly that we're not trying to.
Well, we have "-I$(top_srcdir)/gfs2/include" in CPPFLAGS so gfs2/include/linux/types.h is picked up by <linux/types.h>. We already rely on that working. So gfs2/include/linux/gfs2_ondisk.h would be picked up by <linux/gfs2_ondisk.h> already anyway.
Andreas
PATCH v2 1/8 Import linux/gfs2_ondisk.h
Quoted 13 lines · Andreas Gruenbacher
Quoted 12 lines · Andrew Price
Quoted 10 lines · Andreas Gruenbacher
Andy,
gfs2/include/gfs2_ondisk.h
Quoted 5 lines · Andrew Price
gfs2/include/gfs2_ondisk.h new file +0
-0any reason why this file shouldn't be at
gfs2/include/linux/gfs2_ondisk.h?
Quoted 8 lines
Quoted 3 lines
I didn't feel it was needed, but it does have the benefit of making sure we're not picking up the system
linux/gfs2_ondisk.hwhen we #include <gfs2_ondisk.h> and it shows clearly that we're not trying to.Well, we have "-I$(top_srcdir)/gfs2/include" in CPPFLAGS so
gfs2/include/linux/types.his picked up by <linux/types.h>. We already rely on that working. Sogfs2/include/linux/gfs2_ondisk.hwould be picked up by <linux/gfs2_ondisk.h> already anyway.
So, what would be the advantage of having gfs2_ondisk.h in gfs2/include/linux/? I put types.h in that directory because I didn't want to change the #include statement, but I didn't see a reason to put gfs2_ondisk.h in there.
Andy
PATCH v2 1/8 Import linux/gfs2_ondisk.h
Quoted 23 lines · Andrew Price
Quoted 13 lines · Andreas Gruenbacher
Quoted 12 lines · Andrew Price
Quoted 10 lines · Andreas Gruenbacher
Andy,
gfs2/include/gfs2_ondisk.h
Quoted 5 lines · Andrew Price
gfs2/include/gfs2_ondisk.h new file +0
-0any reason why this file shouldn't be at
gfs2/include/linux/gfs2_ondisk.h?Quoted 8 lines
Quoted 3 lines
I didn't feel it was needed, but it does have the benefit of making sure we're not picking up the system
linux/gfs2_ondisk.hwhen we #include <gfs2_ondisk.h> and it shows clearly that we're not trying to.Well, we have "-I$(top_srcdir)/gfs2/include" in CPPFLAGS so
gfs2/include/linux/types.his picked up by <linux/types.h>. We already rely on that working. Sogfs2/include/linux/gfs2_ondisk.hwould be picked up by <linux/gfs2_ondisk.h> already anyway.
Quoted 4 lines
So, what would be the advantage of having
gfs2_ondisk.hin gfs2/include/linux/? I puttypes.hin that directory because I didn't want to change the #include statement, but I didn't see a reason to putgfs2_ondisk.hin there.
It's more consistent if the definitions are always included as <linux/gfs2_ondisk.h> by the kernel and by all user-space programs.
Andreas
PATCH v2 1/8 Import linux/gfs2_ondisk.h
Quoted 24 lines · Andreas Gruenbacher
Quoted 23 lines · Andrew Price
Quoted 21 lines · Andreas Gruenbacher
Quoted 12 lines · Andrew Price
Quoted 10 lines · Andreas Gruenbacher
Andy,
gfs2/include/gfs2_ondisk.h
Quoted 5 lines · Andrew Price
gfs2/include/gfs2_ondisk.h new file +0
-0any reason why this file shouldn't be at
gfs2/include/linux/gfs2_ondisk.h?Quoted 3 lines
I didn't feel it was needed, but it does have the benefit of making sure we're not picking up the system
linux/gfs2_ondisk.hwhen we #include <gfs2_ondisk.h> and it shows clearly that we're not trying to.Well, we have "-I$(top_srcdir)/gfs2/include" in CPPFLAGS so
gfs2/include/linux/types.his picked up by <linux/types.h>. We already rely on that working. Sogfs2/include/linux/gfs2_ondisk.hwould be picked up by <linux/gfs2_ondisk.h> already anyway.
Quoted 7 lines
Quoted 4 lines
So, what would be the advantage of having
gfs2_ondisk.hin gfs2/include/linux/? I puttypes.hin that directory because I didn't want to change the #include statement, but I didn't see a reason to putgfs2_ondisk.hin there.It's more consistent if the definitions are always included as <
linux/gfs2_ondisk.h> by the kernel and by all user-space programs.
Hmm, I guess. I've moved it into gfs2/include/linux/ in my local branch and I'll push it with that change later, barring objections.
Andy
PATCH v2 2/8 Remove HAS_UUID conditionals
In reply to Andrew PriceNow that we own our own gfs2_ondisk.h we know that it has sb_uuid so we can use it unconditionally (and require libuuid unconditionally).
--- configure.ac | 11 +---------- gfs2/edit/gfs2hex.c | 12 +++--------- gfs2/libgfs2/lang.c | 11 +---------- gfs2/libgfs2/meta.c | 9 +-------- gfs2/libgfs2/ondisk.c | 16 +++------------- gfs2/libgfs2/structures.c | 7 +------ gfs2/mkfs/main_mkfs.c | 16 +++++----------- gfs2/tune/super.c | 16 ++-------------- 8 files changed, 17 insertions(+), 81 deletions(-)
configure.ac +1 -10
@@ -106,9 +106,7 @@ AM_CONDITIONAL([HAVE_CHECK], [test "x$have_check" = "xyes"]) PKG_CHECK_MODULES([zlib],[zlib]) PKG_CHECK_MODULES([bzip2],[bzip2]) PKG_CHECK_MODULES([blkid],[blkid]) -PKG_CHECK_MODULES([uuid],[uuid], - [have_uuid=yes], - [have_uuid=no]) +PKG_CHECK_MODULES([uuid],[uuid]) # old versions of ncurses don't ship pkg-config files PKG_CHECK_MODULES([ncurses],[ncurses],,
@@ -128,8 +126,6 @@ AC_SUBST([udevdir], [$with_udevdir]) 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/limits.h], [], [AC_MSG_ERROR([Unable to find linux/limits.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])],
@@ -143,11 +139,6 @@ AC_CHECK_MEMBER([struct gfs2_rgrp.rg_data0],[AC_DEFINE([GFS2_HAS_RG_RI_FIELDS],[ 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 - AC_MSG_ERROR([libuuid is required for this version of gfs2]) -fi - # *FLAGS handling ENV_CFLAGS="$CFLAGS" ENV_CPPFLAGS="$CPPFLAGS"
gfs2/edit/gfs2hex.c +3 -9
@@ -10,14 +10,12 @@#include <unistd.h> #include <errno.h> #include <curses.h> +#include <uuid.h> #include "hexedit.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); \
@@ -386,6 +384,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" );
@@ -410,14 +410,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/libgfs2/lang.c +1 -10
@@ -7,12 +7,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(char *buf, uint64_t addr, const struct lgfs2_metadata *mtprintf ("%s\t%" PRIu64"\t%u\t%u\t%s\t" , mtype->name, addr, 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 {
@@ -471,7 +467,6 @@ static int ast_field_set(char *buf, const struct lgfs2_metafield *field,int err =0 ;if (field->flags &LGFS2_MFF_UUID ) { -#ifdef GFS2_HAS_UUID uuid_t uuid;if (uuid_parse (val->ast_str, uuid) !=0 ) {
@@ -479,10 +474,6 @@ static int ast_field_set(char *buf, const struct lgfs2_metafield *field,return AST_INTERP_INVAL ; } err =lgfs2_field_assign (buf, field, uuid); -#else -fprintf (stderr,"No UUID support\n" ); - err =1 ; -#endif }else if (field->flags &LGFS2_MFF_STRING ) { err =lgfs2_field_assign (buf, field, val->ast_str); }else {
gfs2/libgfs2/meta.c +1 -8
@@ -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 },
@@ -183,9 +180,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
@@ -880,14 +875,12 @@ int lgfs2_field_str(char *str, const size_t size, const char *blk, const structreturn 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 +3 -13
@@ -6,10 +6,8 @@#include <stdint.h> #include <inttypes.h> #include <ctype.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); \
@@ -112,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)
@@ -139,13 +135,13 @@ 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" );
@@ -160,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)
gfs2/libgfs2/structures.c +1 -6
@@ -11,15 +11,12 @@#include <unistd.h> #include <errno.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;
@@ -62,9 +59,7 @@ void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize, unsigned format) 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)
gfs2/mkfs/main_mkfs.c +5 -11
@@ -22,6 +22,7 @@#include <limits.h> #include <blkid.h> #include <locale.h> +#include <uuid.h> #define _ (String) gettext(String)
@@ -29,10 +30,6 @@#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;
@@ -640,6 +637,10 @@ static int 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 ]; + +uuid_unparse (sb->sb_uuid, readable_uuid); +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:"),
@@ -653,15 +654,8 @@ static void print_results(struct gfs2_sb *sb, struct mkfs_opts *opts, uint64_t rprintf ("%-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 int warn_of_destruction (const char *path)
gfs2/tune/super.c +2 -14
@@ -12,11 +12,8 @@#define _ (String) gettext(String)#include <linux_endian.h> #include <libgfs2.h> -#include "tunegfs2.h" - -#ifdef GFS2_HAS_UUID #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 ];uuid_unparse (tfs->sb->sb_uuid, readable_uuid); +printf (_ ("File system volume name: %s\n" ), tfs->sb->sb_locktable);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 (_ ("File system format version: %" PRIu32"\n" ),be32_to_cpu (tfs->sb->sb_fs_format));printf (_ ("Block size: %d\n" ),be32_to_cpu (tfs->sb->sb_bsize));
@@ -89,7 +82,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;
@@ -97,10 +89,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.30.2
PATCH v2 3/8 Remove GFS2_HAS_LEAF_HINTS conditionals
In reply to Andrew PriceOur own gfs2_ondisk.h has leaf hints so there's no need for these conditionals.
--- configure.ac | 2 -- gfs2/edit/extended.c | 9 ++------- gfs2/libgfs2/fs_ops.c | 6 ------ gfs2/libgfs2/ondisk.c | 10 ---------- 4 files changed, 2 insertions(+), 25 deletions(-)
configure.ac +0 -2
@@ -126,8 +126,6 @@ AC_SUBST([udevdir], [$with_udevdir]) 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/limits.h], [], [AC_MSG_ERROR([Unable to find linux/limits.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])],
gfs2/edit/extended.c +2 -7
@@ -294,14 +294,9 @@ 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_FMTS "lf_inode: 0x%"PRIx64", lf_dist: %"PRIu32", " \ + "lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "#define LEAF_HINT_FIELDS (lp) lp->lf_inode, lp->lf_dist, lp->lf_nsec, lp->lf_sec, -#else -#define LEAF_HINT_FMTS -#define LEAF_HINT_FIELDS (lp) -#endif static int display_leaf (struct iinfo *ind) {
gfs2/libgfs2/fs_ops.c +0 -6
@@ -1001,9 +1001,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);
@@ -1203,9 +1201,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;
@@ -1257,9 +1253,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/ondisk.c +0 -10
@@ -448,15 +448,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)
@@ -468,15 +464,11 @@ 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)
@@ -486,12 +478,10 @@ void gfs2_leaf_print(const struct gfs2_leaf *lf)pv (lf, lf_entries,"%u" ,"0x%x" );pv (lf, lf_dirent_format,"%u" ,"0x%x" );pv (lf, lf_next,"%llu" ,"0x%llx" ); -#ifdef GFS2_HAS_LEAF_HINTS pv (lf, lf_inode,"%llu" ,"0x%llx" );pv (lf, lf_dist,"%u" ,"0x%x" );pv (lf, lf_nsec,"%u" ,"0x%x" );pv (lf, lf_sec,"%llu" ,"0x%llx" ); -#endif }void gfs2_ea_header_in (struct gfs2_ea_header *ea,char *buf)
Signature · 1 line
2.30.2
PATCH v2 4/8 Remove GFS2_HAS_DE_RAHEAD/COOKIE conditionals
In reply to Andrew PriceOur own gfs2_ondisk.h has de_rahead and de_cookie so there's no need for these conditionals.
--- configure.ac | 4 ---- gfs2/edit/extended.c | 8 ++------ gfs2/libgfs2/meta.c | 8 -------- gfs2/libgfs2/ondisk.c | 16 ---------------- 4 files changed, 2 insertions(+), 34 deletions(-)
configure.ac +0 -4
@@ -126,10 +126,6 @@ AC_SUBST([udevdir], [$with_udevdir]) 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/limits.h], [], [AC_MSG_ERROR([Unable to find linux/limits.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])],
gfs2/edit/extended.c +2 -6
@@ -335,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] %lld/%" PRId64" (0x%llx/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);
gfs2/libgfs2/meta.c +0 -8
@@ -481,17 +481,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
gfs2/libgfs2/ondisk.c +0 -16
@@ -404,17 +404,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)
@@ -426,17 +418,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)
Signature · 1 line
2.30.2
PATCH v2 5/8 Remove GFS2_HAS_RG_SKIP conditionals
In reply to Andrew PriceOur own gfs2_ondisk.h has rg_skip so there's no need for these conditionals.
--- configure.ac | 2 -- gfs2/libgfs2/meta.c | 4 ---- gfs2/libgfs2/ondisk.c | 12 ------------ gfs2/libgfs2/rgrp.c | 2 -- 4 files changed, 20 deletions(-)
configure.ac +0 -2
@@ -126,8 +126,6 @@ AC_SUBST([udevdir], [$with_udevdir]) 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/limits.h], [], [AC_MSG_ERROR([Unable to find linux/limits.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])],
gfs2/libgfs2/meta.c +0 -4
@@ -225,11 +225,7 @@ 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))
gfs2/libgfs2/ondisk.c +0 -12
@@ -208,11 +208,7 @@ 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);
@@ -231,11 +227,7 @@ 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);
@@ -254,11 +246,7 @@ void gfs2_rgrp_print(const struct gfs2_rgrp *rg)pv (rg, rg_flags,"%u" ,"0x%x" );pv (rg, rg_free,"%u" ,"0x%x" );pv (rg, rg_dinodes,"%u" ,"0x%x" ); -#ifdef GFS2_HAS_RG_SKIP pv (rg, rg_skip,"%u" ,"0x%x" ); -#else -pv (rg, __pad,"%u" ,"0x%x" ); -#endif pv (rg, rg_igeneration,"%llu" ,"0x%llx" );#ifdef GFS2_HAS_RG_RI_FIELDS pv (rg, rg_data0,"%llu" ,"0x%llx" );
gfs2/libgfs2/rgrp.c +0 -2
@@ -673,9 +673,7 @@ 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;
Signature · 1 line
2.30.2
PATCH v2 6/8 Remove GFS2_HAS_RG_RI_FIELDS conditionals
In reply to Andrew PriceOur own gfs2_ondisk.h has the new rgrp fields so there's no need for these conditionals.
--- configure.ac | 2 -- gfs2/libgfs2/meta.c | 2 -- gfs2/libgfs2/ondisk.c | 8 -------- gfs2/libgfs2/rgrp.c | 6 ------ 4 files changed, 18 deletions(-)
configure.ac +0 -2
@@ -126,8 +126,6 @@ AC_SUBST([udevdir], [$with_udevdir]) 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/limits.h], [], [AC_MSG_ERROR([Unable to find linux/limits.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>]])
gfs2/libgfs2/meta.c +0 -2
@@ -227,12 +227,10 @@ F(rg_free, .flags = LGFS2_MFF_FSBLOCKS) F(rg_dinodes, .flags = LGFS2_MFF_FSBLOCKS) FP(rg_skip, .points_to = (1 << LGFS2_MT_GFS2_RGRP))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) };
gfs2/libgfs2/ondisk.c +0 -8
@@ -210,12 +210,10 @@ void gfs2_rgrp_in(struct gfs2_rgrp *rg, char *buf)CPIN_32 (rg, str, rg_dinodes);CPIN_32 (rg, str, rg_skip);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)); }
@@ -229,15 +227,11 @@ void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf)CPOUT_32 (rg, str, rg_dinodes);CPOUT_32 (rg, str, rg_skip);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)
@@ -248,12 +242,10 @@ void gfs2_rgrp_print(const struct gfs2_rgrp *rg)pv (rg, rg_dinodes,"%u" ,"0x%x" );pv (rg, rg_skip,"%u" ,"0x%x" );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 }void gfs2_quota_in (struct gfs2_quota *qu,char *buf)
gfs2/libgfs2/rgrp.c +0 -6
@@ -156,7 +156,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;
@@ -167,7 +166,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; }
@@ -176,14 +174,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 }/**
@@ -674,12 +670,10 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, ui rg->rg.rg_header.mh_format =GFS2_FORMAT_RG ; rg->rg.rg_free = rg->ri.ri_data; rg->rg.rg_skip = rg_skip; -#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;
Signature · 1 line
2.30.2
PATCH v2 7/8 Remove GFS2_HAS_LH_V2 conditionals
In reply to Andrew PriceOur own gfs2_ondisk.h has v2 log headers so there's no need for these conditionals. There aren't any users of gfs2_log_header_v1_*() functions so fold those into gfs2_log_header*().
--- configure.ac | 2 -- gfs2/libgfs2/libgfs2.h | 3 --- gfs2/libgfs2/meta.c | 4 ---- gfs2/libgfs2/ondisk.c | 35 +++-------------------------------- gfs2/libgfs2/recovery.c | 2 -- gfs2/libgfs2/structures.c | 16 ++-------------- gfs2/mkfs/main_jadd.c | 9 +-------- 7 files changed, 6 insertions(+), 65 deletions(-)
configure.ac +0 -2
@@ -126,8 +126,6 @@ AC_SUBST([udevdir], [$with_udevdir]) 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/limits.h], [], [AC_MSG_ERROR([Unable to find linux/limits.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>]]) # *FLAGS handling ENV_CFLAGS="$CFLAGS"
gfs2/libgfs2/libgfs2.h +0 -3
@@ -715,9 +715,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);
@@ -737,7 +735,6 @@ extern void gfs2_quota_print(const struct gfs2_quota *qu);extern void gfs2_dinode_print (const struct gfs2_dinode *di);extern void gfs2_leaf_print (const struct gfs2_leaf *lf);extern void gfs2_ea_header_print (const struct gfs2_ea_header *ea,char *name); -extern void gfs2_log_header_v1_print (const struct gfs2_log_header *lh);extern void gfs2_log_header_print (const struct gfs2_log_header *lh);extern void gfs2_log_descriptor_print (const struct gfs2_log_descriptor *ld);extern void gfs2_statfs_change_print (const struct gfs2_statfs_change *sc);
gfs2/libgfs2/meta.c +0 -4
@@ -69,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 )
@@ -97,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);
@@ -381,7 +379,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)
@@ -392,7 +389,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
gfs2/libgfs2/ondisk.c +3 -32
@@ -476,7 +476,7 @@ void gfs2_ea_header_print(const struct gfs2_ea_header *ea, char *name)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;
@@ -486,15 +486,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);
@@ -505,11 +496,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;
@@ -519,15 +508,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);
@@ -538,11 +518,9 @@ 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" );
@@ -550,12 +528,6 @@ void gfs2_log_header_v1_print(const struct gfs2_log_header *lh)pv (lh, lh_tail,"%u" ,"0x%x" );pv (lh, lh_blkno,"%u" ,"0x%x" );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" );
@@ -566,7 +538,6 @@ void gfs2_log_header_print(const struct gfs2_log_header *lh)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 }void gfs2_log_descriptor_in (struct gfs2_log_descriptor *ld,char *buf)
gfs2/libgfs2/recovery.c +0 -2
@@ -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/structures.c +2 -14
@@ -107,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 }/**
@@ -135,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,
@@ -146,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_sbd *sdp = ip->i_sbd;unsigned blocks = (ip->i_di.di_size + sdp->bsize -1 ) / sdp->bsize;
@@ -170,10 +162,9 @@ int lgfs2_write_journal_data(struct gfs2_inode *ip)gfs2_log_header_out (&lh, buf); buflh->lh_hash =cpu_to_be32 (lgfs2_log_header_hash (buf)); -#ifdef GFS2_HAS_LH_V2 buflh->lh_addr =cpu_to_be64 (jblk); buflh->lh_crc =cpu_to_be32 (lgfs2_log_header_crc (buf, sdp->bsize)); -#endif +if (pwrite (sdp->device_fd, buf, sdp->bsize, jblk * sdp->bsize) != sdp->bsize) {free (buf);return -1 ;
@@ -230,10 +221,9 @@ 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,1 );if (!bh)
@@ -253,11 +243,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/main_jadd.c +1 -8
@@ -456,7 +456,6 @@ out:return ret; } -#ifdef GFS2_HAS_LH_V2 static uint64_t find_block_address (int fd,off_t offset,unsigned bsize) {struct {
@@ -477,7 +476,6 @@ static uint64_t find_block_address(int fd, off_t offset, unsigned bsize) }return fme.fe.fe_physical / bsize; } -#endif static int alloc_new_journal (int fd,unsigned bytes) {
@@ -551,21 +549,17 @@ static int 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; -#ifdef GFS2_HAS_LH_V2 uint64_t blk_addr =0 ; -#endif lh.lh_sequence = seq; lh.lh_blkno = x;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 if (!(blk_addr =find_block_address (fd, off, sdp->bsize))) { error =-1 ; goto close_fd;
@@ -573,7 +567,6 @@ static int add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts) ((struct gfs2_log_header *)buf)->lh_addr =cpu_to_be64 (blk_addr); 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 write" ); error =-1 ;
Signature · 1 line
2.30.2
PATCH v2 8/8 Use PRI* when printing gfs2 structures
In reply to Andrew PriceNow that we have gfs2 structs defined in terms of standard userspace types instead of kernel types we can use these defines from inttypes.h to print their fields in a consistent way across architectures.
Fixes a number of -Wformat warnings on x86_64.
--- gfs2/edit/extended.c | 37 ++++----- gfs2/edit/gfs2hex.c | 28 +++---- gfs2/edit/journal.c | 13 ++- gfs2/fsck/fs_recovery.c | 10 +-- gfs2/fsck/initialize.c | 47 ++++++----- gfs2/fsck/lost_n_found.c | 10 +-- gfs2/fsck/pass1.c | 5 +- gfs2/fsck/pass2.c | 2 +- gfs2/fsck/rgrepair.c | 37 ++++----- gfs2/libgfs2/ondisk.c | 168 +++++++++++++++++++-------------------- 10 files changed, 170 insertions(+), 187 deletions(-)
gfs2/edit/extended.c +17 -20
@@ -308,9 +308,9 @@ static int display_leaf(struct iinfo *ind)if (gfs2_struct_type ==GFS2_METATYPE_SB )print_gfs2 ("The superblock has 2 directories" );else - print_gfs2("Directory block: lf_depth:%d, lf_entries:%d, " + print_gfs2("Directory block: lf_depth:%"PRIu16", lf_entries:%"PRIu16", " LEAF_HINT_FMTS - "fmt:%d next=0x%llx (%d dirents).", + "fmt:%"PRIu32" next=0x%"PRIx64" (%d dirents).", leaf->lf_depth, leaf->lf_entries, LEAF_HINT_FIELDS(leaf) leaf->lf_dirent_format,
@@ -330,12 +330,11 @@ static int display_leaf(struct iinfo *ind) line - start_line - 1 == edit_row[dmode] - start_row[dmode]) {COLORS_HIGHLIGHT ; -sprintf (estring,"%llx" , - (unsigned long long )ind->ii[0 ].dirent[d].block); +sprintf (estring,"%" PRIx64, ind->ii[0 ].dirent[d].block);strcpy (edit_fmt,"%llx" ); } } - print_gfs2("%d/%d [%08x] %lld/%"PRId64" (0x%llx/0x%"PRIx64") +%"PRIu16": ", + print_gfs2("%d/%d [%08"PRIX32"] %"PRIu64"/%"PRIu64" (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,
@@ -388,11 +387,9 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,while (thisblk) {/* read in the desired block */ if (pread (sbd.device_fd, tmpbuf, sbd.bsize, thisblk * sbd.bsize) != sbd.bsize) { -fprintf (stderr,"bad read: %s from %s:%d: block %lld " -"(0x%llx)\n" ,strerror (errno), __FUNCTION__, - __LINE__, - (unsigned long long )ind->ii[pndx].block, - (unsigned long long )ind->ii[pndx].block); +fprintf (stderr,"bad read: %s from %s:%d: block %" PRIu64 +" (0x%" PRIx64")\n" ,strerror (errno), __FUNCTION__, + __LINE__, ind->ii[pndx].block, ind->ii[pndx].block);exit (-1 ); } thisblk =0 ;
@@ -428,9 +425,9 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,static void gfs_jindex_print (struct gfs_jindex *ji) { -pv ((unsigned long long )ji, ji_addr,"%llu" ,"0x%llx" ); -pv (ji, ji_nsegment,"%u" ,"0x%x" ); -pv (ji, ji_pad,"%u" ,"0x%x" ); +pv (ji, ji_addr,"%" PRIu64,"0x%" PRIx64); +pv (ji, ji_nsegment,"%" PRIu32,"0x%" PRIx32); +pv (ji, ji_pad,"%" PRIu32,"0x%" PRIx32); }static int print_gfs_jindex (struct gfs2_inode *dij)
@@ -440,7 +437,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 ;
@@ -458,7 +455,7 @@ static int print_gfs_jindex(struct gfs2_inode *dij)if (edit_row[dmode] == print_entry_ndx) {COLORS_HIGHLIGHT ;strcpy (efield,"ji_addr" ); -sprintf (estring,"%llx" , (unsigned long long )ji.ji_addr); +sprintf (estring,"%" PRIx64, ji.ji_addr); }print_gfs2 ("Journal #%d" , print_entry_ndx);eol (0 );
@@ -482,7 +479,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 );
@@ -509,7 +506,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 ;
@@ -531,11 +528,11 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex) termlines - start_line - 2)) {if (edit_row[dmode] == print_entry_ndx) {COLORS_HIGHLIGHT ; -sprintf (highlighted_addr,"%llx" , (unsigned long long )ri.ri_addr); +sprintf (highlighted_addr,"%" PRIx64, ri.ri_addr); }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)
@@ -619,7 +616,7 @@ static int print_quota(struct gfs2_inode *diq)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));
gfs2/edit/gfs2hex.c +14 -14
@@ -372,10 +372,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); }/**
@@ -388,15 +388,15 @@ static void gfs2_sb_print2(struct gfs2_sb *sbp2)gfs2_meta_header_print (&sbp2->sb_header); -pv (sbp2, sb_fs_format,"%u" ,"0x%x" ); -pv (sbp2, sb_multihost_format,"%u" ,"0x%x" ); +pv (sbp2, sb_fs_format,"%" PRIu32,"0x%" PRIx32); +pv (sbp2, sb_multihost_format,"%" PRIu32,"0x%" PRIx32);if (sbd.gfs1) -pv (sbd1, sb_flags,"%u" ,"0x%x" ); -pv (sbp2, sb_bsize,"%u" ,"0x%x" ); -pv (sbp2, sb_bsize_shift,"%u" ,"0x%x" ); +pv (sbd1, sb_flags,"%" PRIu32,"0x%" PRIx32); +pv (sbp2, sb_bsize,"%" PRIu32,"0x%" PRIx32); +pv (sbp2, sb_bsize_shift,"%" PRIu32,"0x%" PRIx32);if (sbd.gfs1) { -pv (sbd1, sb_seg_size,"%u" ,"0x%x" ); +pv (sbd1, sb_seg_size,"%" PRIu32,"0x%" PRIx32);gfs2_inum_print2 ("jindex ino" , &sbd1->sb_jindex_di);gfs2_inum_print2 ("rindex ino" , &sbd1->sb_rindex_di); }
@@ -438,14 +438,14 @@ static void gfs1_rgrp_in(struct gfs_rgrp *rgrp, const char *buf)static void gfs1_rgrp_print (struct gfs_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_useddi,"%u" ,"0x%x" ); -pv (rg, rg_freedi,"%u" ,"0x%x" ); +pv (rg, rg_flags,"%" PRIu32,"0x%" PRIx32); +pv (rg, rg_free,"%" PRIu32,"0x%" PRIx32); +pv (rg, rg_useddi,"%" PRIu32,"0x%" PRIx32); +pv (rg, rg_freedi,"%" PRIu32,"0x%" PRIx32);gfs2_inum_print (&rg->rg_freedi_list); -pv (rg, rg_usedmeta,"%u" ,"0x%x" ); -pv (rg, rg_freemeta,"%u" ,"0x%x" ); +pv (rg, rg_usedmeta,"%" PRIu32,"0x%" PRIx32); +pv (rg, rg_freemeta,"%" PRIu32,"0x%" PRIx32); }int display_gfs2 (char *buf)
gfs2/edit/journal.c +6 -7
@@ -534,7 +534,7 @@ 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, +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 +
@@ -544,8 +544,7 @@ void dump_journal(const char *journal, int tblk) *GFS2_NBBY ; bmap = o / sbd.sd_blocks_per_bitmap; bitblk = rgd->ri.ri_addr + bmap; -print_gfs2 ("bitmap: %d, bitblk: 0x%llx" , bmap, - (unsigned long long )bitblk); +print_gfs2 ("bitmap: %d, bitblk: 0x%" PRIx64, bmap, bitblk);eol (0 ); }
@@ -597,8 +596,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:%"PRIx32", 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,
@@ -612,8 +611,8 @@ void dump_journal(const char *journal, int tblk)lgfs2_field_str (flags_str,sizeof (flags_str), buf, 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]", + print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log header: Seq: " + "0x%"PRIx64", tail: 0x%"PRIx32", blk: 0x%"PRIx32" [%s]", abs_block, ((jb + wrappt) % j_size) / sbd.bsize, lh.lh_sequence, lh.lh_tail, lh.lh_blkno,
gfs2/fsck/fs_recovery.c +4 -6
@@ -428,19 +428,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 " +log_err (_ ("Journal block %" PRIu32" (0x%" PRIx32"): sequence no. 0x%" PRIx64" " "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_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 ,0 ); bh =bread (ip->i_sbd, dblock);gfs2_log_header_out (&lh, bh->b_data);
gfs2/fsck/initialize.c +23 -24
137 lines not on this page · raw message
gfs2/fsck/lost_n_found.c +5 -5
@@ -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" ));
gfs2/fsck/pass1.c +2 -3
@@ -2209,11 +2209,10 @@ int pass1(struct gfs2_sbd *sdp) goto out; } next =osi_next (n); -log_debug ("Checking metadata in resource group #%llu\n" , - (unsigned long long )rg_count); +log_debug ("Checking metadata in resource group #%" PRIu64"\n" , rg_count); rgd = (struct rgrp_tree *)n;for (i =0 ; i < rgd->ri.ri_length; i++) { -log_debug ("rgrp block %lld (0x%llx) is now marked as 'rgrp data'\n" , +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_BLKST_USED )) {
gfs2/fsck/pass2.c +1 -1
@@ -1947,7 +1947,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 +14 -23
@@ -414,11 +414,8 @@ 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" ), - prevrgd->ri.ri_addr, length, - (unsigned long long )used_blocks, - free_blocks); +log_info (_ ("rgrp found at 0x%" PRIx64", length=%d, used=%" PRIu64", free=%d\n" ), + prevrgd->ri.ri_addr, length, used_blocks, free_blocks);break ; } }
@@ -686,11 +683,9 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)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" -" / 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, +log_debug ("%d: 0x%" PRIx64"/%" PRIx32"/0x%" PRIx64"/0x%" PRIx32"/0x%" PRIx32"\n" , + rgi +1 , 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;
@@ -1138,16 +1133,14 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)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) ||
@@ -1155,9 +1148,8 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok) !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;
@@ -1199,10 +1191,9 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)damage, fill in a new one with the expected values. */ if (!n ||/* end of actual rindex */ expected->ri.ri_addr < actual->ri.ri_addr) { -log_err (_ ("Entry missing from rindex: 0x%llx\n" ), - (unsigned long long )expected->ri.ri_addr); - actual =rgrp_insert (&sdp->rgtree, - expected->ri.ri_addr); +log_err (_ ("Entry missing from rindex: 0x%" PRIx64"\n" ), + expected->ri.ri_addr); + actual =rgrp_insert (&sdp->rgtree, expected->ri.ri_addr);if (!actual) {log_err (_ ("Out of memory!\n" ));break ;
gfs2/libgfs2/ondisk.c +84 -84
252 lines not on this page · raw message
Signature · 1 line
2.30.2
v2 cover gfs2-utils: Import linux/gfs2_ondisk.h
In reply to Andrew PriceHi Andy,
Quoted 5 lines · Andrew Price
v1: https://listman.redhat.com/archives/cluster-devel/2019-April/msg00021.html
My previous attempt at this did a search+replace to satisfy the field types in
gfs2_ondisk.h, which was a little OTT. This attempt adds alinux/types.hthatgfs2_ondisk.hwill pick up instead of the kernel one.Having our own
gfs2_ondisk.hmeans that we can support new gfs2 features unconditionally and more easily experiment with on-disk changes; we can use the PRI* macros frominttypes.hfor consistent string formatting (appease -Wformat) across architectures, and it gets us closer to being able to compile gfs2-utils on non-linux systems.
this is looking good, thanks.
Andreas