Whamcloud - gitweb
LU-16791 utils: ZFS 2.2 const prop args 19/52519/7
authorBrian Atkinson <batkinson@lanl.gov>
Tue, 26 Sep 2023 18:35:43 +0000 (12:35 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 18 Jan 2024 06:15:36 +0000 (06:15 +0000)
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.

Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Change-Id: I0469eeff6dafa6c276fc616381530b6b679d9da1
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52519
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Akash B <akash-b@hpe.com>
Reviewed-by: Thomas Bertschinger <bertschinger@lanl.gov>
Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
config/lustre-build-zfs.m4
lustre/utils/libmount_utils_zfs.c

index 6137f0a..12d2942 100644 (file)
@@ -818,6 +818,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 <sys/nvpair.h>
+               ], [
+                       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], [
index 7f63cda..cb0a539 100644 (file)
@@ -57,16 +57,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.
@@ -168,7 +178,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;
 
@@ -366,10 +380,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);
@@ -388,10 +408,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);