Whamcloud - gitweb
LU-18360 zfs-osd: za_name flexible array 56/56656/7
authorShaun Tancheff <shaun.tancheff@hpe.com>
Fri, 1 Nov 2024 02:39:13 +0000 (10:39 +0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 18 Jan 2025 22:01:59 +0000 (22:01 +0000)
zfs-2.3 commit 3cf2bfa57008af7f0690f73491d7f9b4ac4ed65a
  Allocate zap_attribute_t from kmem instead of stack

za_name maximum size increased to ZAP_MAXNAMELEN_NEW

Ensure zap_attribute_t.za_name space is available and
zap_attribute_t.za_name_len now needs to be initialized
to the allocated space of MAXNAMELEN.

Also mkfs should disable longname support as it would break
MAX_NAME interop.

HPE-bug-id: LUS-12561
Test-Parameters: fstype=zfs
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I6c48c66a42a36ea6816b37ffce7e17f45eed3dbf
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56656
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
lustre.spec.in
lustre/osd-zfs/osd_handler.c
lustre/osd-zfs/osd_index.c
lustre/osd-zfs/osd_internal.h
lustre/utils/libmount_utils_zfs.c

index 793058c..eb3a157 100644 (file)
@@ -387,7 +387,7 @@ Provides: %{name}-osd-mount = %{version}
 Obsoletes: lustre-osd-mount < %{version}
 %if 0%{confzfsdobjpath} != 0
 %if 0%{?suse_version} >= 1500 || 0%{?rhel} >= 8 || 0%{?fedora} >= 34
-BuildRequires: (libzfs-devel or libzfs4-devel or libzfs5-devel)
+BuildRequires: (libzfs-devel or libzfs4-devel or libzfs5-devel or libzfs6-devel)
 %else
 # 'or' is not available, Use: --define 'zfs 5' or 'zfs 4'
 BuildRequires: libzfs%{?zfs}-devel
index 30063cc..9cf26ee 100644 (file)
@@ -742,10 +742,14 @@ static void *osd_key_init(const struct lu_context *ctx,
        struct osd_thread_info *info;
 
        OBD_ALLOC_PTR(info);
-       if (info != NULL)
-               info->oti_env = container_of(ctx, struct lu_env, le_ctx);
-       else
-               info = ERR_PTR(-ENOMEM);
+       if (!info)
+               return ERR_PTR(-ENOMEM);
+
+       info->oti_env = container_of(ctx, struct lu_env, le_ctx);
+#ifdef ZAP_MAXNAMELEN_NEW
+       info->oti_za.za_name_len = MAXNAMELEN;
+       info->oti_za2.za_name_len = MAXNAMELEN;
+#endif
        return info;
 }
 
index a3ed468..53ee420 100644 (file)
@@ -141,6 +141,9 @@ static struct dt_it *osd_index_it_init(const struct lu_env *env,
 
        it->ozi_obj   = obj;
        it->ozi_reset = 1;
+#ifdef ZAP_MAXNAMELEN_NEW
+       it->ozi_za.za_name_len = MAXNAMELEN;
+#endif
        lu_object_get(lo);
 
        RETURN((struct dt_it *)it);
@@ -1323,7 +1326,11 @@ static int osd_dir_it_next(const struct lu_env *env, struct dt_it *di)
 
        ENTRY;
        /* temp. storage should be enough for any key supported by ZFS */
+#ifdef ZAP_MAXNAMELEN_NEW
+       LASSERT(za->za_name_len <= sizeof(it->ozi_name));
+#else
        BUILD_BUG_ON(sizeof(za->za_name) > sizeof(it->ozi_name));
+#endif
 
        /*
         * the first ->next() moves the cursor to .
index 28b7a9a..fbbe0ee 100644 (file)
@@ -146,6 +146,10 @@ struct osd_zap_it {
        enum osd_zap_pos         ozi_pos;
        struct luz_direntry      ozi_zde;
        zap_attribute_t          ozi_za;
+#ifdef ZAP_MAXNAMELEN_NEW
+       /* flexible array: zap_attribute_t.za_name[], ensure space allocated */
+       char                     ozi_za_name_buffer[MAXNAMELEN];
+#endif
        union {
                char             ozi_name[MAXNAMELEN]; /* file name for dir */
                __u64            ozi_key; /* binary key for index files */
@@ -238,7 +242,15 @@ struct osd_thread_info {
        struct lu_attr           oti_la;
        struct osa_attr          oti_osa;
        zap_attribute_t          oti_za;
+#ifdef ZAP_MAXNAMELEN_NEW
+       /* flexible array: zap_attribute_t.za_name[], ensure space allocated */
+       char                     oti_za_name_buffer[MAXNAMELEN];
+#endif
        zap_attribute_t          oti_za2;
+#ifdef ZAP_MAXNAMELEN_NEW
+       /* flexible array: zap_attribute_t.za_name[], ensure space allocated */
+       char                     oti_za2_name_buffer[MAXNAMELEN];
+#endif
        dmu_object_info_t        oti_doi;
        struct luz_direntry      oti_zde;
 
index f6eb764..68a1c8d 100644 (file)
@@ -636,6 +636,12 @@ static int zfs_create_vdev(struct mkfs_opts *mop, char *vdev)
 
        return ret;
 }
+/* interop will break if we change MAX_NAME from 255 */
+#ifdef ZAP_MAXNAMELEN_NEW
+#define ZFS_LONGNAME_FEATURE   " -o feature@longname=disabled"
+#else
+#define ZFS_LONGNAME_FEATURE   ""
+#endif
 
 int zfs_make_lustre(struct mkfs_opts *mop)
 {
@@ -713,7 +719,8 @@ int zfs_make_lustre(struct mkfs_opts *mop)
 
                memset(mkfs_cmd, 0, PATH_MAX);
                snprintf(mkfs_cmd, PATH_MAX,
-                       "zpool create -f -O canmount=off %s", pool);
+                       "zpool create%s -f -O canmount=off %s",
+                       ZFS_LONGNAME_FEATURE, pool);
 
                /* Append the vdev config and create file vdevs as required */
                while (*mop->mo_pool_vdevs != NULL) {