From fe4d055b36b8f2ec64a8b67bf4fa6366e954f82f Mon Sep 17 00:00:00 2001 From: George Amanakis Date: Tue, 3 Oct 2023 01:57:09 +0200 Subject: [PATCH 1/7] Report ashift of L2ARC devices in zdb Commit 8af1104f does not actually store the ashift of cache devices in their label. However, in order to facilitate reporting the ashift through zdb, we enable this in the present commit. We also document how the retrieval of the ashift is done. Reviewed-by: Brian Behlendorf Signed-off-by: George Amanakis Closes #15331 --- cmd/zdb/zdb.c | 2 +- module/zfs/vdev_label.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 87499cdc95cb..b39a0e8825fb 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -5179,7 +5179,7 @@ dump_label(const char *dev) if (nvlist_size(config, &size, NV_ENCODE_XDR) != 0) size = buflen; - /* If the device is a cache device clear the header. */ + /* If the device is a cache device read the header. */ if (!read_l2arc_header) { if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE, &l2cache) == 0 && diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index a5c76808f2d2..a2e5524a8391 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -1138,6 +1138,16 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason) POOL_STATE_L2CACHE) == 0); VERIFY(nvlist_add_uint64(label, ZPOOL_CONFIG_GUID, vd->vdev_guid) == 0); + + /* + * This is merely to facilitate reporting the ashift of the + * cache device through zdb. The actual retrieval of the + * ashift (in vdev_alloc()) uses the nvlist + * spa->spa_l2cache->sav_config (populated in + * spa_ld_open_aux_vdevs()). + */ + VERIFY(nvlist_add_uint64(label, ZPOOL_CONFIG_ASHIFT, + vd->vdev_ashift) == 0); } else { uint64_t txg = 0ULL; From 249d759caf816eaadd1b4ff3ca22f438a8c25c36 Mon Sep 17 00:00:00 2001 From: Chunwei Chen Date: Mon, 2 Oct 2023 16:58:01 -0700 Subject: [PATCH 2/7] Fix invalid pointer access in trace_dbuf.h In dnode_destroy, dn_objset is invalidated. However, it will later call into dbuf_destroy, in which DTRACE_SET_STATE will try to access spa_name via dn_objset causing illegal pointer access. Reviewed-by: Brian Atkinson Reviewed-by: Brian Behlendorf Signed-off-by: Chunwei Chen Closes #15333 --- include/os/linux/zfs/sys/trace_dbuf.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/os/linux/zfs/sys/trace_dbuf.h b/include/os/linux/zfs/sys/trace_dbuf.h index 11d25be35bc4..0f6a98b47d60 100644 --- a/include/os/linux/zfs/sys/trace_dbuf.h +++ b/include/os/linux/zfs/sys/trace_dbuf.h @@ -60,8 +60,12 @@ #define DBUF_TP_FAST_ASSIGN \ if (db != NULL) { \ - __assign_str(os_spa, \ - spa_name(DB_DNODE(db)->dn_objset->os_spa)); \ + if (POINTER_IS_VALID(DB_DNODE(db)->dn_objset)) { \ + __assign_str(os_spa, \ + spa_name(DB_DNODE(db)->dn_objset->os_spa)); \ + } else { \ + __assign_str(os_spa, "NULL"); \ + } \ \ __entry->ds_object = db->db_objset->os_dsl_dataset ? \ db->db_objset->os_dsl_dataset->ds_object : 0; \ From 4e16964e1c1555704f6e7cd031ae32e1491f0b11 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Tue, 3 Oct 2023 04:58:54 +0500 Subject: [PATCH 3/7] Add '-u' - nomount flag for zfs set This commit adds '-u' flag for zfs set operation. With this flag, mountpoint, sharenfs and sharesmb properties can be updated without actually mounting or sharing the dataset. Previously, if dataset was unmounted, and mountpoint property was updated, dataset was not mounted after the update. This behavior is changed in #15240. We mount the dataset whenever mountpoint property is updated, regardless if it's mounted or not. To provide the user with option to keep the dataset unmounted and still update the mountpoint without mounting the dataset, '-u' flag can be used. If any of mountpoint, sharenfs or sharesmb properties are updated with '-u' flag, the property is set to desired value but the operation to (re/un)mount and/or (re/un)share the dataset is not performed and dataset remains as it was before. Reviewed-by: Alexander Motin Reviewed-by: Brian Behlendorf Signed-off-by: Umer Saleem Closes #15322 --- cmd/zfs/zfs_main.c | 48 ++++---- include/libzfs.h | 8 ++ lib/libzfs/libzfs.abi | 7 ++ lib/libzfs/libzfs_changelist.c | 27 +++-- lib/libzfs/libzfs_dataset.c | 18 ++- man/man7/zfsprops.7 | 26 ++++- man/man8/zfs-set.8 | 7 ++ tests/runfiles/common.run | 2 +- tests/runfiles/sanity.run | 2 +- tests/zfs-tests/tests/Makefile.am | 1 + .../cli_root/zfs_set/zfs_set_nomount.ksh | 103 ++++++++++++++++++ 11 files changed, 216 insertions(+), 33 deletions(-) create mode 100755 tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_nomount.ksh diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 76c82fd53217..9939f206a7f2 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -339,7 +339,7 @@ get_usage(zfs_help_t idx) "\tsend [-nVvPe] -t \n" "\tsend [-PnVv] --saved filesystem\n")); case HELP_SET: - return (gettext("\tset ... " + return (gettext("\tset [-u] ... " " ...\n")); case HELP_SHARE: return (gettext("\tshare [-l] <-a [nfs|smb] | filesystem>\n")); @@ -4206,8 +4206,8 @@ zfs_do_rollback(int argc, char **argv) static int set_callback(zfs_handle_t *zhp, void *data) { - nvlist_t *props = data; - int ret = zfs_prop_set_list(zhp, props); + zprop_set_cbdata_t *cb = data; + int ret = zfs_prop_set_list_flags(zhp, cb->cb_proplist, cb->cb_flags); if (ret != 0 || libzfs_errno(g_zfs) != EZFS_SUCCESS) { switch (libzfs_errno(g_zfs)) { @@ -4227,25 +4227,35 @@ set_callback(zfs_handle_t *zhp, void *data) static int zfs_do_set(int argc, char **argv) { - nvlist_t *props = NULL; + zprop_set_cbdata_t cb = { 0 }; int ds_start = -1; /* argv idx of first dataset arg */ int ret = 0; - int i; + int i, c; - /* check for options */ - if (argc > 1 && argv[1][0] == '-') { - (void) fprintf(stderr, gettext("invalid option '%c'\n"), - argv[1][1]); - usage(B_FALSE); + /* check options */ + while ((c = getopt(argc, argv, "u")) != -1) { + switch (c) { + case 'u': + cb.cb_flags |= ZFS_SET_NOMOUNT; + break; + case '?': + default: + (void) fprintf(stderr, gettext("invalid option '%c'\n"), + optopt); + usage(B_FALSE); + } } + argc -= optind; + argv += optind; + /* check number of arguments */ - if (argc < 2) { + if (argc < 1) { (void) fprintf(stderr, gettext("missing arguments\n")); usage(B_FALSE); } - if (argc < 3) { - if (strchr(argv[1], '=') == NULL) { + if (argc < 2) { + if (strchr(argv[0], '=') == NULL) { (void) fprintf(stderr, gettext("missing property=value " "argument(s)\n")); } else { @@ -4256,7 +4266,7 @@ zfs_do_set(int argc, char **argv) } /* validate argument order: prop=val args followed by dataset args */ - for (i = 1; i < argc; i++) { + for (i = 0; i < argc; i++) { if (strchr(argv[i], '=') != NULL) { if (ds_start > 0) { /* out-of-order prop=val argument */ @@ -4274,20 +4284,20 @@ zfs_do_set(int argc, char **argv) } /* Populate a list of property settings */ - if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0) + if (nvlist_alloc(&cb.cb_proplist, NV_UNIQUE_NAME, 0) != 0) nomem(); - for (i = 1; i < ds_start; i++) { - if (!parseprop(props, argv[i])) { + for (i = 0; i < ds_start; i++) { + if (!parseprop(cb.cb_proplist, argv[i])) { ret = -1; goto error; } } ret = zfs_for_each(argc - ds_start, argv + ds_start, 0, - ZFS_TYPE_DATASET, NULL, NULL, 0, set_callback, props); + ZFS_TYPE_DATASET, NULL, NULL, 0, set_callback, &cb); error: - nvlist_free(props); + nvlist_free(cb.cb_proplist); return (ret); } diff --git a/include/libzfs.h b/include/libzfs.h index 0b5501bbe39f..4adfa38e87be 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -532,6 +532,7 @@ _LIBZFS_H nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t, _LIBZFS_H const char *zfs_prop_to_name(zfs_prop_t); _LIBZFS_H int zfs_prop_set(zfs_handle_t *, const char *, const char *); _LIBZFS_H int zfs_prop_set_list(zfs_handle_t *, nvlist_t *); +_LIBZFS_H int zfs_prop_set_list_flags(zfs_handle_t *, nvlist_t *, int); _LIBZFS_H int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t, zprop_source_t *, char *, size_t, boolean_t); _LIBZFS_H int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t, @@ -654,6 +655,13 @@ typedef struct zprop_get_cbdata { vdev_cbdata_t cb_vdevs; } zprop_get_cbdata_t; +#define ZFS_SET_NOMOUNT 1 + +typedef struct zprop_set_cbdata { + int cb_flags; + nvlist_t *cb_proplist; +} zprop_set_cbdata_t; + _LIBZFS_H void zprop_print_one_property(const char *, zprop_get_cbdata_t *, const char *, const char *, zprop_source_t, const char *, const char *); diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 907b0191f75b..c1ce3d0f67d8 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -396,6 +396,7 @@ + @@ -4428,6 +4429,12 @@ + + + + + + diff --git a/lib/libzfs/libzfs_changelist.c b/lib/libzfs/libzfs_changelist.c index efe1c0c06035..4db1cbce9568 100644 --- a/lib/libzfs/libzfs_changelist.c +++ b/lib/libzfs/libzfs_changelist.c @@ -105,6 +105,15 @@ changelist_prefix(prop_changelist_t *clp) clp->cl_prop != ZFS_PROP_SHARESMB) return (0); + /* + * If CL_GATHER_DONT_UNMOUNT is set, don't want to unmount/unshare and + * later (re)mount/(re)share the filesystem in postfix phase, so we + * return from here. If filesystem is mounted or unmounted, leave it + * as it is. + */ + if (clp->cl_gflags & CL_GATHER_DONT_UNMOUNT) + return (0); + if ((walk = uu_avl_walk_start(clp->cl_tree, UU_WALK_ROBUST)) == NULL) return (-1); @@ -129,8 +138,6 @@ changelist_prefix(prop_changelist_t *clp) */ switch (clp->cl_prop) { case ZFS_PROP_MOUNTPOINT: - if (clp->cl_gflags & CL_GATHER_DONT_UNMOUNT) - break; if (zfs_unmount(cn->cn_handle, NULL, clp->cl_mflags) != 0) { ret = -1; @@ -164,9 +171,8 @@ changelist_prefix(prop_changelist_t *clp) * reshare the filesystems as necessary. In changelist_gather() we recorded * whether the filesystem was previously shared or mounted. The action we take * depends on the previous state, and whether the value was previously 'legacy'. - * For non-legacy properties, we only remount/reshare the filesystem if it was - * previously mounted/shared. Otherwise, we always remount/reshare the - * filesystem. + * For non-legacy properties, we always remount/reshare the filesystem, + * if CL_GATHER_DONT_UNMOUNT is not set. */ int changelist_postfix(prop_changelist_t *clp) @@ -177,6 +183,14 @@ changelist_postfix(prop_changelist_t *clp) boolean_t commit_smb_shares = B_FALSE; boolean_t commit_nfs_shares = B_FALSE; + /* + * If CL_GATHER_DONT_UNMOUNT is set, it means we don't want to (un)mount + * or (re/un)share the filesystem, so we return from here. If filesystem + * is mounted or unmounted, leave it as it is. + */ + if (clp->cl_gflags & CL_GATHER_DONT_UNMOUNT) + return (0); + /* * If we're changing the mountpoint, attempt to destroy the underlying * mountpoint. All other datasets will have inherited from this dataset @@ -239,8 +253,7 @@ changelist_postfix(prop_changelist_t *clp) needs_key = (zfs_prop_get_int(cn->cn_handle, ZFS_PROP_KEYSTATUS) == ZFS_KEYSTATUS_UNAVAILABLE); - mounted = (clp->cl_gflags & CL_GATHER_DONT_UNMOUNT) || - zfs_is_mounted(cn->cn_handle, NULL); + mounted = zfs_is_mounted(cn->cn_handle, NULL); if (!mounted && !needs_key && (cn->cn_mounted || (((clp->cl_prop == ZFS_PROP_MOUNTPOINT && diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 11d3eb6a3c60..727efc5a91ad 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -1771,14 +1771,24 @@ zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval) return (ret); } - - /* * Given an nvlist of property names and values, set the properties for the * given dataset. */ int zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props) +{ + return (zfs_prop_set_list_flags(zhp, props, 0)); +} + +/* + * Given an nvlist of property names, values and flags, set the properties + * for the given dataset. If ZFS_SET_NOMOUNT is set, it allows to update + * mountpoint, sharenfs and sharesmb properties without (un/re)mounting + * and (un/re)sharing the dataset. + */ +int +zfs_prop_set_list_flags(zfs_handle_t *zhp, nvlist_t *props, int flags) { zfs_cmd_t zc = {"\0"}; int ret = -1; @@ -1848,7 +1858,9 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props) if (prop != ZFS_PROP_CANMOUNT || (fnvpair_value_uint64(elem) == ZFS_CANMOUNT_OFF && zfs_is_mounted(zhp, NULL))) { - cls[cl_idx] = changelist_gather(zhp, prop, 0, 0); + cls[cl_idx] = changelist_gather(zhp, prop, + ((flags & ZFS_SET_NOMOUNT) ? + CL_GATHER_DONT_UNMOUNT : 0), 0); if (cls[cl_idx] == NULL) goto error; } diff --git a/man/man7/zfsprops.7 b/man/man7/zfsprops.7 index 51ddd85eb79e..e3674b1f8a8d 100644 --- a/man/man7/zfsprops.7 +++ b/man/man7/zfsprops.7 @@ -1248,10 +1248,18 @@ Otherwise, they are automatically remounted in the new location if the property was previously .Sy legacy or -.Sy none , -or if they were mounted before the property was changed. +.Sy none . In addition, any shared file systems are unshared and shared in the new location. +.Pp +When the +.Sy mountpoint +property is set with +.Nm zfs Cm set Fl u +, the +.Sy mountpoint +property is updated but dataset is not mounted or unmounted and remains +as it was before. .It Sy nbmand Ns = Ns Sy on Ns | Ns Sy off Controls whether the file system should be mounted with .Sy nbmand @@ -1656,6 +1664,13 @@ by default. This means that any additional access control (disallow specific user specific access etc) must be done on the underlying file system. +.Pp +When the +.Sy sharesmb +property is updated with +.Nm zfs Cm set Fl u +, the property is set to desired value, but the operation to share, reshare +or unshare the the dataset is not performed. .It Sy sharenfs Ns = Ns Sy on Ns | Ns Sy off Ns | Ns Ar opts Controls whether the file system is shared via NFS, and what options are to be used. @@ -1699,6 +1714,13 @@ or if they were shared before the property was changed. If the new property is .Sy off , the file systems are unshared. +.Pp +When the +.Sy sharenfs +property is updated with +.Nm zfs Cm set Fl u +, the property is set to desired value, but the operation to share, reshare +or unshare the the dataset is not performed. .It Sy logbias Ns = Ns Sy latency Ns | Ns Sy throughput Provide a hint to ZFS about handling of synchronous requests in this dataset. If diff --git a/man/man8/zfs-set.8 b/man/man8/zfs-set.8 index 4cabdcd8bd83..c01bcc643e5d 100644 --- a/man/man8/zfs-set.8 +++ b/man/man8/zfs-set.8 @@ -39,6 +39,7 @@ .Sh SYNOPSIS .Nm zfs .Cm set +.Op Fl u .Ar property Ns = Ns Ar value Oo Ar property Ns = Ns Ar value Oc Ns … .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns … .Nm zfs @@ -60,6 +61,7 @@ .It Xo .Nm zfs .Cm set +.Op Fl u .Ar property Ns = Ns Ar value Oo Ar property Ns = Ns Ar value Oc Ns … .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns … .Xc @@ -79,6 +81,11 @@ For more information, see the .Em User Properties section of .Xr zfsprops 7 . +.Bl -tag -width "-u" +.It Fl u +Update mountpoint, sharenfs, sharesmb property but do not mount or share the +dataset. +.El .It Xo .Nm zfs .Cm get diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index 342f56d50d04..ef787c65c0f9 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -281,7 +281,7 @@ tests = ['cache_001_pos', 'cache_002_neg', 'canmount_001_pos', 'user_property_004_pos', 'version_001_neg', 'zfs_set_001_neg', 'zfs_set_002_neg', 'zfs_set_003_neg', 'property_alias_001_pos', 'mountpoint_003_pos', 'ro_props_001_pos', 'zfs_set_keylocation', - 'zfs_set_feature_activation'] + 'zfs_set_feature_activation', 'zfs_set_nomount'] tags = ['functional', 'cli_root', 'zfs_set'] [tests/functional/cli_root/zfs_share] diff --git a/tests/runfiles/sanity.run b/tests/runfiles/sanity.run index 449bf1c0f56a..ab41c05b8473 100644 --- a/tests/runfiles/sanity.run +++ b/tests/runfiles/sanity.run @@ -212,7 +212,7 @@ tests = ['cache_001_pos', 'cache_002_neg', 'canmount_001_pos', 'user_property_001_pos', 'user_property_003_neg', 'readonly_001_pos', 'user_property_004_pos', 'version_001_neg', 'zfs_set_003_neg', 'property_alias_001_pos', - 'zfs_set_keylocation', 'zfs_set_feature_activation'] + 'zfs_set_keylocation', 'zfs_set_feature_activation', 'zfs_set_nomount'] tags = ['functional', 'cli_root', 'zfs_set'] [tests/functional/cli_root/zfs_snapshot] diff --git a/tests/zfs-tests/tests/Makefile.am b/tests/zfs-tests/tests/Makefile.am index 1a58e6f774e9..3272a5d5816f 100644 --- a/tests/zfs-tests/tests/Makefile.am +++ b/tests/zfs-tests/tests/Makefile.am @@ -870,6 +870,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \ functional/cli_root/zfs_set/zfs_set_003_neg.ksh \ functional/cli_root/zfs_set/zfs_set_feature_activation.ksh \ functional/cli_root/zfs_set/zfs_set_keylocation.ksh \ + functional/cli_root/zfs_set/zfs_set_nomount.ksh \ functional/cli_root/zfs_share/cleanup.ksh \ functional/cli_root/zfs_share/setup.ksh \ functional/cli_root/zfs_share/zfs_share_001_pos.ksh \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_nomount.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_nomount.ksh new file mode 100755 index 000000000000..ebf08711423c --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_nomount.ksh @@ -0,0 +1,103 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2023 by iXsystems, Inc. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib + +# +# DESCRIPTION: +# 'zfs set -u' should update the mountpoint, sharenfs and sharesmb +# properties without mounting and sharing the dataset. Validate the +# bevaior while dataset is mounted and unmounted. +# +# STRATEGY: +# 1. Confirm dataset is currently mounted +# 2. Update the mountpoint with -u flag +# 3. Confirm mountpoint property is updated with new value +# 4. Confirm dataset is still mounted at previous mountpoint +# 5. Unmount the dataset +# 6. Confirm dataset is unmounted +# 7. Mount the dataset +# 8. Confirm dataset is mounted at new mountpoint, that was set with -u flag. +# 9. Update and mount the dataset at previous mountpoint. +# 10. Unmount the dataset +# 11. Update mountpoint property with zfs set -u +# 12. Confirm dataset is not mounted +# 13. Update sharenfs property with zfs set -u +# 14. Confirm dataset is not mounted +# 15. Update sharesmb property with zfs set -u +# 16. Confirm dataset is not mounted +# 17. Mount the dataset and confirm dataset is mounted at new mountpoint +# + +verify_runnable "both" + +function cleanup +{ + log_must zfs set sharenfs=off $TESTPOOL/$TESTFS + if is_linux; then + log_must zfs set sharesmb=off $TESTPOOL/$TESTFS + fi + rm -r $newmpt +} + +log_assert "'zfs set -u' sets the mountpoint and share properties without " \ + "mounting the dataset" +log_onexit cleanup + +oldmpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) +newmpt=$TEST_BASE_DIR/abc + +# Test while dataset is mounted +log_must ismounted $TESTPOOL/$TESTFS +log_must zfs set -u mountpoint=$newmpt $TESTPOOL/$TESTFS +log_must check_user_prop $TESTPOOL/$TESTFS mountpoint $newmpt +log_must eval "[[ "$(mount | grep $TESTPOOL/$TESTFS | awk '{print $3}')" == $oldmpt ]]" +log_must zfs unmount $TESTPOOL/$TESTFS +log_mustnot ismounted $TESTPOOL/$TESTFS +log_must zfs mount $TESTPOOL/$TESTFS +log_must eval "[[ "$(mount | grep $TESTPOOL/$TESTFS | awk '{print $3}')" == $newmpt ]]" + +# Test while dataset is unmounted +log_must zfs set mountpoint=$oldmpt $TESTPOOL/$TESTFS +log_must ismounted $TESTPOOL/$TESTFS +log_must zfs unmount $TESTPOOL/$TESTFS +log_must zfs set -u mountpoint=$newmpt $TESTPOOL/$TESTFS +log_mustnot ismounted $TESTPOOL/$TESTFS +log_must zfs set -u sharenfs=on $TESTPOOL/$TESTFS +log_mustnot ismounted $TESTPOOL/$TESTFS +if is_linux; then + log_must zfs set -u sharesmb=on $TESTPOOL/$TESTFS + log_mustnot ismounted $TESTPOOL/$TESTFS +fi +log_must zfs mount $TESTPOOL/$TESTFS +log_must check_user_prop $TESTPOOL/$TESTFS mountpoint $newmpt +log_must eval "[[ "$(mount | grep $TESTPOOL/$TESTFS | awk '{print $3}')" == $newmpt ]]" + +log_must zfs set mountpoint=$oldmpt $TESTPOOL/$TESTFS +log_must ismounted $TESTPOOL/$TESTFS + +log_pass "'zfs set -u' functions correctly" From e69ade32e116e72d03068c03799924c3f1a15c95 Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Wed, 20 Sep 2023 19:33:14 +0200 Subject: [PATCH 4/7] contrib: bash_completion.d: make install destination vendor dependent Certain Linux distributions (Debian/Ubuntu at least) expect bash-completion snippets to be installed in /usr/share/bash-completion/completions instead of /etc/bash_completion.d. This patch sets the bashcompletiondir variable based on the vendor, inspired by similar settings for initdir and initconfdir. It seems that commit 612b8dff5bc3d827efb864a199a62bda1a419254 caused the file to be installed in the first-place (thus the error when building debian packages only became apparent when testing a 2.2.0-rc4 build) The change only sets the variable in Makefile context - the rpm/zfs.spec.in file has the path hardcoded as %{_sysconfdir}/bash_completion.d/zfs, but since running ``` ./configure --sysconfdir=/myetc ; make rpm ``` also results in all relevant files to be installed in /etc instead of /myetc I assume this can remain as is. Reviewed-by: Umer Saleem Signed-off-by: Stoiko Ivanov Closes #15304 --- config/zfs-build.m4 | 11 +++++++++++ contrib/bash_completion.d/Makefile.am | 2 -- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index 2703e6c016c4..5ea6aa29a3de 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -617,6 +617,17 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ AC_MSG_RESULT([no]) fi AC_SUBST(RPM_DEFINE_INITRAMFS) + + AC_MSG_CHECKING([default bash completion directory]) + case "$VENDOR" in + ubuntu) bashcompletiondir=/usr/share/bash-completion/completions ;; + debian) bashcompletiondir=/usr/share/bash-completion/completions ;; + freebsd) bashcompletiondir=$sysconfdir/bash_completion.d;; + *) bashcompletiondir=/etc/bash_completion.d ;; + esac + AC_MSG_RESULT([$bashcompletiondir]) + AC_SUBST(bashcompletiondir) + ]) dnl # diff --git a/contrib/bash_completion.d/Makefile.am b/contrib/bash_completion.d/Makefile.am index dc4b610c42b8..1ec05ed73d2d 100644 --- a/contrib/bash_completion.d/Makefile.am +++ b/contrib/bash_completion.d/Makefile.am @@ -1,5 +1,3 @@ -bashcompletiondir = $(sysconfdir)/bash_completion.d - nodist_bashcompletion_DATA = %D%/zfs SUBSTFILES += $(nodist_bashcompletion_DATA) From e14293a4e56ea86563d5d3be10291e0f3832aa4c Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Thu, 21 Sep 2023 15:01:24 +0200 Subject: [PATCH 5/7] contrib: debian: switch to dh-sequence-dkms Follows b191f9a13d3005621ead9a727b811892264505ef from Debian's packaging team at: https://salsa.debian.org/zfsonlinux-team/zfs/ The previous build-dependency is kept as option, to still be able to build on older Debian based distros (e.g. Ubuntu 20.04). Without this building on Debian 12/bookworm does not work, as `dkms` is a virtual package. Reviewed-by: Umer Saleem Signed-off-by: Stoiko Ivanov Closes #15304 --- contrib/debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/debian/control b/contrib/debian/control index b9bb23b09ba0..f4e97fe16145 100644 --- a/contrib/debian/control +++ b/contrib/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: ZFS on Linux specific mailing list Build-Depends: debhelper-compat (= 12), dh-python, - dkms (>> 2.1.1.2-5), + dh-sequence-dkms | dkms (>> 2.1.1.2-5), libaio-dev, libblkid-dev, libcurl4-openssl-dev, From eb955f6e930e2516bbc4c569f33b5314835c45b6 Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Wed, 20 Sep 2023 10:25:37 +0200 Subject: [PATCH 6/7] contrib: debian: drop bashcompletion mangling after install tested by running: ``` ./configure --with-config=user; cp -a contrib/debian . dpkg-buildpackage -b -uc -us ``` on a Debian 12 based system. and checking where the completion file got installed. Reviewed-by: Umer Saleem Signed-off-by: Stoiko Ivanov Closes #15304 --- contrib/debian/openzfs-zfsutils.install | 1 - contrib/debian/rules.in | 5 ----- 2 files changed, 6 deletions(-) diff --git a/contrib/debian/openzfs-zfsutils.install b/contrib/debian/openzfs-zfsutils.install index e2ce5084c095..741014398ade 100644 --- a/contrib/debian/openzfs-zfsutils.install +++ b/contrib/debian/openzfs-zfsutils.install @@ -1,7 +1,6 @@ etc/default/zfs etc/zfs/zfs-functions etc/zfs/zpool.d/ -etc/bash_completion.d/zfs lib/systemd/system-generators/ lib/systemd/system-preset/ lib/systemd/system/zfs-import-cache.service diff --git a/contrib/debian/rules.in b/contrib/debian/rules.in index f0791cfabd38..a3a05efacb50 100755 --- a/contrib/debian/rules.in +++ b/contrib/debian/rules.in @@ -71,10 +71,6 @@ override_dh_auto_install: @# Install the utilities. $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp' - # Use upstream's bash completion - install -D -t '$(CURDIR)/debian/tmp/usr/share/bash-completion/completions/' \ - '$(CURDIR)/contrib/bash_completion.d/zfs' - # Move from bin_dir to /usr/sbin # Remove suffix (.py) as per policy 10.4 - Scripts # https://www.debian.org/doc/debian-policy/ch-files.html#s-scripts @@ -136,7 +132,6 @@ override_dh_auto_install: chmod a-x '$(CURDIR)/debian/tmp/etc/zfs/zfs-functions' chmod a-x '$(CURDIR)/debian/tmp/etc/default/zfs' - chmod a-x '$(CURDIR)/debian/tmp/usr/share/bash-completion/completions/zfs' override_dh_python3: dh_python3 -p openzfs-python3-pyzfs From f795e90a11c683d64bacc260fb7feab705b220b1 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Tue, 3 Oct 2023 23:12:36 +0100 Subject: [PATCH 7/7] Add BTI landing pads to the AArch64 SHA2 assembly The Arm Branch Target Identification (BTI) extension guards against branching to an unintended instruction. To support BTI add the landing pad instructions to the SHA2 functions. These are from the hint space so are a nop on hardware that lacks BTI support or if BTI isn't enabled. Reviewed-by: Allan Jude Reviewed-by: Brian Behlendorf Reviewed-by: Tino Reichardt Signed-off-by: Andrew Turner Closes #14862 Closes #15339 --- module/icp/asm-aarch64/sha2/sha256-armv8.S | 3 +++ module/icp/asm-aarch64/sha2/sha512-armv8.S | 2 ++ 2 files changed, 5 insertions(+) diff --git a/module/icp/asm-aarch64/sha2/sha256-armv8.S b/module/icp/asm-aarch64/sha2/sha256-armv8.S index fa50c4e74d59..7ae486e4e229 100644 --- a/module/icp/asm-aarch64/sha2/sha256-armv8.S +++ b/module/icp/asm-aarch64/sha2/sha256-armv8.S @@ -49,6 +49,7 @@ .type zfs_sha256_block_armv7,%function .align 6 zfs_sha256_block_armv7: + hint #34 // bti c stp x29,x30,[sp,#-128]! add x29,sp,#0 @@ -1015,6 +1016,7 @@ zfs_sha256_block_armv7: .type zfs_sha256_block_armv8,%function .align 6 zfs_sha256_block_armv8: + hint #34 // bti c .Lv8_entry: stp x29,x30,[sp,#-16]! add x29,sp,#0 @@ -1155,6 +1157,7 @@ zfs_sha256_block_armv8: .type zfs_sha256_block_neon,%function .align 4 zfs_sha256_block_neon: + hint #34 // bti c .Lneon_entry: stp x29, x30, [sp, #-16]! mov x29, sp diff --git a/module/icp/asm-aarch64/sha2/sha512-armv8.S b/module/icp/asm-aarch64/sha2/sha512-armv8.S index 1683fc1ca53c..9c61eeee4d7b 100644 --- a/module/icp/asm-aarch64/sha2/sha512-armv8.S +++ b/module/icp/asm-aarch64/sha2/sha512-armv8.S @@ -73,6 +73,7 @@ .type zfs_sha512_block_armv7,%function .align 6 zfs_sha512_block_armv7: + hint #34 // bti c stp x29,x30,[sp,#-128]! add x29,sp,#0 @@ -1040,6 +1041,7 @@ zfs_sha512_block_armv7: .type zfs_sha512_block_armv8,%function .align 6 zfs_sha512_block_armv8: + hint #34 // bti c .Lv8_entry: // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later stp x29,x30,[sp,#-16]!