From: Andrew Price Date: Mon, 15 Feb 2016 13:41:42 +0000 Subject: [Cluster-devel] [PATCH] libgfs2: Support the new dirent de_cookie field Message-ID: <1455543702-27428-1-git-send-email-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Detect whether the new de_cookie field (kernel commit 471f3db27) is present in struct gfs2_dirent in the configure script and update the metadata description to support that field. It also seems that meta.c was not using the GFS2_HAS_* defines from clusterautoconfig.h and that was causing a unit test to fail with gfs2_dirent: __pad: offset is 28, expected 26 gfs2_dirent: size mismatch between struct 40 and fields 38 This commit adds an #include to fix that. Fixes Rawhide bz#1307532 Signed-off-by: Andrew Price --- configure.ac | 2 ++ gfs2/libgfs2/meta.c | 10 ++++++++-- gfs2/libgfs2/ondisk.c | 21 ++++++++++++++++++--- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 130cb01..f6174ff 100644 --- a/configure.ac +++ b/configure.ac @@ -127,6 +127,8 @@ AC_CHECK_MEMBER([struct gfs2_leaf.lf_inode],[AC_DEFINE([GFS2_HAS_LEAF_HINTS],[], [], [[#include ]]) AC_CHECK_MEMBER([struct gfs2_dirent.de_rahead],[AC_DEFINE([GFS2_HAS_DE_RAHEAD],[],[Dirent readahead field])], [], [[#include ]]) +AC_CHECK_MEMBER([struct gfs2_dirent.de_cookie],[AC_DEFINE([GFS2_HAS_DE_COOKIE],[],[Dirent cookie field])], + [], [[#include ]]) # *FLAGS handling ENV_CFLAGS="$CFLAGS" diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c index 4f43af5..90d5647 100644 --- a/gfs2/libgfs2/meta.c +++ b/gfs2/libgfs2/meta.c @@ -1,6 +1,7 @@ #include #include #include "libgfs2.h" +#include "clusterautoconfig.h" #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) #define SYM(x) { x, #x }, @@ -430,10 +431,15 @@ F(de_name_len, .flags = LGFS2_MFF_BYTES) F(de_type) #ifdef GFS2_HAS_DE_RAHEAD F(de_rahead) -RF(__pad2) +#ifdef GFS2_HAS_DE_COOKIE +F(de_cookie) +RF(pad3) +#else +RF(pad2) +#endif /* GFS2_HAS_DE_COOKIE */ #else RF(__pad) -#endif +#endif /* GFS2_HAS_DE_RAHEAD */ }; #undef STRUCT diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c index b9418c5..ea1f61f 100644 --- a/gfs2/libgfs2/ondisk.c +++ b/gfs2/libgfs2/ondisk.c @@ -417,7 +417,15 @@ void gfs2_dirent_in(struct gfs2_dirent *de, char *buf) CPIN_16(de, str, de_type); #ifdef GFS2_HAS_DE_RAHEAD CPIN_16(de, str, de_rahead); -#endif +#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) @@ -429,10 +437,17 @@ 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); - memset(str->__pad, 0, sizeof(str->__pad)); #ifdef GFS2_HAS_DE_RAHEAD CPOUT_16(de, str, de_rahead); -#endif +#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, struct gfs2_buffer_head *bh) -- 2.4.3