libgfs2: Support the new dirent de_cookie field
PATCH 1/1 libgfs2: Support the new dirent de_cookie field
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 <[email protected]>
--- configure.ac | 2 ++ gfs2/libgfs2/meta.c | 10 ++++++++-- gfs2/libgfs2/ondisk.c | 21 ++++++++++++++++++--- 3 files changed, 28 insertions(+), 5 deletions(-)
configure.ac +2 -0
@@ -127,6 +127,8 @@ AC_CHECK_MEMBER([struct gfs2_leaf.lf_inode],[AC_DEFINE([GFS2_HAS_LEAF_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>]]) # *FLAGS handling ENV_CFLAGS="$CFLAGS"
gfs2/libgfs2/meta.c +8 -2
@@ -1,6 +1,7 @@#include <stdint.h> #include <string.h> #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
gfs2/libgfs2/ondisk.c +18 -3
@@ -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)
Signature · 1 line
2.4.3