From 2300621dc7450adccf86ddbf397c72f8e5e2d76c Mon Sep 17 00:00:00 2001 From: Georgy Yakovlev <168902+gyakovlev@users.noreply.github.com> Date: Thu, 16 Dec 2021 11:47:22 -0800 Subject: [PATCH 001/117] systemd: add weekly and monthly scrub timers Timers can be enabled as follows: systemctl enable zfs-scrub-weekly@rpool.timer --now systemctl enable zfs-scrub-monthly@datapool.timer --now Each timer will pull in zfs-scrub@${poolname}.service, which is not schedule-specific. Added PERIODIC SCRUB section to zpool-scrub.8. Reviewed-by: Richard Laager Reviewed-by: Brian Behlendorf Signed-off-by: Georgy Yakovlev Closes #12193 --- etc/systemd/system/.gitignore | 1 + etc/systemd/system/Makefile.am | 5 ++++- .../system/zfs-scrub-monthly@.timer.in | 12 +++++++++++ etc/systemd/system/zfs-scrub-weekly@.timer.in | 12 +++++++++++ etc/systemd/system/zfs-scrub@.service.in | 14 +++++++++++++ man/man8/zpool-scrub.8 | 21 +++++++++++++++++++ 6 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 etc/systemd/system/zfs-scrub-monthly@.timer.in create mode 100644 etc/systemd/system/zfs-scrub-weekly@.timer.in create mode 100644 etc/systemd/system/zfs-scrub@.service.in diff --git a/etc/systemd/system/.gitignore b/etc/systemd/system/.gitignore index efada54ad93..4813c65a25a 100644 --- a/etc/systemd/system/.gitignore +++ b/etc/systemd/system/.gitignore @@ -1,3 +1,4 @@ *.service *.target *.preset +*.timer diff --git a/etc/systemd/system/Makefile.am b/etc/systemd/system/Makefile.am index c374a52ac7d..5e65e1db420 100644 --- a/etc/systemd/system/Makefile.am +++ b/etc/systemd/system/Makefile.am @@ -12,7 +12,10 @@ systemdunit_DATA = \ zfs-volume-wait.service \ zfs-import.target \ zfs-volumes.target \ - zfs.target + zfs.target \ + zfs-scrub-monthly@.timer \ + zfs-scrub-weekly@.timer \ + zfs-scrub@.service SUBSTFILES += $(systemdpreset_DATA) $(systemdunit_DATA) diff --git a/etc/systemd/system/zfs-scrub-monthly@.timer.in b/etc/systemd/system/zfs-scrub-monthly@.timer.in new file mode 100644 index 00000000000..90306846827 --- /dev/null +++ b/etc/systemd/system/zfs-scrub-monthly@.timer.in @@ -0,0 +1,12 @@ +[Unit] +Description=Monthly zpool scrub timer for %i +Documentation=man:zpool-scrub(8) + +[Timer] +OnCalendar=monthly +Persistent=true +RandomizedDelaySec=1h +Unit=zfs-scrub@%i.service + +[Install] +WantedBy=timers.target diff --git a/etc/systemd/system/zfs-scrub-weekly@.timer.in b/etc/systemd/system/zfs-scrub-weekly@.timer.in new file mode 100644 index 00000000000..ede69950059 --- /dev/null +++ b/etc/systemd/system/zfs-scrub-weekly@.timer.in @@ -0,0 +1,12 @@ +[Unit] +Description=Weekly zpool scrub timer for %i +Documentation=man:zpool-scrub(8) + +[Timer] +OnCalendar=weekly +Persistent=true +RandomizedDelaySec=1h +Unit=zfs-scrub@%i.service + +[Install] +WantedBy=timers.target diff --git a/etc/systemd/system/zfs-scrub@.service.in b/etc/systemd/system/zfs-scrub@.service.in new file mode 100644 index 00000000000..bebe91d746a --- /dev/null +++ b/etc/systemd/system/zfs-scrub@.service.in @@ -0,0 +1,14 @@ +[Unit] +Description=zpool scrub on %i +Documentation=man:zpool-scrub(8) +Requires=zfs.target +After=zfs.target +ConditionACPower=true +ConditionPathIsDirectory=/sys/module/zfs + +[Service] +ExecStart=/bin/sh -c '\ +if @sbindir@/zpool status %i | grep "scrub in progress"; then\ +exec @sbindir@/zpool wait -t scrub %i;\ +else exec @sbindir@/zpool scrub -w %i; fi' +ExecStop=-/bin/sh -c '@sbindir@/zpool scrub -p %i 2>/dev/null || true' diff --git a/man/man8/zpool-scrub.8 b/man/man8/zpool-scrub.8 index 768f7153929..69ae825b615 100644 --- a/man/man8/zpool-scrub.8 +++ b/man/man8/zpool-scrub.8 @@ -116,8 +116,29 @@ scanned at 100M/s, and 68.4M of that file data has been scrubbed sequentially at 10.0M/s. .El .El +.Sh PERIODIC SCRUB +On machines using systemd, scrub timers can be enabled on per-pool basis. +.Nm weekly +and +.Nm monthly +timer units are provided. +.Bl -tag -width Ds +.It Xo +.Xc +.Nm systemctl +.Cm enable +.Cm zfs-scrub-\fIweekly\fB@\fIrpool\fB.timer +.Cm --now +.It Xo +.Xc +.Nm systemctl +.Cm enable +.Cm zfs-scrub-\fImonthly\fB@\fIotherpool\fB.timer +.Cm --now +.El . .Sh SEE ALSO +.Xr systemd.timer 5 , .Xr zpool-iostat 8 , .Xr zpool-resilver 8 , .Xr zpool-status 8 From f6a0dac84af2fba9c306a3a307ea7aafcbe32d2b Mon Sep 17 00:00:00 2001 From: Allan Jude Date: Thu, 16 Dec 2021 14:56:22 -0500 Subject: [PATCH 002/117] zfs list: Allow more fields in ZFS_ITER_SIMPLE mode If the fields to be listed and sorted by are constrained to those populated by dsl_dataset_fast_stat(), then zfs list is much faster, as it does not need to open each objset and reads its properties. A previous optimization by Pawel Dawidek (0cee24064a79f9c01fc4521543c37acea538405f) took advantage of this to make listing snapshot names sorted only by name much faster. However, it was limited to `-o name -s name`, this work extends this optimization to work with: - name - guid - createtxg - numclones - inconsistent - redacted - origin and could be further extended to any other properties supported by dsl_dataset_fast_stat() or similar, that do not require extra locking or reading from disk. Reviewed-by: Mark Maybee Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Reviewed-by: Pawel Jakub Dawidek Signed-off-by: Allan Jude Closes #11080 --- cmd/zfs/zfs_iter.c | 64 +++++++++++++++++++++++++++---- cmd/zfs/zfs_iter.h | 12 ++---- cmd/zfs/zfs_main.c | 43 +++++++++++---------- cmd/zpool/zpool_main.c | 2 +- contrib/pam_zfs_key/pam_zfs_key.c | 2 +- include/libzfs.h | 22 +++++++---- lib/libzfs/libzfs.abi | 8 +++- lib/libzfs/libzfs_changelist.c | 6 +-- lib/libzfs/libzfs_crypto.c | 2 +- lib/libzfs/libzfs_dataset.c | 51 +++++++++++++++++------- lib/libzfs/libzfs_iter.c | 50 ++++++++++++++---------- lib/libzfs/libzfs_mount.c | 4 +- lib/libzfs/libzfs_sendrecv.c | 15 ++++---- module/zfs/zfs_ioctl.c | 3 +- 14 files changed, 189 insertions(+), 95 deletions(-) diff --git a/cmd/zfs/zfs_iter.c b/cmd/zfs/zfs_iter.c index f2359508c16..301a179a2b0 100644 --- a/cmd/zfs/zfs_iter.c +++ b/cmd/zfs/zfs_iter.c @@ -144,19 +144,20 @@ zfs_callback(zfs_handle_t *zhp, void *data) (cb->cb_types & (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME))) && zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) { - (void) zfs_iter_filesystems(zhp, zfs_callback, data); + (void) zfs_iter_filesystems(zhp, cb->cb_flags, + zfs_callback, data); } if (((zfs_get_type(zhp) & (ZFS_TYPE_SNAPSHOT | ZFS_TYPE_BOOKMARK)) == 0) && include_snaps) { - (void) zfs_iter_snapshots(zhp, - (cb->cb_flags & ZFS_ITER_SIMPLE) != 0, + (void) zfs_iter_snapshots(zhp, cb->cb_flags, zfs_callback, data, 0, 0); } if (((zfs_get_type(zhp) & (ZFS_TYPE_SNAPSHOT | ZFS_TYPE_BOOKMARK)) == 0) && include_bmarks) { - (void) zfs_iter_bookmarks(zhp, zfs_callback, data); + (void) zfs_iter_bookmarks(zhp, cb->cb_flags, + zfs_callback, data); } cb->cb_depth--; @@ -212,11 +213,58 @@ zfs_free_sort_columns(zfs_sort_column_t *sc) } } -int -zfs_sort_only_by_name(const zfs_sort_column_t *sc) +/* + * Return true if all of the properties to be sorted are populated by + * dsl_dataset_fast_stat(). Note that sc == NULL (no sort) means we + * don't need any extra properties, so returns true. + */ +boolean_t +zfs_sort_only_by_fast(const zfs_sort_column_t *sc) { - return (sc != NULL && sc->sc_next == NULL && - sc->sc_prop == ZFS_PROP_NAME); + while (sc != NULL) { + switch (sc->sc_prop) { + case ZFS_PROP_NAME: + case ZFS_PROP_GUID: + case ZFS_PROP_CREATETXG: + case ZFS_PROP_NUMCLONES: + case ZFS_PROP_INCONSISTENT: + case ZFS_PROP_REDACTED: + case ZFS_PROP_ORIGIN: + break; + default: + return (B_FALSE); + } + sc = sc->sc_next; + } + + return (B_TRUE); +} + +boolean_t +zfs_list_only_by_fast(const zprop_list_t *p) +{ + if (p == NULL) { + /* NULL means 'all' so we can't use simple mode */ + return (B_FALSE); + } + + while (p != NULL) { + switch (p->pl_prop) { + case ZFS_PROP_NAME: + case ZFS_PROP_GUID: + case ZFS_PROP_CREATETXG: + case ZFS_PROP_NUMCLONES: + case ZFS_PROP_INCONSISTENT: + case ZFS_PROP_REDACTED: + case ZFS_PROP_ORIGIN: + break; + default: + return (B_FALSE); + } + p = p->pl_next; + } + + return (B_TRUE); } /* ARGSUSED */ diff --git a/cmd/zfs/zfs_iter.h b/cmd/zfs/zfs_iter.h index 2697fbdca1d..d93d7e322a5 100644 --- a/cmd/zfs/zfs_iter.h +++ b/cmd/zfs/zfs_iter.h @@ -40,19 +40,13 @@ typedef struct zfs_sort_column { boolean_t sc_reverse; } zfs_sort_column_t; -#define ZFS_ITER_RECURSE (1 << 0) -#define ZFS_ITER_ARGS_CAN_BE_PATHS (1 << 1) -#define ZFS_ITER_PROP_LISTSNAPS (1 << 2) -#define ZFS_ITER_DEPTH_LIMIT (1 << 3) -#define ZFS_ITER_RECVD_PROPS (1 << 4) -#define ZFS_ITER_LITERAL_PROPS (1 << 5) -#define ZFS_ITER_SIMPLE (1 << 6) - int zfs_for_each(int, char **, int options, zfs_type_t, zfs_sort_column_t *, zprop_list_t **, int, zfs_iter_f, void *); int zfs_add_sort_column(zfs_sort_column_t **, const char *, boolean_t); void zfs_free_sort_columns(zfs_sort_column_t *); -int zfs_sort_only_by_name(const zfs_sort_column_t *); +boolean_t zfs_sort_only_by_fast(const zfs_sort_column_t *); +boolean_t zfs_list_only_by_fast(const zprop_list_t *); + #ifdef __cplusplus } diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 5aa2508c382..0ac0711bb0d 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -1536,7 +1536,7 @@ destroy_print_snapshots(zfs_handle_t *fs_zhp, destroy_cbdata_t *cb) int err; assert(cb->cb_firstsnap == NULL); assert(cb->cb_prevsnap == NULL); - err = zfs_iter_snapshots_sorted(fs_zhp, destroy_print_cb, cb, 0, 0); + err = zfs_iter_snapshots_sorted(fs_zhp, 0, destroy_print_cb, cb, 0, 0); if (cb->cb_firstsnap != NULL) { uint64_t used = 0; if (err == 0) { @@ -1562,7 +1562,7 @@ snapshot_to_nvl_cb(zfs_handle_t *zhp, void *arg) if (!cb->cb_doclones && !cb->cb_defer_destroy) { cb->cb_target = zhp; cb->cb_first = B_TRUE; - err = zfs_iter_dependents(zhp, B_TRUE, + err = zfs_iter_dependents(zhp, 0, B_TRUE, destroy_check_dependent, cb); } @@ -1580,7 +1580,8 @@ gather_snapshots(zfs_handle_t *zhp, void *arg) destroy_cbdata_t *cb = arg; int err = 0; - err = zfs_iter_snapspec(zhp, cb->cb_snapspec, snapshot_to_nvl_cb, cb); + err = zfs_iter_snapspec(zhp, 0, cb->cb_snapspec, + snapshot_to_nvl_cb, cb); if (err == ENOENT) err = 0; if (err != 0) @@ -1593,7 +1594,7 @@ gather_snapshots(zfs_handle_t *zhp, void *arg) } if (cb->cb_recurse) - err = zfs_iter_filesystems(zhp, gather_snapshots, cb); + err = zfs_iter_filesystems(zhp, 0, gather_snapshots, cb); out: zfs_close(zhp); @@ -1618,7 +1619,7 @@ destroy_clones(destroy_cbdata_t *cb) * false while destroying the clones. */ cb->cb_defer_destroy = B_FALSE; - err = zfs_iter_dependents(zhp, B_FALSE, + err = zfs_iter_dependents(zhp, 0, B_FALSE, destroy_callback, cb); cb->cb_defer_destroy = defer; zfs_close(zhp); @@ -1829,7 +1830,7 @@ zfs_do_destroy(int argc, char **argv) */ cb.cb_first = B_TRUE; if (!cb.cb_doclones && - zfs_iter_dependents(zhp, B_TRUE, destroy_check_dependent, + zfs_iter_dependents(zhp, 0, B_TRUE, destroy_check_dependent, &cb) != 0) { rv = 1; goto out; @@ -1840,7 +1841,7 @@ zfs_do_destroy(int argc, char **argv) goto out; } cb.cb_batchedsnaps = fnvlist_alloc(); - if (zfs_iter_dependents(zhp, B_FALSE, destroy_callback, + if (zfs_iter_dependents(zhp, 0, B_FALSE, destroy_callback, &cb) != 0) { rv = 1; goto out; @@ -3704,13 +3705,6 @@ zfs_do_list(int argc, char **argv) if (fields == NULL) fields = default_fields; - /* - * If we are only going to list snapshot names and sort by name, - * then we can use faster version. - */ - if (strcmp(fields, "name") == 0 && zfs_sort_only_by_name(sortcol)) - flags |= ZFS_ITER_SIMPLE; - /* * If "-o space" and no types were specified, don't display snapshots. */ @@ -3738,6 +3732,15 @@ zfs_do_list(int argc, char **argv) cb.cb_first = B_TRUE; + /* + * If we are only going to list and sort by properties that are "fast" + * then we can use "simple" mode and avoid populating the properties + * nvlist. + */ + if (zfs_list_only_by_fast(cb.cb_proplist) && + zfs_sort_only_by_fast(sortcol)) + flags |= ZFS_ITER_SIMPLE; + ret = zfs_for_each(argc, argv, flags, types, sortcol, &cb.cb_proplist, limit, list_callback, &cb); @@ -4048,7 +4051,7 @@ rollback_check(zfs_handle_t *zhp, void *data) } if (cbp->cb_recurse) { - if (zfs_iter_dependents(zhp, B_TRUE, + if (zfs_iter_dependents(zhp, 0, B_TRUE, rollback_check_dependent, cbp) != 0) { zfs_close(zhp); return (-1); @@ -4147,10 +4150,10 @@ zfs_do_rollback(int argc, char **argv) if (cb.cb_create > 0) min_txg = cb.cb_create; - if ((ret = zfs_iter_snapshots(zhp, B_FALSE, rollback_check, &cb, + if ((ret = zfs_iter_snapshots(zhp, 0, rollback_check, &cb, min_txg, 0)) != 0) goto out; - if ((ret = zfs_iter_bookmarks(zhp, rollback_check, &cb)) != 0) + if ((ret = zfs_iter_bookmarks(zhp, 0, rollback_check, &cb)) != 0) goto out; if ((ret = cb.cb_error) != 0) @@ -4292,7 +4295,7 @@ zfs_snapshot_cb(zfs_handle_t *zhp, void *arg) free(name); if (sd->sd_recursive) - rv = zfs_iter_filesystems(zhp, zfs_snapshot_cb, sd); + rv = zfs_iter_filesystems(zhp, 0, zfs_snapshot_cb, sd); zfs_close(zhp); return (rv); } @@ -6278,7 +6281,7 @@ zfs_do_allow_unallow_impl(int argc, char **argv, boolean_t un) if (un && opts.recursive) { struct deleg_perms data = { un, update_perm_nvl }; - if (zfs_iter_filesystems(zhp, set_deleg_perms, + if (zfs_iter_filesystems(zhp, 0, set_deleg_perms, &data) != 0) goto cleanup0; } @@ -6641,7 +6644,7 @@ get_one_dataset(zfs_handle_t *zhp, void *data) /* * Iterate over any nested datasets. */ - if (zfs_iter_filesystems(zhp, get_one_dataset, data) != 0) { + if (zfs_iter_filesystems(zhp, 0, get_one_dataset, data) != 0) { zfs_close(zhp); return (1); } diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 4e2f828cb2b..dd5c3f205f7 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -8814,7 +8814,7 @@ check_unsupp_fs(zfs_handle_t *zhp, void *unsupp_fs) (*count)++; } - zfs_iter_filesystems(zhp, check_unsupp_fs, unsupp_fs); + zfs_iter_filesystems(zhp, 0, check_unsupp_fs, unsupp_fs); zfs_close(zhp); diff --git a/contrib/pam_zfs_key/pam_zfs_key.c b/contrib/pam_zfs_key/pam_zfs_key.c index dead090f970..d87384cee65 100644 --- a/contrib/pam_zfs_key/pam_zfs_key.c +++ b/contrib/pam_zfs_key/pam_zfs_key.c @@ -532,7 +532,7 @@ zfs_key_config_get_dataset(zfs_key_config_t *config) return (NULL); } - (void) zfs_iter_filesystems(zhp, find_dsname_by_prop_value, + (void) zfs_iter_filesystems(zhp, 0, find_dsname_by_prop_value, config); zfs_close(zhp); char *dsname = config->dsname; diff --git a/include/libzfs.h b/include/libzfs.h index e135ae2ee06..afa6d6a376b 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -644,19 +644,27 @@ _LIBZFS_H void zprop_print_one_property(const char *, zprop_get_cbdata_t *, /* * Iterator functions. */ +#define ZFS_ITER_RECURSE (1 << 0) +#define ZFS_ITER_ARGS_CAN_BE_PATHS (1 << 1) +#define ZFS_ITER_PROP_LISTSNAPS (1 << 2) +#define ZFS_ITER_DEPTH_LIMIT (1 << 3) +#define ZFS_ITER_RECVD_PROPS (1 << 4) +#define ZFS_ITER_LITERAL_PROPS (1 << 5) +#define ZFS_ITER_SIMPLE (1 << 6) + typedef int (*zfs_iter_f)(zfs_handle_t *, void *); _LIBZFS_H int zfs_iter_root(libzfs_handle_t *, zfs_iter_f, void *); -_LIBZFS_H int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *); -_LIBZFS_H int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, +_LIBZFS_H int zfs_iter_children(zfs_handle_t *, int, zfs_iter_f, void *); +_LIBZFS_H int zfs_iter_dependents(zfs_handle_t *, int, boolean_t, zfs_iter_f, void *); -_LIBZFS_H int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *); -_LIBZFS_H int zfs_iter_snapshots(zfs_handle_t *, boolean_t, zfs_iter_f, void *, +_LIBZFS_H int zfs_iter_filesystems(zfs_handle_t *, int, zfs_iter_f, void *); +_LIBZFS_H int zfs_iter_snapshots(zfs_handle_t *, int, zfs_iter_f, void *, uint64_t, uint64_t); -_LIBZFS_H int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *, +_LIBZFS_H int zfs_iter_snapshots_sorted(zfs_handle_t *, int, zfs_iter_f, void *, uint64_t, uint64_t); -_LIBZFS_H int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f, +_LIBZFS_H int zfs_iter_snapspec(zfs_handle_t *, int, const char *, zfs_iter_f, void *); -_LIBZFS_H int zfs_iter_bookmarks(zfs_handle_t *, zfs_iter_f, void *); +_LIBZFS_H int zfs_iter_bookmarks(zfs_handle_t *, int, zfs_iter_f, void *); _LIBZFS_H int zfs_iter_mounted(zfs_handle_t *, zfs_iter_f, void *); typedef struct get_all_cb { diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 9bd1fd0db0e..08767c38140 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -4009,13 +4009,14 @@ + - + @@ -4024,12 +4025,14 @@ + + @@ -4038,6 +4041,7 @@ + @@ -4045,12 +4049,14 @@ + + diff --git a/lib/libzfs/libzfs_changelist.c b/lib/libzfs/libzfs_changelist.c index 4d90a511f60..cb0b0fd0dbc 100644 --- a/lib/libzfs/libzfs_changelist.c +++ b/lib/libzfs/libzfs_changelist.c @@ -551,7 +551,7 @@ change_one(zfs_handle_t *zhp, void *data) } if (!clp->cl_alldependents) - ret = zfs_iter_children(zhp, change_one, data); + ret = zfs_iter_children(zhp, 0, change_one, data); /* * If we added the handle to the changelist, we will re-use it @@ -721,11 +721,11 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags, return (NULL); } } else if (clp->cl_alldependents) { - if (zfs_iter_dependents(zhp, B_TRUE, change_one, clp) != 0) { + if (zfs_iter_dependents(zhp, 0, B_TRUE, change_one, clp) != 0) { changelist_free(clp); return (NULL); } - } else if (zfs_iter_children(zhp, change_one, clp) != 0) { + } else if (zfs_iter_children(zhp, 0, change_one, clp) != 0) { changelist_free(clp); return (NULL); } diff --git a/lib/libzfs/libzfs_crypto.c b/lib/libzfs/libzfs_crypto.c index cfe04a79273..f55c1c957d8 100644 --- a/lib/libzfs/libzfs_crypto.c +++ b/lib/libzfs/libzfs_crypto.c @@ -1226,7 +1226,7 @@ load_keys_cb(zfs_handle_t *zhp, void *arg) cb->cb_numfailed++; out: - (void) zfs_iter_filesystems(zhp, load_keys_cb, cb); + (void) zfs_iter_filesystems(zhp, 0, load_keys_cb, cb); zfs_close(zhp); /* always return 0, since this function is best effort */ diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 5836587d27e..2b0bba47ab7 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -529,9 +529,17 @@ make_dataset_simple_handle_zc(zfs_handle_t *pzhp, zfs_cmd_t *zc) zhp->zfs_hdl = pzhp->zfs_hdl; (void) strlcpy(zhp->zfs_name, zc->zc_name, sizeof (zhp->zfs_name)); - zhp->zfs_head_type = pzhp->zfs_type; - zhp->zfs_type = ZFS_TYPE_SNAPSHOT; zhp->zpool_hdl = zpool_handle(zhp); + zhp->zfs_dmustats = zc->zc_objset_stats; /* structure assignment */ + zhp->zfs_head_type = pzhp->zfs_type; + if (zhp->zfs_dmustats.dds_is_snapshot) + zhp->zfs_type = ZFS_TYPE_SNAPSHOT; + else if (zhp->zfs_dmustats.dds_type == DMU_OST_ZVOL) + zhp->zfs_type = ZFS_TYPE_VOLUME; + else if (zhp->zfs_dmustats.dds_type == DMU_OST_ZFS) + zhp->zfs_type = ZFS_TYPE_FILESYSTEM; + else + abort(); /* we should never see any other types */ return (zhp); } @@ -737,7 +745,7 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types) * Iterate bookmarks to find the right one. */ errno = 0; - if ((zfs_iter_bookmarks(pzhp, zfs_open_bookmarks_cb, + if ((zfs_iter_bookmarks(pzhp, 0, zfs_open_bookmarks_cb, &cb_data) == 0) && (cb_data.zhp == NULL)) { (void) zfs_error(hdl, EZFS_NOENT, errbuf); zfs_close(pzhp); @@ -2087,7 +2095,8 @@ getprop_string(zfs_handle_t *zhp, zfs_prop_t prop, char **source) static boolean_t zfs_is_recvd_props_mode(zfs_handle_t *zhp) { - return (zhp->zfs_props == zhp->zfs_recvd_props); + return (zhp->zfs_props != NULL && + zhp->zfs_props == zhp->zfs_recvd_props); } static void @@ -2292,6 +2301,20 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src, *val = zhp->zfs_dmustats.dds_redacted; break; + case ZFS_PROP_GUID: + if (zhp->zfs_dmustats.dds_guid != 0) + *val = zhp->zfs_dmustats.dds_guid; + else + *val = getprop_uint64(zhp, prop, source); + break; + + case ZFS_PROP_CREATETXG: + if (zhp->zfs_dmustats.dds_creation_txg != 0) + *val = zhp->zfs_dmustats.dds_creation_txg; + else + *val = getprop_uint64(zhp, prop, source); + break; + default: switch (zfs_prop_get_type(prop)) { case PROP_TYPE_NUMBER: @@ -2435,7 +2458,7 @@ get_clones_cb(zfs_handle_t *zhp, void *arg) } out: - (void) zfs_iter_children(zhp, get_clones_cb, gca); + (void) zfs_iter_children(zhp, 0, get_clones_cb, gca); zfs_close(zhp); return (0); } @@ -2722,7 +2745,9 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, break; case ZFS_PROP_ORIGIN: - str = getprop_string(zhp, prop, &source); + str = (char *)&zhp->zfs_dmustats.dds_origin; + if (*str == '\0') + str = zfs_prop_default_string(prop); if (str == NULL) return (-1); (void) strlcpy(propbuf, str, proplen); @@ -3857,7 +3882,7 @@ zfs_check_snap_cb(zfs_handle_t *zhp, void *arg) if (lzc_exists(name)) verify(nvlist_add_boolean(dd->nvl, name) == 0); - rv = zfs_iter_filesystems(zhp, zfs_check_snap_cb, dd); + rv = zfs_iter_filesystems(zhp, 0, zfs_check_snap_cb, dd); zfs_close(zhp); return (rv); } @@ -4098,7 +4123,7 @@ zfs_snapshot_cb(zfs_handle_t *zhp, void *arg) fnvlist_add_boolean(sd->sd_nvl, name); - rv = zfs_iter_filesystems(zhp, zfs_snapshot_cb, sd); + rv = zfs_iter_filesystems(zhp, 0, zfs_snapshot_cb, sd); } zfs_close(zhp); @@ -4273,7 +4298,7 @@ rollback_destroy(zfs_handle_t *zhp, void *data) rollback_data_t *cbp = data; if (zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG) > cbp->cb_create) { - cbp->cb_error |= zfs_iter_dependents(zhp, B_FALSE, + cbp->cb_error |= zfs_iter_dependents(zhp, 0, B_FALSE, rollback_destroy_dependent, cbp); cbp->cb_error |= zfs_destroy(zhp, B_FALSE); @@ -4313,10 +4338,10 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force) if (cb.cb_create > 0) min_txg = cb.cb_create; - (void) zfs_iter_snapshots(zhp, B_FALSE, rollback_destroy, &cb, + (void) zfs_iter_snapshots(zhp, 0, rollback_destroy, &cb, min_txg, 0); - (void) zfs_iter_bookmarks(zhp, rollback_destroy, &cb); + (void) zfs_iter_bookmarks(zhp, 0, rollback_destroy, &cb); if (cb.cb_error) return (-1); @@ -4908,7 +4933,7 @@ zfs_hold_one(zfs_handle_t *zhp, void *arg) fnvlist_add_string(ha->nvl, name, ha->tag); if (ha->recursive) - rv = zfs_iter_filesystems(zhp, zfs_hold_one, ha); + rv = zfs_iter_filesystems(zhp, 0, zfs_hold_one, ha); zfs_close(zhp); return (rv); } @@ -5039,7 +5064,7 @@ zfs_release_one(zfs_handle_t *zhp, void *arg) } if (ha->recursive) - rv = zfs_iter_filesystems(zhp, zfs_release_one, ha); + rv = zfs_iter_filesystems(zhp, 0, zfs_release_one, ha); zfs_close(zhp); return (rv); } diff --git a/lib/libzfs/libzfs_iter.c b/lib/libzfs/libzfs_iter.c index 3c537be7948..0e9d972017d 100644 --- a/lib/libzfs/libzfs_iter.c +++ b/lib/libzfs/libzfs_iter.c @@ -39,7 +39,7 @@ #include "libzfs_impl.h" static int -zfs_iter_clones(zfs_handle_t *zhp, zfs_iter_f func, void *data) +zfs_iter_clones(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data) { nvlist_t *nvl = zfs_get_clones_nvl(zhp); nvpair_t *pair; @@ -104,7 +104,7 @@ top: * Iterate over all child filesystems */ int -zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data) +zfs_iter_filesystems(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data) { zfs_cmd_t zc = {"\0"}; zfs_handle_t *nzhp; @@ -113,19 +113,24 @@ zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data) if (zhp->zfs_type != ZFS_TYPE_FILESYSTEM) return (0); + if ((flags & ZFS_ITER_SIMPLE) == ZFS_ITER_SIMPLE) + zc.zc_simple = B_TRUE; + if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0) return (-1); while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_DATASET_LIST_NEXT, &zc)) == 0) { + if (zc.zc_simple) + nzhp = make_dataset_simple_handle_zc(zhp, &zc); + else + nzhp = make_dataset_handle_zc(zhp->zfs_hdl, &zc); /* * Silently ignore errors, as the only plausible explanation is * that the pool has since been removed. */ - if ((nzhp = make_dataset_handle_zc(zhp->zfs_hdl, - &zc)) == NULL) { + if (nzhp == NULL) continue; - } if ((ret = func(nzhp, data)) != 0) { zcmd_free_nvlists(&zc); @@ -140,7 +145,7 @@ zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data) * Iterate over all snapshots */ int -zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func, +zfs_iter_snapshots(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data, uint64_t min_txg, uint64_t max_txg) { zfs_cmd_t zc = {"\0"}; @@ -152,7 +157,7 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func, zhp->zfs_type == ZFS_TYPE_BOOKMARK) return (0); - zc.zc_simple = simple; + zc.zc_simple = (flags & ZFS_ITER_SIMPLE) != 0; if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0) return (-1); @@ -177,7 +182,7 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func, while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_SNAPSHOT_LIST_NEXT, &zc)) == 0) { - if (simple) + if (zc.zc_simple) nzhp = make_dataset_simple_handle_zc(zhp, &zc); else nzhp = make_dataset_handle_zc(zhp->zfs_hdl, &zc); @@ -199,7 +204,7 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func, * Iterate over all bookmarks */ int -zfs_iter_bookmarks(zfs_handle_t *zhp, zfs_iter_f func, void *data) +zfs_iter_bookmarks(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data) { zfs_handle_t *nzhp; nvlist_t *props = NULL; @@ -306,8 +311,8 @@ zfs_snapshot_compare(const void *larg, const void *rarg) } int -zfs_iter_snapshots_sorted(zfs_handle_t *zhp, zfs_iter_f callback, void *data, - uint64_t min_txg, uint64_t max_txg) +zfs_iter_snapshots_sorted(zfs_handle_t *zhp, int flags, zfs_iter_f callback, + void *data, uint64_t min_txg, uint64_t max_txg) { int ret = 0; zfs_node_t *node; @@ -317,7 +322,7 @@ zfs_iter_snapshots_sorted(zfs_handle_t *zhp, zfs_iter_f callback, void *data, avl_create(&avl, zfs_snapshot_compare, sizeof (zfs_node_t), offsetof(zfs_node_t, zn_avlnode)); - ret = zfs_iter_snapshots(zhp, B_FALSE, zfs_sort_snaps, &avl, min_txg, + ret = zfs_iter_snapshots(zhp, flags, zfs_sort_snaps, &avl, min_txg, max_txg); for (node = avl_first(&avl); node != NULL; node = AVL_NEXT(&avl, node)) @@ -380,7 +385,7 @@ snapspec_cb(zfs_handle_t *zhp, void *arg) * return ENOENT at the end. */ int -zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig, +zfs_iter_snapspec(zfs_handle_t *fs_zhp, int flags, const char *spec_orig, zfs_iter_f func, void *arg) { char *buf, *comma_separated, *cp; @@ -420,7 +425,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig, } } - err = zfs_iter_snapshots_sorted(fs_zhp, + err = zfs_iter_snapshots_sorted(fs_zhp, flags, snapspec_cb, &ssa, 0, 0); if (ret == 0) ret = err; @@ -457,14 +462,14 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig, * and as close as possible. */ int -zfs_iter_children(zfs_handle_t *zhp, zfs_iter_f func, void *data) +zfs_iter_children(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data) { int ret; - if ((ret = zfs_iter_snapshots(zhp, B_FALSE, func, data, 0, 0)) != 0) + if ((ret = zfs_iter_snapshots(zhp, flags, func, data, 0, 0)) != 0) return (ret); - return (zfs_iter_filesystems(zhp, func, data)); + return (zfs_iter_filesystems(zhp, flags, func, data)); } @@ -475,6 +480,7 @@ typedef struct iter_stack_frame { typedef struct iter_dependents_arg { boolean_t first; + int flags; boolean_t allowrecursion; iter_stack_frame_t *stack; zfs_iter_f func; @@ -490,7 +496,7 @@ iter_dependents_cb(zfs_handle_t *zhp, void *arg) ida->first = B_FALSE; if (zhp->zfs_type == ZFS_TYPE_SNAPSHOT) { - err = zfs_iter_clones(zhp, iter_dependents_cb, ida); + err = zfs_iter_clones(zhp, ida->flags, iter_dependents_cb, ida); } else if (zhp->zfs_type != ZFS_TYPE_BOOKMARK) { iter_stack_frame_t isf; iter_stack_frame_t *f; @@ -524,9 +530,10 @@ iter_dependents_cb(zfs_handle_t *zhp, void *arg) isf.zhp = zhp; isf.next = ida->stack; ida->stack = &isf; - err = zfs_iter_filesystems(zhp, iter_dependents_cb, ida); + err = zfs_iter_filesystems(zhp, ida->flags, + iter_dependents_cb, ida); if (err == 0) - err = zfs_iter_snapshots(zhp, B_FALSE, + err = zfs_iter_snapshots(zhp, ida->flags, iter_dependents_cb, ida, 0, 0); ida->stack = isf.next; } @@ -540,10 +547,11 @@ iter_dependents_cb(zfs_handle_t *zhp, void *arg) } int -zfs_iter_dependents(zfs_handle_t *zhp, boolean_t allowrecursion, +zfs_iter_dependents(zfs_handle_t *zhp, int flags, boolean_t allowrecursion, zfs_iter_f func, void *data) { iter_dependents_arg_t ida; + ida.flags = flags; ida.allowrecursion = allowrecursion; ida.stack = NULL; ida.func = func; diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index e97de8f2026..62fed92fa90 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -1128,7 +1128,7 @@ zfs_iter_cb(zfs_handle_t *zhp, void *data) } libzfs_add_handle(cbp, zhp); - if (zfs_iter_filesystems(zhp, zfs_iter_cb, cbp) != 0) { + if (zfs_iter_filesystems(zhp, 0, zfs_iter_cb, cbp) != 0) { zfs_close(zhp); return (-1); } @@ -1475,7 +1475,7 @@ zpool_enable_datasets(zpool_handle_t *zhp, const char *mntopts, int flags) * over all child filesystems. */ libzfs_add_handle(&cb, zfsp); - if (zfs_iter_filesystems(zfsp, zfs_iter_cb, &cb) != 0) + if (zfs_iter_filesystems(zfsp, 0, zfs_iter_cb, &cb) != 0) goto out; /* diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 7460ffc4133..098c7777ce6 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -597,7 +597,7 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg) min_txg = fromsnap_txg; if (!sd->replicate && tosnap_txg != 0) max_txg = tosnap_txg; - (void) zfs_iter_snapshots_sorted(zhp, send_iterate_snap, sd, + (void) zfs_iter_snapshots_sorted(zhp, 0, send_iterate_snap, sd, min_txg, max_txg); } else { char snapname[MAXPATHLEN] = { 0 }; @@ -640,7 +640,7 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg) /* iterate over children */ if (sd->recursive) - rv = zfs_iter_filesystems(zhp, send_iterate_fs, sd); + rv = zfs_iter_filesystems(zhp, 0, send_iterate_fs, sd); out: sd->parent_fromsnap_guid = parent_fromsnap_guid_save; @@ -1212,7 +1212,7 @@ dump_filesystem(zfs_handle_t *zhp, void *arg) if (!sdd->replicate && sdd->tosnap != NULL) max_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, sdd->tosnap); - rv = zfs_iter_snapshots_sorted(zhp, dump_snapshot, arg, + rv = zfs_iter_snapshots_sorted(zhp, 0, dump_snapshot, arg, min_txg, max_txg); } else { char snapname[MAXPATHLEN] = { 0 }; @@ -2959,9 +2959,9 @@ guid_to_name_cb(zfs_handle_t *zhp, void *arg) return (EEXIST); } - err = zfs_iter_children(zhp, guid_to_name_cb, gtnd); + err = zfs_iter_children(zhp, 0, guid_to_name_cb, gtnd); if (err != EEXIST && gtnd->bookmark_ok) - err = zfs_iter_bookmarks(zhp, guid_to_name_cb, gtnd); + err = zfs_iter_bookmarks(zhp, 0, guid_to_name_cb, gtnd); zfs_close(zhp); return (err); } @@ -3015,9 +3015,10 @@ guid_to_name_redact_snaps(libzfs_handle_t *hdl, const char *parent, continue; int err = guid_to_name_cb(zfs_handle_dup(zhp), >nd); if (err != EEXIST) - err = zfs_iter_children(zhp, guid_to_name_cb, >nd); + err = zfs_iter_children(zhp, 0, guid_to_name_cb, >nd); if (err != EEXIST && bookmark_ok) - err = zfs_iter_bookmarks(zhp, guid_to_name_cb, >nd); + err = zfs_iter_bookmarks(zhp, 0, guid_to_name_cb, + >nd); zfs_close(zhp); if (err == EEXIST) return (0); diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index ca2da561220..065540bbd2a 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -2044,7 +2044,7 @@ zfs_ioc_objset_stats_impl(zfs_cmd_t *zc, objset_t *os) dmu_objset_fast_stat(os, &zc->zc_objset_stats); - if (zc->zc_nvlist_dst != 0 && + if (!zc->zc_simple && zc->zc_nvlist_dst != 0 && (error = dsl_prop_get_all(os, &nv)) == 0) { dmu_objset_stats(os, nv); /* @@ -2331,6 +2331,7 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc) } if (zc->zc_simple) { + dsl_dataset_fast_stat(ds, &zc->zc_objset_stats); dsl_dataset_rele(ds, FTAG); break; } From 92a9e8c6181381119ae5c7699748307cf90dfe1c Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Thu, 16 Dec 2021 16:22:15 -0500 Subject: [PATCH 003/117] FreeBSD: Provide correct file generation number va_seq was actually a thin veil over va_gen, so z_gen is a more appropriate value than z_seq to populate the field with. Drop the unnecessary compat obfuscation and provide the correct file generation number. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Ryan Moeller Closes #12851 --- include/os/freebsd/spl/sys/vnode.h | 1 - module/os/freebsd/zfs/zfs_ctldir.c | 2 +- module/os/freebsd/zfs/zfs_vnops_os.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/os/freebsd/spl/sys/vnode.h b/include/os/freebsd/spl/sys/vnode.h index 1ac595aa15d..d2c900854ac 100644 --- a/include/os/freebsd/spl/sys/vnode.h +++ b/include/os/freebsd/spl/sys/vnode.h @@ -134,7 +134,6 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync) /* TODO: This field needs conversion! */ #define va_nblocks va_bytes #define va_blksize va_blocksize -#define va_seq va_gen #define MAXOFFSET_T OFF_MAX #define EXCL 0 diff --git a/module/os/freebsd/zfs/zfs_ctldir.c b/module/os/freebsd/zfs/zfs_ctldir.c index 11620949dec..206f65b08c5 100644 --- a/module/os/freebsd/zfs/zfs_ctldir.c +++ b/module/os/freebsd/zfs/zfs_ctldir.c @@ -496,7 +496,7 @@ zfsctl_common_getattr(vnode_t *vp, vattr_t *vap) */ vap->va_blksize = 0; vap->va_nblocks = 0; - vap->va_seq = 0; + vap->va_gen = 0; vn_fsid(vp, vap); vap->va_mode = zfsctl_ctldir_mode; vap->va_type = VDIR; diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index 9ffaecf4dda..752e5b2f678 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -2051,7 +2051,7 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr) vap->va_size = zp->z_size; if (vp->v_type == VBLK || vp->v_type == VCHR) vap->va_rdev = zfs_cmpldev(rdev); - vap->va_seq = zp->z_seq; + vap->va_gen = zp->z_gen; vap->va_flags = 0; /* FreeBSD: Reset chflags(2) flags. */ vap->va_filerev = zp->z_seq; From 8fdc6f618cf19e1894f5a803e043e80e762a86b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 16 Dec 2021 22:26:04 +0100 Subject: [PATCH 004/117] zcommon: *_prop: make all zprop_index_t tables const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They're already static, and there's no point in them being R/W and living outside .rodata Reviewed-by: RageLtMan Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12836 --- module/zcommon/zfs_prop.c | 48 ++++++++++++++++++------------------- module/zcommon/zpool_prop.c | 8 +++---- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 2a0e26eca9c..592ba8bc32e 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -74,7 +74,7 @@ zfs_prop_get_table(void) void zfs_prop_init(void) { - static zprop_index_t checksum_table[] = { + static const zprop_index_t checksum_table[] = { { "on", ZIO_CHECKSUM_ON }, { "off", ZIO_CHECKSUM_OFF }, { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 }, @@ -87,7 +87,7 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t dedup_table[] = { + static const zprop_index_t dedup_table[] = { { "on", ZIO_CHECKSUM_ON }, { "off", ZIO_CHECKSUM_OFF }, { "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY }, @@ -105,7 +105,7 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t compress_table[] = { + static const zprop_index_t compress_table[] = { { "on", ZIO_COMPRESS_ON }, { "off", ZIO_COMPRESS_OFF }, { "lzjb", ZIO_COMPRESS_LZJB }, @@ -205,7 +205,7 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t crypto_table[] = { + static const zprop_index_t crypto_table[] = { { "on", ZIO_CRYPT_ON }, { "off", ZIO_CRYPT_OFF }, { "aes-128-ccm", ZIO_CRYPT_AES_128_CCM }, @@ -217,7 +217,7 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t keyformat_table[] = { + static const zprop_index_t keyformat_table[] = { { "none", ZFS_KEYFORMAT_NONE }, { "raw", ZFS_KEYFORMAT_RAW }, { "hex", ZFS_KEYFORMAT_HEX }, @@ -225,19 +225,19 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t snapdir_table[] = { + static const zprop_index_t snapdir_table[] = { { "hidden", ZFS_SNAPDIR_HIDDEN }, { "visible", ZFS_SNAPDIR_VISIBLE }, { NULL } }; - static zprop_index_t snapdev_table[] = { + static const zprop_index_t snapdev_table[] = { { "hidden", ZFS_SNAPDEV_HIDDEN }, { "visible", ZFS_SNAPDEV_VISIBLE }, { NULL } }; - static zprop_index_t acl_mode_table[] = { + static const zprop_index_t acl_mode_table[] = { { "discard", ZFS_ACL_DISCARD }, { "groupmask", ZFS_ACL_GROUPMASK }, { "passthrough", ZFS_ACL_PASSTHROUGH }, @@ -245,7 +245,7 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t acltype_table[] = { + static const zprop_index_t acltype_table[] = { { "off", ZFS_ACLTYPE_OFF }, { "posix", ZFS_ACLTYPE_POSIX }, { "nfsv4", ZFS_ACLTYPE_NFSV4 }, @@ -255,7 +255,7 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t acl_inherit_table[] = { + static const zprop_index_t acl_inherit_table[] = { { "discard", ZFS_ACL_DISCARD }, { "noallow", ZFS_ACL_NOALLOW }, { "restricted", ZFS_ACL_RESTRICTED }, @@ -265,14 +265,14 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t case_table[] = { + static const zprop_index_t case_table[] = { { "sensitive", ZFS_CASE_SENSITIVE }, { "insensitive", ZFS_CASE_INSENSITIVE }, { "mixed", ZFS_CASE_MIXED }, { NULL } }; - static zprop_index_t copies_table[] = { + static const zprop_index_t copies_table[] = { { "1", 1 }, { "2", 2 }, { "3", 3 }, @@ -284,7 +284,7 @@ zfs_prop_init(void) * u8_textprep() to represent the various normalization property * values. */ - static zprop_index_t normalize_table[] = { + static const zprop_index_t normalize_table[] = { { "none", 0 }, { "formD", U8_TEXTPREP_NFD }, { "formKC", U8_TEXTPREP_NFKC }, @@ -293,7 +293,7 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t version_table[] = { + static const zprop_index_t version_table[] = { { "1", 1 }, { "2", 2 }, { "3", 3 }, @@ -303,47 +303,47 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t boolean_table[] = { + static const zprop_index_t boolean_table[] = { { "off", 0 }, { "on", 1 }, { NULL } }; - static zprop_index_t keystatus_table[] = { + static const zprop_index_t keystatus_table[] = { { "none", ZFS_KEYSTATUS_NONE}, { "unavailable", ZFS_KEYSTATUS_UNAVAILABLE}, { "available", ZFS_KEYSTATUS_AVAILABLE}, { NULL } }; - static zprop_index_t logbias_table[] = { + static const zprop_index_t logbias_table[] = { { "latency", ZFS_LOGBIAS_LATENCY }, { "throughput", ZFS_LOGBIAS_THROUGHPUT }, { NULL } }; - static zprop_index_t canmount_table[] = { + static const zprop_index_t canmount_table[] = { { "off", ZFS_CANMOUNT_OFF }, { "on", ZFS_CANMOUNT_ON }, { "noauto", ZFS_CANMOUNT_NOAUTO }, { NULL } }; - static zprop_index_t cache_table[] = { + static const zprop_index_t cache_table[] = { { "none", ZFS_CACHE_NONE }, { "metadata", ZFS_CACHE_METADATA }, { "all", ZFS_CACHE_ALL }, { NULL } }; - static zprop_index_t sync_table[] = { + static const zprop_index_t sync_table[] = { { "standard", ZFS_SYNC_STANDARD }, { "always", ZFS_SYNC_ALWAYS }, { "disabled", ZFS_SYNC_DISABLED }, { NULL } }; - static zprop_index_t xattr_table[] = { + static const zprop_index_t xattr_table[] = { { "off", ZFS_XATTR_OFF }, { "on", ZFS_XATTR_DIR }, { "sa", ZFS_XATTR_SA }, @@ -351,7 +351,7 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t dnsize_table[] = { + static const zprop_index_t dnsize_table[] = { { "legacy", ZFS_DNSIZE_LEGACY }, { "auto", ZFS_DNSIZE_AUTO }, { "1k", ZFS_DNSIZE_1K }, @@ -362,13 +362,13 @@ zfs_prop_init(void) { NULL } }; - static zprop_index_t redundant_metadata_table[] = { + static const zprop_index_t redundant_metadata_table[] = { { "all", ZFS_REDUNDANT_METADATA_ALL }, { "most", ZFS_REDUNDANT_METADATA_MOST }, { NULL } }; - static zprop_index_t volmode_table[] = { + static const zprop_index_t volmode_table[] = { { "default", ZFS_VOLMODE_DEFAULT }, { "full", ZFS_VOLMODE_GEOM }, { "geom", ZFS_VOLMODE_GEOM }, diff --git a/module/zcommon/zpool_prop.c b/module/zcommon/zpool_prop.c index 8e7a20e8efd..bfe4ef9adc8 100644 --- a/module/zcommon/zpool_prop.c +++ b/module/zcommon/zpool_prop.c @@ -52,13 +52,13 @@ zpool_prop_get_table(void) void zpool_prop_init(void) { - static zprop_index_t boolean_table[] = { + static const zprop_index_t boolean_table[] = { { "off", 0}, { "on", 1}, { NULL } }; - static zprop_index_t failuremode_table[] = { + static const zprop_index_t failuremode_table[] = { { "wait", ZIO_FAILURE_MODE_WAIT }, { "continue", ZIO_FAILURE_MODE_CONTINUE }, { "panic", ZIO_FAILURE_MODE_PANIC }, @@ -271,12 +271,12 @@ vdev_prop_get_table(void) void vdev_prop_init(void) { - static zprop_index_t boolean_table[] = { + static const zprop_index_t boolean_table[] = { { "off", 0}, { "on", 1}, { NULL } }; - static zprop_index_t boolean_na_table[] = { + static const zprop_index_t boolean_na_table[] = { { "off", 0}, { "on", 1}, { "-", 2}, /* ZPROP_BOOLEAN_NA */ From eb51a9d74742bd2dc4e31c1806532149593101df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 17 Dec 2021 01:43:10 +0100 Subject: [PATCH 005/117] zcommon: pre-iterate over sysfs instead of statting every feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If sufficient memory (<2K, realistically) is available, libzfs_init() can be significantly shorted by iterating over the correct sysfs directory before registrations, we can turn 168 stats into 15/18 syscalls (3 opens (6 if built in), 3 fstats, 6 getdentses, and 3 closes), a tenfoldish reduction; this is probably a bit faster, too. The list is always optional, and registration functions (and one-off users) can simply pass NULL, which will fall back to the previous mechanism Also, don't allocate in zfs_mod_supported_impl, and use use access() instead of stat(), since existence is really what we care about Also, fix pre-prop-checking compat in fallback for built-in ZFS Reviewed-by: Brian Behlendorf Reviewed-by: Tony Nguyen Signed-off-by: Ahelenia Ziemiańska Closes #12089 --- include/sys/zfs_sysfs.h | 7 +- include/zfs_prop.h | 15 +- lib/libzfs/libzfs.abi | 16 + module/zcommon/zfeature_common.c | 535 ++++++++++++++++++------------- module/zcommon/zfs_prop.c | 215 +++++++------ module/zcommon/zpool_prop.c | 171 +++++----- module/zcommon/zprop_common.c | 30 +- 7 files changed, 584 insertions(+), 405 deletions(-) diff --git a/include/sys/zfs_sysfs.h b/include/sys/zfs_sysfs.h index 912ef234f8c..d1cb2ef4321 100644 --- a/include/sys/zfs_sysfs.h +++ b/include/sys/zfs_sysfs.h @@ -25,6 +25,10 @@ #ifndef _SYS_ZFS_SYSFS_H #define _SYS_ZFS_SYSFS_H extern __attribute__((visibility("default"))) +struct zfs_mod_supported_features; +struct zfs_mod_supported_features *zfs_mod_list_supported(const char *scope); +void zfs_mod_list_supported_free(struct zfs_mod_supported_features *); + #ifdef _KERNEL void zfs_sysfs_init(void); @@ -35,7 +39,8 @@ void zfs_sysfs_fini(void); #define zfs_sysfs_init() #define zfs_sysfs_fini() -_SYS_ZFS_SYSFS_H boolean_t zfs_mod_supported(const char *, const char *); +_SYS_ZFS_SYSFS_H boolean_t zfs_mod_supported(const char *, const char *, + const struct zfs_mod_supported_features *); #endif #define ZFS_SYSFS_POOL_PROPERTIES "properties.pool" diff --git a/include/zfs_prop.h b/include/zfs_prop.h index 8014c757aaf..c7363f70153 100644 --- a/include/zfs_prop.h +++ b/include/zfs_prop.h @@ -28,6 +28,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -111,15 +112,19 @@ _ZFS_PROP_H zprop_desc_t *vdev_prop_get_table(void); */ _ZFS_PROP_H void zprop_register_impl(int, const char *, zprop_type_t, uint64_t, const char *, zprop_attr_t, int, const char *, const char *, - boolean_t, boolean_t, const zprop_index_t *); + boolean_t, boolean_t, const zprop_index_t *, + const struct zfs_mod_supported_features *); _ZFS_PROP_H void zprop_register_string(int, const char *, const char *, - zprop_attr_t attr, int, const char *, const char *); + zprop_attr_t attr, int, const char *, const char *, + const struct zfs_mod_supported_features *); _ZFS_PROP_H void zprop_register_number(int, const char *, uint64_t, - zprop_attr_t, int, const char *, const char *); + zprop_attr_t, int, const char *, const char *, + const struct zfs_mod_supported_features *); _ZFS_PROP_H void zprop_register_index(int, const char *, uint64_t, zprop_attr_t, - int, const char *, const char *, const zprop_index_t *); + int, const char *, const char *, const zprop_index_t *, + const struct zfs_mod_supported_features *); _ZFS_PROP_H void zprop_register_hidden(int, const char *, zprop_type_t, - zprop_attr_t, int, const char *); + zprop_attr_t, int, const char *, const struct zfs_mod_supported_features *); /* * Common routines for zfs and zpool property management diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 08767c38140..ce26c5ee066 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -1947,8 +1947,18 @@ + + + + + + + + + + @@ -1978,6 +1988,7 @@ + @@ -2793,6 +2804,7 @@ + @@ -2803,6 +2815,7 @@ + @@ -2813,6 +2826,7 @@ + @@ -2824,6 +2838,7 @@ + @@ -2833,6 +2848,7 @@ + diff --git a/module/zcommon/zfeature_common.c b/module/zcommon/zfeature_common.c index 8d84c6d1514..c7278fa0076 100644 --- a/module/zcommon/zfeature_common.c +++ b/module/zcommon/zfeature_common.c @@ -32,6 +32,8 @@ #ifndef _KERNEL #include #include +#include +#include #include #endif #include @@ -164,30 +166,109 @@ deps_contains_feature(const spa_feature_t *deps, const spa_feature_t feature) return (B_FALSE); } +#define STRCMP ((int(*)(const void *, const void *))&strcmp) +struct zfs_mod_supported_features { + void *tree; + boolean_t all_features; +}; + +struct zfs_mod_supported_features * +zfs_mod_list_supported(const char *scope) +{ +#if defined(__FreeBSD__) || defined(_KERNEL) || defined(LIB_ZPOOL_BUILD) + (void) scope; + return (NULL); +#else + struct zfs_mod_supported_features *ret = calloc(1, sizeof (*ret)); + if (ret == NULL) + return (NULL); + + DIR *sysfs_dir = NULL; + char path[128]; + + if (snprintf(path, sizeof (path), "%s/%s", + ZFS_SYSFS_DIR, scope) < sizeof (path)) + sysfs_dir = opendir(path); + if (sysfs_dir == NULL && errno == ENOENT) { + if (snprintf(path, sizeof (path), "%s/%s", + ZFS_SYSFS_ALT_DIR, scope) < sizeof (path)) + sysfs_dir = opendir(path); + } + if (sysfs_dir == NULL) { + ret->all_features = errno == ENOENT && + (access(ZFS_SYSFS_DIR, F_OK) == 0 || + access(ZFS_SYSFS_ALT_DIR, F_OK) == 0); + return (ret); + } + + struct dirent *node; + while ((node = readdir(sysfs_dir)) != NULL) { + if (strcmp(node->d_name, ".") == 0 || + strcmp(node->d_name, "..") == 0) + continue; + + char *name = strdup(node->d_name); + if (name == NULL) { + goto nomem; + } + + if (tsearch(name, &ret->tree, STRCMP) == NULL) { + /* + * Don't bother checking for duplicate entries: + * we're iterating a single directory. + */ + free(name); + goto nomem; + } + } + +end: + closedir(sysfs_dir); + return (ret); + +nomem: + zfs_mod_list_supported_free(ret); + ret = NULL; + goto end; +#endif +} + +void +zfs_mod_list_supported_free(struct zfs_mod_supported_features *list) +{ +#if !defined(__FreeBSD__) && !defined(_KERNEL) && !defined(LIB_ZPOOL_BUILD) + if (list) { + tdestroy(list->tree, free); + free(list); + } +#else + (void) list; +#endif +} + #if !defined(_KERNEL) && !defined(LIB_ZPOOL_BUILD) static boolean_t zfs_mod_supported_impl(const char *scope, const char *name, const char *sysfs) { - boolean_t supported = B_FALSE; - char *path; - - int len = asprintf(&path, "%s%s%s%s%s", sysfs, - scope == NULL ? "" : "/", scope == NULL ? "" : scope, - name == NULL ? "" : "/", name == NULL ? "" : name); - if (len > 0) { - struct stat64 statbuf; - supported = !!(stat64(path, &statbuf) == 0); - free(path); - } - - return (supported); + char path[128]; + if (snprintf(path, sizeof (path), "%s%s%s%s%s", sysfs, + scope == NULL ? "" : "/", scope ?: "", + name == NULL ? "" : "/", name ?: "") < sizeof (path)) + return (access(path, F_OK) == 0); + else + return (B_FALSE); } boolean_t -zfs_mod_supported(const char *scope, const char *name) +zfs_mod_supported(const char *scope, const char *name, + const struct zfs_mod_supported_features *sfeatures) { boolean_t supported; + if (sfeatures != NULL) + return (sfeatures->all_features || + tfind(name, &sfeatures->tree, STRCMP)); + /* * Check both the primary and alternate sysfs locations to determine * if the required functionality is supported. @@ -202,10 +283,10 @@ zfs_mod_supported(const char *scope, const char *name) * scope directory does not exist. */ if (supported == B_FALSE) { - struct stat64 statbuf; - if ((stat64(ZFS_SYSFS_DIR, &statbuf) == 0) && - !zfs_mod_supported_impl(scope, NULL, ZFS_SYSFS_DIR) && - !zfs_mod_supported_impl(scope, NULL, ZFS_SYSFS_ALT_DIR)) { + if ((access(ZFS_SYSFS_DIR, F_OK) == 0 && + !zfs_mod_supported_impl(scope, NULL, ZFS_SYSFS_DIR)) || + (access(ZFS_SYSFS_ALT_DIR, F_OK) == 0 && + !zfs_mod_supported_impl(scope, NULL, ZFS_SYSFS_ALT_DIR))) { supported = B_TRUE; } } @@ -215,7 +296,8 @@ zfs_mod_supported(const char *scope, const char *name) #endif static boolean_t -zfs_mod_supported_feature(const char *name) +zfs_mod_supported_feature(const char *name, + const struct zfs_mod_supported_features *sfeatures) { /* * The zfs module spa_feature_table[], whether in-kernel or in @@ -229,17 +311,18 @@ zfs_mod_supported_feature(const char *name) */ #if defined(_KERNEL) || defined(LIB_ZPOOL_BUILD) || defined(__FreeBSD__) - (void) name; + (void) name, (void) sfeatures; return (B_TRUE); #else - return (zfs_mod_supported(ZFS_SYSFS_POOL_FEATURES, name)); + return (zfs_mod_supported(ZFS_SYSFS_POOL_FEATURES, name, sfeatures)); #endif } static void zfeature_register(spa_feature_t fid, const char *guid, const char *name, const char *desc, zfeature_flags_t flags, zfeature_type_t type, - const spa_feature_t *deps) + const spa_feature_t *deps, + const struct zfs_mod_supported_features *sfeatures) { zfeature_info_t *feature = &spa_feature_table[fid]; static spa_feature_t nodeps[] = { SPA_FEATURE_NONE }; @@ -264,7 +347,8 @@ zfeature_register(spa_feature_t fid, const char *guid, const char *name, feature->fi_flags = flags; feature->fi_type = type; feature->fi_depends = deps; - feature->fi_zfs_mod_supported = zfs_mod_supported_feature(guid); + feature->fi_zfs_mod_supported = + zfs_mod_supported_feature(guid, sfeatures); } /* @@ -283,318 +367,335 @@ zfeature_register(spa_feature_t fid, const char *guid, const char *name, void zpool_feature_init(void) { + struct zfs_mod_supported_features *sfeatures = + zfs_mod_list_supported(ZFS_SYSFS_POOL_FEATURES); + zfeature_register(SPA_FEATURE_ASYNC_DESTROY, "com.delphix:async_destroy", "async_destroy", "Destroy filesystems asynchronously.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); zfeature_register(SPA_FEATURE_EMPTY_BPOBJ, "com.delphix:empty_bpobj", "empty_bpobj", "Snapshots use less space.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); zfeature_register(SPA_FEATURE_LZ4_COMPRESS, "org.illumos:lz4_compress", "lz4_compress", "LZ4 compression algorithm support.", - ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); zfeature_register(SPA_FEATURE_MULTI_VDEV_CRASH_DUMP, "com.joyent:multi_vdev_crash_dump", "multi_vdev_crash_dump", "Crash dumps to multiple vdev pools.", - 0, ZFEATURE_TYPE_BOOLEAN, NULL); + 0, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures); zfeature_register(SPA_FEATURE_SPACEMAP_HISTOGRAM, "com.delphix:spacemap_histogram", "spacemap_histogram", "Spacemaps maintain space histograms.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); zfeature_register(SPA_FEATURE_ENABLED_TXG, "com.delphix:enabled_txg", "enabled_txg", "Record txg at which a feature is enabled", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); { - static const spa_feature_t hole_birth_deps[] = { - SPA_FEATURE_ENABLED_TXG, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_HOLE_BIRTH, - "com.delphix:hole_birth", "hole_birth", - "Retain hole birth txg for more precise zfs send", - ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, - ZFEATURE_TYPE_BOOLEAN, hole_birth_deps); + static const spa_feature_t hole_birth_deps[] = { + SPA_FEATURE_ENABLED_TXG, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_HOLE_BIRTH, + "com.delphix:hole_birth", "hole_birth", + "Retain hole birth txg for more precise zfs send", + ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, + ZFEATURE_TYPE_BOOLEAN, hole_birth_deps, sfeatures); } zfeature_register(SPA_FEATURE_POOL_CHECKPOINT, "com.delphix:zpool_checkpoint", "zpool_checkpoint", "Pool state can be checkpointed, allowing rewind later.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); zfeature_register(SPA_FEATURE_SPACEMAP_V2, "com.delphix:spacemap_v2", "spacemap_v2", "Space maps representing large segments are more efficient.", ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, - ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures); zfeature_register(SPA_FEATURE_EXTENSIBLE_DATASET, "com.delphix:extensible_dataset", "extensible_dataset", "Enhanced dataset functionality, used by other features.", - 0, ZFEATURE_TYPE_BOOLEAN, NULL); + 0, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures); { - static const spa_feature_t bookmarks_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; + static const spa_feature_t bookmarks_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; - zfeature_register(SPA_FEATURE_BOOKMARKS, - "com.delphix:bookmarks", "bookmarks", - "\"zfs bookmark\" command", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, - bookmarks_deps); + zfeature_register(SPA_FEATURE_BOOKMARKS, + "com.delphix:bookmarks", "bookmarks", + "\"zfs bookmark\" command", + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, + bookmarks_deps, sfeatures); } { - static const spa_feature_t filesystem_limits_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_FS_SS_LIMIT, - "com.joyent:filesystem_limits", "filesystem_limits", - "Filesystem and snapshot limits.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, - filesystem_limits_deps); + static const spa_feature_t filesystem_limits_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_FS_SS_LIMIT, + "com.joyent:filesystem_limits", "filesystem_limits", + "Filesystem and snapshot limits.", + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, + filesystem_limits_deps, sfeatures); } zfeature_register(SPA_FEATURE_EMBEDDED_DATA, "com.delphix:embedded_data", "embedded_data", "Blocks which compress very well use even less space.", ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, - ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures); { - static const spa_feature_t livelist_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_LIVELIST, - "com.delphix:livelist", "livelist", - "Improved clone deletion performance.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, - livelist_deps); + static const spa_feature_t livelist_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_LIVELIST, + "com.delphix:livelist", "livelist", + "Improved clone deletion performance.", + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, + livelist_deps, sfeatures); } { - static const spa_feature_t log_spacemap_deps[] = { - SPA_FEATURE_SPACEMAP_V2, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_LOG_SPACEMAP, - "com.delphix:log_spacemap", "log_spacemap", - "Log metaslab changes on a single spacemap and " - "flush them periodically.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, - log_spacemap_deps); + static const spa_feature_t log_spacemap_deps[] = { + SPA_FEATURE_SPACEMAP_V2, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_LOG_SPACEMAP, + "com.delphix:log_spacemap", "log_spacemap", + "Log metaslab changes on a single spacemap and " + "flush them periodically.", + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, + log_spacemap_deps, sfeatures); } { - static const spa_feature_t large_blocks_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_LARGE_BLOCKS, - "org.open-zfs:large_blocks", "large_blocks", - "Support for blocks larger than 128KB.", - ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, - large_blocks_deps); + static const spa_feature_t large_blocks_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_LARGE_BLOCKS, + "org.open-zfs:large_blocks", "large_blocks", + "Support for blocks larger than 128KB.", + ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, + large_blocks_deps, sfeatures); } { - static const spa_feature_t large_dnode_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_LARGE_DNODE, - "org.zfsonlinux:large_dnode", "large_dnode", - "Variable on-disk size of dnodes.", - ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, - large_dnode_deps); + static const spa_feature_t large_dnode_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_LARGE_DNODE, + "org.zfsonlinux:large_dnode", "large_dnode", + "Variable on-disk size of dnodes.", + ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, + large_dnode_deps, sfeatures); } { - static const spa_feature_t sha512_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_SHA512, - "org.illumos:sha512", "sha512", - "SHA-512/256 hash algorithm.", - ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, - sha512_deps); + static const spa_feature_t sha512_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_SHA512, + "org.illumos:sha512", "sha512", + "SHA-512/256 hash algorithm.", + ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, + sha512_deps, sfeatures); } { - static const spa_feature_t skein_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_SKEIN, - "org.illumos:skein", "skein", - "Skein hash algorithm.", - ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, - skein_deps); + static const spa_feature_t skein_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_SKEIN, + "org.illumos:skein", "skein", + "Skein hash algorithm.", + ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, + skein_deps, sfeatures); } { - static const spa_feature_t edonr_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_EDONR, - "org.illumos:edonr", "edonr", - "Edon-R hash algorithm.", - ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, - edonr_deps); + static const spa_feature_t edonr_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_EDONR, + "org.illumos:edonr", "edonr", + "Edon-R hash algorithm.", + ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, + edonr_deps, sfeatures); } { - static const spa_feature_t redact_books_deps[] = { - SPA_FEATURE_BOOKMARK_V2, - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_BOOKMARKS, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_REDACTION_BOOKMARKS, - "com.delphix:redaction_bookmarks", "redaction_bookmarks", - "Support for bookmarks which store redaction lists for zfs " - "redacted send/recv.", 0, ZFEATURE_TYPE_BOOLEAN, - redact_books_deps); + static const spa_feature_t redact_books_deps[] = { + SPA_FEATURE_BOOKMARK_V2, + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_BOOKMARKS, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_REDACTION_BOOKMARKS, + "com.delphix:redaction_bookmarks", "redaction_bookmarks", + "Support for bookmarks which store redaction lists for zfs " + "redacted send/recv.", 0, ZFEATURE_TYPE_BOOLEAN, + redact_books_deps, sfeatures); } { - static const spa_feature_t redact_datasets_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_REDACTED_DATASETS, - "com.delphix:redacted_datasets", "redacted_datasets", "Support for " - "redacted datasets, produced by receiving a redacted zfs send " - "stream.", ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_UINT64_ARRAY, - redact_datasets_deps); + static const spa_feature_t redact_datasets_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_REDACTED_DATASETS, + "com.delphix:redacted_datasets", "redacted_datasets", + "Support for redacted datasets, produced by receiving " + "a redacted zfs send stream.", + ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_UINT64_ARRAY, + redact_datasets_deps, sfeatures); } { - static const spa_feature_t bookmark_written_deps[] = { - SPA_FEATURE_BOOKMARK_V2, - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_BOOKMARKS, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_BOOKMARK_WRITTEN, - "com.delphix:bookmark_written", "bookmark_written", - "Additional accounting, enabling the written# property" - "(space written since a bookmark), and estimates of send stream " - "sizes for incrementals from bookmarks.", - 0, ZFEATURE_TYPE_BOOLEAN, bookmark_written_deps); + static const spa_feature_t bookmark_written_deps[] = { + SPA_FEATURE_BOOKMARK_V2, + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_BOOKMARKS, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_BOOKMARK_WRITTEN, + "com.delphix:bookmark_written", "bookmark_written", + "Additional accounting, enabling the written# " + "property (space written since a bookmark), " + "and estimates of send stream sizes for incrementals from " + "bookmarks.", + 0, ZFEATURE_TYPE_BOOLEAN, bookmark_written_deps, sfeatures); } zfeature_register(SPA_FEATURE_DEVICE_REMOVAL, "com.delphix:device_removal", "device_removal", "Top-level vdevs can be removed, reducing logical pool size.", - ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures); { - static const spa_feature_t obsolete_counts_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_DEVICE_REMOVAL, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_OBSOLETE_COUNTS, - "com.delphix:obsolete_counts", "obsolete_counts", - "Reduce memory used by removed devices when their blocks are " - "freed or remapped.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, - obsolete_counts_deps); + static const spa_feature_t obsolete_counts_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_DEVICE_REMOVAL, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_OBSOLETE_COUNTS, + "com.delphix:obsolete_counts", "obsolete_counts", + "Reduce memory used by removed devices when their blocks " + "are freed or remapped.", + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, + obsolete_counts_deps, sfeatures); } { - static const spa_feature_t userobj_accounting_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_USEROBJ_ACCOUNTING, - "org.zfsonlinux:userobj_accounting", "userobj_accounting", - "User/Group object accounting.", - ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET, - ZFEATURE_TYPE_BOOLEAN, userobj_accounting_deps); + static const spa_feature_t userobj_accounting_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_USEROBJ_ACCOUNTING, + "org.zfsonlinux:userobj_accounting", "userobj_accounting", + "User/Group object accounting.", + ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET, + ZFEATURE_TYPE_BOOLEAN, userobj_accounting_deps, sfeatures); } { - static const spa_feature_t bookmark_v2_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_BOOKMARKS, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_BOOKMARK_V2, - "com.datto:bookmark_v2", "bookmark_v2", - "Support for larger bookmarks", - 0, ZFEATURE_TYPE_BOOLEAN, bookmark_v2_deps); + static const spa_feature_t bookmark_v2_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_BOOKMARKS, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_BOOKMARK_V2, + "com.datto:bookmark_v2", "bookmark_v2", + "Support for larger bookmarks", + 0, ZFEATURE_TYPE_BOOLEAN, bookmark_v2_deps, sfeatures); } { - static const spa_feature_t encryption_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_BOOKMARK_V2, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_ENCRYPTION, - "com.datto:encryption", "encryption", - "Support for dataset level encryption", - ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, - encryption_deps); + static const spa_feature_t encryption_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_BOOKMARK_V2, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_ENCRYPTION, + "com.datto:encryption", "encryption", + "Support for dataset level encryption", + ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, + encryption_deps, sfeatures); } { - static const spa_feature_t project_quota_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_PROJECT_QUOTA, - "org.zfsonlinux:project_quota", "project_quota", - "space/object accounting based on project ID.", - ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET, - ZFEATURE_TYPE_BOOLEAN, project_quota_deps); + static const spa_feature_t project_quota_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_PROJECT_QUOTA, + "org.zfsonlinux:project_quota", "project_quota", + "space/object accounting based on project ID.", + ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET, + ZFEATURE_TYPE_BOOLEAN, project_quota_deps, sfeatures); } zfeature_register(SPA_FEATURE_ALLOCATION_CLASSES, "org.zfsonlinux:allocation_classes", "allocation_classes", "Support for separate allocation classes.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); zfeature_register(SPA_FEATURE_RESILVER_DEFER, "com.datto:resilver_defer", "resilver_defer", "Support for deferring new resilvers when one is already running.", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); zfeature_register(SPA_FEATURE_DEVICE_REBUILD, "org.openzfs:device_rebuild", "device_rebuild", "Support for sequential mirror/dRAID device rebuilds", - ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); { - static const spa_feature_t zstd_deps[] = { - SPA_FEATURE_EXTENSIBLE_DATASET, - SPA_FEATURE_NONE - }; - zfeature_register(SPA_FEATURE_ZSTD_COMPRESS, - "org.freebsd:zstd_compress", "zstd_compress", - "zstd compression algorithm support.", - ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, zstd_deps); + static const spa_feature_t zstd_deps[] = { + SPA_FEATURE_EXTENSIBLE_DATASET, + SPA_FEATURE_NONE + }; + zfeature_register(SPA_FEATURE_ZSTD_COMPRESS, + "org.freebsd:zstd_compress", "zstd_compress", + "zstd compression algorithm support.", + ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, zstd_deps, + sfeatures); } zfeature_register(SPA_FEATURE_DRAID, "org.openzfs:draid", "draid", "Support for distributed spare RAID", - ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL); + ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures); + + zfs_mod_list_supported_free(sfeatures); } #if defined(_KERNEL) diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 592ba8bc32e..800885ee648 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -377,44 +377,47 @@ zfs_prop_init(void) { NULL } }; + struct zfs_mod_supported_features *sfeatures = + zfs_mod_list_supported(ZFS_SYSFS_DATASET_PROPERTIES); + /* inherit index properties */ zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata", ZFS_REDUNDANT_METADATA_ALL, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "all | most", "REDUND_MD", - redundant_metadata_table); + redundant_metadata_table, sfeatures); zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "standard | always | disabled", "SYNC", - sync_table); + sync_table, sfeatures); zprop_register_index(ZFS_PROP_CHECKSUM, "checksum", ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein" " | edonr", - "CHECKSUM", checksum_table); + "CHECKSUM", checksum_table, sfeatures); zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off | verify | sha256[,verify] | sha512[,verify] | " "skein[,verify] | edonr,verify", - "DEDUP", dedup_table); + "DEDUP", dedup_table, sfeatures); zprop_register_index(ZFS_PROP_COMPRESSION, "compression", ZIO_COMPRESS_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4 | " "zstd | zstd-[1-19] | " "zstd-fast | zstd-fast-[1-10,20,30,40,50,60,70,80,90,100,500,1000]", - "COMPRESS", compress_table); + "COMPRESS", compress_table, sfeatures); zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, - "hidden | visible", "SNAPDIR", snapdir_table); + "hidden | visible", "SNAPDIR", snapdir_table, sfeatures); zprop_register_index(ZFS_PROP_SNAPDEV, "snapdev", ZFS_SNAPDEV_HIDDEN, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - "hidden | visible", "SNAPDEV", snapdev_table); + "hidden | visible", "SNAPDEV", snapdev_table, sfeatures); zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "discard | groupmask | passthrough | restricted", "ACLMODE", - acl_mode_table); + acl_mode_table, sfeatures); zprop_register_index(ZFS_PROP_ACLTYPE, "acltype", #ifdef __linux__ /* Linux doesn't natively support ZFS's NFSv4-style ACLs. */ @@ -423,270 +426,288 @@ zfs_prop_init(void) ZFS_ACLTYPE_NFSV4, #endif PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, - "off | nfsv4 | posix", "ACLTYPE", acltype_table); + "off | nfsv4 | posix", "ACLTYPE", acltype_table, sfeatures); zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit", ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "discard | noallow | restricted | passthrough | passthrough-x", - "ACLINHERIT", acl_inherit_table); + "ACLINHERIT", acl_inherit_table, sfeatures); zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - "1 | 2 | 3", "COPIES", copies_table); + "1 | 2 | 3", "COPIES", copies_table, sfeatures); zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache", ZFS_CACHE_ALL, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, - "all | none | metadata", "PRIMARYCACHE", cache_table); + "all | none | metadata", "PRIMARYCACHE", cache_table, sfeatures); zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache", ZFS_CACHE_ALL, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, - "all | none | metadata", "SECONDARYCACHE", cache_table); + "all | none | metadata", "SECONDARYCACHE", cache_table, sfeatures); zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - "latency | throughput", "LOGBIAS", logbias_table); + "latency | throughput", "LOGBIAS", logbias_table, sfeatures); zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_DIR, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, - "on | off | dir | sa", "XATTR", xattr_table); + "on | off | dir | sa", "XATTR", xattr_table, sfeatures); zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize", ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, - "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table); + "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table, + sfeatures); zprop_register_index(ZFS_PROP_VOLMODE, "volmode", ZFS_VOLMODE_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - "default | full | geom | dev | none", "VOLMODE", volmode_table); + "default | full | geom | dev | none", "VOLMODE", volmode_table, + sfeatures); /* inherit index (boolean) properties */ zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT, - ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table); + ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table, sfeatures); zprop_register_index(ZFS_PROP_RELATIME, "relatime", 0, PROP_INHERIT, - ZFS_TYPE_FILESYSTEM, "on | off", "RELATIME", boolean_table); + ZFS_TYPE_FILESYSTEM, "on | off", "RELATIME", boolean_table, + sfeatures); zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES", - boolean_table); + boolean_table, sfeatures); zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC", - boolean_table); + boolean_table, sfeatures); zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID", - boolean_table); + boolean_table, sfeatures); zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY", - boolean_table); + boolean_table, sfeatures); #ifdef __FreeBSD__ zprop_register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT, - ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table); + ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table, + sfeatures); #else zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT, - ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table); + ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table, sfeatures); #endif zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT, - ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table); + ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table, sfeatures); zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND", - boolean_table); + boolean_table, sfeatures); zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 1, PROP_INHERIT, - ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table); + ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table, + sfeatures); /* default index properties */ zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, - "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table); + "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table, sfeatures); zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto", - "CANMOUNT", canmount_table); + "CANMOUNT", canmount_table, sfeatures); /* readonly index properties */ zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY, - ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table); + ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table, + sfeatures); zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0, PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY", - boolean_table); + boolean_table, sfeatures); zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus", ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET, "none | unavailable | available", - "KEYSTATUS", keystatus_table); + "KEYSTATUS", keystatus_table, sfeatures); /* set once index properties */ zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0, PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "none | formC | formD | formKC | formKD", "NORMALIZATION", - normalize_table); + normalize_table, sfeatures); zprop_register_index(ZFS_PROP_CASE, "casesensitivity", ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, - "sensitive | insensitive | mixed", "CASE", case_table); + "sensitive | insensitive | mixed", "CASE", case_table, sfeatures); zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat", ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table); + "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table, + sfeatures); zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption", ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET, "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | " "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION", - crypto_table); + crypto_table, sfeatures); /* set once index (boolean) properties */ zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, - "on | off", "UTF8ONLY", boolean_table); + "on | off", "UTF8ONLY", boolean_table, sfeatures); /* string properties */ zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY, - ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", "ORIGIN"); + ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", "ORIGIN", + sfeatures); zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY, - ZFS_TYPE_SNAPSHOT, "[,...]", "CLONES"); + ZFS_TYPE_SNAPSHOT, "[,...]", "CLONES", sfeatures); zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", PROP_INHERIT, ZFS_TYPE_FILESYSTEM, " | legacy | none", - "MOUNTPOINT"); + "MOUNTPOINT", sfeatures); zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | NFS share options", - "SHARENFS"); + "SHARENFS", sfeatures); zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, - "filesystem | volume | snapshot | bookmark", "TYPE"); + "filesystem | volume | snapshot | bookmark", "TYPE", sfeatures); zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", PROP_INHERIT, ZFS_TYPE_FILESYSTEM, - "on | off | SMB share options", "SHARESMB"); + "on | off | SMB share options", "SHARESMB", sfeatures); zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel", ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET, - "", "MLSLABEL"); + "", "MLSLABEL", sfeatures); zprop_register_string(ZFS_PROP_SELINUX_CONTEXT, "context", "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "", - "CONTEXT"); + "CONTEXT", sfeatures); zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT, "fscontext", "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "", - "FSCONTEXT"); + "FSCONTEXT", sfeatures); zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT, "defcontext", "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "", - "DEFCONTEXT"); + "DEFCONTEXT", sfeatures); zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT, "rootcontext", "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "", - "ROOTCONTEXT"); + "ROOTCONTEXT", sfeatures); zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN, "receive_resume_token", NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - "", "RESUMETOK"); + "", "RESUMETOK", sfeatures); zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL, PROP_READONLY, ZFS_TYPE_DATASET, "", - "ENCROOT"); + "ENCROOT", sfeatures); zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation", "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - "prompt | | | ", "KEYLOCATION"); + "prompt | | | ", "KEYLOCATION", + sfeatures); zprop_register_string(ZFS_PROP_REDACT_SNAPS, "redact_snaps", NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "[,...]", - "RSNAPS"); + "RSNAPS", sfeatures); /* readonly number properties */ zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY, - ZFS_TYPE_DATASET, "", "USED"); + ZFS_TYPE_DATASET, "", "USED", sfeatures); zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY, - ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", "AVAIL"); + ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", "AVAIL", + sfeatures); zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "", - "REFER"); + "REFER", sfeatures); zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, - "<1.00x or higher if compressed>", "RATIO"); + "<1.00x or higher if compressed>", "RATIO", sfeatures); zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0, PROP_READONLY, ZFS_TYPE_DATASET, - "<1.00x or higher if compressed>", "REFRATIO"); + "<1.00x or higher if compressed>", "REFRATIO", sfeatures); zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME, - ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK"); + ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK", sfeatures); zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", - "USEDSNAP"); + "USEDSNAP", sfeatures); zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", - "USEDDS"); + "USEDDS", sfeatures); zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", - "USEDCHILD"); + "USEDCHILD", sfeatures); zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0, PROP_READONLY, - ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", "USEDREFRESERV"); + ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", "USEDREFRESERV", + sfeatures); zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY, - ZFS_TYPE_SNAPSHOT, "", "USERREFS"); + ZFS_TYPE_SNAPSHOT, "", "USERREFS", sfeatures); zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY, - ZFS_TYPE_DATASET, "", "WRITTEN"); + ZFS_TYPE_DATASET, "", "WRITTEN", sfeatures); zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "", - "LUSED"); + "LUSED", sfeatures); zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced", 0, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "", - "LREFER"); + "LREFER", sfeatures); zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count", UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM, - "", "FSCOUNT"); + "", "FSCOUNT", sfeatures); zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count", UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - "", "SSCOUNT"); + "", "SSCOUNT", sfeatures); zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY, - ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "", "GUID"); + ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "", "GUID", + sfeatures); zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY, - ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "", "CREATETXG"); + ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "", "CREATETXG", + sfeatures); zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters", 0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - "", "PBKDF2ITERS"); + "", "PBKDF2ITERS", sfeatures); zprop_register_number(ZFS_PROP_OBJSETID, "objsetid", 0, - PROP_READONLY, ZFS_TYPE_DATASET, "", "OBJSETID"); + PROP_READONLY, ZFS_TYPE_DATASET, "", "OBJSETID", sfeatures); /* default number properties */ zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT, - ZFS_TYPE_FILESYSTEM, " | none", "QUOTA"); + ZFS_TYPE_FILESYSTEM, " | none", "QUOTA", sfeatures); zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - " | none", "RESERV"); + " | none", "RESERV", sfeatures); zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT, - ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "", "VOLSIZE"); + ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "", "VOLSIZE", + sfeatures); zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT, - ZFS_TYPE_FILESYSTEM, " | none", "REFQUOTA"); + ZFS_TYPE_FILESYSTEM, " | none", "REFQUOTA", sfeatures); zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - " | none", "REFRESERV"); + " | none", "REFRESERV", sfeatures); zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit", UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, - " | none", "FSLIMIT"); + " | none", "FSLIMIT", sfeatures); zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit", UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, - " | none", "SSLIMIT"); + " | none", "SSLIMIT", sfeatures); /* inherit number properties */ zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize", SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT, - ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE"); + ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE", sfeatures); zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS, "special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, - "zero or 512 to 1M, power of 2", "SPECIAL_SMALL_BLOCKS"); + "zero or 512 to 1M, power of 2", "SPECIAL_SMALL_BLOCKS", sfeatures); /* hidden properties */ zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, - PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES"); + PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES", sfeatures); zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING, - PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME"); + PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME", + sfeatures); zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", - PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS"); + PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS", + sfeatures); zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu", PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, - "STMF_SBD_LU"); + "STMF_SBD_LU", sfeatures); zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting", PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, - "USERACCOUNTING"); + "USERACCOUNTING", sfeatures); zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER, - PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE"); + PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE", sfeatures); zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent", - PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT"); + PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT", + sfeatures); zprop_register_hidden(ZFS_PROP_IVSET_GUID, "ivsetguid", PROP_TYPE_NUMBER, PROP_READONLY, - ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID"); + ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID", sfeatures); zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING, - PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP"); + PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP", + sfeatures); zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt", PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT, - ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT"); + ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT", sfeatures); zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER, - PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID"); + PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID", sfeatures); zprop_register_hidden(ZFS_PROP_REDACTED, "redacted", PROP_TYPE_NUMBER, - PROP_READONLY, ZFS_TYPE_DATASET, "REDACTED"); + PROP_READONLY, ZFS_TYPE_DATASET, "REDACTED", sfeatures); /* * Properties that are obsolete and not used. These are retained so @@ -694,12 +715,14 @@ zfs_prop_init(void) * have NULL pointers in the zfs_prop_table[]. */ zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER, - PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG"); + PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG", sfeatures); /* oddball properties */ zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, - "", "CREATION", B_FALSE, B_TRUE, NULL); + "", "CREATION", B_FALSE, B_TRUE, NULL, sfeatures); + + zfs_mod_list_supported_free(sfeatures); } boolean_t diff --git a/module/zcommon/zpool_prop.c b/module/zcommon/zpool_prop.c index bfe4ef9adc8..44bfe4add23 100644 --- a/module/zcommon/zpool_prop.c +++ b/module/zcommon/zpool_prop.c @@ -65,90 +65,105 @@ zpool_prop_init(void) { NULL } }; + struct zfs_mod_supported_features *sfeatures = + zfs_mod_list_supported(ZFS_SYSFS_POOL_PROPERTIES); + /* string properties */ zprop_register_string(ZPOOL_PROP_ALTROOT, "altroot", NULL, PROP_DEFAULT, - ZFS_TYPE_POOL, "", "ALTROOT"); + ZFS_TYPE_POOL, "", "ALTROOT", sfeatures); zprop_register_string(ZPOOL_PROP_BOOTFS, "bootfs", NULL, PROP_DEFAULT, - ZFS_TYPE_POOL, "", "BOOTFS"); + ZFS_TYPE_POOL, "", "BOOTFS", sfeatures); zprop_register_string(ZPOOL_PROP_CACHEFILE, "cachefile", NULL, - PROP_DEFAULT, ZFS_TYPE_POOL, " | none", "CACHEFILE"); + PROP_DEFAULT, ZFS_TYPE_POOL, " | none", "CACHEFILE", + sfeatures); zprop_register_string(ZPOOL_PROP_COMMENT, "comment", NULL, - PROP_DEFAULT, ZFS_TYPE_POOL, "", "COMMENT"); + PROP_DEFAULT, ZFS_TYPE_POOL, "", "COMMENT", + sfeatures); zprop_register_string(ZPOOL_PROP_COMPATIBILITY, "compatibility", "off", PROP_DEFAULT, ZFS_TYPE_POOL, - " | off | legacy", "COMPATIBILITY"); + " | off | legacy", "COMPATIBILITY", sfeatures); /* readonly number properties */ zprop_register_number(ZPOOL_PROP_SIZE, "size", 0, PROP_READONLY, - ZFS_TYPE_POOL, "", "SIZE"); + ZFS_TYPE_POOL, "", "SIZE", sfeatures); zprop_register_number(ZPOOL_PROP_FREE, "free", 0, PROP_READONLY, - ZFS_TYPE_POOL, "", "FREE"); + ZFS_TYPE_POOL, "", "FREE", sfeatures); zprop_register_number(ZPOOL_PROP_FREEING, "freeing", 0, PROP_READONLY, - ZFS_TYPE_POOL, "", "FREEING"); + ZFS_TYPE_POOL, "", "FREEING", sfeatures); zprop_register_number(ZPOOL_PROP_CHECKPOINT, "checkpoint", 0, - PROP_READONLY, ZFS_TYPE_POOL, "", "CKPOINT"); + PROP_READONLY, ZFS_TYPE_POOL, "", "CKPOINT", sfeatures); zprop_register_number(ZPOOL_PROP_LEAKED, "leaked", 0, PROP_READONLY, - ZFS_TYPE_POOL, "", "LEAKED"); + ZFS_TYPE_POOL, "", "LEAKED", sfeatures); zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0, - PROP_READONLY, ZFS_TYPE_POOL, "", "ALLOC"); + PROP_READONLY, ZFS_TYPE_POOL, "", "ALLOC", sfeatures); zprop_register_number(ZPOOL_PROP_EXPANDSZ, "expandsize", 0, - PROP_READONLY, ZFS_TYPE_POOL, "", "EXPANDSZ"); + PROP_READONLY, ZFS_TYPE_POOL, "", "EXPANDSZ", sfeatures); zprop_register_number(ZPOOL_PROP_FRAGMENTATION, "fragmentation", 0, - PROP_READONLY, ZFS_TYPE_POOL, "", "FRAG"); + PROP_READONLY, ZFS_TYPE_POOL, "", "FRAG", sfeatures); zprop_register_number(ZPOOL_PROP_CAPACITY, "capacity", 0, PROP_READONLY, - ZFS_TYPE_POOL, "", "CAP"); + ZFS_TYPE_POOL, "", "CAP", sfeatures); zprop_register_number(ZPOOL_PROP_GUID, "guid", 0, PROP_READONLY, - ZFS_TYPE_POOL, "", "GUID"); + ZFS_TYPE_POOL, "", "GUID", sfeatures); zprop_register_number(ZPOOL_PROP_LOAD_GUID, "load_guid", 0, - PROP_READONLY, ZFS_TYPE_POOL, "", "LOAD_GUID"); + PROP_READONLY, ZFS_TYPE_POOL, "", "LOAD_GUID", + sfeatures); zprop_register_number(ZPOOL_PROP_HEALTH, "health", 0, PROP_READONLY, - ZFS_TYPE_POOL, "", "HEALTH"); + ZFS_TYPE_POOL, "", "HEALTH", sfeatures); zprop_register_number(ZPOOL_PROP_DEDUPRATIO, "dedupratio", 0, PROP_READONLY, ZFS_TYPE_POOL, "<1.00x or higher if deduped>", - "DEDUP"); + "DEDUP", sfeatures); /* default number properties */ zprop_register_number(ZPOOL_PROP_VERSION, "version", SPA_VERSION, - PROP_DEFAULT, ZFS_TYPE_POOL, "", "VERSION"); + PROP_DEFAULT, ZFS_TYPE_POOL, "", "VERSION", sfeatures); zprop_register_number(ZPOOL_PROP_ASHIFT, "ashift", 0, PROP_DEFAULT, - ZFS_TYPE_POOL, "", "ASHIFT"); + ZFS_TYPE_POOL, "", "ASHIFT", sfeatures); /* default index (boolean) properties */ zprop_register_index(ZPOOL_PROP_DELEGATION, "delegation", 1, PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "DELEGATION", - boolean_table); + boolean_table, sfeatures); zprop_register_index(ZPOOL_PROP_AUTOREPLACE, "autoreplace", 0, - PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "REPLACE", boolean_table); + PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "REPLACE", boolean_table, + sfeatures); zprop_register_index(ZPOOL_PROP_LISTSNAPS, "listsnapshots", 0, PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "LISTSNAPS", - boolean_table); + boolean_table, sfeatures); zprop_register_index(ZPOOL_PROP_AUTOEXPAND, "autoexpand", 0, - PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "EXPAND", boolean_table); + PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "EXPAND", boolean_table, + sfeatures); zprop_register_index(ZPOOL_PROP_READONLY, "readonly", 0, - PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "RDONLY", boolean_table); + PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "RDONLY", boolean_table, + sfeatures); zprop_register_index(ZPOOL_PROP_MULTIHOST, "multihost", 0, PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "MULTIHOST", - boolean_table); + boolean_table, sfeatures); /* default index properties */ zprop_register_index(ZPOOL_PROP_FAILUREMODE, "failmode", ZIO_FAILURE_MODE_WAIT, PROP_DEFAULT, ZFS_TYPE_POOL, - "wait | continue | panic", "FAILMODE", failuremode_table); + "wait | continue | panic", "FAILMODE", failuremode_table, + sfeatures); zprop_register_index(ZPOOL_PROP_AUTOTRIM, "autotrim", SPA_AUTOTRIM_DEFAULT, PROP_DEFAULT, ZFS_TYPE_POOL, - "on | off", "AUTOTRIM", boolean_table); + "on | off", "AUTOTRIM", boolean_table, sfeatures); /* hidden properties */ zprop_register_hidden(ZPOOL_PROP_NAME, "name", PROP_TYPE_STRING, - PROP_READONLY, ZFS_TYPE_POOL, "NAME"); + PROP_READONLY, ZFS_TYPE_POOL, "NAME", sfeatures); zprop_register_hidden(ZPOOL_PROP_MAXBLOCKSIZE, "maxblocksize", - PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXBLOCKSIZE"); + PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXBLOCKSIZE", + sfeatures); zprop_register_hidden(ZPOOL_PROP_TNAME, "tname", PROP_TYPE_STRING, - PROP_ONETIME, ZFS_TYPE_POOL, "TNAME"); + PROP_ONETIME, ZFS_TYPE_POOL, "TNAME", sfeatures); zprop_register_hidden(ZPOOL_PROP_MAXDNODESIZE, "maxdnodesize", - PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXDNODESIZE"); + PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXDNODESIZE", + sfeatures); zprop_register_hidden(ZPOOL_PROP_DEDUPDITTO, "dedupditto", - PROP_TYPE_NUMBER, PROP_DEFAULT, ZFS_TYPE_POOL, "DEDUPDITTO"); + PROP_TYPE_NUMBER, PROP_DEFAULT, ZFS_TYPE_POOL, "DEDUPDITTO", + sfeatures); + + zfs_mod_list_supported_free(sfeatures); } /* @@ -283,102 +298,110 @@ vdev_prop_init(void) { NULL } }; + struct zfs_mod_supported_features *sfeatures = + zfs_mod_list_supported(ZFS_SYSFS_VDEV_PROPERTIES); + /* string properties */ zprop_register_string(VDEV_PROP_COMMENT, "comment", NULL, - PROP_DEFAULT, ZFS_TYPE_VDEV, "", "COMMENT"); + PROP_DEFAULT, ZFS_TYPE_VDEV, "", "COMMENT", + sfeatures); zprop_register_string(VDEV_PROP_PATH, "path", NULL, - PROP_DEFAULT, ZFS_TYPE_VDEV, "", "PATH"); + PROP_DEFAULT, ZFS_TYPE_VDEV, "", "PATH", sfeatures); zprop_register_string(VDEV_PROP_DEVID, "devid", NULL, - PROP_READONLY, ZFS_TYPE_VDEV, "", "DEVID"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "DEVID", sfeatures); zprop_register_string(VDEV_PROP_PHYS_PATH, "physpath", NULL, - PROP_READONLY, ZFS_TYPE_VDEV, "", "PHYSPATH"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "PHYSPATH", sfeatures); zprop_register_string(VDEV_PROP_ENC_PATH, "encpath", NULL, - PROP_READONLY, ZFS_TYPE_VDEV, "", "ENCPATH"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "ENCPATH", sfeatures); zprop_register_string(VDEV_PROP_FRU, "fru", NULL, - PROP_READONLY, ZFS_TYPE_VDEV, "", "FRU"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "FRU", sfeatures); zprop_register_string(VDEV_PROP_PARENT, "parent", NULL, - PROP_READONLY, ZFS_TYPE_VDEV, "", "PARENT"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "PARENT", sfeatures); zprop_register_string(VDEV_PROP_CHILDREN, "children", NULL, - PROP_READONLY, ZFS_TYPE_VDEV, "", "CHILDREN"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "CHILDREN", + sfeatures); /* readonly number properties */ zprop_register_number(VDEV_PROP_SIZE, "size", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "SIZE"); + ZFS_TYPE_VDEV, "", "SIZE", sfeatures); zprop_register_number(VDEV_PROP_FREE, "free", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "FREE"); + ZFS_TYPE_VDEV, "", "FREE", sfeatures); zprop_register_number(VDEV_PROP_ALLOCATED, "allocated", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "ALLOC"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "ALLOC", sfeatures); zprop_register_number(VDEV_PROP_EXPANDSZ, "expandsize", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "EXPANDSZ"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "EXPANDSZ", sfeatures); zprop_register_number(VDEV_PROP_FRAGMENTATION, "fragmentation", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "FRAG"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "FRAG", sfeatures); zprop_register_number(VDEV_PROP_CAPACITY, "capacity", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "CAP"); + ZFS_TYPE_VDEV, "", "CAP", sfeatures); zprop_register_number(VDEV_PROP_GUID, "guid", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "GUID"); + ZFS_TYPE_VDEV, "", "GUID", sfeatures); zprop_register_number(VDEV_PROP_STATE, "state", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "STATE"); + ZFS_TYPE_VDEV, "", "STATE", sfeatures); zprop_register_number(VDEV_PROP_BOOTSIZE, "bootsize", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "BOOTSIZE"); + ZFS_TYPE_VDEV, "", "BOOTSIZE", sfeatures); zprop_register_number(VDEV_PROP_ASIZE, "asize", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "ASIZE"); + ZFS_TYPE_VDEV, "", "ASIZE", sfeatures); zprop_register_number(VDEV_PROP_PSIZE, "psize", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "PSIZE"); + ZFS_TYPE_VDEV, "", "PSIZE", sfeatures); zprop_register_number(VDEV_PROP_ASHIFT, "ashift", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "ASHIFT"); + ZFS_TYPE_VDEV, "", "ASHIFT", sfeatures); zprop_register_number(VDEV_PROP_PARITY, "parity", 0, PROP_READONLY, - ZFS_TYPE_VDEV, "", "PARITY"); + ZFS_TYPE_VDEV, "", "PARITY", sfeatures); zprop_register_number(VDEV_PROP_NUMCHILDREN, "numchildren", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "NUMCHILD"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "NUMCHILD", + sfeatures); zprop_register_number(VDEV_PROP_READ_ERRORS, "read_errors", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "RDERR"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "RDERR", sfeatures); zprop_register_number(VDEV_PROP_WRITE_ERRORS, "write_errors", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "WRERR"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "WRERR", sfeatures); zprop_register_number(VDEV_PROP_CHECKSUM_ERRORS, "checksum_errors", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "CKERR"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "CKERR", sfeatures); zprop_register_number(VDEV_PROP_INITIALIZE_ERRORS, "initialize_errors", 0, PROP_READONLY, ZFS_TYPE_VDEV, "", - "INITERR"); + "INITERR", sfeatures); zprop_register_number(VDEV_PROP_OPS_NULL, "null_ops", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "NULLOP"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "NULLOP", sfeatures); zprop_register_number(VDEV_PROP_OPS_READ, "read_ops", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "READOP"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "READOP", sfeatures); zprop_register_number(VDEV_PROP_OPS_WRITE, "write_ops", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "WRITEOP"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "WRITEOP", sfeatures); zprop_register_number(VDEV_PROP_OPS_FREE, "free_ops", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "FREEOP"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "FREEOP", sfeatures); zprop_register_number(VDEV_PROP_OPS_CLAIM, "claim_ops", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "CLAIMOP"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "CLAIMOP", sfeatures); zprop_register_number(VDEV_PROP_OPS_TRIM, "trim_ops", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "TRIMOP"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "TRIMOP", sfeatures); zprop_register_number(VDEV_PROP_BYTES_NULL, "null_bytes", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "NULLBYTE"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "NULLBYTE", sfeatures); zprop_register_number(VDEV_PROP_BYTES_READ, "read_bytes", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "READBYTE"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "READBYTE", sfeatures); zprop_register_number(VDEV_PROP_BYTES_WRITE, "write_bytes", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "WRITEBYTE"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "WRITEBYTE", sfeatures); zprop_register_number(VDEV_PROP_BYTES_FREE, "free_bytes", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "FREEBYTE"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "FREEBYTE", sfeatures); zprop_register_number(VDEV_PROP_BYTES_CLAIM, "claim_bytes", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "CLAIMBYTE"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "CLAIMBYTE", sfeatures); zprop_register_number(VDEV_PROP_BYTES_TRIM, "trim_bytes", 0, - PROP_READONLY, ZFS_TYPE_VDEV, "", "TRIMBYTE"); + PROP_READONLY, ZFS_TYPE_VDEV, "", "TRIMBYTE", sfeatures); /* default numeric properties */ /* default index (boolean) properties */ zprop_register_index(VDEV_PROP_REMOVING, "removing", 0, PROP_READONLY, ZFS_TYPE_VDEV, "on | off", "REMOVING", - boolean_table); + boolean_table, sfeatures); zprop_register_index(VDEV_PROP_ALLOCATING, "allocating", 1, PROP_DEFAULT, ZFS_TYPE_VDEV, "on | off", "ALLOCATING", - boolean_na_table); + boolean_na_table, sfeatures); /* default index properties */ /* hidden properties */ zprop_register_hidden(VDEV_PROP_NAME, "name", PROP_TYPE_STRING, - PROP_READONLY, ZFS_TYPE_VDEV, "NAME"); + PROP_READONLY, ZFS_TYPE_VDEV, "NAME", sfeatures); + + zfs_mod_list_supported_free(sfeatures); } /* diff --git a/module/zcommon/zprop_common.c b/module/zcommon/zprop_common.c index 17a48361f96..428af57419c 100644 --- a/module/zcommon/zprop_common.c +++ b/module/zcommon/zprop_common.c @@ -71,7 +71,8 @@ zprop_get_numprops(zfs_type_t type) } static boolean_t -zfs_mod_supported_prop(const char *name, zfs_type_t type) +zfs_mod_supported_prop(const char *name, zfs_type_t type, + const struct zfs_mod_supported_features *sfeatures) { /* * The zfs module spa_feature_table[], whether in-kernel or in libzpool, @@ -86,7 +87,8 @@ zfs_mod_supported_prop(const char *name, zfs_type_t type) #else return (zfs_mod_supported(type == ZFS_TYPE_POOL ? ZFS_SYSFS_POOL_PROPERTIES : (type == ZFS_TYPE_VDEV ? - ZFS_SYSFS_VDEV_PROPERTIES : ZFS_SYSFS_DATASET_PROPERTIES), name)); + ZFS_SYSFS_VDEV_PROPERTIES : ZFS_SYSFS_DATASET_PROPERTIES), + name, sfeatures)); #endif } @@ -94,7 +96,8 @@ void zprop_register_impl(int prop, const char *name, zprop_type_t type, uint64_t numdefault, const char *strdefault, zprop_attr_t attr, int objset_types, const char *values, const char *colname, - boolean_t rightalign, boolean_t visible, const zprop_index_t *idx_tbl) + boolean_t rightalign, boolean_t visible, const zprop_index_t *idx_tbl, + const struct zfs_mod_supported_features *sfeatures) { zprop_desc_t *prop_tbl = zprop_get_proptable(objset_types); zprop_desc_t *pd; @@ -116,7 +119,8 @@ zprop_register_impl(int prop, const char *name, zprop_type_t type, pd->pd_colname = colname; pd->pd_rightalign = rightalign; pd->pd_visible = visible; - pd->pd_zfs_mod_supported = zfs_mod_supported_prop(name, objset_types); + pd->pd_zfs_mod_supported = + zfs_mod_supported_prop(name, objset_types, sfeatures); pd->pd_table = idx_tbl; pd->pd_table_size = 0; while (idx_tbl && (idx_tbl++)->pi_name != NULL) @@ -126,38 +130,40 @@ zprop_register_impl(int prop, const char *name, zprop_type_t type, void zprop_register_string(int prop, const char *name, const char *def, zprop_attr_t attr, int objset_types, const char *values, - const char *colname) + const char *colname, const struct zfs_mod_supported_features *sfeatures) { zprop_register_impl(prop, name, PROP_TYPE_STRING, 0, def, attr, - objset_types, values, colname, B_FALSE, B_TRUE, NULL); + objset_types, values, colname, B_FALSE, B_TRUE, NULL, sfeatures); } void zprop_register_number(int prop, const char *name, uint64_t def, zprop_attr_t attr, int objset_types, const char *values, - const char *colname) + const char *colname, const struct zfs_mod_supported_features *sfeatures) { zprop_register_impl(prop, name, PROP_TYPE_NUMBER, def, NULL, attr, - objset_types, values, colname, B_TRUE, B_TRUE, NULL); + objset_types, values, colname, B_TRUE, B_TRUE, NULL, sfeatures); } void zprop_register_index(int prop, const char *name, uint64_t def, zprop_attr_t attr, int objset_types, const char *values, - const char *colname, const zprop_index_t *idx_tbl) + const char *colname, const zprop_index_t *idx_tbl, + const struct zfs_mod_supported_features *sfeatures) { zprop_register_impl(prop, name, PROP_TYPE_INDEX, def, NULL, attr, - objset_types, values, colname, B_FALSE, B_TRUE, idx_tbl); + objset_types, values, colname, B_FALSE, B_TRUE, idx_tbl, sfeatures); } void zprop_register_hidden(int prop, const char *name, zprop_type_t type, - zprop_attr_t attr, int objset_types, const char *colname) + zprop_attr_t attr, int objset_types, const char *colname, + const struct zfs_mod_supported_features *sfeatures) { zprop_register_impl(prop, name, type, 0, NULL, attr, objset_types, NULL, colname, - type == PROP_TYPE_NUMBER, B_FALSE, NULL); + type == PROP_TYPE_NUMBER, B_FALSE, NULL, sfeatures); } From ca1b2bb4b5bd7d3c481f2a7c5e35bb2cfe6b5871 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 17 Dec 2021 10:50:12 -0700 Subject: [PATCH 006/117] FreeBSD: Update argument types for VOP_READDIR A recent commit to FreeBSD changed the type of vop_readdir_args.a_cookies to a uint64_t**. There is no functional impact to ZFS because ZFS only uses 32-bit cookies, which will be zero-extended to 64-bits by the existing code. https://github.com/freebsd/freebsd-src/commit/b214fcceacad6b842545150664bd2695c1c2b34f Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Alan Somers Closes #12874 --- module/os/freebsd/zfs/zfs_vnops_os.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index 752e5b2f678..3db11752521 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -113,6 +113,12 @@ VFS_SMR_DECLARE; #define VNCHECKREF(vp) #endif +#if __FreeBSD_version >= 1400045 +typedef uint64_t cookie_t; +#else +typedef ulong_t cookie_t; +#endif + /* * Programming rules. * @@ -1665,7 +1671,7 @@ zfs_rmdir(znode_t *dzp, const char *name, znode_t *cwd, cred_t *cr, int flags) /* ARGSUSED */ static int zfs_readdir(vnode_t *vp, zfs_uio_t *uio, cred_t *cr, int *eofp, - int *ncookies, ulong_t **cookies) + int *ncookies, cookie_t **cookies) { znode_t *zp = VTOZ(vp); iovec_t *iovp; @@ -1687,7 +1693,7 @@ zfs_readdir(vnode_t *vp, zfs_uio_t *uio, cred_t *cr, int *eofp, boolean_t check_sysattrs; uint8_t type; int ncooks; - ulong_t *cooks = NULL; + cookie_t *cooks = NULL; int flags = 0; ZFS_ENTER(zfsvfs); @@ -1764,7 +1770,7 @@ zfs_readdir(vnode_t *vp, zfs_uio_t *uio, cred_t *cr, int *eofp, */ ncooks = zfs_uio_resid(uio) / (sizeof (struct dirent) - sizeof (((struct dirent *)NULL)->d_name) + 1); - cooks = malloc(ncooks * sizeof (ulong_t), M_TEMP, M_WAITOK); + cooks = malloc(ncooks * sizeof (*cooks), M_TEMP, M_WAITOK); *cookies = cooks; *ncookies = ncooks; } @@ -4718,7 +4724,7 @@ struct vop_readdir_args { struct ucred *a_cred; int *a_eofflag; int *a_ncookies; - ulong_t **a_cookies; + cookie_t **a_cookies; }; #endif From 8a02d01e85556bbe3a1c6947bc11b8ef028d4023 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 17 Dec 2021 09:52:13 -0800 Subject: [PATCH 007/117] Fix zvol_open() lock inversion When restructuring the zvol_open() logic for the Linux 5.13 kernel a lock inversion was accidentally introduced. In the updated code the spa_namespace_lock is now taken before the zv_suspend_lock allowing the following scenario to occur: down_read <=== waiting for zv_suspend_lock zvol_open <=== holds spa_namespace_lock __blkdev_get blkdev_get_by_dev blkdev_open ... mutex_lock <== waiting for spa_namespace_lock spa_open_common spa_open dsl_pool_hold dmu_objset_hold_flags dmu_objset_hold dsl_prop_get dsl_prop_get_integer zvol_create_minor dmu_recv_end zfs_ioc_recv_impl <=== holds zv_suspend_lock via zvol_suspend() zfs_ioc_recv ... This commit resolves the issue by moving the acquisition of the spa_namespace_lock back to after the zv_suspend_lock which restores the original ordering. Additionally, as part of this change the error exit paths were simplified where possible. Reviewed-by: Tony Hutter Reviewed-by: Rich Ercolani Signed-off-by: Brian Behlendorf Closes #12863 --- module/os/linux/zfs/zvol_os.c | 121 ++++++++++++++++------------------ 1 file changed, 58 insertions(+), 63 deletions(-) diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index 44caadd587f..69479b3f798 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -496,8 +496,7 @@ zvol_open(struct block_device *bdev, fmode_t flag) { zvol_state_t *zv; int error = 0; - boolean_t drop_suspend = B_TRUE; - boolean_t drop_namespace = B_FALSE; + boolean_t drop_suspend = B_FALSE; #ifndef HAVE_BLKDEV_GET_ERESTARTSYS hrtime_t timeout = MSEC2NSEC(zvol_open_timeout_ms); hrtime_t start = gethrtime(); @@ -517,7 +516,36 @@ retry: return (SET_ERROR(-ENXIO)); } - if (zv->zv_open_count == 0 && !mutex_owned(&spa_namespace_lock)) { + mutex_enter(&zv->zv_state_lock); + /* + * Make sure zvol is not suspended during first open + * (hold zv_suspend_lock) and respect proper lock acquisition + * ordering - zv_suspend_lock before zv_state_lock + */ + if (zv->zv_open_count == 0) { + if (!rw_tryenter(&zv->zv_suspend_lock, RW_READER)) { + mutex_exit(&zv->zv_state_lock); + rw_enter(&zv->zv_suspend_lock, RW_READER); + mutex_enter(&zv->zv_state_lock); + /* check to see if zv_suspend_lock is needed */ + if (zv->zv_open_count != 0) { + rw_exit(&zv->zv_suspend_lock); + } else { + drop_suspend = B_TRUE; + } + } else { + drop_suspend = B_TRUE; + } + } + rw_exit(&zvol_state_lock); + + ASSERT(MUTEX_HELD(&zv->zv_state_lock)); + + if (zv->zv_open_count == 0) { + boolean_t drop_namespace = B_FALSE; + + ASSERT(RW_READ_HELD(&zv->zv_suspend_lock)); + /* * In all other call paths the spa_namespace_lock is taken * before the bdev->bd_mutex lock. However, on open(2) @@ -542,84 +570,51 @@ retry: * the kernel so the only option is to return the error for * the caller to handle it. */ - if (!mutex_tryenter(&spa_namespace_lock)) { - rw_exit(&zvol_state_lock); + if (!mutex_owned(&spa_namespace_lock)) { + if (!mutex_tryenter(&spa_namespace_lock)) { + mutex_exit(&zv->zv_state_lock); + rw_exit(&zv->zv_suspend_lock); #ifdef HAVE_BLKDEV_GET_ERESTARTSYS - schedule(); - return (SET_ERROR(-ERESTARTSYS)); -#else - if ((gethrtime() - start) > timeout) + schedule(); return (SET_ERROR(-ERESTARTSYS)); +#else + if ((gethrtime() - start) > timeout) + return (SET_ERROR(-ERESTARTSYS)); - schedule_timeout(MSEC_TO_TICK(10)); - goto retry; + schedule_timeout(MSEC_TO_TICK(10)); + goto retry; #endif - } else { - drop_namespace = B_TRUE; - } - } - - mutex_enter(&zv->zv_state_lock); - /* - * make sure zvol is not suspended during first open - * (hold zv_suspend_lock) and respect proper lock acquisition - * ordering - zv_suspend_lock before zv_state_lock - */ - if (zv->zv_open_count == 0) { - if (!rw_tryenter(&zv->zv_suspend_lock, RW_READER)) { - mutex_exit(&zv->zv_state_lock); - rw_enter(&zv->zv_suspend_lock, RW_READER); - mutex_enter(&zv->zv_state_lock); - /* check to see if zv_suspend_lock is needed */ - if (zv->zv_open_count != 0) { - rw_exit(&zv->zv_suspend_lock); - drop_suspend = B_FALSE; + } else { + drop_namespace = B_TRUE; } } - } else { - drop_suspend = B_FALSE; - } - rw_exit(&zvol_state_lock); - ASSERT(MUTEX_HELD(&zv->zv_state_lock)); - - if (zv->zv_open_count == 0) { - ASSERT(RW_READ_HELD(&zv->zv_suspend_lock)); error = -zvol_first_open(zv, !(flag & FMODE_WRITE)); - if (error) - goto out_mutex; + + if (drop_namespace) + mutex_exit(&spa_namespace_lock); } - if ((flag & FMODE_WRITE) && (zv->zv_flags & ZVOL_RDONLY)) { - error = -EROFS; - goto out_open_count; - } + if (error == 0) { + if ((flag & FMODE_WRITE) && (zv->zv_flags & ZVOL_RDONLY)) { + if (zv->zv_open_count == 0) + zvol_last_close(zv); - zv->zv_open_count++; + error = SET_ERROR(-EROFS); + } else { + zv->zv_open_count++; + } + } mutex_exit(&zv->zv_state_lock); - if (drop_namespace) - mutex_exit(&spa_namespace_lock); if (drop_suspend) rw_exit(&zv->zv_suspend_lock); - zfs_check_media_change(bdev); + if (error == 0) + zfs_check_media_change(bdev); - return (0); - -out_open_count: - if (zv->zv_open_count == 0) - zvol_last_close(zv); - -out_mutex: - mutex_exit(&zv->zv_state_lock); - if (drop_namespace) - mutex_exit(&spa_namespace_lock); - if (drop_suspend) - rw_exit(&zv->zv_suspend_lock); - - return (SET_ERROR(error)); + return (error); } static void From 9aa0915f8785bafb99f39464bebe5966548677bb Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Fri, 17 Dec 2021 12:37:21 -0800 Subject: [PATCH 008/117] ZTS: Fix zpool_reopen_[1-5] on Fedora 35 The zpool_reopen_[1-5] tests are failing Fedora 35 with: zpool_reopen_001_pos.ksh[64]: log_must[67]: log_pos[270]: wait_for_resilver_end[98]: wait_for_action: line 71: func: is read only Renaming 'func' -> 'funct' fixes the issue. Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: Tony Hutter Closes #12871 --- .../tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib b/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib index 075ad85e9f9..3d142fdf70c 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib @@ -68,11 +68,11 @@ function wait_for_action #pool timeout function { typeset pool=$1 typeset -i timeout=$2 - typeset func=$3 + typeset funct=$3 while [ $timeout -gt 0 ]; do (( --timeout )) - if ( $func $pool ); then + if ( $funct $pool ); then return 0 fi sleep 1 From 1a79f7e86021c5de33d3518dd9a0f14f924ee345 Mon Sep 17 00:00:00 2001 From: Rich Ercolani <214141+rincebrain@users.noreply.github.com> Date: Fri, 17 Dec 2021 15:39:10 -0500 Subject: [PATCH 009/117] ZTS: Avoid piping send directly to /dev/null Unfortunately, #11445 means while we fail gracefully now, we still fail, unless people want to implement a complex workaround just to support /dev/null. So let's just use the cheap workaround in a test for now. Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Rich Ercolani Closes #12872 --- tests/zfs-tests/tests/functional/history/history_006_neg.ksh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/zfs-tests/tests/functional/history/history_006_neg.ksh b/tests/zfs-tests/tests/functional/history/history_006_neg.ksh index 19b7114faf5..c3a5e092d02 100755 --- a/tests/zfs-tests/tests/functional/history/history_006_neg.ksh +++ b/tests/zfs-tests/tests/functional/history/history_006_neg.ksh @@ -75,7 +75,9 @@ if ! is_linux; then log_must zfs share $fs log_must zfs unshare $fs fi -log_must zfs send -i $snap1 $snap2 > /dev/null +# https://github.com/openzfs/zfs/issues/11445 +set -o pipefail +log_must zfs send -i $snap1 $snap2 | cat > /dev/null log_must zfs holds $snap1 log_must eval "zpool history $TESTPOOL > $NEW_HISTORY" From eecd3f1a2184282a389440f102f756aab900da47 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 17 Dec 2021 12:40:34 -0800 Subject: [PATCH 010/117] ZTS: alloc_class.ksh must wait for the process to exit The alloc_class_* tests may fail on Linux with an EBUSY error if `zfs destroy` is run before the `dd` process has had a chance to terminate. Wait on the pid after the `kill -9` to make sure. When testing I didn't observe any failures for the alloc_class tests. Remove them from the exceptions list, the CI was used to verify the tests pass on all platforms. Reviewed-by: John Kennedy Reviewed-by: Rich Ercolani Signed-off-by: Brian Behlendorf Closes #12873 --- tests/test-runner/bin/zts-report.py.in | 5 ----- .../tests/functional/alloc_class/alloc_class.kshlib | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index e14472e2f4f..da22ae7be0a 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -289,11 +289,6 @@ if sys.platform.startswith('freebsd'): }) elif sys.platform.startswith('linux'): maybe.update({ - 'alloc_class/alloc_class_009_pos': ['FAIL', known_reason], - 'alloc_class/alloc_class_010_pos': ['FAIL', known_reason], - 'alloc_class/alloc_class_011_neg': ['FAIL', known_reason], - 'alloc_class/alloc_class_012_pos': ['FAIL', known_reason], - 'alloc_class/alloc_class_013_pos': ['FAIL', '11888'], 'cli_root/zfs_rename/zfs_rename_002_pos': ['FAIL', known_reason], 'cli_root/zpool_expand/zpool_expand_001_pos': ['FAIL', known_reason], 'cli_root/zpool_expand/zpool_expand_005_pos': ['FAIL', known_reason], diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib b/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib index 4c64cff6964..e204f43b3bc 100644 --- a/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib +++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib @@ -62,6 +62,7 @@ function display_status ((ret |= $?)) kill -9 $pid + wait $pid 2> /dev/null return $ret } From f68b9c81c8cf362e87655509c692dd8848c83732 Mon Sep 17 00:00:00 2001 From: Rich Ercolani <214141+rincebrain@users.noreply.github.com> Date: Fri, 17 Dec 2021 15:43:13 -0500 Subject: [PATCH 011/117] Workaround Debian's fake System.map behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debian ships fake System.map files by default, leading to the invocation of depmod with them to flood you with errors about missing symbols. Let's notice and not do that. Reviewed-by: Ahelenia Ziemiańska Reviewed-by: Brian Behlendorf Signed-off-by: Rich Ercolani Closes #12862 --- module/Makefile.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/module/Makefile.in b/module/Makefile.in index b15ab910972..b47ee73b87c 100644 --- a/module/Makefile.in +++ b/module/Makefile.in @@ -90,7 +90,15 @@ modules_install-Linux: if [ -n "$(DESTDIR)" ]; then \ find $$kmoddir -name 'modules.*' | xargs $(RM); \ fi + @# Debian ships tiny fake System.map files that are + @# syntactically valid but just say + @# "if you want system.map go install this package" + @# Naturally, depmod is less than amused by this. + @# So if we find it missing or with one of these present, + @# we check for the alternate path for the System.map sysmap=$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \ + { [ -f "$$sysmap" ] && [ $$(wc -l < "$$sysmap") -ge 100 ]; } || \ + sysmap=$(INSTALL_MOD_PATH)/usr/lib/debug/boot/System.map-@LINUX_VERSION@; \ if [ -f $$sysmap ]; then \ depmod -ae -F $$sysmap @LINUX_VERSION@; \ fi From 3a661613dff54d363c603aceaed80ecafb3d4f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 17 Dec 2021 21:44:23 +0100 Subject: [PATCH 012/117] contrib/initrd: systemd-ask-password --no-tty before argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In systemd 249 (sid), sd-a-p processes its arguments in getopt + mode, so "systemd-ask-password zupa --no-tty" prompts for "zupa --no-tty", not "zupa" not on the tty, as expected (bullseye, 247). Ref: https://github.com/systemd/systemd/commit/4b1c842d95bfd6ab352ade1a4655f9e512f35185 Ref: https://github.com/systemd/systemd/pull/19806 Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12870 --- contrib/dracut/90zfs/zfs-load-key.sh.in | 2 +- contrib/initramfs/scripts/zfs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/dracut/90zfs/zfs-load-key.sh.in b/contrib/dracut/90zfs/zfs-load-key.sh.in index 2138ff943c6..c974b3d9ec4 100755 --- a/contrib/dracut/90zfs/zfs-load-key.sh.in +++ b/contrib/dracut/90zfs/zfs-load-key.sh.in @@ -45,7 +45,7 @@ if [ "$(zpool list -H -o feature@encryption "${BOOTFS%%/*}")" = 'active' ]; then case "${KEYLOCATION%%://*}" in prompt) for _ in 1 2 3; do - systemd-ask-password "Encrypted ZFS password for ${BOOTFS}" --no-tty | zfs load-key "${ENCRYPTIONROOT}" && break + systemd-ask-password --no-tty "Encrypted ZFS password for ${BOOTFS}" | zfs load-key "${ENCRYPTIONROOT}" && break done ;; http*) diff --git a/contrib/initramfs/scripts/zfs b/contrib/initramfs/scripts/zfs index fcb712cff27..85b00f9da86 100644 --- a/contrib/initramfs/scripts/zfs +++ b/contrib/initramfs/scripts/zfs @@ -421,7 +421,7 @@ decrypt_fs() elif [ -e /run/systemd/system ]; then echo "systemd-ask-password" > /run/zfs_console_askpwd_cmd for _ in 1 2 3; do - systemd-ask-password "Encrypted ZFS password for ${ENCRYPTIONROOT}" --no-tty | \ + systemd-ask-password --no-tty "Encrypted ZFS password for ${ENCRYPTIONROOT}" | \ $ZFS load-key "${ENCRYPTIONROOT}" && break done From cf65c33c9c7e1d753bb038fdb11fd0853065c069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 17 May 2021 18:09:46 +0200 Subject: [PATCH 013/117] zfs-share.8: document -l flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description stolen from zfs-mount.8 Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12067 --- man/man8/zfs-share.8 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/man/man8/zfs-share.8 b/man/man8/zfs-share.8 index e30d538814c..89121ead095 100644 --- a/man/man8/zfs-share.8 +++ b/man/man8/zfs-share.8 @@ -29,7 +29,7 @@ .\" Copyright 2018 Nexenta Systems, Inc. .\" Copyright 2019 Joyent, Inc. .\" -.Dd June 30, 2019 +.Dd May 17, 2021 .Dt ZFS-SHARE 8 .Os . @@ -39,6 +39,7 @@ .Sh SYNOPSIS .Nm zfs .Cm share +.Op Fl l .Fl a Ns | Ns Ar filesystem .Nm zfs .Cm unshare @@ -49,10 +50,19 @@ .It Xo .Nm zfs .Cm share +.Op Fl l .Fl a Ns | Ns Ar filesystem .Xc Shares available ZFS file systems. .Bl -tag -width "-a" +.It Fl l +Load keys for encrypted filesystems as they are being mounted. +This is equivalent to executing +.Nm zfs Cm load-key +on each encryption root before mounting it. +Note that if a filesystem has +.Sy keylocation Ns = Ns Sy prompt , +this will cause the terminal to interactively block after asking for the key. .It Fl a Share all available ZFS file systems. Invoked automatically as part of the boot process. From bdf6464c6c7c79bb11f69298e8353f6db3b3c26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 17 May 2021 18:03:26 +0200 Subject: [PATCH 014/117] freebsd/libshare: nfs: don't send SIGHUP to all processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pidfile_open() sets *pidptr to -1 if the process currently holding the lock is between pidfile_open() and pidfile_write(), the subsequent kill(mountdpid) would potentially SIGHUP all non-system processes except init: just sleep for half a millisecond and try again in that case Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12067 --- lib/libshare/os/freebsd/nfs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c index 0041bc228bb..8abc3bf8230 100644 --- a/lib/libshare/os/freebsd/nfs.c +++ b/lib/libshare/os/freebsd/nfs.c @@ -306,9 +306,10 @@ nfs_commit_shares(void) struct pidfh *pfh; pid_t mountdpid; +start: pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &mountdpid); if (pfh != NULL) { - /* Mountd is not running. */ + /* mountd(8) is not running. */ pidfile_remove(pfh); return (SA_OK); } @@ -316,6 +317,11 @@ nfs_commit_shares(void) /* Cannot open pidfile for some reason. */ return (SA_SYSTEM_ERR); } + if (mountdpid == -1) { + /* mountd(8) exists, but didn't write the PID yet */ + usleep(500); + goto start; + } /* We have mountd(8) PID in mountdpid variable. */ kill(mountdpid, SIGHUP); return (SA_OK); From f50697f95b1601d40e7c33249ab1b5d8163d9f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 17 May 2021 18:08:35 +0200 Subject: [PATCH 015/117] libshare: nfs: retry flock() when interrupted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12067 --- lib/libshare/nfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index e339ebc81f1..2b0c70001df 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -50,7 +50,9 @@ nfs_exports_lock(const char *name) return (err); } - if (flock(nfs_lock_fd, LOCK_EX) != 0) { + while ((err = flock(nfs_lock_fd, LOCK_EX)) != 0 && errno == EINTR) + ; + if (err != 0) { err = errno; fprintf(stderr, "failed to lock %s: %s\n", name, strerror(err)); (void) close(nfs_lock_fd); From c53f2e9b5086051a9aede27254a109983443e557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 17 May 2021 18:13:18 +0200 Subject: [PATCH 016/117] libshare: nfs: open temporary file once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12067 --- lib/libshare/nfs.c | 83 +++++++++++++++++++++++------------ lib/libshare/nfs.h | 4 +- lib/libshare/os/freebsd/nfs.c | 43 ++++-------------- lib/libshare/os/linux/nfs.c | 57 +++++++----------------- lib/libshare/os/linux/smb.c | 2 +- 5 files changed, 80 insertions(+), 109 deletions(-) diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 2b0c70001df..e7037b104c1 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -77,10 +77,18 @@ nfs_exports_unlock(const char *name) nfs_lock_fd = -1; } -static char * -nfs_init_tmpfile(const char *prefix, const char *mdir) +struct tmpfile { + /* + * This only needs to be as wide as ZFS_EXPORTS_FILE and mktemp suffix, + * 64 is more than enough. + */ + char name[64]; + FILE *fp; +}; + +static boolean_t +nfs_init_tmpfile(const char *prefix, const char *mdir, struct tmpfile *tmpf) { - char *tmpfile = NULL; struct stat sb; if (mdir != NULL && @@ -88,72 +96,89 @@ nfs_init_tmpfile(const char *prefix, const char *mdir) mkdir(mdir, 0755) < 0) { fprintf(stderr, "failed to create %s: %s\n", mdir, strerror(errno)); - return (NULL); + return (B_FALSE); } - if (asprintf(&tmpfile, "%s.XXXXXXXX", prefix) == -1) { - fprintf(stderr, "Unable to allocate temporary file\n"); - return (NULL); - } + strcpy(tmpf->name, prefix); + strcat(tmpf->name, ".XXXXXXXX"); - int fd = mkostemp(tmpfile, O_CLOEXEC); + int fd = mkostemp(tmpf->name, O_CLOEXEC); if (fd == -1) { fprintf(stderr, "Unable to create temporary file: %s", strerror(errno)); - free(tmpfile); - return (NULL); + return (B_FALSE); } - close(fd); - return (tmpfile); + + tmpf->fp = fdopen(fd, "w+"); + if (tmpf->fp == NULL) { + fprintf(stderr, "Unable to reopen temporary file: %s", + strerror(errno)); + close(fd); + return (B_FALSE); + } + + return (B_TRUE); +} + +static void +nfs_abort_tmpfile(struct tmpfile *tmpf) +{ + unlink(tmpf->name); + fclose(tmpf->fp); } static int -nfs_fini_tmpfile(const char *exports, char *tmpfile) +nfs_fini_tmpfile(const char *exports, struct tmpfile *tmpf) { - if (rename(tmpfile, exports) == -1) { - fprintf(stderr, "Unable to rename %s: %s\n", tmpfile, + if (fflush(tmpf->fp) != 0) { + fprintf(stderr, "Failed to write to temporary file: %s\n", strerror(errno)); - unlink(tmpfile); - free(tmpfile); + nfs_abort_tmpfile(tmpf); return (SA_SYSTEM_ERR); } - free(tmpfile); + + if (rename(tmpf->name, exports) == -1) { + fprintf(stderr, "Unable to rename %s -> %s: %s\n", + tmpf->name, exports, strerror(errno)); + nfs_abort_tmpfile(tmpf); + return (SA_SYSTEM_ERR); + } + + fclose(tmpf->fp); return (SA_OK); } int nfs_toggle_share(const char *lockfile, const char *exports, const char *expdir, sa_share_impl_t impl_share, - int(*cbk)(sa_share_impl_t impl_share, char *filename)) + int(*cbk)(sa_share_impl_t impl_share, FILE *tmpfile)) { int error; - char *filename; + struct tmpfile tmpf; - if ((filename = nfs_init_tmpfile(exports, expdir)) == NULL) + if (!nfs_init_tmpfile(exports, expdir, &tmpf)) return (SA_SYSTEM_ERR); error = nfs_exports_lock(lockfile); if (error != 0) { - unlink(filename); - free(filename); + nfs_abort_tmpfile(&tmpf); return (error); } - error = nfs_copy_entries(filename, impl_share->sa_mountpoint); + error = nfs_copy_entries(tmpf.fp, impl_share->sa_mountpoint); if (error != SA_OK) goto fullerr; - error = cbk(impl_share, filename); + error = cbk(impl_share, tmpf.fp); if (error != SA_OK) goto fullerr; - error = nfs_fini_tmpfile(exports, filename); + error = nfs_fini_tmpfile(exports, &tmpf); nfs_exports_unlock(lockfile); return (error); fullerr: - unlink(filename); - free(filename); + nfs_abort_tmpfile(&tmpf); nfs_exports_unlock(lockfile); return (error); } diff --git a/lib/libshare/nfs.h b/lib/libshare/nfs.h index 4dbcdf59859..370c409bec7 100644 --- a/lib/libshare/nfs.h +++ b/lib/libshare/nfs.h @@ -30,7 +30,7 @@ void libshare_nfs_init(void); -int nfs_copy_entries(char *filename, const char *mountpoint); +int nfs_copy_entries(FILE *tmpfile, const char *mountpoint); int nfs_toggle_share(const char *lockfile, const char *exports, const char *expdir, sa_share_impl_t impl_share, - int(*cbk)(sa_share_impl_t impl_share, char *filename)); + int(*cbk)(sa_share_impl_t impl_share, FILE *tmpfile)); diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c index 8abc3bf8230..08202983890 100644 --- a/lib/libshare/os/freebsd/nfs.c +++ b/lib/libshare/os/freebsd/nfs.c @@ -144,23 +144,16 @@ translate_opts(const char *shareopts) } /* - * This function copies all entries from the exports file to "filename", + * This function copies all entries from the exports file to newfp, * omitting any entries for the specified mountpoint. */ int -nfs_copy_entries(char *filename, const char *mountpoint) +nfs_copy_entries(FILE *newfp, const char *mountpoint) { int error = SA_OK; char *line; FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "re"); - FILE *newfp = fopen(filename, "w+e"); - if (newfp == NULL) { - fprintf(stderr, "failed to open %s file: %s", filename, - strerror(errno)); - fclose(oldfp); - return (SA_SYSTEM_ERR); - } fputs(FILE_HEADER, newfp); /* @@ -175,47 +168,27 @@ nfs_copy_entries(char *filename, const char *mountpoint) } if (fclose(oldfp) != 0) { fprintf(stderr, "Unable to close file %s: %s\n", - filename, strerror(errno)); + ZFS_EXPORTS_FILE, strerror(errno)); error = error != 0 ? error : SA_SYSTEM_ERR; } } - if (error == 0 && ferror(newfp) != 0) { + if (error == SA_OK && ferror(newfp) != 0) error = ferror(newfp); - } - if (fclose(newfp) != 0) { - fprintf(stderr, "Unable to close file %s: %s\n", - filename, strerror(errno)); - error = error != 0 ? error : SA_SYSTEM_ERR; - } return (error); } static int -nfs_enable_share_impl(sa_share_impl_t impl_share, char *filename) +nfs_enable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile) { - FILE *fp = fopen(filename, "a+e"); - if (fp == NULL) { - fprintf(stderr, "failed to open %s file: %s", filename, - strerror(errno)); - return (SA_SYSTEM_ERR); - } - char *shareopts = FSINFO(impl_share, nfs_fstype)->shareopts; if (strcmp(shareopts, "on") == 0) shareopts = ""; - if (fprintf(fp, "%s\t%s\n", impl_share->sa_mountpoint, + if (fprintf(tmpfile, "%s\t%s\n", impl_share->sa_mountpoint, translate_opts(shareopts)) < 0) { - fprintf(stderr, "failed to write to %s\n", filename); - fclose(fp); - return (SA_SYSTEM_ERR); - } - - if (fclose(fp) != 0) { - fprintf(stderr, "Unable to close file %s: %s\n", - filename, strerror(errno)); + fprintf(stderr, "failed to write to temporary file\n"); return (SA_SYSTEM_ERR); } @@ -231,7 +204,7 @@ nfs_enable_share(sa_share_impl_t impl_share) } static int -nfs_disable_share_impl(sa_share_impl_t impl_share, char *filename) +nfs_disable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile) { return (SA_OK); } diff --git a/lib/libshare/os/linux/nfs.c b/lib/libshare/os/linux/nfs.c index 4f754aabd3a..bf372914117 100644 --- a/lib/libshare/os/linux/nfs.c +++ b/lib/libshare/os/linux/nfs.c @@ -51,7 +51,7 @@ static sa_fstype_t *nfs_fstype; typedef int (*nfs_shareopt_callback_t)(const char *opt, const char *value, void *cookie); -typedef int (*nfs_host_callback_t)(const char *sharepath, const char *filename, +typedef int (*nfs_host_callback_t)(FILE *tmpfile, const char *sharepath, const char *host, const char *security, const char *access, void *cookie); /* @@ -122,7 +122,7 @@ typedef struct nfs_host_cookie_s { nfs_host_callback_t callback; const char *sharepath; void *cookie; - const char *filename; + FILE *tmpfile; const char *security; } nfs_host_cookie_t; @@ -203,7 +203,7 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie) } } - error = udata->callback(udata->filename, + error = udata->callback(udata->tmpfile, udata->sharepath, host, udata->security, access, udata->cookie); @@ -226,7 +226,7 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie) * Invokes a callback function for all NFS hosts that are set for a share. */ static int -foreach_nfs_host(sa_share_impl_t impl_share, char *filename, +foreach_nfs_host(sa_share_impl_t impl_share, FILE *tmpfile, nfs_host_callback_t callback, void *cookie) { nfs_host_cookie_t udata; @@ -235,7 +235,7 @@ foreach_nfs_host(sa_share_impl_t impl_share, char *filename, udata.callback = callback; udata.sharepath = impl_share->sa_mountpoint; udata.cookie = cookie; - udata.filename = filename; + udata.tmpfile = tmpfile; udata.security = "sys"; shareopts = FSINFO(impl_share, nfs_fstype)->shareopts; @@ -393,7 +393,7 @@ get_linux_shareopts(const char *shareopts, char **plinux_opts) * automatically exported upon boot or whenever the nfs server restarts. */ static int -nfs_add_entry(const char *filename, const char *sharepath, +nfs_add_entry(FILE *tmpfile, const char *sharepath, const char *host, const char *security, const char *access_opts, void *pcookie) { @@ -408,50 +408,29 @@ nfs_add_entry(const char *filename, const char *sharepath, if (linux_opts == NULL) linux_opts = ""; - FILE *fp = fopen(filename, "a+e"); - if (fp == NULL) { - fprintf(stderr, "failed to open %s file: %s", filename, - strerror(errno)); - free(linuxhost); - return (SA_SYSTEM_ERR); - } - - if (fprintf(fp, "%s %s(sec=%s,%s,%s)\n", sharepath, linuxhost, + if (fprintf(tmpfile, "%s %s(sec=%s,%s,%s)\n", sharepath, linuxhost, security, access_opts, linux_opts) < 0) { - fprintf(stderr, "failed to write to %s\n", filename); + fprintf(stderr, "failed to write to temporary file\n"); free(linuxhost); - fclose(fp); return (SA_SYSTEM_ERR); } free(linuxhost); - if (fclose(fp) != 0) { - fprintf(stderr, "Unable to close file %s: %s\n", - filename, strerror(errno)); - return (SA_SYSTEM_ERR); - } return (SA_OK); } /* - * This function copies all entries from the exports file to "filename", + * This function copies all entries from the exports file to newfp, * omitting any entries for the specified mountpoint. */ int -nfs_copy_entries(char *filename, const char *mountpoint) +nfs_copy_entries(FILE *newfp, const char *mountpoint) { char *buf = NULL; size_t buflen = 0; int error = SA_OK; FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "re"); - FILE *newfp = fopen(filename, "w+e"); - if (newfp == NULL) { - fprintf(stderr, "failed to open %s file: %s", filename, - strerror(errno)); - fclose(oldfp); - return (SA_SYSTEM_ERR); - } fputs(FILE_HEADER, newfp); /* @@ -482,21 +461,15 @@ nfs_copy_entries(char *filename, const char *mountpoint) } if (fclose(oldfp) != 0) { fprintf(stderr, "Unable to close file %s: %s\n", - filename, strerror(errno)); + ZFS_EXPORTS_FILE, strerror(errno)); error = error != 0 ? error : SA_SYSTEM_ERR; } } - if (error == 0 && ferror(newfp) != 0) { + if (error == SA_OK && ferror(newfp) != 0) error = ferror(newfp); - } free(buf); - if (fclose(newfp) != 0) { - fprintf(stderr, "Unable to close file %s: %s\n", - filename, strerror(errno)); - error = error != 0 ? error : SA_SYSTEM_ERR; - } return (error); } @@ -504,7 +477,7 @@ nfs_copy_entries(char *filename, const char *mountpoint) * Enables NFS sharing for the specified share. */ static int -nfs_enable_share_impl(sa_share_impl_t impl_share, char *filename) +nfs_enable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile) { char *shareopts, *linux_opts; int error; @@ -514,7 +487,7 @@ nfs_enable_share_impl(sa_share_impl_t impl_share, char *filename) if (error != SA_OK) return (error); - error = foreach_nfs_host(impl_share, filename, nfs_add_entry, + error = foreach_nfs_host(impl_share, tmpfile, nfs_add_entry, linux_opts); free(linux_opts); return (error); @@ -532,7 +505,7 @@ nfs_enable_share(sa_share_impl_t impl_share) * Disables NFS sharing for the specified share. */ static int -nfs_disable_share_impl(sa_share_impl_t impl_share, char *filename) +nfs_disable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile) { return (SA_OK); } diff --git a/lib/libshare/os/linux/smb.c b/lib/libshare/os/linux/smb.c index 9b18848e09c..312ffb97d12 100644 --- a/lib/libshare/os/linux/smb.c +++ b/lib/libshare/os/linux/smb.c @@ -254,7 +254,7 @@ smb_enable_share_one(const char *sharename, const char *sharepath) argv[5] = (char *)name; argv[6] = (char *)sharepath; argv[7] = (char *)comment; - argv[8] = "Everyone:F"; + argv[8] = (char *)"Everyone:F"; argv[9] = NULL; rc = libzfs_run_process(argv[0], argv, 0); From 4e225e7316d5e65dcfd2694e79930400740b7260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 17 May 2021 19:56:48 +0200 Subject: [PATCH 017/117] libshare: nfs: share nfs_copy_entries() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12067 --- lib/libshare/nfs.c | 53 +++++++++++++++++++++++++- lib/libshare/nfs.h | 1 - lib/libshare/os/freebsd/nfs.c | 72 ----------------------------------- lib/libshare/os/linux/nfs.c | 54 -------------------------- 4 files changed, 52 insertions(+), 128 deletions(-) diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index e7037b104c1..4bc7e7779ea 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -148,6 +148,57 @@ nfs_fini_tmpfile(const char *exports, struct tmpfile *tmpf) return (SA_OK); } +/* + * Copy all entries from the exports file to newfp, + * omitting any entries for the specified mountpoint. + */ +static int +nfs_copy_entries(FILE *newfp, const char *exports, const char *mountpoint) +{ + int error = SA_OK; + + fputs(FILE_HEADER, newfp); + + /* + * ZFS_EXPORTS_FILE may not exist yet. + * If that's the case, then just write out the new file. + */ + FILE *oldfp = fopen(exports, "re"); + if (oldfp != NULL) { + char *buf = NULL, *sep; + size_t buflen = 0, mplen = strlen(mountpoint); + + while (getline(&buf, &buflen, oldfp) != -1) { + + if (buf[0] == '\n' || buf[0] == '#') + continue; + + if ((sep = strpbrk(buf, "\t \n")) != NULL && + sep - buf == mplen && + strncmp(buf, mountpoint, mplen) == 0) + continue; + + fputs(buf, newfp); + } + + if (ferror(oldfp) != 0) + error = ferror(oldfp); + + if (fclose(oldfp) != 0) { + fprintf(stderr, "Unable to close file %s: %s\n", + exports, strerror(errno)); + error = error != SA_OK ? error : SA_SYSTEM_ERR; + } + + free(buf); + } + + if (error == SA_OK && ferror(newfp) != 0) + error = ferror(newfp); + + return (error); +} + int nfs_toggle_share(const char *lockfile, const char *exports, const char *expdir, sa_share_impl_t impl_share, @@ -165,7 +216,7 @@ nfs_toggle_share(const char *lockfile, const char *exports, return (error); } - error = nfs_copy_entries(tmpf.fp, impl_share->sa_mountpoint); + error = nfs_copy_entries(tmpf.fp, exports, impl_share->sa_mountpoint); if (error != SA_OK) goto fullerr; diff --git a/lib/libshare/nfs.h b/lib/libshare/nfs.h index 370c409bec7..63838032ba1 100644 --- a/lib/libshare/nfs.h +++ b/lib/libshare/nfs.h @@ -30,7 +30,6 @@ void libshare_nfs_init(void); -int nfs_copy_entries(FILE *tmpfile, const char *mountpoint); int nfs_toggle_share(const char *lockfile, const char *exports, const char *expdir, sa_share_impl_t impl_share, int(*cbk)(sa_share_impl_t impl_share, FILE *tmpfile)); diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c index 08202983890..ba98a647264 100644 --- a/lib/libshare/os/freebsd/nfs.c +++ b/lib/libshare/os/freebsd/nfs.c @@ -54,42 +54,6 @@ __FBSDID("$FreeBSD$"); static sa_fstype_t *nfs_fstype; -/* - * Read one line from a file. Skip comments, empty lines and a line with a - * mountpoint specified in the 'skip' argument. - * - * NOTE: This function returns a static buffer and thus is not thread-safe. - */ -static char * -zgetline(FILE *fd, const char *skip) -{ - static char line[MAXLINESIZE]; - size_t len, skiplen = 0; - char *s, last; - - if (skip != NULL) - skiplen = strlen(skip); - for (;;) { - s = fgets(line, sizeof (line), fd); - if (s == NULL) - return (NULL); - /* Skip empty lines and comments. */ - if (line[0] == '\n' || line[0] == '#') - continue; - len = strlen(line); - if (line[len - 1] == '\n') - line[len - 1] = '\0'; - last = line[skiplen]; - /* Skip the given mountpoint. */ - if (skip != NULL && strncmp(skip, line, skiplen) == 0 && - (last == '\t' || last == ' ' || last == '\0')) { - continue; - } - break; - } - return (line); -} - /* * This function translate options to a format acceptable by exports(5), eg. * @@ -143,42 +107,6 @@ translate_opts(const char *shareopts) return (newopts); } -/* - * This function copies all entries from the exports file to newfp, - * omitting any entries for the specified mountpoint. - */ -int -nfs_copy_entries(FILE *newfp, const char *mountpoint) -{ - int error = SA_OK; - char *line; - - FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "re"); - fputs(FILE_HEADER, newfp); - - /* - * The ZFS_EXPORTS_FILE may not exist yet. If that's the - * case then just write out the new file. - */ - if (oldfp != NULL) { - while ((line = zgetline(oldfp, mountpoint)) != NULL) - fprintf(newfp, "%s\n", line); - if (ferror(oldfp) != 0) { - error = ferror(oldfp); - } - if (fclose(oldfp) != 0) { - fprintf(stderr, "Unable to close file %s: %s\n", - ZFS_EXPORTS_FILE, strerror(errno)); - error = error != 0 ? error : SA_SYSTEM_ERR; - } - } - - if (error == SA_OK && ferror(newfp) != 0) - error = ferror(newfp); - - return (error); -} - static int nfs_enable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile) { diff --git a/lib/libshare/os/linux/nfs.c b/lib/libshare/os/linux/nfs.c index bf372914117..7f8ebd7f65e 100644 --- a/lib/libshare/os/linux/nfs.c +++ b/lib/libshare/os/linux/nfs.c @@ -419,60 +419,6 @@ nfs_add_entry(FILE *tmpfile, const char *sharepath, return (SA_OK); } -/* - * This function copies all entries from the exports file to newfp, - * omitting any entries for the specified mountpoint. - */ -int -nfs_copy_entries(FILE *newfp, const char *mountpoint) -{ - char *buf = NULL; - size_t buflen = 0; - int error = SA_OK; - - FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "re"); - fputs(FILE_HEADER, newfp); - - /* - * The ZFS_EXPORTS_FILE may not exist yet. If that's the - * case then just write out the new file. - */ - if (oldfp != NULL) { - while (getline(&buf, &buflen, oldfp) != -1) { - char *space = NULL; - - if (buf[0] == '\n' || buf[0] == '#') - continue; - - if ((space = strchr(buf, ' ')) != NULL) { - int mountpoint_len = strlen(mountpoint); - - if (space - buf == mountpoint_len && - strncmp(mountpoint, buf, - mountpoint_len) == 0) { - continue; - } - } - fputs(buf, newfp); - } - - if (ferror(oldfp) != 0) { - error = ferror(oldfp); - } - if (fclose(oldfp) != 0) { - fprintf(stderr, "Unable to close file %s: %s\n", - ZFS_EXPORTS_FILE, strerror(errno)); - error = error != 0 ? error : SA_SYSTEM_ERR; - } - } - - if (error == SA_OK && ferror(newfp) != 0) - error = ferror(newfp); - - free(buf); - return (error); -} - /* * Enables NFS sharing for the specified share. */ From 605e03e51a8baeb90c4194c511e85e3663d4a78d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 17 May 2021 20:25:29 +0200 Subject: [PATCH 018/117] libshare: nfs: share nfs_is_shared() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12067 --- lib/libshare/nfs.c | 70 +++++++++++++++++++++++++---------- lib/libshare/nfs.h | 1 + lib/libshare/os/freebsd/nfs.c | 30 +-------------- lib/libshare/os/linux/nfs.c | 26 +------------ 4 files changed, 53 insertions(+), 74 deletions(-) diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 4bc7e7779ea..79b822fbcc2 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -148,38 +148,29 @@ nfs_fini_tmpfile(const char *exports, struct tmpfile *tmpf) return (SA_OK); } -/* - * Copy all entries from the exports file to newfp, - * omitting any entries for the specified mountpoint. - */ static int -nfs_copy_entries(FILE *newfp, const char *exports, const char *mountpoint) +nfs_process_exports(const char *exports, const char *mountpoint, + boolean_t (*cbk)(void *userdata, char *line, boolean_t found_mountpoint), + void *userdata) { int error = SA_OK; + boolean_t cont = B_TRUE; - fputs(FILE_HEADER, newfp); - - /* - * ZFS_EXPORTS_FILE may not exist yet. - * If that's the case, then just write out the new file. - */ FILE *oldfp = fopen(exports, "re"); if (oldfp != NULL) { char *buf = NULL, *sep; size_t buflen = 0, mplen = strlen(mountpoint); - while (getline(&buf, &buflen, oldfp) != -1) { - + while (cont && getline(&buf, &buflen, oldfp) != -1) { if (buf[0] == '\n' || buf[0] == '#') continue; - if ((sep = strpbrk(buf, "\t \n")) != NULL && + cont = cbk(userdata, buf, + (sep = strpbrk(buf, "\t \n")) != NULL && sep - buf == mplen && - strncmp(buf, mountpoint, mplen) == 0) - continue; - - fputs(buf, newfp); + strncmp(buf, mountpoint, mplen) == 0); } + free(buf); if (ferror(oldfp) != 0) error = ferror(oldfp); @@ -189,10 +180,32 @@ nfs_copy_entries(FILE *newfp, const char *exports, const char *mountpoint) exports, strerror(errno)); error = error != SA_OK ? error : SA_SYSTEM_ERR; } - - free(buf); } + return (error); +} + +static boolean_t +nfs_copy_entries_cb(void *userdata, char *line, boolean_t found_mountpoint) +{ + FILE *newfp = userdata; + if (!found_mountpoint) + fputs(line, newfp); + return (B_TRUE); +} + +/* + * Copy all entries from the exports file (if it exists) to newfp, + * omitting any entries for the specified mountpoint. + */ +static int +nfs_copy_entries(FILE *newfp, const char *exports, const char *mountpoint) +{ + fputs(FILE_HEADER, newfp); + + int error = nfs_process_exports( + exports, mountpoint, nfs_copy_entries_cb, newfp); + if (error == SA_OK && ferror(newfp) != 0) error = ferror(newfp); @@ -233,3 +246,20 @@ fullerr: nfs_exports_unlock(lockfile); return (error); } + +static boolean_t +nfs_is_shared_cb(void *userdata, char *line, boolean_t found_mountpoint) +{ + boolean_t *found = userdata; + *found = found_mountpoint; + return (!found_mountpoint); +} + +boolean_t +nfs_is_shared_impl(const char *exports, sa_share_impl_t impl_share) +{ + boolean_t found = B_FALSE; + nfs_process_exports(exports, impl_share->sa_mountpoint, + nfs_is_shared_cb, &found); + return (found); +} diff --git a/lib/libshare/nfs.h b/lib/libshare/nfs.h index 63838032ba1..cfac274c3d2 100644 --- a/lib/libshare/nfs.h +++ b/lib/libshare/nfs.h @@ -30,6 +30,7 @@ void libshare_nfs_init(void); +boolean_t nfs_is_shared_impl(const char *exports, sa_share_impl_t impl_share); int nfs_toggle_share(const char *lockfile, const char *exports, const char *expdir, sa_share_impl_t impl_share, int(*cbk)(sa_share_impl_t impl_share, FILE *tmpfile)); diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c index ba98a647264..b53ff09872b 100644 --- a/lib/libshare/os/freebsd/nfs.c +++ b/lib/libshare/os/freebsd/nfs.c @@ -148,35 +148,7 @@ nfs_disable_share(sa_share_impl_t impl_share) static boolean_t nfs_is_shared(sa_share_impl_t impl_share) { - char *s, last, line[MAXLINESIZE]; - size_t len; - char *mntpoint = impl_share->sa_mountpoint; - size_t mntlen = strlen(mntpoint); - - FILE *fp = fopen(ZFS_EXPORTS_FILE, "re"); - if (fp == NULL) - return (B_FALSE); - - for (;;) { - s = fgets(line, sizeof (line), fp); - if (s == NULL) - return (B_FALSE); - /* Skip empty lines and comments. */ - if (line[0] == '\n' || line[0] == '#') - continue; - len = strlen(line); - if (line[len - 1] == '\n') - line[len - 1] = '\0'; - last = line[mntlen]; - /* Skip the given mountpoint. */ - if (strncmp(mntpoint, line, mntlen) == 0 && - (last == '\t' || last == ' ' || last == '\0')) { - fclose(fp); - return (B_TRUE); - } - } - fclose(fp); - return (B_FALSE); + return (nfs_is_shared_impl(ZFS_EXPORTS_FILE, impl_share)); } static int diff --git a/lib/libshare/os/linux/nfs.c b/lib/libshare/os/linux/nfs.c index 7f8ebd7f65e..d66228336d4 100644 --- a/lib/libshare/os/linux/nfs.c +++ b/lib/libshare/os/linux/nfs.c @@ -467,31 +467,7 @@ nfs_disable_share(sa_share_impl_t impl_share) static boolean_t nfs_is_shared(sa_share_impl_t impl_share) { - size_t buflen = 0; - char *buf = NULL; - - FILE *fp = fopen(ZFS_EXPORTS_FILE, "re"); - if (fp == NULL) { - return (B_FALSE); - } - while ((getline(&buf, &buflen, fp)) != -1) { - char *space = NULL; - - if ((space = strchr(buf, ' ')) != NULL) { - int mountpoint_len = strlen(impl_share->sa_mountpoint); - - if (space - buf == mountpoint_len && - strncmp(impl_share->sa_mountpoint, buf, - mountpoint_len) == 0) { - fclose(fp); - free(buf); - return (B_TRUE); - } - } - } - free(buf); - fclose(fp); - return (B_FALSE); + return (nfs_is_shared_impl(ZFS_EXPORTS_FILE, impl_share)); } /* From 9d4a44f0b8353859b43f126ee65b013af22d6819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 17 May 2021 20:34:04 +0200 Subject: [PATCH 019/117] linux/libshare: nfs: don't needlessly strdup() hostspec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12067 --- lib/libshare/os/linux/nfs.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/lib/libshare/os/linux/nfs.c b/lib/libshare/os/linux/nfs.c index d66228336d4..d6dbc158ce9 100644 --- a/lib/libshare/os/linux/nfs.c +++ b/lib/libshare/os/linux/nfs.c @@ -247,8 +247,8 @@ foreach_nfs_host(sa_share_impl_t impl_share, FILE *tmpfile, /* * Converts a Solaris NFS host specification to its Linux equivalent. */ -static int -get_linux_hostspec(const char *solaris_hostspec, char **plinux_hostspec) +static const char * +get_linux_hostspec(const char *solaris_hostspec) { /* * For now we just support CIDR masks (e.g. @192.168.0.0/16) and host @@ -259,16 +259,10 @@ get_linux_hostspec(const char *solaris_hostspec, char **plinux_hostspec) * Solaris host specifier, e.g. @192.168.0.0/16; we just need * to skip the @ in this case */ - *plinux_hostspec = strdup(solaris_hostspec + 1); + return (solaris_hostspec + 1); } else { - *plinux_hostspec = strdup(solaris_hostspec); + return (solaris_hostspec); } - - if (*plinux_hostspec == NULL) { - return (SA_NO_MEMORY); - } - - return (SA_OK); } /* @@ -397,25 +391,18 @@ nfs_add_entry(FILE *tmpfile, const char *sharepath, const char *host, const char *security, const char *access_opts, void *pcookie) { - int error; - char *linuxhost; const char *linux_opts = (const char *)pcookie; - error = get_linux_hostspec(host, &linuxhost); - if (error != SA_OK) - return (error); - if (linux_opts == NULL) linux_opts = ""; - if (fprintf(tmpfile, "%s %s(sec=%s,%s,%s)\n", sharepath, linuxhost, - security, access_opts, linux_opts) < 0) { + if (fprintf(tmpfile, "%s %s(sec=%s,%s,%s)\n", sharepath, + get_linux_hostspec(host), security, access_opts, + linux_opts) < 0) { fprintf(stderr, "failed to write to temporary file\n"); - free(linuxhost); return (SA_SYSTEM_ERR); } - free(linuxhost); return (SA_OK); } From 1e78b4eee04b80ac132bdd789b67c0e87ab566ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 17 May 2021 21:08:16 +0200 Subject: [PATCH 020/117] libshare: nfs: set export file 644 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shares are publicly known anyway and can be interrogated by any user, so this is a debugging aid more than anything. Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12067 --- lib/libshare/nfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 79b822fbcc2..153de04c210 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -144,6 +144,7 @@ nfs_fini_tmpfile(const char *exports, struct tmpfile *tmpf) return (SA_SYSTEM_ERR); } + (void) fchmod(fileno(tmpf->fp), 0644); fclose(tmpf->fp); return (SA_OK); } From 82e414f1b2e4d3c45d107b79da4a750485038c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 18 May 2021 18:00:26 +0200 Subject: [PATCH 021/117] libshare: nfs: always try to mkdir() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also works out to one syscall if the directory exists, but is one syscall shorter if it doesn't. Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12067 --- lib/libshare/nfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 153de04c210..980e517cb61 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -89,11 +89,9 @@ struct tmpfile { static boolean_t nfs_init_tmpfile(const char *prefix, const char *mdir, struct tmpfile *tmpf) { - struct stat sb; - if (mdir != NULL && - stat(mdir, &sb) < 0 && - mkdir(mdir, 0755) < 0) { + mkdir(mdir, 0755) < 0 && + errno != EEXIST) { fprintf(stderr, "failed to create %s: %s\n", mdir, strerror(errno)); return (B_FALSE); From 3fa5266d727a0e9506dfeed0118cbe7dd3c2a18d Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Fri, 17 Dec 2021 19:18:37 -0500 Subject: [PATCH 022/117] Linux: Implement FS_IOC_GETVERSION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide access to file generation number on Linux. Add test coverage. Reviewed-by: Brian Behlendorf Reviewed-by: Ahelenia Ziemiańska Signed-off-by: Ryan Moeller Closes #12856 --- configure.ac | 2 + module/os/linux/zfs/zpl_file.c | 13 +++++ tests/runfiles/common.run | 4 ++ tests/zfs-tests/cmd/Makefile.am | 1 + tests/zfs-tests/cmd/getversion/.gitignore | 1 + tests/zfs-tests/cmd/getversion/Makefile.am | 6 ++ tests/zfs-tests/cmd/getversion/getversion.c | 48 ++++++++++++++++ tests/zfs-tests/include/commands.cfg | 1 + tests/zfs-tests/include/libtest.shlib | 14 +++++ tests/zfs-tests/tests/functional/Makefile.am | 1 + .../tests/functional/stat/Makefile.am | 8 +++ .../tests/functional/stat/cleanup.ksh | 34 +++++++++++ .../zfs-tests/tests/functional/stat/setup.ksh | 36 ++++++++++++ .../tests/functional/stat/stat_001_pos.ksh | 57 +++++++++++++++++++ 14 files changed, 226 insertions(+) create mode 100644 tests/zfs-tests/cmd/getversion/.gitignore create mode 100644 tests/zfs-tests/cmd/getversion/Makefile.am create mode 100644 tests/zfs-tests/cmd/getversion/getversion.c create mode 100644 tests/zfs-tests/tests/functional/stat/Makefile.am create mode 100755 tests/zfs-tests/tests/functional/stat/cleanup.ksh create mode 100755 tests/zfs-tests/tests/functional/stat/setup.ksh create mode 100755 tests/zfs-tests/tests/functional/stat/stat_001_pos.ksh diff --git a/configure.ac b/configure.ac index 4ff902cdc28..1ba037a36aa 100644 --- a/configure.ac +++ b/configure.ac @@ -213,6 +213,7 @@ AC_CONFIG_FILES([ tests/zfs-tests/cmd/file_trunc/Makefile tests/zfs-tests/cmd/file_write/Makefile tests/zfs-tests/cmd/get_diff/Makefile + tests/zfs-tests/cmd/getversion/Makefile tests/zfs-tests/cmd/largest_file/Makefile tests/zfs-tests/cmd/libzfs_input_check/Makefile tests/zfs-tests/cmd/mkbusy/Makefile @@ -388,6 +389,7 @@ AC_CONFIG_FILES([ tests/zfs-tests/tests/functional/snapshot/Makefile tests/zfs-tests/tests/functional/snapused/Makefile tests/zfs-tests/tests/functional/sparse/Makefile + tests/zfs-tests/tests/functional/stat/Makefile tests/zfs-tests/tests/functional/suid/Makefile tests/zfs-tests/tests/functional/threadsappend/Makefile tests/zfs-tests/tests/functional/tmpfile/Makefile diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 7e88eae3371..ff324222d15 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -817,6 +817,14 @@ zpl_fallocate(struct file *filp, int mode, loff_t offset, loff_t len) mode, offset, len); } +static int +zpl_ioctl_getversion(struct file *filp, void __user *arg) +{ + uint32_t generation = file_inode(filp)->i_generation; + + return (copy_to_user(arg, &generation, sizeof (generation))); +} + #define ZFS_FL_USER_VISIBLE (FS_FL_USER_VISIBLE | ZFS_PROJINHERIT_FL) #define ZFS_FL_USER_MODIFIABLE (FS_FL_USER_MODIFIABLE | ZFS_PROJINHERIT_FL) @@ -989,6 +997,8 @@ static long zpl_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { switch (cmd) { + case FS_IOC_GETVERSION: + return (zpl_ioctl_getversion(filp, (void *)arg)); case FS_IOC_GETFLAGS: return (zpl_ioctl_getflags(filp, (void *)arg)); case FS_IOC_SETFLAGS: @@ -1007,6 +1017,9 @@ static long zpl_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { switch (cmd) { + case FS_IOC32_GETVERSION: + cmd = FS_IOC_GETVERSION; + break; case FS_IOC32_GETFLAGS: cmd = FS_IOC_GETFLAGS; break; diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index d5052172d26..0f0eab050fa 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -874,6 +874,10 @@ tags = ['functional', 'snapused'] tests = ['sparse_001_pos'] tags = ['functional', 'sparse'] +[tests/functional/stat] +tests = ['stat_001_pos'] +tags = ['functional', 'stat'] + [tests/functional/suid] tests = ['suid_write_to_suid', 'suid_write_to_sgid', 'suid_write_to_suid_sgid', 'suid_write_to_none'] diff --git a/tests/zfs-tests/cmd/Makefile.am b/tests/zfs-tests/cmd/Makefile.am index d1c29fcd1c6..2470397a90a 100644 --- a/tests/zfs-tests/cmd/Makefile.am +++ b/tests/zfs-tests/cmd/Makefile.am @@ -32,6 +32,7 @@ SUBDIRS = \ if BUILD_LINUX SUBDIRS += \ + getversion \ randfree_file \ user_ns_exec \ xattrtest diff --git a/tests/zfs-tests/cmd/getversion/.gitignore b/tests/zfs-tests/cmd/getversion/.gitignore new file mode 100644 index 00000000000..b347c417aa1 --- /dev/null +++ b/tests/zfs-tests/cmd/getversion/.gitignore @@ -0,0 +1 @@ +/getversion diff --git a/tests/zfs-tests/cmd/getversion/Makefile.am b/tests/zfs-tests/cmd/getversion/Makefile.am new file mode 100644 index 00000000000..d6b5e84082b --- /dev/null +++ b/tests/zfs-tests/cmd/getversion/Makefile.am @@ -0,0 +1,6 @@ +include $(top_srcdir)/config/Rules.am + +pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin + +pkgexec_PROGRAMS = getversion +getversion_SOURCES = getversion.c diff --git a/tests/zfs-tests/cmd/getversion/getversion.c b/tests/zfs-tests/cmd/getversion/getversion.c new file mode 100644 index 00000000000..62c1c5b6abc --- /dev/null +++ b/tests/zfs-tests/cmd/getversion/getversion.c @@ -0,0 +1,48 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2021 iXsystems, Inc. + */ + +/* + * FreeBSD and macOS expose file generation number through stat(2) and stat(1). + * Linux exposes it instead through an ioctl. + */ + +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, const char * const argv[]) +{ + if (argc != 2) + errx(EXIT_FAILURE, "usage: %s filename", argv[0]); + + int fd = open(argv[1], O_RDONLY); + if (fd == -1) + err(EXIT_FAILURE, "failed to open %s", argv[1]); + + int gen = 0; + if (ioctl(fd, FS_IOC_GETVERSION, &gen) == -1) + err(EXIT_FAILURE, "FS_IOC_GETVERSION failed"); + + (void) close(fd); + + (void) printf("%d\n", gen); + + return (EXIT_SUCCESS); +} diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index 4497a6248b4..e479f2c01f1 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -201,6 +201,7 @@ export ZFSTEST_FILES='badsend file_trunc file_write get_diff + getversion largest_file libzfs_input_check mkbusy diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 2e6ec7601db..66aec104c27 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -4051,6 +4051,20 @@ function stat_crtime # esac } +function stat_generation # +{ + typeset path=$1 + + case $(uname) in + Linux) + getversion "${path}" + ;; + *) + stat -f %v "${path}" + ;; + esac +} + # Run a command as if it was being run in a TTY. # # Usage: diff --git a/tests/zfs-tests/tests/functional/Makefile.am b/tests/zfs-tests/tests/functional/Makefile.am index 137cddd5f78..1412e3d8132 100644 --- a/tests/zfs-tests/tests/functional/Makefile.am +++ b/tests/zfs-tests/tests/functional/Makefile.am @@ -73,6 +73,7 @@ SUBDIRS = \ snapshot \ snapused \ sparse \ + stat \ suid \ threadsappend \ trim \ diff --git a/tests/zfs-tests/tests/functional/stat/Makefile.am b/tests/zfs-tests/tests/functional/stat/Makefile.am new file mode 100644 index 00000000000..1a861a655cb --- /dev/null +++ b/tests/zfs-tests/tests/functional/stat/Makefile.am @@ -0,0 +1,8 @@ +include $(top_srcdir)/config/Rules.am + +pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/stat + +dist_pkgdata_SCRIPTS = \ + cleanup.ksh \ + setup.ksh \ + stat_001_pos.ksh diff --git a/tests/zfs-tests/tests/functional/stat/cleanup.ksh b/tests/zfs-tests/tests/functional/stat/cleanup.ksh new file mode 100755 index 00000000000..3166bd6ec16 --- /dev/null +++ b/tests/zfs-tests/tests/functional/stat/cleanup.ksh @@ -0,0 +1,34 @@ +#!/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 http://www.opensolaris.org/os/licensing. +# 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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +default_cleanup diff --git a/tests/zfs-tests/tests/functional/stat/setup.ksh b/tests/zfs-tests/tests/functional/stat/setup.ksh new file mode 100755 index 00000000000..4fc55cd4780 --- /dev/null +++ b/tests/zfs-tests/tests/functional/stat/setup.ksh @@ -0,0 +1,36 @@ +#!/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 http://www.opensolaris.org/os/licensing. +# 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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +DISK=${DISKS%% *} + +default_setup ${DISK} diff --git a/tests/zfs-tests/tests/functional/stat/stat_001_pos.ksh b/tests/zfs-tests/tests/functional/stat/stat_001_pos.ksh new file mode 100755 index 00000000000..e6f9775f4b8 --- /dev/null +++ b/tests/zfs-tests/tests/functional/stat/stat_001_pos.ksh @@ -0,0 +1,57 @@ +#! /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 http://www.opensolaris.org/os/licensing. +# 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 2021 iXsystems, Inc. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# Ensure znode generation number is accessible. +# +# STRATEGY: +# 1) Create a file +# 2) Verify that the znode generation number can be obtained +# 3) Verify that the znode generation number is not empty +# + +verify_runnable "both" + +function cleanup +{ + rm -f ${TESTFILE} +} + +log_onexit cleanup + +log_assert "Ensure znode generation number is accessible." + +TESTFILE=${TESTDIR}/${TESTFILE0} + +log_must touch ${TESTFILE} +log_must stat_generation ${TESTFILE} +log_must test $(stat_generation ${TESTFILE}) -ne 0 + +log_pass "Successfully obtained file znode generation number." From 8623bd962da29716bab6bc0f0a4ef219d3151dd8 Mon Sep 17 00:00:00 2001 From: Philipp Riederer Date: Mon, 20 Dec 2021 19:50:46 +0100 Subject: [PATCH 023/117] Fix error propagation from lzc_send_redacted Any error from lzc_send_redacted is overwritten by the error of send_conclusion_record; skip writing the conclusion record if there was an earlier error. Reviewed-by: Paul Dagnelie Reviewed-by: Brian Behlendorf Signed-off-by: Philipp Riederer Closes #12766 --- lib/libzfs/libzfs_sendrecv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 098c7777ce6..9143ea11e5d 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -2542,7 +2542,7 @@ zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, "progress thread exited nonzero"))); } - if (flags->props || flags->holds || flags->backup) { + if (err == 0 && (flags->props || flags->holds || flags->backup)) { /* Write the final end record. */ err = send_conclusion_record(fd, NULL); if (err != 0) From 20f5c5b9128771c212b359b805f653851962498d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Matu=C5=A1ka?= Date: Mon, 20 Dec 2021 23:28:43 +0100 Subject: [PATCH 024/117] FreeBSD: fix world build after 143476ce8 Do not redefine the fallthrough macro when building with libcpp. Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Signed-off-by: Martin Matuska Closes #12880 --- lib/libspl/include/sys/feature_tests.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libspl/include/sys/feature_tests.h b/lib/libspl/include/sys/feature_tests.h index a36fd7b8cff..c9564b2c326 100644 --- a/lib/libspl/include/sys/feature_tests.h +++ b/lib/libspl/include/sys/feature_tests.h @@ -30,7 +30,7 @@ #define ____cacheline_aligned #define __NORETURN __attribute__((__noreturn__)) -#if !defined(fallthrough) +#if !defined(fallthrough) && !defined(_LIBCPP_VERSION) #if defined(HAVE_IMPLICIT_FALLTHROUGH) #define fallthrough __attribute__((__fallthrough__)) #else From 7b5d783a46bc5419e8bc7415f9424e7722425978 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 17 Dec 2021 23:20:10 +0000 Subject: [PATCH 025/117] ZTS: rsend_007_pos failures The rsend_007_pos test reliably fails on Linux in the cleanup function. This is caused by an unmount error when attempting to recursively destroy the newly received datasets. Invoking `df` prior to the `zfs destroy` interestingly avoids the unmont error. Why this should matter is unclear and should be investigated. However, this minor tweak may allow us to remove the ZTS rsend exceptions. The subsequent rsend_010_pos and rsend_011_pos failures were a result of this initial failure. The other "maybe" failures I was unable to reproduce and have not been recently observed in the master branch. Reviewed-by: Tony Nguyen Reviewed-by: Ryan Moeller Signed-off-by: Brian Behlendorf Closes #5665 Closes #6086 Closes #6087 Closes #6446 Closes #12876 --- tests/test-runner/bin/zts-report.py.in | 9 --------- tests/zfs-tests/tests/functional/rsend/rsend.kshlib | 1 + 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index da22ae7be0a..4c2735152f5 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -250,12 +250,6 @@ maybe = { 'removal/removal_condense_export': ['FAIL', known_reason], 'reservation/reservation_008_pos': ['FAIL', '7741'], 'reservation/reservation_018_pos': ['FAIL', '5642'], - 'rsend/rsend_019_pos': ['FAIL', '6086'], - 'rsend/rsend_020_pos': ['FAIL', '6446'], - 'rsend/rsend_021_pos': ['FAIL', '6446'], - 'rsend/rsend_024_pos': ['FAIL', '5665'], - 'rsend/send-c_volume': ['FAIL', '6087'], - 'rsend/send_partial_dataset': ['FAIL', known_reason], 'snapshot/clone_001_pos': ['FAIL', known_reason], 'snapshot/snapshot_009_pos': ['FAIL', '7961'], 'snapshot/snapshot_010_pos': ['FAIL', '7961'], @@ -301,9 +295,6 @@ elif sys.platform.startswith('linux'): 'mmp/mmp_exported_import': ['FAIL', known_reason], 'mmp/mmp_inactive_import': ['FAIL', known_reason], 'refreserv/refreserv_raidz': ['FAIL', known_reason], - 'rsend/rsend_007_pos': ['FAIL', known_reason], - 'rsend/rsend_010_pos': ['FAIL', known_reason], - 'rsend/rsend_011_pos': ['FAIL', known_reason], 'snapshot/rollback_003_pos': ['FAIL', known_reason], 'zvol/zvol_misc/zvol_misc_snapdev': ['FAIL', '12621'], 'zvol/zvol_misc/zvol_misc_volmode': ['FAIL', known_reason], diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index d06bd39b4d4..8cd35e4afdf 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -121,6 +121,7 @@ function cleanup_pool log_must rm -rf $BACKDIR/* if is_global_zone ; then + log_must df >/dev/null log_must_busy zfs destroy -Rf $pool else typeset list=$(zfs list -H -r -t all -o name $pool) From ff1acbac3035cc9d208f33d15b6025949f1fe0bf Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 17 Dec 2021 23:29:23 +0000 Subject: [PATCH 026/117] ZTS: speed up rsend tests With some minor tweaks several of rsend tests can be sped up considerably without significantly reducing test coverage. * send-c_verify_ratio: ~120s -> ~60s * send_realloc_*_files: ~330s -> ~65s For the send_realloc* tests this also has the advantage of removing (most of) the linux/freebsd conditional logic. Note that for this test more passes, and thus more incremental send/recvs, are preferable to a larger number of files. Total run time of the rsend test group was reduced from roughly 20 to 11 minutes in an environment similar to what's used by the CI. Reviewed-by: Tony Nguyen Reviewed-by: Ryan Moeller Signed-off-by: Brian Behlendorf Closes #12876 --- .../tests/functional/rsend/send-c_verify_ratio.ksh | 2 +- .../tests/functional/rsend/send_realloc_encrypted_files.ksh | 6 +----- .../zfs-tests/tests/functional/rsend/send_realloc_files.ksh | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_verify_ratio.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_verify_ratio.ksh index b7d978624f2..845349a9587 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_verify_ratio.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_verify_ratio.ksh @@ -36,7 +36,7 @@ log_assert "Verify send -c streams are compressed" log_onexit cleanup_pool $POOL2 typeset sendfs=$POOL2/$FS -typeset megs=128 +typeset megs=64 for prop in "${compress_prop_vals[@]}"; do for compressible in 'yes' 'no'; do diff --git a/tests/zfs-tests/tests/functional/rsend/send_realloc_encrypted_files.ksh b/tests/zfs-tests/tests/functional/rsend/send_realloc_encrypted_files.ksh index a653f8b3f15..361f6b375ea 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_realloc_encrypted_files.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_realloc_encrypted_files.ksh @@ -72,12 +72,8 @@ if is_kmemleak; then # to avoid timeout due to reduced performance. nr_files=100 passes=2 -elif is_freebsd; then - # Use fewer files and passes on FreeBSD to avoid timeout. - nr_files=500 - passes=2 else - nr_files=1000 + nr_files=300 passes=3 fi diff --git a/tests/zfs-tests/tests/functional/rsend/send_realloc_files.ksh b/tests/zfs-tests/tests/functional/rsend/send_realloc_files.ksh index 083a2bec9da..187a899a23c 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_realloc_files.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_realloc_files.ksh @@ -64,12 +64,8 @@ if is_kmemleak; then # to avoid timeout due to reduced performance. nr_files=100 passes=2 -elif is_freebsd; then - # Use fewer passes and files on FreeBSD to avoid timeout. - nr_files=500 - passes=2 else - nr_files=1000 + nr_files=300 passes=3 fi From 876b60dcfbf11abd2d620aa55500650c729d1028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 00:53:04 +0100 Subject: [PATCH 027/117] raidz_test: init_rand: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/raidz_test/raidz_test.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cmd/raidz_test/raidz_test.c b/cmd/raidz_test/raidz_test.c index c1610a8d1b0..b177105ee63 100644 --- a/cmd/raidz_test/raidz_test.c +++ b/cmd/raidz_test/raidz_test.c @@ -266,12 +266,8 @@ cmp_data(raidz_test_opts_t *opts, raidz_map_t *rm) static int init_rand(void *data, size_t size, void *private) { - int i; - int *dst = (int *)data; - - for (i = 0; i < size / sizeof (int); i++) - dst[i] = rand_data[i]; - + (void) private; + memcpy(data, rand_data, size); return (0); } From 63b6c3e1d1194abb1031405a9ee5f21953b3e544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 00:56:00 +0100 Subject: [PATCH 028/117] zhack: space_delta_cb: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zhack/zhack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/zhack/zhack.c b/cmd/zhack/zhack.c index bae242712a7..96871d2aab9 100644 --- a/cmd/zhack/zhack.c +++ b/cmd/zhack/zhack.c @@ -107,11 +107,12 @@ fatal(spa_t *spa, void *tag, const char *fmt, ...) exit(1); } -/* ARGSUSED */ static int space_delta_cb(dmu_object_type_t bonustype, const void *data, zfs_file_info_t *zoi) { + (void) data, (void) zoi; + /* * Is it a valid type of object to track? */ From 964e6a497b8e6ebcb8b067ea9f8633a4583cefe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 00:56:59 +0100 Subject: [PATCH 029/117] zinject: cancel_one_handler: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zinject/zinject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zinject/zinject.c b/cmd/zinject/zinject.c index bf97b0d6871..10d5dbe9004 100644 --- a/cmd/zinject/zinject.c +++ b/cmd/zinject/zinject.c @@ -497,11 +497,11 @@ print_all_handlers(void) return (count + total); } -/* ARGSUSED */ static int cancel_one_handler(int id, const char *pool, zinject_record_t *record, void *data) { + (void) pool, (void) record, (void) data; zfs_cmd_t zc = {"\0"}; zc.zc_guid = (uint64_t)id; From b487738d34f0f6550abbbac7033635887d0285f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:05:01 +0100 Subject: [PATCH 030/117] zpool: iter: zpool_compare: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zpool/zpool_iter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zpool/zpool_iter.c b/cmd/zpool/zpool_iter.c index 8cf6bab42ff..65e53f8e0e2 100644 --- a/cmd/zpool/zpool_iter.c +++ b/cmd/zpool/zpool_iter.c @@ -63,10 +63,10 @@ struct zpool_list { zfs_type_t zl_type; }; -/* ARGSUSED */ static int zpool_compare(const void *larg, const void *rarg, void *unused) { + (void) unused; zpool_handle_t *l = ((zpool_node_t *)larg)->zn_handle; zpool_handle_t *r = ((zpool_node_t *)rarg)->zn_handle; const char *lname = zpool_get_name(l); From e40ca391f8d20ef75039ddcd33a9c833a3fac103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:05:17 +0100 Subject: [PATCH 031/117] zpool: main: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zpool/zpool_main.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index dd5c3f205f7..b8462b3698b 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -906,8 +906,7 @@ add_prop_list(const char *propname, char *propval, nvlist_t **props, * Set a default property pair (name, string-value) in a property nvlist */ static int -add_prop_list_default(const char *propname, char *propval, nvlist_t **props, - boolean_t poolprop) +add_prop_list_default(const char *propname, char *propval, nvlist_t **props) { char *pval; @@ -1501,7 +1500,7 @@ zpool_do_create(int argc, char **argv) ZPOOL_PROP_ALTROOT), optarg, &props, B_TRUE)) goto errout; if (add_prop_list_default(zpool_prop_to_name( - ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE)) + ZPOOL_PROP_CACHEFILE), "none", &props)) goto errout; break; case 'm': @@ -1579,7 +1578,7 @@ zpool_do_create(int argc, char **argv) ZPOOL_PROP_TNAME), optarg, &props, B_TRUE)) goto errout; if (add_prop_list_default(zpool_prop_to_name( - ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE)) + ZPOOL_PROP_CACHEFILE), "none", &props)) goto errout; tname = optarg; break; @@ -3618,7 +3617,7 @@ zpool_do_import(int argc, char **argv) ZPOOL_PROP_ALTROOT), optarg, &props, B_TRUE)) goto error; if (add_prop_list_default(zpool_prop_to_name( - ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE)) + ZPOOL_PROP_CACHEFILE), "none", &props)) goto error; break; case 's': @@ -3627,7 +3626,7 @@ zpool_do_import(int argc, char **argv) case 't': flags |= ZFS_IMPORT_TEMP_NAME; if (add_prop_list_default(zpool_prop_to_name( - ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE)) + ZPOOL_PROP_CACHEFILE), "none", &props)) goto error; break; @@ -4570,11 +4569,8 @@ single_histo_average(uint64_t *histo, unsigned int buckets) } static void -print_iostat_queues(iostat_cbdata_t *cb, nvlist_t *oldnv, - nvlist_t *newnv) +print_iostat_queues(iostat_cbdata_t *cb, nvlist_t *newnv) { - int i; - uint64_t val; const char *names[] = { ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE, ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE, @@ -4604,8 +4600,8 @@ print_iostat_queues(iostat_cbdata_t *cb, nvlist_t *oldnv, else format = ZFS_NICENUM_1024; - for (i = 0; i < ARRAY_SIZE(names); i++) { - val = nva[i].data[0]; + for (int i = 0; i < ARRAY_SIZE(names); i++) { + uint64_t val = nva[i].data[0]; print_one_stat(val, format, column_width, cb->cb_scripted); } @@ -4796,7 +4792,7 @@ print_vdev_stats(zpool_handle_t *zhp, const char *name, nvlist_t *oldnv, if (cb->cb_flags & IOS_LATENCY_M) print_iostat_latency(cb, oldnv, newnv); if (cb->cb_flags & IOS_QUEUES_M) - print_iostat_queues(cb, oldnv, newnv); + print_iostat_queues(cb, newnv); if (cb->cb_flags & IOS_ANYHISTO_M) { printf("\n"); print_iostat_histos(cb, oldnv, newnv, scale, name); @@ -6596,7 +6592,6 @@ zpool_do_attach_or_replace(int argc, char **argv, int replacing) * * Replace with . */ -/* ARGSUSED */ int zpool_do_replace(int argc, char **argv) { @@ -6632,7 +6627,6 @@ zpool_do_attach(int argc, char **argv) * is the last device in the mirror, or if the DTLs indicate that this device * has the only valid copy of some data. */ -/* ARGSUSED */ int zpool_do_detach(int argc, char **argv) { @@ -6939,7 +6933,6 @@ zpool_do_online(int argc, char **argv) * -t Only take the device off-line temporarily. The offline/faulted * state will not be persistent across reboots. */ -/* ARGSUSED */ int zpool_do_offline(int argc, char **argv) { @@ -9084,7 +9077,6 @@ upgrade_list_disabled_cb(zpool_handle_t *zhp, void *arg) return (0); } -/* ARGSUSED */ static int upgrade_one(zpool_handle_t *zhp, void *data) { @@ -9849,7 +9841,7 @@ zpool_do_events_next(ev_opts_t *opts) } static int -zpool_do_events_clear(ev_opts_t *opts) +zpool_do_events_clear(void) { int count, ret; @@ -9916,7 +9908,7 @@ zpool_do_events(int argc, char **argv) } if (opts.clear) - ret = zpool_do_events_clear(&opts); + ret = zpool_do_events_clear(); else ret = zpool_do_events_next(&opts); @@ -10854,6 +10846,8 @@ find_command_idx(char *command, int *idx) static int zpool_do_version(int argc, char **argv) { + (void) argc, (void) argv; + if (zfs_version_print() == -1) return (1); From ab860757f59e8a219a9e1d3e5e09c4dcfbeff8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:06:29 +0100 Subject: [PATCH 032/117] zpool: vdev_os: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zpool/os/freebsd/zpool_vdev_os.c | 2 ++ cmd/zpool/os/linux/zpool_vdev_os.c | 1 + 2 files changed, 3 insertions(+) diff --git a/cmd/zpool/os/freebsd/zpool_vdev_os.c b/cmd/zpool/os/freebsd/zpool_vdev_os.c index 66bfe28f13f..8ebd3e60d5d 100644 --- a/cmd/zpool/os/freebsd/zpool_vdev_os.c +++ b/cmd/zpool/os/freebsd/zpool_vdev_os.c @@ -86,6 +86,7 @@ int check_device(const char *name, boolean_t force, boolean_t isspare, boolean_t iswholedisk) { + (void) iswholedisk; char path[MAXPATHLEN]; if (strncmp(name, _PATH_DEV, sizeof (_PATH_DEV) - 1) != 0) @@ -99,6 +100,7 @@ check_device(const char *name, boolean_t force, boolean_t isspare, boolean_t check_sector_size_database(char *path, int *sector_size) { + (void) path, (void) sector_size; return (0); } diff --git a/cmd/zpool/os/linux/zpool_vdev_os.c b/cmd/zpool/os/linux/zpool_vdev_os.c index 10929fa65a1..9d2c21c2a87 100644 --- a/cmd/zpool/os/linux/zpool_vdev_os.c +++ b/cmd/zpool/os/linux/zpool_vdev_os.c @@ -409,6 +409,7 @@ check_device(const char *path, boolean_t force, void after_zpool_upgrade(zpool_handle_t *zhp) { + (void) zhp; } int From 008f30c730f96de378068a4dc0ccfe81795ce622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:07:21 +0100 Subject: [PATCH 033/117] zed: main: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zed/zed.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/zed/zed.c b/cmd/zed/zed.c index e45176c00bf..4a413af6f92 100644 --- a/cmd/zed/zed.c +++ b/cmd/zed/zed.c @@ -36,6 +36,7 @@ static volatile sig_atomic_t _got_hup = 0; static void _exit_handler(int signum) { + (void) signum; _got_exit = 1; } @@ -45,6 +46,7 @@ _exit_handler(int signum) static void _hup_handler(int signum) { + (void) signum; _got_hup = 1; } From e2a59aa7010717f46f0a5c6b98bd6f3a92923733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:07:57 +0100 Subject: [PATCH 034/117] zed: exec: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zed/zed_exec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/zed/zed_exec.c b/cmd/zed/zed_exec.c index 03dcd03aceb..369c4b6950c 100644 --- a/cmd/zed/zed_exec.c +++ b/cmd/zed/zed_exec.c @@ -187,11 +187,14 @@ _zed_exec_fork_child(uint64_t eid, const char *dir, const char *prog, static void _nop(int sig) -{} +{ + (void) sig; +} static void * _reap_children(void *arg) { + (void) arg; struct launched_process_node node, *pnode; pid_t pid; int status; From 16529f305a07ea84470b4ea1a6c05ae61cbbf001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:08:22 +0100 Subject: [PATCH 035/117] zed: agents: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zed/agents/zfs_agents.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/zed/agents/zfs_agents.c b/cmd/zed/agents/zfs_agents.c index 35dd818ff80..2bc84a4f57d 100644 --- a/cmd/zed/agents/zfs_agents.c +++ b/cmd/zed/agents/zfs_agents.c @@ -327,6 +327,8 @@ zfs_agent_dispatch(const char *class, const char *subclass, nvlist_t *nvl) static void * zfs_agent_consumer_thread(void *arg) { + (void) arg; + for (;;) { agent_event_t *event; From e265a082ebbe694643f91c514e0d209d5221e3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:18:01 +0100 Subject: [PATCH 036/117] zed: agents: zfs_diagnosis: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zed/agents/zfs_diagnosis.c | 36 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/cmd/zed/agents/zfs_diagnosis.c b/cmd/zed/agents/zfs_diagnosis.c index 0b27f6702ee..3e45a957f70 100644 --- a/cmd/zed/agents/zfs_diagnosis.c +++ b/cmd/zed/agents/zfs_diagnosis.c @@ -119,7 +119,7 @@ uu_list_t *zfs_cases; * Write out the persistent representation of an active case. */ static void -zfs_case_serialize(fmd_hdl_t *hdl, zfs_case_t *zcp) +zfs_case_serialize(zfs_case_t *zcp) { zcp->zc_data.zc_version = CASE_DATA_VERSION_SERD; } @@ -209,10 +209,10 @@ zfs_mark_vdev(uint64_t pool_guid, nvlist_t *vd, er_timeval_t *loaded) } } -/*ARGSUSED*/ static int zfs_mark_pool(zpool_handle_t *zhp, void *unused) { + (void) unused; zfs_case_t *zcp; uint64_t pool_guid; uint64_t *tod; @@ -373,8 +373,7 @@ zfs_serd_name(char *buf, uint64_t pool_guid, uint64_t vdev_guid, * case. */ static void -zfs_case_solve(fmd_hdl_t *hdl, zfs_case_t *zcp, const char *faultname, - boolean_t checkunusable) +zfs_case_solve(fmd_hdl_t *hdl, zfs_case_t *zcp, const char *faultname) { nvlist_t *detector, *fault; boolean_t serialize; @@ -412,7 +411,7 @@ zfs_case_solve(fmd_hdl_t *hdl, zfs_case_t *zcp, const char *faultname, serialize = B_TRUE; } if (serialize) - zfs_case_serialize(hdl, zcp); + zfs_case_serialize(zcp); nvlist_free(detector); } @@ -424,10 +423,10 @@ timeval_earlier(er_timeval_t *a, er_timeval_t *b) (a->ertv_sec == b->ertv_sec && a->ertv_nsec < b->ertv_nsec)); } -/*ARGSUSED*/ static void zfs_ereport_when(fmd_hdl_t *hdl, nvlist_t *nvl, er_timeval_t *when) { + (void) hdl; int64_t *tod; uint_t nelem; @@ -443,7 +442,6 @@ zfs_ereport_when(fmd_hdl_t *hdl, nvlist_t *nvl, er_timeval_t *when) /* * Main fmd entry point. */ -/*ARGSUSED*/ static void zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) { @@ -686,7 +684,7 @@ zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) if (zcp->zc_data.zc_has_remove_timer) { fmd_timer_remove(hdl, zcp->zc_remove_timer); zcp->zc_data.zc_has_remove_timer = 0; - zfs_case_serialize(hdl, zcp); + zfs_case_serialize(zcp); } if (zcp->zc_data.zc_serd_io[0] != '\0') fmd_serd_reset(hdl, zcp->zc_data.zc_serd_io); @@ -751,18 +749,18 @@ zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) fmd_case_close(hdl, dcp->zc_case); } - zfs_case_solve(hdl, zcp, "fault.fs.zfs.pool", B_TRUE); + zfs_case_solve(hdl, zcp, "fault.fs.zfs.pool"); } else if (fmd_nvl_class_match(hdl, nvl, ZFS_MAKE_EREPORT(FM_EREPORT_ZFS_LOG_REPLAY))) { /* * Pool level fault for reading the intent logs. */ - zfs_case_solve(hdl, zcp, "fault.fs.zfs.log_replay", B_TRUE); + zfs_case_solve(hdl, zcp, "fault.fs.zfs.log_replay"); } else if (fmd_nvl_class_match(hdl, nvl, "ereport.fs.zfs.vdev.*")) { /* * Device fault. */ - zfs_case_solve(hdl, zcp, "fault.fs.zfs.device", B_TRUE); + zfs_case_solve(hdl, zcp, "fault.fs.zfs.device"); } else if (fmd_nvl_class_match(hdl, nvl, ZFS_MAKE_EREPORT(FM_EREPORT_ZFS_IO)) || fmd_nvl_class_match(hdl, nvl, @@ -789,7 +787,7 @@ zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) fmd_serd_create(hdl, zcp->zc_data.zc_serd_io, fmd_prop_get_int32(hdl, "io_N"), fmd_prop_get_int64(hdl, "io_T")); - zfs_case_serialize(hdl, zcp); + zfs_case_serialize(zcp); } if (fmd_serd_record(hdl, zcp->zc_data.zc_serd_io, ep)) checkremove = B_TRUE; @@ -802,12 +800,12 @@ zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) zcp->zc_data.zc_serd_checksum, fmd_prop_get_int32(hdl, "checksum_N"), fmd_prop_get_int64(hdl, "checksum_T")); - zfs_case_serialize(hdl, zcp); + zfs_case_serialize(zcp); } if (fmd_serd_record(hdl, zcp->zc_data.zc_serd_checksum, ep)) { zfs_case_solve(hdl, zcp, - "fault.fs.zfs.vdev.checksum", B_FALSE); + "fault.fs.zfs.vdev.checksum"); } } else if (fmd_nvl_class_match(hdl, nvl, ZFS_MAKE_EREPORT(FM_EREPORT_ZFS_IO_FAILURE)) && @@ -817,12 +815,11 @@ zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) if (strncmp(failmode, FM_EREPORT_FAILMODE_CONTINUE, strlen(FM_EREPORT_FAILMODE_CONTINUE)) == 0) { zfs_case_solve(hdl, zcp, - "fault.fs.zfs.io_failure_continue", - B_FALSE); + "fault.fs.zfs.io_failure_continue"); } else if (strncmp(failmode, FM_EREPORT_FAILMODE_WAIT, strlen(FM_EREPORT_FAILMODE_WAIT)) == 0) { zfs_case_solve(hdl, zcp, - "fault.fs.zfs.io_failure_wait", B_FALSE); + "fault.fs.zfs.io_failure_wait"); } } else if (fmd_nvl_class_match(hdl, nvl, ZFS_MAKE_EREPORT(FM_EREPORT_ZFS_PROBE_FAILURE))) { @@ -844,7 +841,7 @@ zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) zfs_remove_timeout); if (!zcp->zc_data.zc_has_remove_timer) { zcp->zc_data.zc_has_remove_timer = 1; - zfs_case_serialize(hdl, zcp); + zfs_case_serialize(zcp); } } } @@ -854,14 +851,13 @@ zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) * The timeout is fired when we diagnosed an I/O error, and it was not due to * device removal (which would cause the timeout to be cancelled). */ -/* ARGSUSED */ static void zfs_fm_timeout(fmd_hdl_t *hdl, id_t id, void *data) { zfs_case_t *zcp = data; if (id == zcp->zc_remove_timer) - zfs_case_solve(hdl, zcp, "fault.fs.zfs.vdev.io", B_FALSE); + zfs_case_solve(hdl, zcp, "fault.fs.zfs.vdev.io"); } /* From 491165c079adc1f8e6970fda7968da09d4f4841b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:20:55 +0100 Subject: [PATCH 037/117] zed: agents: zfs_mod: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zed/agents/zfs_mod.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/zed/agents/zfs_mod.c b/cmd/zed/agents/zfs_mod.c index b496b29ac13..c62a976c2e3 100644 --- a/cmd/zed/agents/zfs_mod.c +++ b/cmd/zed/agents/zfs_mod.c @@ -681,7 +681,7 @@ guid_iter(uint64_t pool_guid, uint64_t vdev_guid, const char *devid, * phys_path: 'pci-0000:04:00.0-sas-0x4433221106000000-lun-0' */ static int -zfs_deliver_add(nvlist_t *nvl, boolean_t is_lofi) +zfs_deliver_add(nvlist_t *nvl) { char *devpath = NULL, *devid; uint64_t pool_guid = 0, vdev_guid = 0; @@ -866,18 +866,15 @@ static int zfs_slm_deliver_event(const char *class, const char *subclass, nvlist_t *nvl) { int ret; - boolean_t is_lofi = B_FALSE, is_check = B_FALSE, is_dle = B_FALSE; + boolean_t is_check = B_FALSE, is_dle = B_FALSE; if (strcmp(class, EC_DEV_ADD) == 0) { /* * We're mainly interested in disk additions, but we also listen * for new loop devices, to allow for simplified testing. */ - if (strcmp(subclass, ESC_DISK) == 0) - is_lofi = B_FALSE; - else if (strcmp(subclass, ESC_LOFI) == 0) - is_lofi = B_TRUE; - else + if (strcmp(subclass, ESC_DISK) != 0 && + strcmp(subclass, ESC_LOFI) != 0) return (0); is_check = B_FALSE; @@ -901,15 +898,16 @@ zfs_slm_deliver_event(const char *class, const char *subclass, nvlist_t *nvl) else if (is_check) ret = zfs_deliver_check(nvl); else - ret = zfs_deliver_add(nvl, is_lofi); + ret = zfs_deliver_add(nvl); return (ret); } -/*ARGSUSED*/ static void * zfs_enum_pools(void *arg) { + (void) arg; + (void) zpool_iter(g_zfshdl, zfs_unavail_pool, (void *)&g_pool_list); /* * Linux - instead of using a thread pool, each list entry From d6fccfe62ed338aef3a4c906b1cddaf3e501290e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:21:46 +0100 Subject: [PATCH 038/117] zed: agents: zfs_retire: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zed/agents/zfs_retire.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/zed/agents/zfs_retire.c b/cmd/zed/agents/zfs_retire.c index 5fb7b4e84c5..8f12bb82e1e 100644 --- a/cmd/zed/agents/zfs_retire.c +++ b/cmd/zed/agents/zfs_retire.c @@ -263,7 +263,6 @@ replace_with_spare(fmd_hdl_t *hdl, zpool_handle_t *zhp, nvlist_t *vdev) * ASRU is now usable. ZFS has found the device to be present and * functioning. */ -/*ARGSUSED*/ static void zfs_vdev_repair(fmd_hdl_t *hdl, nvlist_t *nvl) { @@ -302,11 +301,11 @@ zfs_vdev_repair(fmd_hdl_t *hdl, nvlist_t *nvl) vdev_guid, pool_guid); } -/*ARGSUSED*/ static void zfs_retire_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) { + (void) ep; uint64_t pool_guid, vdev_guid; zpool_handle_t *zhp; nvlist_t *resource, *fault; From 724e6c68e5702f632803eb0d9e691e583bb1da52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:26:20 +0100 Subject: [PATCH 039/117] zed: agents: fmd_api: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zed/agents/fmd_api.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/cmd/zed/agents/fmd_api.c b/cmd/zed/agents/fmd_api.c index c9231fba2ae..4095901dff0 100644 --- a/cmd/zed/agents/fmd_api.c +++ b/cmd/zed/agents/fmd_api.c @@ -97,6 +97,7 @@ _umem_logging_init(void) int fmd_hdl_register(fmd_hdl_t *hdl, int version, const fmd_hdl_info_t *mip) { + (void) version; fmd_module_t *mp = (fmd_module_t *)hdl; mp->mod_info = mip; @@ -179,18 +180,21 @@ fmd_hdl_getspecific(fmd_hdl_t *hdl) void * fmd_hdl_alloc(fmd_hdl_t *hdl, size_t size, int flags) { + (void) hdl; return (umem_alloc(size, flags)); } void * fmd_hdl_zalloc(fmd_hdl_t *hdl, size_t size, int flags) { + (void) hdl; return (umem_zalloc(size, flags)); } void fmd_hdl_free(fmd_hdl_t *hdl, void *data, size_t size) { + (void) hdl; umem_free(data, size); } @@ -217,6 +221,8 @@ fmd_hdl_debug(fmd_hdl_t *hdl, const char *format, ...) int32_t fmd_prop_get_int32(fmd_hdl_t *hdl, const char *name) { + (void) hdl; + /* * These can be looked up in mp->modinfo->fmdi_props * For now we just hard code for phase 2. In the @@ -234,6 +240,8 @@ fmd_prop_get_int32(fmd_hdl_t *hdl, const char *name) int64_t fmd_prop_get_int64(fmd_hdl_t *hdl, const char *name) { + (void) hdl; + /* * These can be looked up in mp->modinfo->fmdi_props * For now we just hard code for phase 2. In the @@ -337,12 +345,14 @@ fmd_case_uuresolved(fmd_hdl_t *hdl, const char *uuid) int fmd_case_solved(fmd_hdl_t *hdl, fmd_case_t *cp) { + (void) hdl; return ((cp->ci_state >= FMD_CASE_SOLVED) ? FMD_B_TRUE : FMD_B_FALSE); } void fmd_case_add_ereport(fmd_hdl_t *hdl, fmd_case_t *cp, fmd_event_t *ep) { + (void) hdl, (void) cp, (void) ep; } static void @@ -444,19 +454,21 @@ fmd_case_add_suspect(fmd_hdl_t *hdl, fmd_case_t *cp, nvlist_t *fault) void fmd_case_setspecific(fmd_hdl_t *hdl, fmd_case_t *cp, void *data) { + (void) hdl; cp->ci_data = data; } void * fmd_case_getspecific(fmd_hdl_t *hdl, fmd_case_t *cp) { + (void) hdl; return (cp->ci_data); } void fmd_buf_create(fmd_hdl_t *hdl, fmd_case_t *cp, const char *name, size_t size) { - assert(strcmp(name, "data") == 0); + assert(strcmp(name, "data") == 0), (void) name; assert(cp->ci_bufptr == NULL); assert(size < (1024 * 1024)); @@ -468,7 +480,8 @@ void fmd_buf_read(fmd_hdl_t *hdl, fmd_case_t *cp, const char *name, void *buf, size_t size) { - assert(strcmp(name, "data") == 0); + (void) hdl; + assert(strcmp(name, "data") == 0), (void) name; assert(cp->ci_bufptr != NULL); assert(size <= cp->ci_bufsiz); @@ -479,7 +492,8 @@ void fmd_buf_write(fmd_hdl_t *hdl, fmd_case_t *cp, const char *name, const void *buf, size_t size) { - assert(strcmp(name, "data") == 0); + (void) hdl; + assert(strcmp(name, "data") == 0), (void) name; assert(cp->ci_bufptr != NULL); assert(cp->ci_bufsiz >= size); @@ -583,6 +597,7 @@ _timer_notify(union sigval sv) fmd_timer_t * fmd_timer_install(fmd_hdl_t *hdl, void *arg, fmd_event_t *ep, hrtime_t delta) { + (void) ep; struct sigevent sev; struct itimerspec its; fmd_timer_t *ftp; @@ -626,6 +641,7 @@ nvlist_t * fmd_nvl_create_fault(fmd_hdl_t *hdl, const char *class, uint8_t certainty, nvlist_t *asru, nvlist_t *fru, nvlist_t *resource) { + (void) hdl; nvlist_t *nvl; int err = 0; @@ -689,6 +705,7 @@ fmd_strmatch(const char *s, const char *p) int fmd_nvl_class_match(fmd_hdl_t *hdl, nvlist_t *nvl, const char *pattern) { + (void) hdl; char *class; return (nvl != NULL && @@ -699,6 +716,7 @@ fmd_nvl_class_match(fmd_hdl_t *hdl, nvlist_t *nvl, const char *pattern) nvlist_t * fmd_nvl_alloc(fmd_hdl_t *hdl, int flags) { + (void) hdl, (void) flags; nvlist_t *nvl = NULL; if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) From 6fa118b8570ee223921e4bd5baac82bf5480e998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:37:25 +0100 Subject: [PATCH 040/117] zdb: main: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zdb/zdb.c | 60 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 8fe926c50e8..2d64ce6ef1f 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -383,10 +383,10 @@ livelist_verify(dsl_deadlist_t *dl, void *arg) * Check for errors in the livelist entry and discard the intermediary * data structures */ -/* ARGSUSED */ static int sublivelist_verify_lightweight(void *args, dsl_deadlist_entry_t *dle) { + (void) args; sublivelist_verify_t sv; zfs_btree_create(&sv.sv_leftover, livelist_block_compare, sizeof (sublivelist_verify_block_t)); @@ -916,10 +916,10 @@ fatal(const char *fmt, ...) exit(1); } -/* ARGSUSED */ static void dump_packed_nvlist(objset_t *os, uint64_t object, void *data, size_t size) { + (void) size; nvlist_t *nv; size_t nvsize = *(uint64_t *)data; char *packed = umem_alloc(nvsize, UMEM_NOFAIL); @@ -935,10 +935,10 @@ dump_packed_nvlist(objset_t *os, uint64_t object, void *data, size_t size) nvlist_free(nv); } -/* ARGSUSED */ static void dump_history_offsets(objset_t *os, uint64_t object, void *data, size_t size) { + (void) os, (void) object, (void) size; spa_history_phys_t *shp = data; if (shp == NULL) @@ -1058,26 +1058,25 @@ dump_zap_stats(objset_t *os, uint64_t object) dump_histogram(zs.zs_buckets_with_n_entries, ZAP_HISTOGRAM_SIZE, 0); } -/*ARGSUSED*/ static void dump_none(objset_t *os, uint64_t object, void *data, size_t size) { + (void) os, (void) object, (void) data, (void) size; } -/*ARGSUSED*/ static void dump_unknown(objset_t *os, uint64_t object, void *data, size_t size) { + (void) os, (void) object, (void) data, (void) size; (void) printf("\tUNKNOWN OBJECT TYPE\n"); } -/*ARGSUSED*/ static void dump_uint8(objset_t *os, uint64_t object, void *data, size_t size) { + (void) os, (void) object, (void) data, (void) size; } -/*ARGSUSED*/ static void dump_uint64(objset_t *os, uint64_t object, void *data, size_t size) { @@ -1134,10 +1133,10 @@ dump_uint64(objset_t *os, uint64_t object, void *data, size_t size) kmem_free(arr, oursize); } -/*ARGSUSED*/ static void dump_zap(objset_t *os, uint64_t object, void *data, size_t size) { + (void) data, (void) size; zap_cursor_t zc; zap_attribute_t attr; void *prop; @@ -1254,10 +1253,10 @@ dump_bpobj(objset_t *os, uint64_t object, void *data, size_t size) } } -/* ARGSUSED */ static void dump_bpobj_subobjs(objset_t *os, uint64_t object, void *data, size_t size) { + (void) data, (void) size; dmu_object_info_t doi; int64_t i; @@ -1283,18 +1282,18 @@ dump_bpobj_subobjs(objset_t *os, uint64_t object, void *data, size_t size) kmem_free(subobjs, doi.doi_max_offset); } -/*ARGSUSED*/ static void dump_ddt_zap(objset_t *os, uint64_t object, void *data, size_t size) { + (void) data, (void) size; dump_zap_stats(os, object); /* contents are printed elsewhere, properly decoded */ } -/*ARGSUSED*/ static void dump_sa_attrs(objset_t *os, uint64_t object, void *data, size_t size) { + (void) data, (void) size; zap_cursor_t zc; zap_attribute_t attr; @@ -1318,10 +1317,10 @@ dump_sa_attrs(objset_t *os, uint64_t object, void *data, size_t size) zap_cursor_fini(&zc); } -/*ARGSUSED*/ static void dump_sa_layouts(objset_t *os, uint64_t object, void *data, size_t size) { + (void) data, (void) size; zap_cursor_t zc; zap_attribute_t attr; uint16_t *layout_attrs; @@ -1356,10 +1355,10 @@ dump_sa_layouts(objset_t *os, uint64_t object, void *data, size_t size) zap_cursor_fini(&zc); } -/*ARGSUSED*/ static void dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size) { + (void) data, (void) size; zap_cursor_t zc; zap_attribute_t attr; const char *typenames[] = { @@ -2215,10 +2214,10 @@ next: free(buf); } -/*ARGSUSED*/ static void dump_dnode(objset_t *os, uint64_t object, void *data, size_t size) { + (void) os, (void) object, (void) data, (void) size; } static uint64_t @@ -2440,19 +2439,17 @@ visit_indirect(spa_t *spa, const dnode_phys_t *dnp, return (err); } -/*ARGSUSED*/ static void dump_indirect(dnode_t *dn) { dnode_phys_t *dnp = dn->dn_phys; - int j; zbookmark_phys_t czb; (void) printf("Indirect blocks:\n"); SET_BOOKMARK(&czb, dmu_objset_id(dn->dn_objset), dn->dn_object, dnp->dn_nlevels - 1, 0); - for (j = 0; j < dnp->dn_nblkptr; j++) { + for (int j = 0; j < dnp->dn_nblkptr; j++) { czb.zb_blkid = j; (void) visit_indirect(dmu_objset_spa(dn->dn_objset), dnp, &dnp->dn_blkptr[j], &czb); @@ -2461,10 +2458,10 @@ dump_indirect(dnode_t *dn) (void) printf("\n"); } -/*ARGSUSED*/ static void dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size) { + (void) os, (void) object; dsl_dir_phys_t *dd = data; time_t crtime; char nice[32]; @@ -2518,10 +2515,10 @@ dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size) (u_longlong_t)dd->dd_clones); } -/*ARGSUSED*/ static void dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size) { + (void) os, (void) object; dsl_dataset_phys_t *ds = data; time_t crtime; char used[32], compressed[32], uncompressed[32], unique[32]; @@ -2581,10 +2578,10 @@ dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size) (void) printf("\t\tbp = %s\n", blkbuf); } -/* ARGSUSED */ static int dump_bptree_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx) { + (void) arg, (void) tx; char blkbuf[BP_SPRINTF_LEN]; if (bp->blk_birth != 0) { @@ -2622,10 +2619,10 @@ dump_bptree(objset_t *os, uint64_t obj, const char *name) (void) bptree_iterate(os, obj, B_FALSE, dump_bptree_cb, NULL, NULL); } -/* ARGSUSED */ static int dump_bpobj_cb(void *arg, const blkptr_t *bp, boolean_t bp_freed, dmu_tx_t *tx) { + (void) arg, (void) tx; char blkbuf[BP_SPRINTF_LEN]; ASSERT(bp->blk_birth != 0); @@ -3187,10 +3184,10 @@ dump_znode_symlink(sa_handle_t *hdl) (void) printf("\ttarget %s\n", linktarget); } -/*ARGSUSED*/ static void dump_znode(objset_t *os, uint64_t object, void *data, size_t size) { + (void) data, (void) size; char path[MAXPATHLEN * 2]; /* allow for xattr and failure prefix */ sa_handle_t *hdl; uint64_t xattr, rdev, gen; @@ -3282,16 +3279,16 @@ dump_znode(objset_t *os, uint64_t object, void *data, size_t size) sa_handle_destroy(hdl); } -/*ARGSUSED*/ static void dump_acl(objset_t *os, uint64_t object, void *data, size_t size) { + (void) os, (void) object, (void) data, (void) size; } -/*ARGSUSED*/ static void dump_dmu_objset(objset_t *os, uint64_t object, void *data, size_t size) { + (void) os, (void) object, (void) data, (void) size; } static object_viewer_t *object_viewer[DMU_OT_NUMTYPES + 1] = { @@ -4985,10 +4982,10 @@ static uint64_t dataset_feature_count[SPA_FEATURES]; static uint64_t global_feature_count[SPA_FEATURES]; static uint64_t remap_deadlist_count = 0; -/*ARGSUSED*/ static int dump_one_objset(const char *dsname, void *arg) { + (void) arg; int error; objset_t *os; spa_feature_t f; @@ -5553,7 +5550,6 @@ static metaslab_ops_t zdb_metaslab_ops = { NULL /* alloc */ }; -/* ARGSUSED */ static int load_unflushed_svr_segs_cb(spa_t *spa, space_map_entry_t *sme, uint64_t txg, void *arg) @@ -5582,11 +5578,12 @@ load_unflushed_svr_segs_cb(spa_t *spa, space_map_entry_t *sme, return (0); } -/* ARGSUSED */ static void claim_segment_impl_cb(uint64_t inner_offset, vdev_t *vd, uint64_t offset, uint64_t size, void *arg) { + (void) inner_offset, (void) arg; + /* * This callback was called through a remap from * a device being removed. Therefore, the vdev that @@ -5660,11 +5657,11 @@ zdb_claim_removing(spa_t *spa, zdb_cb_t *zcb) spa_config_exit(spa, SCL_CONFIG, FTAG); } -/* ARGSUSED */ static int increment_indirect_mapping_cb(void *arg, const blkptr_t *bp, boolean_t bp_freed, dmu_tx_t *tx) { + (void) tx; zdb_cb_t *zcb = arg; spa_t *spa = zcb->zcb_spa; vdev_t *vd; @@ -6276,10 +6273,10 @@ zdb_leak_fini(spa_t *spa, zdb_cb_t *zcb) return (leaks); } -/* ARGSUSED */ static int count_block_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx) { + (void) tx; zdb_cb_t *zcb = arg; if (dump_opt['b'] >= 5) { @@ -6736,11 +6733,11 @@ typedef struct zdb_ddt_entry { avl_node_t zdde_node; } zdb_ddt_entry_t; -/* ARGSUSED */ static int zdb_ddt_add_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, const zbookmark_phys_t *zb, const dnode_phys_t *dnp, void *arg) { + (void) zilog, (void) dnp; avl_tree_t *t = arg; avl_index_t where; zdb_ddt_entry_t *zdde, zdde_search; @@ -7363,10 +7360,10 @@ verify_checkpoint(spa_t *spa) return (error); } -/* ARGSUSED */ static void mos_leaks_cb(void *arg, uint64_t start, uint64_t size) { + (void) arg; for (uint64_t i = start; i < size; i++) { (void) printf("MOS object %llu referenced but not allocated\n", (u_longlong_t)i); @@ -7967,6 +7964,7 @@ static boolean_t zdb_decompress_block(abd_t *pabd, void *buf, void *lbuf, uint64_t lsize, uint64_t psize, int flags) { + (void) buf; boolean_t exceeded = B_FALSE; /* * We don't know how the data was compressed, so just try From 058cd62432cc1d128e9935908cc2af3b802b3214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:40:42 +0100 Subject: [PATCH 041/117] zdb: il: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zdb/zdb_il.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/cmd/zdb/zdb_il.c b/cmd/zdb/zdb_il.c index 553765b7171..d6f588d8316 100644 --- a/cmd/zdb/zdb_il.c +++ b/cmd/zdb/zdb_il.c @@ -60,10 +60,10 @@ print_log_bp(const blkptr_t *bp, const char *prefix) (void) printf("%s%s\n", prefix, blkbuf); } -/* ARGSUSED */ static void zil_prt_rec_create(zilog_t *zilog, int txtype, const void *arg) { + (void) zilog; const lr_create_t *lr = arg; time_t crtime = lr->lr_crtime[0]; char *name, *link; @@ -96,20 +96,20 @@ zil_prt_rec_create(zilog_t *zilog, int txtype, const void *arg) (u_longlong_t)lr->lr_gen, (u_longlong_t)lr->lr_rdev); } -/* ARGSUSED */ static void zil_prt_rec_remove(zilog_t *zilog, int txtype, const void *arg) { + (void) zilog, (void) txtype; const lr_remove_t *lr = arg; (void) printf("%sdoid %llu, name %s\n", tab_prefix, (u_longlong_t)lr->lr_doid, (char *)(lr + 1)); } -/* ARGSUSED */ static void zil_prt_rec_link(zilog_t *zilog, int txtype, const void *arg) { + (void) zilog, (void) txtype; const lr_link_t *lr = arg; (void) printf("%sdoid %llu, link_obj %llu, name %s\n", tab_prefix, @@ -117,10 +117,10 @@ zil_prt_rec_link(zilog_t *zilog, int txtype, const void *arg) (char *)(lr + 1)); } -/* ARGSUSED */ static void zil_prt_rec_rename(zilog_t *zilog, int txtype, const void *arg) { + (void) zilog, (void) txtype; const lr_rename_t *lr = arg; char *snm = (char *)(lr + 1); char *tnm = snm + strlen(snm) + 1; @@ -130,10 +130,10 @@ zil_prt_rec_rename(zilog_t *zilog, int txtype, const void *arg) (void) printf("%ssrc %s tgt %s\n", tab_prefix, snm, tnm); } -/* ARGSUSED */ static int zil_prt_rec_write_cb(void *data, size_t len, void *unused) { + (void) unused; char *cdata = data; for (size_t i = 0; i < len; i++) { @@ -146,7 +146,6 @@ zil_prt_rec_write_cb(void *data, size_t len, void *unused) return (0); } -/* ARGSUSED */ static void zil_prt_rec_write(zilog_t *zilog, int txtype, const void *arg) { @@ -209,10 +208,10 @@ out: abd_free(data); } -/* ARGSUSED */ static void zil_prt_rec_truncate(zilog_t *zilog, int txtype, const void *arg) { + (void) zilog, (void) txtype; const lr_truncate_t *lr = arg; (void) printf("%sfoid %llu, offset 0x%llx, length 0x%llx\n", tab_prefix, @@ -220,10 +219,10 @@ zil_prt_rec_truncate(zilog_t *zilog, int txtype, const void *arg) (u_longlong_t)lr->lr_length); } -/* ARGSUSED */ static void zil_prt_rec_setattr(zilog_t *zilog, int txtype, const void *arg) { + (void) zilog, (void) txtype; const lr_setattr_t *lr = arg; time_t atime = (time_t)lr->lr_atime[0]; time_t mtime = (time_t)lr->lr_mtime[0]; @@ -266,10 +265,10 @@ zil_prt_rec_setattr(zilog_t *zilog, int txtype, const void *arg) } } -/* ARGSUSED */ static void zil_prt_rec_acl(zilog_t *zilog, int txtype, const void *arg) { + (void) zilog, (void) txtype; const lr_acl_t *lr = arg; (void) printf("%sfoid %llu, aclcnt %llu\n", tab_prefix, @@ -307,10 +306,10 @@ static zil_rec_info_t zil_rec_info[TX_MAX_TYPE] = { {.zri_print = zil_prt_rec_write, .zri_name = "TX_WRITE2 "}, }; -/* ARGSUSED */ static int print_log_record(zilog_t *zilog, const lr_t *lr, void *arg, uint64_t claim_txg) { + (void) arg, (void) claim_txg; int txtype; int verbose = MAX(dump_opt['d'], dump_opt['i']); @@ -341,11 +340,11 @@ print_log_record(zilog_t *zilog, const lr_t *lr, void *arg, uint64_t claim_txg) return (0); } -/* ARGSUSED */ static int print_log_block(zilog_t *zilog, const blkptr_t *bp, void *arg, uint64_t claim_txg) { + (void) arg; char blkbuf[BP_SPRINTF_LEN + 10]; int verbose = MAX(dump_opt['d'], dump_opt['i']); const char *claim; @@ -396,7 +395,6 @@ print_log_stats(int verbose) (void) printf("\n"); } -/* ARGSUSED */ void dump_intent_log(zilog_t *zilog) { From d8f32c0eb7cc91b3a7e099612cb729a9b7e4a247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 01:57:41 +0100 Subject: [PATCH 042/117] ztest: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/ztest/ztest.c | 74 +++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index a2568962d87..a99f60964ae 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -1189,10 +1189,10 @@ ztest_kill(ztest_shared_t *zs) (void) kill(getpid(), SIGKILL); } -/* ARGSUSED */ static void ztest_record_enospc(const char *s) { + (void) s; ztest_shared->zs_enospc_count++; } @@ -2389,10 +2389,10 @@ zil_replay_func_t *ztest_replay_vector[TX_MAX_TYPE] = { * ZIL get_data callbacks */ -/* ARGSUSED */ static void ztest_get_done(zgd_t *zgd, int error) { + (void) error; ztest_ds_t *zd = zgd->zgd_private; uint64_t object = ((rl_t *)zgd->zgd_lr)->rl_object; @@ -2409,6 +2409,7 @@ static int ztest_get_data(void *arg, uint64_t arg2, lr_write_t *lr, char *buf, struct lwb *lwb, zio_t *zio) { + (void) arg2; ztest_ds_t *zd = arg; objset_t *os = zd->zd_os; uint64_t object = lr->lr_foid; @@ -2869,10 +2870,10 @@ ztest_object_init(ztest_ds_t *zd, ztest_od_t *od, size_t size, boolean_t remove) return (rv); } -/* ARGSUSED */ void ztest_zil_commit(ztest_ds_t *zd, uint64_t id) { + (void) id; zilog_t *zilog = zd->zd_zilog; (void) pthread_rwlock_rdlock(&zd->zd_zilog_lock); @@ -2898,10 +2899,10 @@ ztest_zil_commit(ztest_ds_t *zd, uint64_t id) * mount/unmount operation. We hold the dataset across these operations in an * attempt to expose any implicit assumptions about ZIL management. */ -/* ARGSUSED */ void ztest_zil_remount(ztest_ds_t *zd, uint64_t id) { + (void) id; objset_t *os = zd->zd_os; /* @@ -2935,10 +2936,10 @@ ztest_zil_remount(ztest_ds_t *zd, uint64_t id) * Verify that we can't destroy an active pool, create an existing pool, * or create a pool with a bad vdev spec. */ -/* ARGSUSED */ void ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; ztest_shared_opts_t *zo = &ztest_opts; spa_t *spa; nvlist_t *nvroot; @@ -2998,10 +2999,10 @@ ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id) * Start and then stop the MMP threads to ensure the startup and shutdown code * works properly. Actual protection and property-related code tested via ZTS. */ -/* ARGSUSED */ void ztest_mmp_enable_disable(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; ztest_shared_opts_t *zo = &ztest_opts; spa_t *spa = ztest_spa; @@ -3044,10 +3045,10 @@ ztest_mmp_enable_disable(ztest_ds_t *zd, uint64_t id) spa_config_exit(spa, SCL_CONFIG, FTAG); } -/* ARGSUSED */ void ztest_spa_upgrade(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; spa_t *spa; uint64_t initial_version = SPA_VERSION_INITIAL; uint64_t version, newversion; @@ -3164,10 +3165,10 @@ ztest_spa_discard_checkpoint(spa_t *spa) } -/* ARGSUSED */ void ztest_spa_checkpoint_create_discard(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; spa_t *spa = ztest_spa; mutex_enter(&ztest_checkpoint_lock); @@ -3208,10 +3209,10 @@ spa_num_top_vdevs(spa_t *spa) /* * Verify that vdev_add() works as expected. */ -/* ARGSUSED */ void ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; ztest_shared_t *zs = ztest_shared; spa_t *spa = ztest_spa; uint64_t leaves; @@ -3298,10 +3299,10 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id) mutex_exit(&ztest_vdev_lock); } -/* ARGSUSED */ void ztest_vdev_class_add(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; ztest_shared_t *zs = ztest_shared; spa_t *spa = ztest_spa; uint64_t leaves; @@ -3379,10 +3380,10 @@ ztest_vdev_class_add(ztest_ds_t *zd, uint64_t id) /* * Verify that adding/removing aux devices (l2arc, hot spare) works as expected. */ -/* ARGSUSED */ void ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; ztest_shared_t *zs = ztest_shared; spa_t *spa = ztest_spa; vdev_t *rvd = spa->spa_root_vdev; @@ -3491,10 +3492,10 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id) /* * split a pool if it has mirror tlvdevs */ -/* ARGSUSED */ void ztest_split_pool(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; ztest_shared_t *zs = ztest_shared; spa_t *spa = ztest_spa; vdev_t *rvd = spa->spa_root_vdev; @@ -3586,10 +3587,10 @@ ztest_split_pool(ztest_ds_t *zd, uint64_t id) /* * Verify that we can attach and detach devices. */ -/* ARGSUSED */ void ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; ztest_shared_t *zs = ztest_shared; spa_t *spa = ztest_spa; spa_aux_vdev_t *sav = &spa->spa_spares; @@ -3829,10 +3830,10 @@ out: umem_free(newpath, MAXPATHLEN); } -/* ARGSUSED */ void ztest_device_removal(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; spa_t *spa = ztest_spa; vdev_t *vd; uint64_t guid; @@ -3922,10 +3923,10 @@ grow_vdev(vdev_t *vd, void *arg) /* * Callback function which expands a given vdev by calling vdev_online(). */ -/* ARGSUSED */ static vdev_t * online_vdev(vdev_t *vd, void *arg) { + (void) arg; spa_t *spa = vd->vdev_spa; vdev_t *tvd = vd->vdev_top; uint64_t guid = vd->vdev_guid; @@ -4006,10 +4007,10 @@ vdev_walk_tree(vdev_t *vd, vdev_t *(*func)(vdev_t *, void *), void *arg) /* * Verify that dynamic LUN growth works as expected. */ -/* ARGSUSED */ void ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; spa_t *spa = ztest_spa; vdev_t *vd, *tvd; metaslab_class_t *mc; @@ -4161,10 +4162,11 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) /* * Verify that dmu_objset_{create,destroy,open,close} work as expected. */ -/* ARGSUSED */ static void ztest_objset_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx) { + (void) arg, (void) cr; + /* * Create the objects common to all ztest datasets. */ @@ -4241,10 +4243,10 @@ ztest_dataset_create(char *dsname) ZFS_SYNC_ALWAYS, B_FALSE)); } -/* ARGSUSED */ static int ztest_objset_destroy_cb(const char *name, void *arg) { + (void) arg; objset_t *os; dmu_object_info_t doi; int error; @@ -4317,10 +4319,10 @@ ztest_snapshot_destroy(char *osname, uint64_t id) return (B_TRUE); } -/* ARGSUSED */ void ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id) { + (void) zd; ztest_ds_t *zdtmp; int iters; int error; @@ -4642,6 +4644,7 @@ ztest_dmu_object_alloc_free(ztest_ds_t *zd, uint64_t id) void ztest_dmu_object_next_chunk(ztest_ds_t *zd, uint64_t id) { + (void) id; objset_t *os = zd->zd_os; int dnodes_per_chunk = 1 << dmu_object_alloc_chunk_shift; uint64_t object; @@ -5188,10 +5191,10 @@ ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id) umem_free(od, size); } -/* ARGSUSED */ void ztest_dmu_write_parallel(ztest_ds_t *zd, uint64_t id) { + (void) id; ztest_od_t *od; od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL); @@ -5450,10 +5453,10 @@ out: umem_free(od, sizeof (ztest_od_t)); } -/* ARGSUSED */ void ztest_zap_parallel(ztest_ds_t *zd, uint64_t id) { + (void) id; objset_t *os = zd->zd_os; ztest_od_t *od; uint64_t txg, object, count, wsize, wc, zl_wsize, zl_wc; @@ -5785,10 +5788,10 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id) * are consistent what was stored in the block tag when it was created, * and that its unused bonus buffer space has not been overwritten. */ -/* ARGSUSED */ void ztest_verify_dnode_bt(ztest_ds_t *zd, uint64_t id) { + (void) id; objset_t *os = zd->zd_os; uint64_t obj; int err = 0; @@ -5820,21 +5823,20 @@ ztest_verify_dnode_bt(ztest_ds_t *zd, uint64_t id) } } -/* ARGSUSED */ void ztest_dsl_prop_get_set(ztest_ds_t *zd, uint64_t id) { + (void) id; zfs_prop_t proplist[] = { ZFS_PROP_CHECKSUM, ZFS_PROP_COMPRESSION, ZFS_PROP_COPIES, ZFS_PROP_DEDUP }; - int p; (void) pthread_rwlock_rdlock(&ztest_name_lock); - for (p = 0; p < sizeof (proplist) / sizeof (proplist[0]); p++) + for (int p = 0; p < sizeof (proplist) / sizeof (proplist[0]); p++) (void) ztest_dsl_prop_set_uint64(zd->zd_name, proplist[p], ztest_random_dsl_prop(proplist[p]), (int)ztest_random(2)); @@ -5844,10 +5846,10 @@ ztest_dsl_prop_get_set(ztest_ds_t *zd, uint64_t id) (void) pthread_rwlock_unlock(&ztest_name_lock); } -/* ARGSUSED */ void ztest_spa_prop_get_set(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; nvlist_t *props = NULL; (void) pthread_rwlock_rdlock(&ztest_name_lock); @@ -6008,10 +6010,10 @@ out: /* * Inject random faults into the on-disk data. */ -/* ARGSUSED */ void ztest_fault_inject(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; ztest_shared_t *zs = ztest_shared; spa_t *spa = ztest_spa; int fd; @@ -6324,10 +6326,10 @@ ztest_scrub_impl(spa_t *spa) /* * Scrub the pool. */ -/* ARGSUSED */ void ztest_scrub(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; spa_t *spa = ztest_spa; int error; @@ -6352,10 +6354,10 @@ ztest_scrub(ztest_ds_t *zd, uint64_t id) /* * Change the guid for the pool. */ -/* ARGSUSED */ void ztest_reguid(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; spa_t *spa = ztest_spa; uint64_t orig, load; int error; @@ -6385,6 +6387,7 @@ ztest_reguid(ztest_ds_t *zd, uint64_t id) void ztest_fletcher(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; hrtime_t end = gethrtime() + NANOSEC; while (gethrtime() <= end) { @@ -6454,6 +6457,7 @@ ztest_fletcher(ztest_ds_t *zd, uint64_t id) void ztest_fletcher_incr(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; void *buf; size_t size; int *ptr; @@ -6657,10 +6661,10 @@ ztest_random_concrete_vdev_leaf(vdev_t *vd) return (ztest_random_concrete_vdev_leaf(eligible[child_no])); } -/* ARGSUSED */ void ztest_initialize(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; spa_t *spa = ztest_spa; int error = 0; @@ -6729,10 +6733,10 @@ ztest_initialize(ztest_ds_t *zd, uint64_t id) mutex_exit(&ztest_vdev_lock); } -/* ARGSUSED */ void ztest_trim(ztest_ds_t *zd, uint64_t id) { + (void) zd, (void) id; spa_t *spa = ztest_spa; int error = 0; @@ -7246,10 +7250,10 @@ ztest_dataset_close(int d) ztest_zd_fini(zd); } -/* ARGSUSED */ static int ztest_replay_zil_cb(const char *name, void *arg) { + (void) arg; objset_t *os; ztest_ds_t *zdtmp; @@ -7371,7 +7375,7 @@ ztest_freeze(void) } static void -ztest_import_impl(ztest_shared_t *zs) +ztest_import_impl(void) { importargs_t args = { 0 }; nvlist_t *cfg = NULL; @@ -7404,7 +7408,7 @@ ztest_import(ztest_shared_t *zs) kernel_init(SPA_MODE_READ | SPA_MODE_WRITE); - ztest_import_impl(zs); + ztest_import_impl(); VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG)); zs->zs_metaslab_sz = @@ -7470,7 +7474,7 @@ ztest_run(ztest_shared_t *zs) error = spa_open(ztest_opts.zo_pool, &spa, FTAG); if (error) { VERIFY3S(error, ==, ENOENT); - ztest_import_impl(zs); + ztest_import_impl(); VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG)); zs->zs_metaslab_sz = 1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift; From 1fedd012472a6d6923eec153ee69ec0b9b13518a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 02:00:02 +0100 Subject: [PATCH 043/117] zfs: iter: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- cmd/zfs/zfs_iter.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/zfs/zfs_iter.c b/cmd/zfs/zfs_iter.c index 301a179a2b0..7d1eae07cb3 100644 --- a/cmd/zfs/zfs_iter.c +++ b/cmd/zfs/zfs_iter.c @@ -267,9 +267,8 @@ zfs_list_only_by_fast(const zprop_list_t *p) return (B_TRUE); } -/* ARGSUSED */ static int -zfs_compare(const void *larg, const void *rarg, void *unused) +zfs_compare(const void *larg, const void *rarg) { zfs_handle_t *l = ((zfs_node_t *)larg)->zn_handle; zfs_handle_t *r = ((zfs_node_t *)rarg)->zn_handle; @@ -430,7 +429,7 @@ zfs_sort(const void *larg, const void *rarg, void *data) } } - return (zfs_compare(larg, rarg, NULL)); + return (zfs_compare(larg, rarg)); } int From cf8d708b7a17d301b09dc9513ad5e2741083895d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 11 Dec 2021 02:24:35 +0100 Subject: [PATCH 044/117] tests: fix unused, remove argsused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Closes #12835 --- tests/zfs-tests/cmd/btree_test/btree_test.c | 1 + tests/zfs-tests/cmd/largest_file/largest_file.c | 2 +- tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c | 1 + tests/zfs-tests/cmd/rename_dir/rename_dir.c | 2 +- .../zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c | 4 ++-- tests/zfs-tests/cmd/xattrtest/xattrtest.c | 6 +++--- .../tests/functional/cli_root/zpool_events/ereports.c | 3 +-- tests/zfs-tests/tests/functional/ctime/ctime.c | 3 +-- tests/zfs-tests/tests/functional/hkdf/hkdf_test.c | 2 +- tests/zfs-tests/tests/functional/libzfs/many_fds.c | 3 +-- tests/zfs-tests/tests/functional/tmpfile/tmpfile_001_pos.c | 6 ++---- tests/zfs-tests/tests/functional/tmpfile/tmpfile_002_pos.c | 2 +- tests/zfs-tests/tests/functional/tmpfile/tmpfile_003_pos.c | 2 +- .../zfs-tests/tests/functional/tmpfile/tmpfile_stat_mode.c | 2 +- 14 files changed, 18 insertions(+), 21 deletions(-) diff --git a/tests/zfs-tests/cmd/btree_test/btree_test.c b/tests/zfs-tests/cmd/btree_test/btree_test.c index 8de14ff2a26..aaad4e47e46 100644 --- a/tests/zfs-tests/cmd/btree_test/btree_test.c +++ b/tests/zfs-tests/cmd/btree_test/btree_test.c @@ -294,6 +294,7 @@ drain_tree(zfs_btree_t *bt, char *why) static int stress_tree(zfs_btree_t *bt, char *why) { + (void) why; avl_tree_t avl; int_node_t *node; struct timeval tp; diff --git a/tests/zfs-tests/cmd/largest_file/largest_file.c b/tests/zfs-tests/cmd/largest_file/largest_file.c index 00e1019cc8e..91260764096 100644 --- a/tests/zfs-tests/cmd/largest_file/largest_file.c +++ b/tests/zfs-tests/cmd/largest_file/largest_file.c @@ -137,9 +137,9 @@ usage(char *name) exit(1); } -/* ARGSUSED */ static void sigxfsz(int signo) { + (void) signo; (void) printf("\nlargest_file: sigxfsz() caught SIGXFSZ\n"); } diff --git a/tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c b/tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c index 21119ebca9d..a02f46d91b3 100644 --- a/tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c +++ b/tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c @@ -52,6 +52,7 @@ do_sync_io(struct iocb *iocb) int main(int argc, char **argv) { + (void) argc; char *buf; int page_size = getpagesize(); int buf_size = strtol(argv[2], NULL, 0); diff --git a/tests/zfs-tests/cmd/rename_dir/rename_dir.c b/tests/zfs-tests/cmd/rename_dir/rename_dir.c index 5f80f722946..897ec7b8414 100644 --- a/tests/zfs-tests/cmd/rename_dir/rename_dir.c +++ b/tests/zfs-tests/cmd/rename_dir/rename_dir.c @@ -49,7 +49,7 @@ #include int -main(int argc, char *argvp[]) +main(void) { int i = 1; diff --git a/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c b/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c index e262ecefea9..f8b6e3e808b 100644 --- a/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c +++ b/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c @@ -55,10 +55,10 @@ pickidx(void) return (random() % 1000); } -/* ARGSUSED */ static void * mover(void *a) { + (void) a; char buf[256]; int idx, len, ret; @@ -75,10 +75,10 @@ mover(void *a) return (NULL); } -/* ARGSUSED */ static void * cleaner(void *a) { + (void) a; char buf[256]; int idx, len, ret; diff --git a/tests/zfs-tests/cmd/xattrtest/xattrtest.c b/tests/zfs-tests/cmd/xattrtest/xattrtest.c index 0b68126c032..49b6629ba05 100644 --- a/tests/zfs-tests/cmd/xattrtest/xattrtest.c +++ b/tests/zfs-tests/cmd/xattrtest/xattrtest.c @@ -96,12 +96,12 @@ static char script[PATH_MAX] = "/bin/true"; static char xattrbytes[XATTR_SIZE_MAX]; static int -usage(int argc, char **argv) +usage(char *argv0) { fprintf(stderr, "usage: %s [-hvycdrRk] [-n ] [-f ] [-x ]\n" " [-s ] [-p ] [-t