From: Brian Atkinson Date: Tue, 26 Sep 2023 18:35:43 +0000 (-0600) Subject: LU-16791 utils: ZFS 2.2 const prop args X-Git-Tag: 2.15.6-RC1~22 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F18%2F54818%2F9;p=fs%2Flustre-release.git LU-16791 utils: ZFS 2.2 const prop args ZFS 2.2 now expects const char * from certain interfaces in sys/nvpair.h. I updated the build system to detect if this is the case and if so update the paramters passed to certain functions in libmount_utils_zfs.c to account for these changes. Without this patch, Lustre master would not build with ZFS master and the 2.2 release candidates. Lustre-change: https://review.whamcloud.com/52519 Lustre-commit: b4b32ffd22d276bc1d8f40e3336df982f3717070 Test-Parameters: trivial testgroup=review-dne-zfs-part-1 Test-Parameters: testgroup=review-dne-zfs-part-2 Test-Parameters: testgroup=review-dne-zfs-part-3 Test-Parameters: testgroup=review-dne-zfs-part-4 Test-Parameters: testgroup=review-dne-zfs-part-5 Test-Parameters: testgroup=review-dne-zfs-part-6 Test-Parameters: testgroup=review-dne-zfs-part-7 Signed-off-by: Brian Atkinson Signed-off-by: Eric Carbonneau Change-Id: I0469eeff6dafa6c276fc616381530b6b679d9da1 Reviewed-by: Akash B Reviewed-by: Thomas Bertschinger Reviewed-by: Olaf Faaland Reviewed-by: Brian Behlendorf Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54818 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/config/lustre-build-zfs.m4 b/config/lustre-build-zfs.m4 index 8ed44a1..e054ded 100644 --- a/config/lustre-build-zfs.m4 +++ b/config/lustre-build-zfs.m4 @@ -782,6 +782,25 @@ your distribution. AC_DEFINE(HAVE_ZFS_REFCOUNT_HEADER, 1, [Have zfs_refcount.h]) ]) + dnl # + dnl # ZFS 2.2 nvpair now returns and expects constant args + dnl # + old_EXTRA_KCFLAGS=$EXTRA_KCFLAGS + EXTRA_KCFLAGS+=" -Werror" + LB_CHECK_COMPILE([if ZFS nvlist interfaces require const], + zfs_nvpair_const, [ + #include + ], [ + nvpair_t *nvp = NULL; + nvlist_t *nvl = NULL; + const char *name = nvpair_name(nvp); + nvlist_lookup_string(nvl, name, &name); + nvlist_lookup_nvlist(nvl, name, &nvl); + ], [ + AC_DEFINE(HAVE_ZFS_NVLIST_CONST_INTERFACES, 1, + [ZFS nvlist interfaces require const]) + ]) + EXTRA_KCFLAGS=$old_EXTRA_KCFLAGS ]) AS_IF([test "x$enable_zfs" = xyes], [ diff --git a/lustre/utils/libmount_utils_zfs.c b/lustre/utils/libmount_utils_zfs.c index 71966fc..a293b04 100644 --- a/lustre/utils/libmount_utils_zfs.c +++ b/lustre/utils/libmount_utils_zfs.c @@ -62,16 +62,26 @@ struct zfs_ldd_prop_bridge { int zlpb_ldd_offset; /* Function pointer responsible for reading in the @prop * property from @zhp and storing it in @ldd_field */ +#ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES + int (*zlpb_get_prop_fn)(zfs_handle_t *zhp, const char *prop, + void *ldd_field); +#else int (*zlpb_get_prop_fn)(zfs_handle_t *zhp, char *prop, void *ldd_field); +#endif /* Function pointer responsible for writing the value of @ldd_field * into the @prop dataset property in @zhp */ int (*zlpb_set_prop_fn)(zfs_handle_t *zhp, char *prop, void *ldd_field); }; /* Forward declarations needed to initialize the ldd prop bridge list */ +#ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES +static int zfs_get_prop_int(zfs_handle_t *, const char *, void *); +static int zfs_get_prop_str(zfs_handle_t *, const char *, void *); +#else static int zfs_get_prop_int(zfs_handle_t *, char *, void *); -static int zfs_set_prop_int(zfs_handle_t *, char *, void *); static int zfs_get_prop_str(zfs_handle_t *, char *, void *); +#endif +static int zfs_set_prop_int(zfs_handle_t *, char *, void *); static int zfs_set_prop_str(zfs_handle_t *, char *, void *); /* Helper for initializing the entries in the special_ldd_prop_params list. @@ -173,7 +183,11 @@ static int zfs_erase_prop(zfs_handle_t *zhp, char *param) return zfs_remove_prop(zhp, nvl, propname); } +#ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES +static int zfs_is_special_ldd_prop_param(const char *name) +#else static int zfs_is_special_ldd_prop_param(char *name) +#endif { int i; @@ -478,10 +492,16 @@ int zfs_erase_ldd(struct mkfs_opts *mop, char *param) return add_param(mop->mo_ldd.ldd_params, key, ""); } +#ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES +static int zfs_get_prop_int(zfs_handle_t *zhp, const char *prop, void *val) +{ + const char *propstr; +#else static int zfs_get_prop_int(zfs_handle_t *zhp, char *prop, void *val) { - nvlist_t *propval; char *propstr; +#endif + nvlist_t *propval; int ret; ret = nvlist_lookup_nvlist(zfs_get_user_props(zhp), prop, &propval); @@ -500,10 +520,16 @@ static int zfs_get_prop_int(zfs_handle_t *zhp, char *prop, void *val) return ret; } +#ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES +static int zfs_get_prop_str(zfs_handle_t *zhp, const char *prop, void *val) +{ + const char *propstr; +#else static int zfs_get_prop_str(zfs_handle_t *zhp, char *prop, void *val) { - nvlist_t *propval; char *propstr; +#endif + nvlist_t *propval; int ret; ret = nvlist_lookup_nvlist(zfs_get_user_props(zhp), prop, &propval);