Skip to content

Commit

Permalink
Merge ../zfs into adam92
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdmoss committed Oct 4, 2023
2 parents 47fe4c6 + f795e90 commit 621fe12
Show file tree
Hide file tree
Showing 21 changed files with 250 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
48 changes: 29 additions & 19 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ get_usage(zfs_help_t idx)
"\tsend [-nVvPe] -t <receive_resume_token>\n"
"\tsend [-PnVv] --saved filesystem\n"));
case HELP_SET:
return (gettext("\tset <property=value> ... "
return (gettext("\tset [-u] <property=value> ... "
"<filesystem|volume|snapshot> ...\n"));
case HELP_SHARE:
return (gettext("\tshare [-l] <-a [nfs|smb] | filesystem>\n"));
Expand Down Expand Up @@ -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)) {
Expand All @@ -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 {
Expand All @@ -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 */
Expand All @@ -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);
}

Expand Down
11 changes: 11 additions & 0 deletions config/zfs-build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
2 changes: 0 additions & 2 deletions contrib/bash_completion.d/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
bashcompletiondir = $(sysconfdir)/bash_completion.d

nodist_bashcompletion_DATA = %D%/zfs
SUBSTFILES += $(nodist_bashcompletion_DATA)

Expand Down
2 changes: 1 addition & 1 deletion contrib/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Priority: optional
Maintainer: ZFS on Linux specific mailing list <[email protected]>
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,
Expand Down
1 change: 0 additions & 1 deletion contrib/debian/openzfs-zfsutils.install
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 0 additions & 5 deletions contrib/debian/rules.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 *);
Expand Down
8 changes: 6 additions & 2 deletions include/os/linux/zfs/sys/trace_dbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down
7 changes: 7 additions & 0 deletions lib/libzfs/libzfs.abi
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@
<elf-symbol name='zfs_prop_readonly' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_prop_set' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_prop_set_list' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_prop_set_list_flags' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_prop_setonce' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_prop_string_to_index' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_prop_to_name' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
Expand Down Expand Up @@ -4428,6 +4429,12 @@
<parameter type-id='5ce45b60' name='props'/>
<return type-id='95e97e5e'/>
</function-decl>
<function-decl name='zfs_prop_set_list_flags' mangled-name='zfs_prop_set_list_flags' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_prop_set_list_flags'>
<parameter type-id='9200a744' name='zhp'/>
<parameter type-id='5ce45b60' name='props'/>
<parameter type-id='95e97e5e' name='flags'/>
<return type-id='95e97e5e'/>
</function-decl>
<function-decl name='zfs_prop_inherit' mangled-name='zfs_prop_inherit' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_prop_inherit'>
<parameter type-id='9200a744' name='zhp'/>
<parameter type-id='80f4b756' name='propname'/>
Expand Down
27 changes: 20 additions & 7 deletions lib/libzfs/libzfs_changelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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 &&
Expand Down
18 changes: 15 additions & 3 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
26 changes: 24 additions & 2 deletions man/man7/zfsprops.7
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 621fe12

Please sign in to comment.