zfs: merge openzfs/zfs@ec64fdb93 (master) into main

Notable upstream pull request merges:
  #12392 Avoid panic in case of pool errors and missing L2ARC
  #12448 skip snapshot in zfs_iter_mounted()
  #12516 Fix NFS and large reads on older kernels
  #12533 Fail invalid incremental recursive send gracefully
  #12569 FreeBSD: Really zero the zero page
  #12575 Reject zfs send -RI with nonexistent fromsnap
  #12602 Correct refcount_add in dmu_zfetch
  #12650 zpool should call zfs_nicestrtonum() with non-NULL handle

Obtained from:	OpenZFS
OpenZFS commit:	ec64fdb93d
This commit is contained in:
Martin Matuska 2021-10-21 13:58:45 +02:00
commit 6ba2210ee0
92 changed files with 2710 additions and 1724 deletions

View File

@ -45,7 +45,6 @@ USER_C = \
# FreeBSD
USER_C += \
libzfs_compat.c \
libzfs_ioctl_compat.c \
libzfs_zmount.c
# libshare

View File

@ -2,6 +2,8 @@
.PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libzfs_core
.PATH: ${SRCTOP}/sys/contrib/openzfs/include
.PATH: ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/zfs
.PATH: ${SRCTOP}/sys/contrib/openzfs/module/os/freebsd/zfs
LIB= zfs_core
@ -9,7 +11,9 @@ LIBADD= nvpair
PACKAGE= runtime
INCS= libzfs_core.h
SRCS= libzfs_core.c
SRCS= libzfs_core.c \
os/freebsd/libzfs_core_ioctl.c \
zfs_ioctl_compat.c
WARNS?= 2
CSTD= c99
@ -18,6 +22,7 @@ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzfs_core/common
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/zfs
CFLAGS+= -I${SRCTOP}/sys
CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include

View File

@ -18,9 +18,8 @@ SRCS = \
zutil_pool.c
SRCS += \
zutil_device_path_os.c \
zutil_import_os.c \
zutil_compat.c
os/freebsd/zutil_device_path_os.c \
os/freebsd/zutil_import_os.c
SRCS += zfs_ioctl_compat.c

View File

@ -6,5 +6,5 @@ Release: 1
Release-Tags: relext
License: CDDL
Author: OpenZFS
Linux-Maximum: 5.13
Linux-Maximum: 5.14
Linux-Minimum: 3.10

View File

@ -441,73 +441,73 @@ def calculate():
v = dict()
v["time"] = time.strftime("%H:%M:%S", time.localtime())
v["hits"] = d["hits"] / sint
v["miss"] = d["misses"] / sint
v["hits"] = d["hits"] // sint
v["miss"] = d["misses"] // sint
v["read"] = v["hits"] + v["miss"]
v["hit%"] = 100 * v["hits"] / v["read"] if v["read"] > 0 else 0
v["hit%"] = 100 * v["hits"] // v["read"] if v["read"] > 0 else 0
v["miss%"] = 100 - v["hit%"] if v["read"] > 0 else 0
v["dhit"] = (d["demand_data_hits"] + d["demand_metadata_hits"]) / sint
v["dmis"] = (d["demand_data_misses"] + d["demand_metadata_misses"]) / sint
v["dhit"] = (d["demand_data_hits"] + d["demand_metadata_hits"]) // sint
v["dmis"] = (d["demand_data_misses"] + d["demand_metadata_misses"]) // sint
v["dread"] = v["dhit"] + v["dmis"]
v["dh%"] = 100 * v["dhit"] / v["dread"] if v["dread"] > 0 else 0
v["dh%"] = 100 * v["dhit"] // v["dread"] if v["dread"] > 0 else 0
v["dm%"] = 100 - v["dh%"] if v["dread"] > 0 else 0
v["phit"] = (d["prefetch_data_hits"] + d["prefetch_metadata_hits"]) / sint
v["phit"] = (d["prefetch_data_hits"] + d["prefetch_metadata_hits"]) // sint
v["pmis"] = (d["prefetch_data_misses"] +
d["prefetch_metadata_misses"]) / sint
d["prefetch_metadata_misses"]) // sint
v["pread"] = v["phit"] + v["pmis"]
v["ph%"] = 100 * v["phit"] / v["pread"] if v["pread"] > 0 else 0
v["ph%"] = 100 * v["phit"] // v["pread"] if v["pread"] > 0 else 0
v["pm%"] = 100 - v["ph%"] if v["pread"] > 0 else 0
v["mhit"] = (d["prefetch_metadata_hits"] +
d["demand_metadata_hits"]) / sint
d["demand_metadata_hits"]) // sint
v["mmis"] = (d["prefetch_metadata_misses"] +
d["demand_metadata_misses"]) / sint
d["demand_metadata_misses"]) // sint
v["mread"] = v["mhit"] + v["mmis"]
v["mh%"] = 100 * v["mhit"] / v["mread"] if v["mread"] > 0 else 0
v["mh%"] = 100 * v["mhit"] // v["mread"] if v["mread"] > 0 else 0
v["mm%"] = 100 - v["mh%"] if v["mread"] > 0 else 0
v["arcsz"] = cur["size"]
v["size"] = cur["size"]
v["c"] = cur["c"]
v["mfu"] = d["mfu_hits"] / sint
v["mru"] = d["mru_hits"] / sint
v["mrug"] = d["mru_ghost_hits"] / sint
v["mfug"] = d["mfu_ghost_hits"] / sint
v["eskip"] = d["evict_skip"] / sint
v["el2skip"] = d["evict_l2_skip"] / sint
v["el2cach"] = d["evict_l2_cached"] / sint
v["el2el"] = d["evict_l2_eligible"] / sint
v["el2mfu"] = d["evict_l2_eligible_mfu"] / sint
v["el2mru"] = d["evict_l2_eligible_mru"] / sint
v["el2inel"] = d["evict_l2_ineligible"] / sint
v["mtxmis"] = d["mutex_miss"] / sint
v["mfu"] = d["mfu_hits"] // sint
v["mru"] = d["mru_hits"] // sint
v["mrug"] = d["mru_ghost_hits"] // sint
v["mfug"] = d["mfu_ghost_hits"] // sint
v["eskip"] = d["evict_skip"] // sint
v["el2skip"] = d["evict_l2_skip"] // sint
v["el2cach"] = d["evict_l2_cached"] // sint
v["el2el"] = d["evict_l2_eligible"] // sint
v["el2mfu"] = d["evict_l2_eligible_mfu"] // sint
v["el2mru"] = d["evict_l2_eligible_mru"] // sint
v["el2inel"] = d["evict_l2_ineligible"] // sint
v["mtxmis"] = d["mutex_miss"] // sint
if l2exist:
v["l2hits"] = d["l2_hits"] / sint
v["l2miss"] = d["l2_misses"] / sint
v["l2hits"] = d["l2_hits"] // sint
v["l2miss"] = d["l2_misses"] // sint
v["l2read"] = v["l2hits"] + v["l2miss"]
v["l2hit%"] = 100 * v["l2hits"] / v["l2read"] if v["l2read"] > 0 else 0
v["l2hit%"] = 100 * v["l2hits"] // v["l2read"] if v["l2read"] > 0 else 0
v["l2miss%"] = 100 - v["l2hit%"] if v["l2read"] > 0 else 0
v["l2asize"] = cur["l2_asize"]
v["l2size"] = cur["l2_size"]
v["l2bytes"] = d["l2_read_bytes"] / sint
v["l2bytes"] = d["l2_read_bytes"] // sint
v["l2pref"] = cur["l2_prefetch_asize"]
v["l2mfu"] = cur["l2_mfu_asize"]
v["l2mru"] = cur["l2_mru_asize"]
v["l2data"] = cur["l2_bufc_data_asize"]
v["l2meta"] = cur["l2_bufc_metadata_asize"]
v["l2pref%"] = 100 * v["l2pref"] / v["l2asize"]
v["l2mfu%"] = 100 * v["l2mfu"] / v["l2asize"]
v["l2mru%"] = 100 * v["l2mru"] / v["l2asize"]
v["l2data%"] = 100 * v["l2data"] / v["l2asize"]
v["l2meta%"] = 100 * v["l2meta"] / v["l2asize"]
v["l2pref%"] = 100 * v["l2pref"] // v["l2asize"]
v["l2mfu%"] = 100 * v["l2mfu"] // v["l2asize"]
v["l2mru%"] = 100 * v["l2mru"] // v["l2asize"]
v["l2data%"] = 100 * v["l2data"] // v["l2asize"]
v["l2meta%"] = 100 * v["l2meta"] // v["l2asize"]
v["grow"] = 0 if cur["arc_no_grow"] else 1
v["need"] = cur["arc_need_free"]

View File

@ -622,8 +622,8 @@ enclosure_handler () {
PCI_ID=$(echo "$PCI_ID_LONG" | sed -r 's/^[0-9]+://g')
# Name our device according to vdev_id.conf (like "L0" or "U1").
NAME=$(awk '/channel/{if ($1 == "channel" && $2 == "$PCI_ID" && \
$3 == "$PORT_ID") {print ${4}int(count[$4])}; count[$4]++}' $CONFIG)
NAME=$(awk "/channel/{if (\$1 == \"channel\" && \$2 == \"$PCI_ID\" && \
\$3 == \"$PORT_ID\") {print \$4\$3}}" $CONFIG)
echo "${NAME}"
}

View File

@ -5469,9 +5469,9 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
uint64_t now = gethrtime();
char buf[10];
uint64_t bytes = zcb->zcb_type[ZB_TOTAL][ZDB_OT_TOTAL].zb_asize;
int kb_per_sec =
uint64_t kb_per_sec =
1 + bytes / (1 + ((now - zcb->zcb_start) / 1000 / 1000));
int sec_remaining =
uint64_t sec_remaining =
(zcb->zcb_totalasize - bytes) / 1024 / kb_per_sec;
/* make sure nicenum has enough space */
@ -5479,8 +5479,9 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
zfs_nicebytes(bytes, buf, sizeof (buf));
(void) fprintf(stderr,
"\r%5s completed (%4dMB/s) "
"estimated time remaining: %uhr %02umin %02usec ",
"\r%5s completed (%4"PRIu64"MB/s) "
"estimated time remaining: "
"%"PRIu64"hr %02"PRIu64"min %02"PRIu64"sec ",
buf, kb_per_sec / 1024,
sec_remaining / 60 / 60,
sec_remaining / 60 % 60,

View File

@ -15,7 +15,7 @@
# Send notification in response to a fault induced statechange
#
# ZEVENT_SUBCLASS: 'statechange'
# ZEVENT_VDEV_STATE_STR: 'DEGRADED', 'FAULTED' or 'REMOVED'
# ZEVENT_VDEV_STATE_STR: 'DEGRADED', 'FAULTED', 'REMOVED', or 'UNAVAIL'
#
# Exit codes:
# 0: notification sent
@ -31,7 +31,8 @@
if [ "${ZEVENT_VDEV_STATE_STR}" != "FAULTED" ] \
&& [ "${ZEVENT_VDEV_STATE_STR}" != "DEGRADED" ] \
&& [ "${ZEVENT_VDEV_STATE_STR}" != "REMOVED" ]; then
&& [ "${ZEVENT_VDEV_STATE_STR}" != "REMOVED" ] \
&& [ "${ZEVENT_VDEV_STATE_STR}" != "UNAVAIL" ]; then
exit 3
fi

View File

@ -26,7 +26,8 @@ zpool_LDADD = \
$(abs_top_builddir)/lib/libzfs/libzfs.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libuutil/libuutil.la
$(abs_top_builddir)/lib/libuutil/libuutil.la \
$(abs_top_builddir)/lib/libzutil/libzutil.la
zpool_LDADD += $(LTLIBINTL)

View File

@ -264,51 +264,6 @@ for_each_pool(int argc, char **argv, boolean_t unavail,
return (ret);
}
static int
for_each_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, pool_vdev_iter_f func,
void *data)
{
nvlist_t **child;
uint_t c, children;
int ret = 0;
int i;
char *type;
const char *list[] = {
ZPOOL_CONFIG_SPARES,
ZPOOL_CONFIG_L2CACHE,
ZPOOL_CONFIG_CHILDREN
};
for (i = 0; i < ARRAY_SIZE(list); i++) {
if (nvlist_lookup_nvlist_array(nv, list[i], &child,
&children) == 0) {
for (c = 0; c < children; c++) {
uint64_t ishole = 0;
(void) nvlist_lookup_uint64(child[c],
ZPOOL_CONFIG_IS_HOLE, &ishole);
if (ishole)
continue;
ret |= for_each_vdev_cb(zhp, child[c], func,
data);
}
}
}
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) != 0)
return (ret);
/* Don't run our function on root vdevs */
if (strcmp(type, VDEV_TYPE_ROOT) != 0) {
ret |= func(zhp, nv, data);
}
return (ret);
}
/*
* This is the equivalent of for_each_pool() for vdevs. It iterates thorough
* all vdevs in the pool, ignoring root vdevs and holes, calling func() on
@ -327,7 +282,7 @@ for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data)
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) == 0);
}
return (for_each_vdev_cb(zhp, nvroot, func, data));
return (for_each_vdev_cb((void *) zhp, nvroot, func, data));
}
/*
@ -603,7 +558,7 @@ vdev_run_cmd_thread(void *cb_cmd_data)
/* For each vdev in the pool run a command */
static int
for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl)
for_each_vdev_run_cb(void *zhp_data, nvlist_t *nv, void *cb_vcdl)
{
vdev_cmd_data_list_t *vcdl = cb_vcdl;
vdev_cmd_data_t *data;
@ -611,6 +566,7 @@ for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl)
char *vname = NULL;
char *vdev_enc_sysfs_path = NULL;
int i, match = 0;
zpool_handle_t *zhp = zhp_data;
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) != 0)
return (1);

View File

@ -5156,11 +5156,12 @@ get_stat_flags(zpool_list_t *list)
* Return 1 if cb_data->cb_vdev_names[0] is this vdev's name, 0 otherwise.
*/
static int
is_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_data)
is_vdev_cb(void *zhp_data, nvlist_t *nv, void *cb_data)
{
iostat_cbdata_t *cb = cb_data;
char *name = NULL;
int ret = 0;
zpool_handle_t *zhp = zhp_data;
name = zpool_vdev_name(g_zfs, zhp, nv, cb->cb_name_flags);
@ -7352,9 +7353,10 @@ zpool_do_trim(int argc, char **argv)
"combined with the -c or -s options\n"));
usage(B_FALSE);
}
if (zfs_nicestrtonum(NULL, optarg, &rate) == -1) {
(void) fprintf(stderr,
gettext("invalid value for rate\n"));
if (zfs_nicestrtonum(g_zfs, optarg, &rate) == -1) {
(void) fprintf(stderr, "%s: %s\n",
gettext("invalid value for rate"),
libzfs_error_description(g_zfs));
usage(B_FALSE);
}
break;

View File

@ -27,6 +27,7 @@
#include <libnvpair.h>
#include <libzfs.h>
#include <libzutil.h>
#ifdef __cplusplus
extern "C" {
@ -68,7 +69,6 @@ int for_each_pool(int, char **, boolean_t unavail, zprop_list_t **,
boolean_t, zpool_iter_f, void *);
/* Vdev list functions */
typedef int (*pool_vdev_iter_f)(zpool_handle_t *, nvlist_t *, void *);
int for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data);
typedef struct zpool_list zpool_list_t;

View File

@ -17,7 +17,6 @@ for req in "@sbindir@/zpool" "@sbindir@/zfs" "@mounthelperdir@/mount.zfs"; do
}
done
copy_exec "@sbindir@/zdb"
copy_exec "@udevdir@/vdev_id"
copy_exec "@udevdir@/zvol_id"
if command -v systemd-ask-password > /dev/null; then

View File

@ -630,6 +630,7 @@ setup_snapshot_booting()
then
# Rollback snapshot
rollback_snap "$s" || retval=$((retval + 1))
ZFS_BOOTFS="${rootfs}"
else
# Setup a destination filesystem name.
# Ex: Called with 'rpool/ROOT/debian@snap2'

View File

@ -650,6 +650,7 @@ _LIBZFS_H int zfs_create_ancestors(libzfs_handle_t *, const char *);
_LIBZFS_H int zfs_destroy(zfs_handle_t *, boolean_t);
_LIBZFS_H int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t);
_LIBZFS_H int zfs_destroy_snaps_nvl(libzfs_handle_t *, nvlist_t *, boolean_t);
_LIBZFS_H int zfs_destroy_snaps_nvl_os(libzfs_handle_t *, nvlist_t *);
_LIBZFS_H int zfs_clone(zfs_handle_t *, const char *, nvlist_t *);
_LIBZFS_H int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t,
nvlist_t *);

View File

@ -41,6 +41,9 @@ extern "C" {
_LIBZFS_CORE_H int libzfs_core_init(void);
_LIBZFS_CORE_H void libzfs_core_fini(void);
struct zfs_cmd;
_LIBZFS_CORE_H int lzc_ioctl_fd(int, unsigned long, struct zfs_cmd *);
/*
* NB: this type should be kept binary-compatible with dmu_objset_type_t.
*/

View File

@ -146,7 +146,6 @@ _LIBZUTIL_H int zpool_history_unpack(char *, uint64_t, uint64_t *, nvlist_t ***,
uint_t *);
struct zfs_cmd;
_LIBZUTIL_H int zfs_ioctl_fd(int fd, unsigned long request, struct zfs_cmd *zc);
/*
* List of colors to use
@ -163,6 +162,16 @@ _LIBZUTIL_H int printf_color(char *color, char *format, ...);
_LIBZUTIL_H const char *zfs_basename(const char *path);
_LIBZUTIL_H ssize_t zfs_dirnamelen(const char *path);
/*
* These functions are used by the ZFS libraries and cmd/zpool code, but are
* not exported in the ABI.
*/
typedef int (*pool_vdev_iter_f)(void *, nvlist_t *, void *);
int for_each_vdev_cb(void *zhp, nvlist_t *nv, pool_vdev_iter_f func,
void *data);
int for_each_vdev_in_nvlist(nvlist_t *nvroot, pool_vdev_iter_f func,
void *data);
void update_vdevs_config_dev_sysfs_path(nvlist_t *config);
#ifdef __cplusplus
}
#endif

View File

@ -148,7 +148,6 @@ nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int,
int zfs_ioctl_legacy_to_ozfs(int request);
int zfs_ioctl_ozfs_to_legacy(int request);
void zfs_cmd_legacy_to_ozfs(zfs_cmd_legacy_t *src, zfs_cmd_t *dst);
void zfs_cmd_compat_get(zfs_cmd_t *, caddr_t, const int);
void zfs_cmd_ozfs_to_legacy(zfs_cmd_t *src, zfs_cmd_legacy_t *dst);
void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int);

View File

@ -559,6 +559,8 @@ int dmu_spill_hold_existing(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp);
*/
int dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset,
void *tag, dmu_buf_t **, int flags);
int dmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset,
uint64_t length, int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp);
int dmu_buf_hold_by_dnode(dnode_t *dn, uint64_t offset,
void *tag, dmu_buf_t **dbp, int flags);
int dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset,

View File

@ -72,6 +72,14 @@ int zfs_refcount_is_zero(zfs_refcount_t *);
int64_t zfs_refcount_count(zfs_refcount_t *);
int64_t zfs_refcount_add(zfs_refcount_t *, const void *);
int64_t zfs_refcount_remove(zfs_refcount_t *, const void *);
/*
* Note that (add|remove)_many add/remove one reference with "number" N,
* _not_ make N references with "number" 1, which is what vanilla
* zfs_refcount_(add|remove) would do if called N times.
*
* Attempting to remove a reference with number N when none exists is a
* panic on debug kernels with reference_tracking enabled.
*/
int64_t zfs_refcount_add_many(zfs_refcount_t *, uint64_t, const void *);
int64_t zfs_refcount_remove_many(zfs_refcount_t *, uint64_t, const void *);
void zfs_refcount_transfer(zfs_refcount_t *, zfs_refcount_t *);

View File

@ -104,7 +104,7 @@ enum zio_checksum {
#define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON
#define ZIO_CHECKSUM_MASK 0xffULL
#define ZIO_CHECKSUM_VERIFY (1 << 8)
#define ZIO_CHECKSUM_VERIFY (1U << 8)
#define ZIO_DEDUPCHECKSUM ZIO_CHECKSUM_SHA256
@ -169,27 +169,27 @@ enum zio_flag {
* Flags inherited by gang, ddt, and vdev children,
* and that must be equal for two zios to aggregate
*/
ZIO_FLAG_DONT_AGGREGATE = 1 << 0,
ZIO_FLAG_IO_REPAIR = 1 << 1,
ZIO_FLAG_SELF_HEAL = 1 << 2,
ZIO_FLAG_RESILVER = 1 << 3,
ZIO_FLAG_SCRUB = 1 << 4,
ZIO_FLAG_SCAN_THREAD = 1 << 5,
ZIO_FLAG_PHYSICAL = 1 << 6,
ZIO_FLAG_DONT_AGGREGATE = 1U << 0,
ZIO_FLAG_IO_REPAIR = 1U << 1,
ZIO_FLAG_SELF_HEAL = 1U << 2,
ZIO_FLAG_RESILVER = 1U << 3,
ZIO_FLAG_SCRUB = 1U << 4,
ZIO_FLAG_SCAN_THREAD = 1U << 5,
ZIO_FLAG_PHYSICAL = 1U << 6,
#define ZIO_FLAG_AGG_INHERIT (ZIO_FLAG_CANFAIL - 1)
/*
* Flags inherited by ddt, gang, and vdev children.
*/
ZIO_FLAG_CANFAIL = 1 << 7, /* must be first for INHERIT */
ZIO_FLAG_SPECULATIVE = 1 << 8,
ZIO_FLAG_CONFIG_WRITER = 1 << 9,
ZIO_FLAG_DONT_RETRY = 1 << 10,
ZIO_FLAG_DONT_CACHE = 1 << 11,
ZIO_FLAG_NODATA = 1 << 12,
ZIO_FLAG_INDUCE_DAMAGE = 1 << 13,
ZIO_FLAG_IO_ALLOCATING = 1 << 14,
ZIO_FLAG_CANFAIL = 1U << 7, /* must be first for INHERIT */
ZIO_FLAG_SPECULATIVE = 1U << 8,
ZIO_FLAG_CONFIG_WRITER = 1U << 9,
ZIO_FLAG_DONT_RETRY = 1U << 10,
ZIO_FLAG_DONT_CACHE = 1U << 11,
ZIO_FLAG_NODATA = 1U << 12,
ZIO_FLAG_INDUCE_DAMAGE = 1U << 13,
ZIO_FLAG_IO_ALLOCATING = 1U << 14,
#define ZIO_FLAG_DDT_INHERIT (ZIO_FLAG_IO_RETRY - 1)
#define ZIO_FLAG_GANG_INHERIT (ZIO_FLAG_IO_RETRY - 1)
@ -197,29 +197,29 @@ enum zio_flag {
/*
* Flags inherited by vdev children.
*/
ZIO_FLAG_IO_RETRY = 1 << 15, /* must be first for INHERIT */
ZIO_FLAG_PROBE = 1 << 16,
ZIO_FLAG_TRYHARD = 1 << 17,
ZIO_FLAG_OPTIONAL = 1 << 18,
ZIO_FLAG_IO_RETRY = 1U << 15, /* must be first for INHERIT */
ZIO_FLAG_PROBE = 1U << 16,
ZIO_FLAG_TRYHARD = 1U << 17,
ZIO_FLAG_OPTIONAL = 1U << 18,
#define ZIO_FLAG_VDEV_INHERIT (ZIO_FLAG_DONT_QUEUE - 1)
/*
* Flags not inherited by any children.
*/
ZIO_FLAG_DONT_QUEUE = 1 << 19, /* must be first for INHERIT */
ZIO_FLAG_DONT_PROPAGATE = 1 << 20,
ZIO_FLAG_IO_BYPASS = 1 << 21,
ZIO_FLAG_IO_REWRITE = 1 << 22,
ZIO_FLAG_RAW_COMPRESS = 1 << 23,
ZIO_FLAG_RAW_ENCRYPT = 1 << 24,
ZIO_FLAG_GANG_CHILD = 1 << 25,
ZIO_FLAG_DDT_CHILD = 1 << 26,
ZIO_FLAG_GODFATHER = 1 << 27,
ZIO_FLAG_NOPWRITE = 1 << 28,
ZIO_FLAG_REEXECUTED = 1 << 29,
ZIO_FLAG_DELEGATED = 1 << 30,
ZIO_FLAG_FASTWRITE = 1 << 31,
ZIO_FLAG_DONT_QUEUE = 1U << 19, /* must be first for INHERIT */
ZIO_FLAG_DONT_PROPAGATE = 1U << 20,
ZIO_FLAG_IO_BYPASS = 1U << 21,
ZIO_FLAG_IO_REWRITE = 1U << 22,
ZIO_FLAG_RAW_COMPRESS = 1U << 23,
ZIO_FLAG_RAW_ENCRYPT = 1U << 24,
ZIO_FLAG_GANG_CHILD = 1U << 25,
ZIO_FLAG_DDT_CHILD = 1U << 26,
ZIO_FLAG_GODFATHER = 1U << 27,
ZIO_FLAG_NOPWRITE = 1U << 28,
ZIO_FLAG_REEXECUTED = 1U << 29,
ZIO_FLAG_DELEGATED = 1U << 30,
ZIO_FLAG_FASTWRITE = 1U << 31,
};
#define ZIO_FLAG_MUSTSUCCEED 0
@ -237,8 +237,8 @@ enum zio_flag {
(((zio)->io_flags & ZIO_FLAG_VDEV_INHERIT) | \
ZIO_FLAG_DONT_PROPAGATE | ZIO_FLAG_CANFAIL)
#define ZIO_CHILD_BIT(x) (1 << (x))
#define ZIO_CHILD_BIT_IS_SET(val, x) ((val) & (1 << (x)))
#define ZIO_CHILD_BIT(x) (1U << (x))
#define ZIO_CHILD_BIT_IS_SET(val, x) ((val) & (1U << (x)))
enum zio_child {
ZIO_CHILD_VDEV = 0,
@ -404,7 +404,7 @@ typedef zio_t *zio_pipe_stage_t(zio_t *zio);
* only apply to ZIO_TYPE_TRIM zios are distinct from io_flags.
*/
enum trim_flag {
ZIO_TRIM_SECURE = 1 << 0,
ZIO_TRIM_SECURE = 1U << 0,
};
typedef struct zio_alloc_list {

View File

@ -1,5 +1,44 @@
#
# Shown below is a simplified dependency graph of the OpenZFS provided
# libraries. Administrative commands (`zfs`, `zpool`, etc) interface with
# the kernel modules using the `libzfs.so` and `libzfs_core.so` libraries.
# These libraries provide a stable ABI across OpenZFS point releases.
#
# The `libzpool.so` library is a user space build of the DMU and SPA layers
# used to implement debugging tools (zdb) and code validation tools (ztest).
# These library interfaces are subject to change at any time.
#
#
# CMDS: zhack/ztest/zdb/ zfs/zpool/zed/
# raidz_{test,bench} zinject/zstream
# | |
# LIBS: | | libzfsbootenv*
# | | |
# | | |
# libzpool libzfs* ----------------+
# | | | \ / | | |
# libicp --/ | | \ / | | \------- libshare
# | | \ / | |
# libzstd ---/ | \ / | \--------- libuutil
# | \ / \ | |
# libunicode --/ \ / \ | |
# \ / \ | |
# libzutil libzfs_core* | |
# | | | | \ | | | |
# | | | | | | | | |
# | | | | | | | | |
# libtpool -------------/ | | | \---- libnvpair* | | |
# | | | | | |
# libefi -----------------/ | \------ libavl* --------/ |
# | | |
# \-------- libspl ----+------/
#
# * - A stable ABI is provided for these libraries
#
#
# NB: GNU Automake Manual, Chapter 8.3.5: Libtool Convenience Libraries
# These nine libraries are intermediary build components.
#
SUBDIRS = libavl libicp libshare libspl libtpool libzstd
CPPCHECKDIRS = libavl libicp libnvpair libshare libspl libtpool libunicode
CPPCHECKDIRS += libuutil libzfs libzfs_core libzfsbootenv libzpool libzutil

View File

@ -136,8 +136,9 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie)
{
int error;
const char *access;
char *host_dup, *host, *next;
char *host_dup, *host, *next, *v6Literal;
nfs_host_cookie_t *udata = (nfs_host_cookie_t *)pcookie;
int cidr_len;
#ifdef DEBUG
fprintf(stderr, "foreach_nfs_host_cb: key=%s, value=%s\n", opt, value);
@ -160,10 +161,46 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie)
host = host_dup;
do {
next = strchr(host, ':');
if (next != NULL) {
*next = '\0';
next++;
if (*host == '[') {
host++;
v6Literal = strchr(host, ']');
if (v6Literal == NULL) {
free(host_dup);
return (SA_SYNTAX_ERR);
}
if (v6Literal[1] == '\0') {
*v6Literal = '\0';
next = NULL;
} else if (v6Literal[1] == '/') {
next = strchr(v6Literal + 2, ':');
if (next == NULL) {
cidr_len =
strlen(v6Literal + 1);
memmove(v6Literal,
v6Literal + 1,
cidr_len);
v6Literal[cidr_len] = '\0';
} else {
cidr_len = next - v6Literal - 1;
memmove(v6Literal,
v6Literal + 1,
cidr_len);
v6Literal[cidr_len] = '\0';
next++;
}
} else if (v6Literal[1] == ':') {
*v6Literal = '\0';
next = v6Literal + 2;
} else {
free(host_dup);
return (SA_SYNTAX_ERR);
}
} else {
next = strchr(host, ':');
if (next != NULL) {
*next = '\0';
next++;
}
}
error = udata->callback(udata->filename,

View File

@ -21,6 +21,7 @@
*/
#include <unistd.h>
#include <sys/param.h>
static size_t pagesize = 0;

View File

@ -35,7 +35,6 @@ USER_C = \
if BUILD_FREEBSD
USER_C += \
os/freebsd/libzfs_compat.c \
os/freebsd/libzfs_ioctl_compat.c \
os/freebsd/libzfs_zmount.c
endif
@ -75,6 +74,7 @@ libzfs_la_LIBADD = \
$(abs_top_builddir)/lib/libshare/libshare.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libzutil/libzutil.la \
$(abs_top_builddir)/lib/libuutil/libuutil.la
libzfs_la_LIBADD += -lm $(LIBCRYPTO_LIBS) $(ZLIB_LIBS) $(LIBFETCH_LIBS) $(LTLIBINTL)

File diff suppressed because it is too large Load Diff

View File

@ -3884,10 +3884,13 @@ zfs_destroy_snaps(zfs_handle_t *zhp, char *snapname, boolean_t defer)
int
zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer)
{
int ret;
nvlist_t *errlist = NULL;
nvpair_t *pair;
int ret = zfs_destroy_snaps_nvl_os(hdl, snaps);
if (ret != 0)
return (ret);
ret = lzc_destroy_snaps(snaps, defer, &errlist);
if (ret == 0) {

View File

@ -575,8 +575,11 @@ zfs_iter_mounted(zfs_handle_t *zhp, zfs_iter_f func, void *data)
/* Ignore datasets not within the provided dataset */
if (strncmp(entry.mnt_special, zhp->zfs_name, namelen) != 0 ||
(entry.mnt_special[namelen] != '/' &&
entry.mnt_special[namelen] != '@'))
entry.mnt_special[namelen] != '/')
continue;
/* Skip snapshot of any child dataset */
if (strchr(entry.mnt_special, '@') != NULL)
continue;
if ((mtab_zhp = zfs_open(zhp->zfs_hdl, entry.mnt_special,

View File

@ -1059,9 +1059,14 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
nvlist_t *nvfs = fsavl_find(sdd->fsavl,
zhp->zfs_dmustats.dds_guid, &snapname);
snapprops = fnvlist_lookup_nvlist(nvfs, "snapprops");
snapprops = fnvlist_lookup_nvlist(snapprops, thissnap);
exclude = !nvlist_exists(snapprops, "is_clone_origin");
if (nvfs != NULL) {
snapprops = fnvlist_lookup_nvlist(nvfs,
"snapprops");
snapprops = fnvlist_lookup_nvlist(snapprops,
thissnap);
exclude = !nvlist_exists(snapprops,
"is_clone_origin");
}
} else {
exclude = B_TRUE;
}
@ -2144,6 +2149,23 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
return (zfs_error(zhp->zfs_hdl, EZFS_NOENT, errbuf));
}
if (fromsnap) {
char full_fromsnap_name[ZFS_MAX_DATASET_NAME_LEN];
if (snprintf(full_fromsnap_name, sizeof (full_fromsnap_name),
"%s@%s", zhp->zfs_name, fromsnap) >=
sizeof (full_fromsnap_name)) {
err = EINVAL;
goto stderr_out;
}
zfs_handle_t *fromsnapn = zfs_open(zhp->zfs_hdl,
full_fromsnap_name, ZFS_TYPE_SNAPSHOT);
if (fromsnapn == NULL) {
err = -1;
goto err_out;
}
zfs_close(fromsnapn);
}
if (flags->replicate || flags->doall || flags->props ||
flags->holds || flags->backup) {
char full_tosnap_name[ZFS_MAX_DATASET_NAME_LEN];

View File

@ -22,7 +22,6 @@
/*
* Copyright (c) 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
*/
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
#include "../../libzfs_impl.h"
#include <libzfs.h>
#include <libzutil.h>
@ -224,7 +223,7 @@ libzfs_error_init(int error)
int
zfs_ioctl(libzfs_handle_t *hdl, int request, zfs_cmd_t *zc)
{
return (zfs_ioctl_fd(hdl->libzfs_fd, request, zc));
return (lzc_ioctl_fd(hdl->libzfs_fd, request, zc));
}
/*
@ -267,6 +266,12 @@ find_shares_object(differ_info_t *di)
return (0);
}
int
zfs_destroy_snaps_nvl_os(libzfs_handle_t *hdl, nvlist_t *snaps)
{
return (0);
}
/*
* Attach/detach the given filesystem to/from the given jail.
*/

View File

@ -1,432 +0,0 @@
/*
* 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 2013 Xin Li <delphij@FreeBSD.org>. All rights reserved.
* Copyright 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Portions Copyright 2005, 2010, Oracle and/or its affiliates.
* All rights reserved.
* Use is subject to license terms.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/cred.h>
#include <sys/dmu.h>
#include <sys/zio.h>
#include <sys/nvpair.h>
#include <sys/dsl_deleg.h>
#include <sys/zfs_ioctl.h>
#include "zfs_namecheck.h"
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
/*
* FreeBSD zfs_cmd compatibility with older binaries
* appropriately remap/extend the zfs_cmd_t structure
*/
void
zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_t addr, const int cflag)
{
}
#if 0
static int
zfs_ioctl_compat_get_nvlist(uint64_t nvl, size_t size, int iflag,
nvlist_t **nvp)
{
char *packed;
int error;
nvlist_t *list = NULL;
/*
* Read in and unpack the user-supplied nvlist.
*/
if (size == 0)
return (EINVAL);
#ifdef _KERNEL
packed = kmem_alloc(size, KM_SLEEP);
if ((error = ddi_copyin((void *)(uintptr_t)nvl, packed, size,
iflag)) != 0) {
kmem_free(packed, size);
return (error);
}
#else
packed = (void *)(uintptr_t)nvl;
#endif
error = nvlist_unpack(packed, size, &list, 0);
#ifdef _KERNEL
kmem_free(packed, size);
#endif
if (error != 0)
return (error);
*nvp = list;
return (0);
}
static int
zfs_ioctl_compat_put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl)
{
char *packed = NULL;
int error = 0;
size_t size;
VERIFY(nvlist_size(nvl, &size, NV_ENCODE_NATIVE) == 0);
#ifdef _KERNEL
packed = kmem_alloc(size, KM_SLEEP);
VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE,
KM_SLEEP) == 0);
if (ddi_copyout(packed,
(void *)(uintptr_t)zc->zc_nvlist_dst, size, zc->zc_iflags) != 0)
error = EFAULT;
kmem_free(packed, size);
#else
packed = (void *)(uintptr_t)zc->zc_nvlist_dst;
VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE,
0) == 0);
#endif
zc->zc_nvlist_dst_size = size;
return (error);
}
static void
zfs_ioctl_compat_fix_stats_nvlist(nvlist_t *nvl)
{
nvlist_t **child;
nvlist_t *nvroot = NULL;
vdev_stat_t *vs;
uint_t c, children, nelem;
if (nvlist_lookup_nvlist_array(nvl, ZPOOL_CONFIG_CHILDREN,
&child, &children) == 0) {
for (c = 0; c < children; c++) {
zfs_ioctl_compat_fix_stats_nvlist(child[c]);
}
}
if (nvlist_lookup_nvlist(nvl, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) == 0)
zfs_ioctl_compat_fix_stats_nvlist(nvroot);
if ((nvlist_lookup_uint64_array(nvl, "stats",
(uint64_t **)&vs, &nelem) == 0)) {
nvlist_add_uint64_array(nvl,
ZPOOL_CONFIG_VDEV_STATS,
(uint64_t *)vs, nelem);
nvlist_remove(nvl, "stats",
DATA_TYPE_UINT64_ARRAY);
}
}
static int
zfs_ioctl_compat_fix_stats(zfs_cmd_t *zc, const int nc)
{
nvlist_t *nv, *nvp = NULL;
nvpair_t *elem;
int error;
if ((error = zfs_ioctl_compat_get_nvlist(zc->zc_nvlist_dst,
zc->zc_nvlist_dst_size, zc->zc_iflags, &nv)) != 0)
return (error);
if (nc == 5) { /* ZFS_IOC_POOL_STATS */
elem = NULL;
while ((elem = nvlist_next_nvpair(nv, elem)) != NULL) {
if (nvpair_value_nvlist(elem, &nvp) == 0)
zfs_ioctl_compat_fix_stats_nvlist(nvp);
}
elem = NULL;
} else
zfs_ioctl_compat_fix_stats_nvlist(nv);
error = zfs_ioctl_compat_put_nvlist(zc, nv);
nvlist_free(nv);
return (error);
}
static int
zfs_ioctl_compat_pool_get_props(zfs_cmd_t *zc)
{
nvlist_t *nv, *nva = NULL;
int error;
if ((error = zfs_ioctl_compat_get_nvlist(zc->zc_nvlist_dst,
zc->zc_nvlist_dst_size, zc->zc_iflags, &nv)) != 0)
return (error);
if (nvlist_lookup_nvlist(nv, "used", &nva) == 0) {
nvlist_add_nvlist(nv, "allocated", nva);
nvlist_remove(nv, "used", DATA_TYPE_NVLIST);
}
if (nvlist_lookup_nvlist(nv, "available", &nva) == 0) {
nvlist_add_nvlist(nv, "free", nva);
nvlist_remove(nv, "available", DATA_TYPE_NVLIST);
}
error = zfs_ioctl_compat_put_nvlist(zc, nv);
nvlist_free(nv);
return (error);
}
#endif
#ifdef _KERNEL
int
zfs_ioctl_compat_pre(zfs_cmd_t *zc, int *vec, const int cflag)
{
int error = 0;
/* are we creating a clone? */
if (*vec == ZFS_IOC_CREATE && zc->zc_value[0] != '\0')
*vec = ZFS_IOC_CLONE;
if (cflag == ZFS_CMD_COMPAT_V15) {
switch (*vec) {
case 7: /* ZFS_IOC_POOL_SCRUB (v15) */
zc->zc_cookie = POOL_SCAN_SCRUB;
break;
}
}
return (error);
}
void
zfs_ioctl_compat_post(zfs_cmd_t *zc, int vec, const int cflag)
{
if (cflag == ZFS_CMD_COMPAT_V15) {
switch (vec) {
case ZFS_IOC_POOL_CONFIGS:
case ZFS_IOC_POOL_STATS:
case ZFS_IOC_POOL_TRYIMPORT:
zfs_ioctl_compat_fix_stats(zc, vec);
break;
case 41: /* ZFS_IOC_POOL_GET_PROPS (v15) */
zfs_ioctl_compat_pool_get_props(zc);
break;
}
}
}
nvlist_t *
zfs_ioctl_compat_innvl(zfs_cmd_t *zc, nvlist_t *innvl, const int vec,
const int cflag)
{
nvlist_t *nvl, *tmpnvl, *hnvl;
nvpair_t *elem;
char *poolname, *snapname;
int err;
if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC ||
cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP ||
cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES)
goto out;
switch (vec) {
case ZFS_IOC_CREATE:
nvl = fnvlist_alloc();
fnvlist_add_int32(nvl, "type", zc->zc_objset_type);
if (innvl != NULL) {
fnvlist_add_nvlist(nvl, "props", innvl);
nvlist_free(innvl);
}
return (nvl);
break;
case ZFS_IOC_CLONE:
nvl = fnvlist_alloc();
fnvlist_add_string(nvl, "origin", zc->zc_value);
if (innvl != NULL) {
fnvlist_add_nvlist(nvl, "props", innvl);
nvlist_free(innvl);
}
return (nvl);
break;
case ZFS_IOC_SNAPSHOT:
if (innvl == NULL)
goto out;
nvl = fnvlist_alloc();
fnvlist_add_nvlist(nvl, "props", innvl);
tmpnvl = fnvlist_alloc();
snapname = kmem_asprintf("%s@%s", zc->zc_name, zc->zc_value);
fnvlist_add_boolean(tmpnvl, snapname);
kmem_free(snapname, strlen(snapname + 1));
/* check if we are doing a recursive snapshot */
if (zc->zc_cookie)
dmu_get_recursive_snaps_nvl(zc->zc_name, zc->zc_value,
tmpnvl);
fnvlist_add_nvlist(nvl, "snaps", tmpnvl);
fnvlist_free(tmpnvl);
nvlist_free(innvl);
/* strip dataset part from zc->zc_name */
zc->zc_name[strcspn(zc->zc_name, "/@")] = '\0';
return (nvl);
break;
case ZFS_IOC_SPACE_SNAPS:
nvl = fnvlist_alloc();
fnvlist_add_string(nvl, "firstsnap", zc->zc_value);
if (innvl != NULL)
nvlist_free(innvl);
return (nvl);
break;
case ZFS_IOC_DESTROY_SNAPS:
if (innvl == NULL && cflag == ZFS_CMD_COMPAT_DEADMAN)
goto out;
nvl = fnvlist_alloc();
if (innvl != NULL) {
fnvlist_add_nvlist(nvl, "snaps", innvl);
} else {
/*
* We are probably called by even older binaries,
* allocate and populate nvlist with recursive
* snapshots
*/
if (zfs_component_namecheck(zc->zc_value, NULL,
NULL) == 0) {
tmpnvl = fnvlist_alloc();
if (dmu_get_recursive_snaps_nvl(zc->zc_name,
zc->zc_value, tmpnvl) == 0)
fnvlist_add_nvlist(nvl, "snaps",
tmpnvl);
nvlist_free(tmpnvl);
}
}
if (innvl != NULL)
nvlist_free(innvl);
/* strip dataset part from zc->zc_name */
zc->zc_name[strcspn(zc->zc_name, "/@")] = '\0';
return (nvl);
break;
case ZFS_IOC_HOLD:
nvl = fnvlist_alloc();
tmpnvl = fnvlist_alloc();
if (zc->zc_cleanup_fd != -1)
fnvlist_add_int32(nvl, "cleanup_fd",
(int32_t)zc->zc_cleanup_fd);
if (zc->zc_cookie) {
hnvl = fnvlist_alloc();
if (dmu_get_recursive_snaps_nvl(zc->zc_name,
zc->zc_value, hnvl) == 0) {
elem = NULL;
while ((elem = nvlist_next_nvpair(hnvl,
elem)) != NULL) {
nvlist_add_string(tmpnvl,
nvpair_name(elem), zc->zc_string);
}
}
nvlist_free(hnvl);
} else {
snapname = kmem_asprintf("%s@%s", zc->zc_name,
zc->zc_value);
nvlist_add_string(tmpnvl, snapname, zc->zc_string);
kmem_free(snapname, strlen(snapname + 1));
}
fnvlist_add_nvlist(nvl, "holds", tmpnvl);
nvlist_free(tmpnvl);
if (innvl != NULL)
nvlist_free(innvl);
/* strip dataset part from zc->zc_name */
zc->zc_name[strcspn(zc->zc_name, "/@")] = '\0';
return (nvl);
break;
case ZFS_IOC_RELEASE:
nvl = fnvlist_alloc();
tmpnvl = fnvlist_alloc();
if (zc->zc_cookie) {
hnvl = fnvlist_alloc();
if (dmu_get_recursive_snaps_nvl(zc->zc_name,
zc->zc_value, hnvl) == 0) {
elem = NULL;
while ((elem = nvlist_next_nvpair(hnvl,
elem)) != NULL) {
fnvlist_add_boolean(tmpnvl,
zc->zc_string);
fnvlist_add_nvlist(nvl,
nvpair_name(elem), tmpnvl);
}
}
nvlist_free(hnvl);
} else {
snapname = kmem_asprintf("%s@%s", zc->zc_name,
zc->zc_value);
fnvlist_add_boolean(tmpnvl, zc->zc_string);
fnvlist_add_nvlist(nvl, snapname, tmpnvl);
kmem_free(snapname, strlen(snapname + 1));
}
nvlist_free(tmpnvl);
if (innvl != NULL)
nvlist_free(innvl);
/* strip dataset part from zc->zc_name */
zc->zc_name[strcspn(zc->zc_name, "/@")] = '\0';
return (nvl);
break;
}
out:
return (innvl);
}
nvlist_t *
zfs_ioctl_compat_outnvl(zfs_cmd_t *zc, nvlist_t *outnvl, const int vec,
const int cflag)
{
nvlist_t *tmpnvl;
if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC ||
cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP ||
cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES)
return (outnvl);
switch (vec) {
case ZFS_IOC_SPACE_SNAPS:
(void) nvlist_lookup_uint64(outnvl, "used", &zc->zc_cookie);
(void) nvlist_lookup_uint64(outnvl, "compressed",
&zc->zc_objset_type);
(void) nvlist_lookup_uint64(outnvl, "uncompressed",
&zc->zc_perm_action);
nvlist_free(outnvl);
/* return empty outnvl */
tmpnvl = fnvlist_alloc();
return (tmpnvl);
break;
case ZFS_IOC_CREATE:
case ZFS_IOC_CLONE:
case ZFS_IOC_HOLD:
case ZFS_IOC_RELEASE:
nvlist_free(outnvl);
/* return empty outnvl */
tmpnvl = fnvlist_alloc();
return (tmpnvl);
break;
}
return (outnvl);
}
#endif /* KERNEL */

View File

@ -184,6 +184,12 @@ find_shares_object(differ_info_t *di)
return (0);
}
int
zfs_destroy_snaps_nvl_os(libzfs_handle_t *hdl, nvlist_t *snaps)
{
return (0);
}
/*
* Fill given version buffer with zfs kernel version read from ZFS_SYSFS_DIR
* Returns 0 on success, and -1 on error (with errno set)

View File

@ -11,11 +11,27 @@ include $(top_srcdir)/config/Abigail.am
USER_C = \
libzfs_core.c
if BUILD_LINUX
USER_C += \
os/linux/libzfs_core_ioctl.c
endif
if BUILD_FREEBSD
DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/freebsd/zfs
USER_C += \
os/freebsd/libzfs_core_ioctl.c
VPATH += $(top_srcdir)/module/os/freebsd/zfs
nodist_libzfs_core_la_SOURCES = zfs_ioctl_compat.c
endif
libzfs_core_la_SOURCES = $(USER_C)
libzfs_core_la_LIBADD = \
$(abs_top_builddir)/lib/libzutil/libzutil.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libspl/libspl.la
libzfs_core_la_LIBADD += $(LTLIBINTL)

File diff suppressed because it is too large Load Diff

View File

@ -209,7 +209,7 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name,
}
}
while (zfs_ioctl_fd(g_fd, ioc, &zc) != 0) {
while (lzc_ioctl_fd(g_fd, ioc, &zc) != 0) {
/*
* If ioctl exited with ENOMEM, we retry the ioctl after
* increasing the size of the destination nvlist.
@ -298,7 +298,7 @@ lzc_promote(const char *fsname, char *snapnamebuf, int snapnamelen)
VERIFY3S(g_fd, !=, -1);
(void) strlcpy(zc.zc_name, fsname, sizeof (zc.zc_name));
if (zfs_ioctl_fd(g_fd, ZFS_IOC_PROMOTE, &zc) != 0) {
if (lzc_ioctl_fd(g_fd, ZFS_IOC_PROMOTE, &zc) != 0) {
int error = errno;
if (error == EEXIST && snapnamebuf != NULL)
(void) strlcpy(snapnamebuf, zc.zc_string, snapnamelen);
@ -317,7 +317,7 @@ lzc_rename(const char *source, const char *target)
VERIFY3S(g_fd, !=, -1);
(void) strlcpy(zc.zc_name, source, sizeof (zc.zc_name));
(void) strlcpy(zc.zc_value, target, sizeof (zc.zc_value));
error = zfs_ioctl_fd(g_fd, ZFS_IOC_RENAME, &zc);
error = lzc_ioctl_fd(g_fd, ZFS_IOC_RENAME, &zc);
if (error != 0)
error = errno;
return (error);
@ -468,7 +468,7 @@ lzc_exists(const char *dataset)
VERIFY3S(g_fd, !=, -1);
(void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
return (zfs_ioctl_fd(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0);
return (lzc_ioctl_fd(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0);
}
/*
@ -925,7 +925,7 @@ recv_impl(const char *snapname, nvlist_t *recvdprops, nvlist_t *localprops,
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)
malloc(zc.zc_nvlist_dst_size);
error = zfs_ioctl_fd(g_fd, ZFS_IOC_RECV, &zc);
error = lzc_ioctl_fd(g_fd, ZFS_IOC_RECV, &zc);
if (error != 0) {
error = errno;
} else {

View File

@ -23,9 +23,8 @@
#include <sys/sysctl.h>
#include <sys/zfs_ioctl.h>
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
#include <libzutil.h>
#include <err.h>
#include <libzfs_core.h>
int zfs_ioctl_version = ZFS_IOCVER_UNDEF;
@ -92,7 +91,7 @@ zcmd_ioctl_compat(int fd, int request, zfs_cmd_t *zc, const int cflag)
* error is returned zc_nvlist_dst_size won't be updated.
*/
int
zfs_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
lzc_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
{
size_t oldsize;
int ret, cflag = ZFS_CMD_COMPAT_NONE;

View File

@ -21,10 +21,10 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/zfs_ioctl.h>
#include <libzutil.h>
#include <libzfs_core.h>
int
zfs_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
lzc_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
{
return (ioctl(fd, request, zc));
}

View File

@ -214,9 +214,9 @@ nodist_libzpool_la_SOURCES = \
libzpool_la_LIBADD = \
$(abs_top_builddir)/lib/libicp/libicp.la \
$(abs_top_builddir)/lib/libunicode/libunicode.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libzstd/libzstd.la
$(abs_top_builddir)/lib/libzstd/libzstd.la \
$(abs_top_builddir)/lib/libzutil/libzutil.la
libzpool_la_LIBADD += $(LIBCLOCK_GETTIME) $(ZLIB_LIBS) -ldl -lm

View File

@ -245,39 +245,96 @@ refresh_config(void *unused, nvlist_t *tryconfig)
return (spa_tryimport(tryconfig));
}
#if defined(__FreeBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
static int
pool_active(void *unused, const char *name, uint64_t guid, boolean_t *isactive)
{
zfs_iocparm_t zp;
zfs_cmd_t *zc = NULL;
zfs_cmd_legacy_t *zcl = NULL;
unsigned long request;
int ret;
int fd = open(ZFS_DEV, O_RDWR | O_CLOEXEC);
if (fd < 0)
return (-1);
/*
* Use ZFS_IOC_POOL_STATS to check if the pool is active. We want to
* avoid adding a dependency on libzfs_core solely for this ioctl(),
* therefore we manually craft the stats command. Note that the command
* ID is identical between the openzfs and legacy ioctl() formats.
*/
int ver = ZFS_IOCVER_NONE;
size_t ver_size = sizeof (ver);
sysctlbyname("vfs.zfs.version.ioctl", &ver, &ver_size, NULL, 0);
switch (ver) {
case ZFS_IOCVER_OZFS:
zc = umem_zalloc(sizeof (zfs_cmd_t), UMEM_NOFAIL);
(void) strlcpy(zc->zc_name, name, sizeof (zc->zc_name));
zp.zfs_cmd = (uint64_t)(uintptr_t)zc;
zp.zfs_cmd_size = sizeof (zfs_cmd_t);
zp.zfs_ioctl_version = ZFS_IOCVER_OZFS;
request = _IOWR('Z', ZFS_IOC_POOL_STATS, zfs_iocparm_t);
ret = ioctl(fd, request, &zp);
free((void *)(uintptr_t)zc->zc_nvlist_dst);
umem_free(zc, sizeof (zfs_cmd_t));
break;
case ZFS_IOCVER_LEGACY:
zcl = umem_zalloc(sizeof (zfs_cmd_legacy_t), UMEM_NOFAIL);
(void) strlcpy(zcl->zc_name, name, sizeof (zcl->zc_name));
zp.zfs_cmd = (uint64_t)(uintptr_t)zcl;
zp.zfs_cmd_size = sizeof (zfs_cmd_legacy_t);
zp.zfs_ioctl_version = ZFS_IOCVER_LEGACY;
request = _IOWR('Z', ZFS_IOC_POOL_STATS, zfs_iocparm_t);
ret = ioctl(fd, request, &zp);
free((void *)(uintptr_t)zcl->zc_nvlist_dst);
umem_free(zcl, sizeof (zfs_cmd_legacy_t));
break;
default:
fprintf(stderr, "unrecognized zfs ioctl version %d", ver);
exit(1);
}
(void) close(fd);
*isactive = (ret == 0);
return (0);
}
#else
static int
pool_active(void *unused, const char *name, uint64_t guid,
boolean_t *isactive)
{
zfs_cmd_t *zcp;
nvlist_t *innvl;
char *packed = NULL;
size_t size = 0;
int fd, ret;
/*
* Use ZFS_IOC_POOL_SYNC to confirm if a pool is active
*/
fd = open(ZFS_DEV, O_RDWR | O_CLOEXEC);
int fd = open(ZFS_DEV, O_RDWR | O_CLOEXEC);
if (fd < 0)
return (-1);
zcp = umem_zalloc(sizeof (zfs_cmd_t), UMEM_NOFAIL);
innvl = fnvlist_alloc();
fnvlist_add_boolean_value(innvl, "force", B_FALSE);
/*
* Use ZFS_IOC_POOL_STATS to check if a pool is active.
*/
zfs_cmd_t *zcp = umem_zalloc(sizeof (zfs_cmd_t), UMEM_NOFAIL);
(void) strlcpy(zcp->zc_name, name, sizeof (zcp->zc_name));
packed = fnvlist_pack(innvl, &size);
zcp->zc_nvlist_src = (uint64_t)(uintptr_t)packed;
zcp->zc_nvlist_src_size = size;
ret = zfs_ioctl_fd(fd, ZFS_IOC_POOL_SYNC, zcp);
int ret = ioctl(fd, ZFS_IOC_POOL_STATS, zcp);
fnvlist_pack_free(packed, size);
free((void *)(uintptr_t)zcp->zc_nvlist_dst);
nvlist_free(innvl);
umem_free(zcp, sizeof (zfs_cmd_t));
(void) close(fd);
@ -286,6 +343,7 @@ pool_active(void *unused, const char *name, uint64_t guid,
return (0);
}
#endif
const pool_config_ops_t libzpool_config_ops = {
.pco_refresh_config = refresh_config,

View File

@ -19,21 +19,13 @@ USER_C = \
if BUILD_LINUX
USER_C += \
os/linux/zutil_device_path_os.c \
os/linux/zutil_import_os.c \
os/linux/zutil_compat.c
os/linux/zutil_import_os.c
endif
if BUILD_FREEBSD
DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/freebsd/zfs
USER_C += \
os/freebsd/zutil_device_path_os.c \
os/freebsd/zutil_import_os.c \
os/freebsd/zutil_compat.c
VPATH += $(top_srcdir)/module/os/freebsd/zfs
nodist_libzutil_la_SOURCES = zfs_ioctl_compat.c
os/freebsd/zutil_import_os.c
endif
libzutil_la_SOURCES = $(USER_C)

View File

@ -247,3 +247,8 @@ zfs_dev_flush(int fd __unused)
{
return (0);
}
void
update_vdevs_config_dev_sysfs_path(nvlist_t *config)
{
}

View File

@ -65,6 +65,7 @@
#include <thread_pool.h>
#include <libzutil.h>
#include <libnvpair.h>
#include <libzfs.h>
#include "zutil_import.h"
@ -757,6 +758,58 @@ no_dev:
#endif
}
/*
* Rescan the enclosure sysfs path for turning on enclosure LEDs and store it
* in the nvlist * (if applicable). Like:
* vdev_enc_sysfs_path: '/sys/class/enclosure/11:0:1:0/SLOT 4'
*/
static void
update_vdev_config_dev_sysfs_path(nvlist_t *nv, char *path)
{
char *upath, *spath;
/* Add enclosure sysfs path (if disk is in an enclosure). */
upath = zfs_get_underlying_path(path);
spath = zfs_get_enclosure_sysfs_path(upath);
if (spath) {
nvlist_add_string(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH, spath);
} else {
nvlist_remove_all(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH);
}
free(upath);
free(spath);
}
/*
* This will get called for each leaf vdev.
*/
static int
sysfs_path_pool_vdev_iter_f(void *hdl_data, nvlist_t *nv, void *data)
{
char *path = NULL;
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) != 0)
return (1);
/* Rescan our enclosure sysfs path for this vdev */
update_vdev_config_dev_sysfs_path(nv, path);
return (0);
}
/*
* Given an nvlist for our pool (with vdev tree), iterate over all the
* leaf vdevs and update their ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH.
*/
void
update_vdevs_config_dev_sysfs_path(nvlist_t *config)
{
nvlist_t *nvroot = NULL;
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) == 0);
for_each_vdev_in_nvlist(nvroot, sysfs_path_pool_vdev_iter_f, NULL);
}
/*
* Update a leaf vdev's persistent device strings
*
@ -783,7 +836,6 @@ update_vdev_config_dev_strs(nvlist_t *nv)
vdev_dev_strs_t vds;
char *env, *type, *path;
uint64_t wholedisk = 0;
char *upath, *spath;
/*
* For the benefit of legacy ZFS implementations, allow
@ -830,18 +882,7 @@ update_vdev_config_dev_strs(nvlist_t *nv)
(void) nvlist_add_string(nv, ZPOOL_CONFIG_PHYS_PATH,
vds.vds_devphys);
}
/* Add enclosure sysfs path (if disk is in an enclosure). */
upath = zfs_get_underlying_path(path);
spath = zfs_get_enclosure_sysfs_path(upath);
if (spath)
nvlist_add_string(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH,
spath);
else
nvlist_remove_all(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH);
free(upath);
free(spath);
update_vdev_config_dev_sysfs_path(nv, path);
} else {
/* Clear out any stale entries. */
(void) nvlist_remove_all(nv, ZPOOL_CONFIG_DEVID);

View File

@ -1705,6 +1705,8 @@ zpool_find_import_cached(libpc_handle_t *hdl, importargs_t *iarg)
return (NULL);
}
update_vdevs_config_dev_sysfs_path(src);
if ((dst = zutil_refresh_config(hdl, src)) == NULL) {
nvlist_free(raw);
nvlist_free(pools);
@ -1859,3 +1861,69 @@ zpool_find_config(void *hdl, const char *target, nvlist_t **configp,
return (0);
}
/*
* Internal function for iterating over the vdevs.
*
* For each vdev, func() will be called and will be passed 'zhp' (which is
* typically the zpool_handle_t cast as a void pointer), the vdev's nvlist, and
* a user-defined data pointer).
*
* The return values from all the func() calls will be OR'd together and
* returned.
*/
int
for_each_vdev_cb(void *zhp, nvlist_t *nv, pool_vdev_iter_f func,
void *data)
{
nvlist_t **child;
uint_t c, children;
int ret = 0;
int i;
char *type;
const char *list[] = {
ZPOOL_CONFIG_SPARES,
ZPOOL_CONFIG_L2CACHE,
ZPOOL_CONFIG_CHILDREN
};
for (i = 0; i < ARRAY_SIZE(list); i++) {
if (nvlist_lookup_nvlist_array(nv, list[i], &child,
&children) == 0) {
for (c = 0; c < children; c++) {
uint64_t ishole = 0;
(void) nvlist_lookup_uint64(child[c],
ZPOOL_CONFIG_IS_HOLE, &ishole);
if (ishole)
continue;
ret |= for_each_vdev_cb(zhp, child[c],
func, data);
}
}
}
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) != 0)
return (ret);
/* Don't run our function on root vdevs */
if (strcmp(type, VDEV_TYPE_ROOT) != 0) {
ret |= func(zhp, nv, data);
}
return (ret);
}
/*
* Given an ZPOOL_CONFIG_VDEV_TREE nvpair, iterate over all the vdevs, calling
* func() for each one. func() is passed the vdev's nvlist and an optional
* user-defined 'data' pointer.
*/
int
for_each_vdev_in_nvlist(nvlist_t *nvroot, pool_vdev_iter_f func, void *data)
{
return (for_each_vdev_cb(NULL, nvroot, func, data));
}

View File

@ -198,6 +198,9 @@ will not have their data recompressed on the receiver side using
.Fl o Sy compress Ns = Ar value .
The data will stay compressed as it was from the sender.
The new compression property will be set for future data.
Note that uncompressed data from the sender will still attempt to
compress on the receiver, unless you specify
.Fl o Sy compress Ns = Em off .
.It Fl w , -raw
For encrypted datasets, send data exactly as it exists on disk.
This allows backups to be taken even if encryption keys are not currently loaded.

View File

@ -545,7 +545,7 @@ access for a set of IP addresses and to enable root access for system
on the
.Ar tank/home
file system:
.Dl # Nm zfs Cm set Sy sharenfs Ns = Ns ' Ns Ar rw Ns =@123.123.0.0/16,root= Ns Ar neo Ns ' tank/home
.Dl # Nm zfs Cm set Sy sharenfs Ns = Ns ' Ns Ar rw Ns =@123.123.0.0/16:[::1],root= Ns Ar neo Ns ' tank/home
.Pp
If you are using DNS for host name resolution,
specify the fully-qualified hostname.

View File

@ -1,6 +1,7 @@
include Kbuild
INSTALL_MOD_DIR ?= extra
INSTALL_MOD_PATH ?= $(DESTDIR)
SUBDIR_TARGETS = icp lua zstd
@ -81,15 +82,15 @@ clean: clean-@ac_system@
modules_install-Linux:
@# Install the kernel modules
$(MAKE) -C @LINUX_OBJ@ M=`pwd` modules_install \
INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
KERNELRELEASE=@LINUX_VERSION@
@# Remove extraneous build products when packaging
kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
if [ -n "$(DESTDIR)" ]; then \
find $$kmoddir -name 'modules.*' | xargs $(RM); \
fi
sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
sysmap=$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
if [ -f $$sysmap ]; then \
depmod -ae -F $$sysmap @LINUX_VERSION@; \
fi
@ -102,7 +103,7 @@ modules_install: modules_install-@ac_system@
modules_uninstall-Linux:
@# Uninstall the kernel modules
kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
for objdir in $(ZFS_MODULES); do \
$(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \
done

View File

@ -250,6 +250,7 @@ abd_alloc_zero_scatter(void)
n = abd_chunkcnt_for_bytes(SPA_MAXBLOCKSIZE);
abd_zero_buf = kmem_cache_alloc(abd_chunk_cache, KM_PUSHPAGE);
bzero(abd_zero_buf, PAGE_SIZE);
abd_zero_scatter = abd_alloc_struct(SPA_MAXBLOCKSIZE);
abd_zero_scatter->abd_flags |= ABD_FLAG_OWNER | ABD_FLAG_ZEROS;

View File

@ -78,25 +78,6 @@ __FBSDID("$FreeBSD$");
#define dmu_page_unlock(m)
#endif
static int
dmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset,
uint64_t length, int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp)
{
dnode_t *dn;
int err;
err = dnode_hold(os, object, FTAG, &dn);
if (err)
return (err);
err = dmu_buf_hold_array_by_dnode(dn, offset, length, read, tag,
numbufsp, dbpp, DMU_READ_PREFETCH);
dnode_rele(dn, FTAG);
return (err);
}
int
dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
vm_page_t *ma, dmu_tx_t *tx)

View File

@ -3775,8 +3775,13 @@ arc_hdr_destroy(arc_buf_hdr_t *hdr)
* to acquire the l2ad_mtx. If that happens, we don't
* want to re-destroy the header's L2 portion.
*/
if (HDR_HAS_L2HDR(hdr))
if (HDR_HAS_L2HDR(hdr)) {
if (!HDR_EMPTY(hdr))
buf_discard_identity(hdr);
arc_hdr_l2hdr_destroy(hdr);
}
if (!buflist_held)
mutex_exit(&dev->l2ad_mtx);

View File

@ -613,7 +613,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
return (0);
}
static int
int
dmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset,
uint64_t length, int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp)
{
@ -968,9 +968,7 @@ dmu_free_long_object(objset_t *os, uint64_t object)
dmu_tx_mark_netfree(tx);
err = dmu_tx_assign(tx, TXG_WAIT);
if (err == 0) {
if (err == 0)
err = dmu_object_free(os, object, tx);
err = dmu_object_free(os, object, tx);
dmu_tx_commit(tx);
} else {
dmu_tx_abort(tx);

View File

@ -488,7 +488,8 @@ dmu_zfetch_run(zstream_t *zs, boolean_t missed, boolean_t have_lock)
issued = pf_end - pf_start + ipf_end - ipf_start;
if (issued > 1) {
/* More references on top of taken in dmu_zfetch_prepare(). */
zfs_refcount_add_many(&zs->zs_refs, issued - 1, NULL);
for (int i = 0; i < issued - 1; i++)
zfs_refcount_add(&zs->zs_refs, NULL);
} else if (issued == 0) {
/* Some other thread has done our work, so drop the ref. */
if (zfs_refcount_remove(&zs->zs_refs, NULL) == 0)

View File

@ -2037,10 +2037,40 @@ dnode_set_dirtyctx(dnode_t *dn, dmu_tx_t *tx, void *tag)
}
}
static void
dnode_partial_zero(dnode_t *dn, uint64_t off, uint64_t blkoff, uint64_t len,
dmu_tx_t *tx)
{
dmu_buf_impl_t *db;
int res;
rw_enter(&dn->dn_struct_rwlock, RW_READER);
res = dbuf_hold_impl(dn, 0, dbuf_whichblock(dn, 0, off), TRUE, FALSE,
FTAG, &db);
rw_exit(&dn->dn_struct_rwlock);
if (res == 0) {
db_lock_type_t dblt;
boolean_t dirty;
dblt = dmu_buf_lock_parent(db, RW_READER, FTAG);
/* don't dirty if not on disk and not dirty */
dirty = !list_is_empty(&db->db_dirty_records) ||
(db->db_blkptr && !BP_IS_HOLE(db->db_blkptr));
dmu_buf_unlock_parent(db, dblt, FTAG);
if (dirty) {
caddr_t data;
dmu_buf_will_dirty(&db->db, tx);
data = db->db.db_data;
bzero(data + blkoff, len);
}
dbuf_rele(db, FTAG);
}
}
void
dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx)
{
dmu_buf_impl_t *db;
uint64_t blkoff, blkid, nblks;
int blksz, blkshift, head, tail;
int trunc = FALSE;
@ -2089,31 +2119,10 @@ dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx)
}
/* zero out any partial block data at the start of the range */
if (head) {
int res;
ASSERT3U(blkoff + head, ==, blksz);
if (len < head)
head = len;
rw_enter(&dn->dn_struct_rwlock, RW_READER);
res = dbuf_hold_impl(dn, 0, dbuf_whichblock(dn, 0, off),
TRUE, FALSE, FTAG, &db);
rw_exit(&dn->dn_struct_rwlock);
if (res == 0) {
caddr_t data;
boolean_t dirty;
db_lock_type_t dblt = dmu_buf_lock_parent(db, RW_READER,
FTAG);
/* don't dirty if it isn't on disk and isn't dirty */
dirty = !list_is_empty(&db->db_dirty_records) ||
(db->db_blkptr && !BP_IS_HOLE(db->db_blkptr));
dmu_buf_unlock_parent(db, dblt, FTAG);
if (dirty) {
dmu_buf_will_dirty(&db->db, tx);
data = db->db.db_data;
bzero(data + blkoff, head);
}
dbuf_rele(db, FTAG);
}
dnode_partial_zero(dn, off, blkoff, head, tx);
off += head;
len -= head;
}
@ -2135,27 +2144,9 @@ dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx)
ASSERT0(P2PHASE(off, blksz));
/* zero out any partial block data at the end of the range */
if (tail) {
int res;
if (len < tail)
tail = len;
rw_enter(&dn->dn_struct_rwlock, RW_READER);
res = dbuf_hold_impl(dn, 0, dbuf_whichblock(dn, 0, off+len),
TRUE, FALSE, FTAG, &db);
rw_exit(&dn->dn_struct_rwlock);
if (res == 0) {
boolean_t dirty;
/* don't dirty if not on disk and not dirty */
db_lock_type_t type = dmu_buf_lock_parent(db, RW_READER,
FTAG);
dirty = !list_is_empty(&db->db_dirty_records) ||
(db->db_blkptr && !BP_IS_HOLE(db->db_blkptr));
dmu_buf_unlock_parent(db, type, FTAG);
if (dirty) {
dmu_buf_will_dirty(&db->db, tx);
bzero(db->db.db_data, tail);
}
dbuf_rele(db, FTAG);
}
dnode_partial_zero(dn, off + len, 0, tail, tx);
len -= tail;
}

View File

@ -318,6 +318,14 @@ zfs_refcount_not_held(zfs_refcount_t *rc, const void *holder)
return (B_TRUE);
}
EXPORT_SYMBOL(zfs_refcount_create);
EXPORT_SYMBOL(zfs_refcount_destroy);
EXPORT_SYMBOL(zfs_refcount_is_zero);
EXPORT_SYMBOL(zfs_refcount_count);
EXPORT_SYMBOL(zfs_refcount_add);
EXPORT_SYMBOL(zfs_refcount_remove);
EXPORT_SYMBOL(zfs_refcount_held);
/* BEGIN CSTYLED */
ZFS_MODULE_PARAM(zfs, ,reference_tracking_enable, INT, ZMOD_RW,
"Track reference holders to refcount_t objects");

View File

@ -2373,6 +2373,7 @@ vdev_validate(vdev_t *vd)
static void
vdev_copy_path_impl(vdev_t *svd, vdev_t *dvd)
{
char *old, *new;
if (svd->vdev_path != NULL && dvd->vdev_path != NULL) {
if (strcmp(svd->vdev_path, dvd->vdev_path) != 0) {
zfs_dbgmsg("vdev_copy_path: vdev %llu: path changed "
@ -2386,6 +2387,29 @@ vdev_copy_path_impl(vdev_t *svd, vdev_t *dvd)
zfs_dbgmsg("vdev_copy_path: vdev %llu: path set to '%s'",
(u_longlong_t)dvd->vdev_guid, dvd->vdev_path);
}
/*
* Our enclosure sysfs path may have changed between imports
*/
old = dvd->vdev_enc_sysfs_path;
new = svd->vdev_enc_sysfs_path;
if ((old != NULL && new == NULL) ||
(old == NULL && new != NULL) ||
((old != NULL && new != NULL) && strcmp(new, old) != 0)) {
zfs_dbgmsg("vdev_copy_path: vdev %llu: vdev_enc_sysfs_path "
"changed from '%s' to '%s'", (u_longlong_t)dvd->vdev_guid,
old, new);
if (dvd->vdev_enc_sysfs_path)
spa_strfree(dvd->vdev_enc_sysfs_path);
if (svd->vdev_enc_sysfs_path) {
dvd->vdev_enc_sysfs_path = spa_strdup(
svd->vdev_enc_sysfs_path);
} else {
dvd->vdev_enc_sysfs_path = NULL;
}
}
}
/*

View File

@ -254,6 +254,7 @@ zfs_read(struct znode *zp, zfs_uio_t *uio, int ioflag, cred_t *cr)
}
ASSERT(zfs_uio_offset(uio) < zp->z_size);
ssize_t start_offset = zfs_uio_offset(uio);
ssize_t n = MIN(zfs_uio_resid(uio), zp->z_size - zfs_uio_offset(uio));
ssize_t start_resid = n;
@ -276,6 +277,13 @@ zfs_read(struct znode *zp, zfs_uio_t *uio, int ioflag, cred_t *cr)
/* convert checksum errors into IO errors */
if (error == ECKSUM)
error = SET_ERROR(EIO);
/*
* if we actually read some bytes, bubbling EFAULT
* up to become EAGAIN isn't what we want here.
*/
if (error == EFAULT &&
(zfs_uio_offset(uio) - start_offset) != 0)
error = 0;
break;
}

View File

@ -53,7 +53,7 @@ tags = ['functional', 'cli_root', 'zfs_mount']
[tests/functional/cli_root/zfs_share:Linux]
tests = ['zfs_share_005_pos', 'zfs_share_007_neg', 'zfs_share_009_neg',
'zfs_share_012_pos']
'zfs_share_012_pos', 'zfs_share_013_pos']
tags = ['functional', 'cli_root', 'zfs_share']
[tests/functional/cli_root/zfs_sysfs:Linux]

View File

@ -414,7 +414,7 @@ user =
tags = ['functional', 'cli_user', 'zpool_list']
[tests/functional/compression]
tests = ['compress_003_pos']
tests = ['compress_003_pos','compress_zstd_bswap']
tags = ['functional', 'compression']
[tests/functional/exec]

View File

@ -283,7 +283,8 @@ if sys.platform.startswith('freebsd'):
'delegate/zfs_allow_003_pos': ['FAIL', known_reason],
'inheritance/inherit_001_pos': ['FAIL', '11829'],
'resilver/resilver_restart_001': ['FAIL', known_reason],
'zvol/zvol_misc/zvol_misc_volmode': ['FAIL', known_reason],
'pool_checkpoint/checkpoint_big_rewind': ['FAIL', '12622'],
'pool_checkpoint/checkpoint_indirect': ['FAIL', '12623'],
})
elif sys.platform.startswith('linux'):
maybe.update({
@ -308,6 +309,7 @@ elif sys.platform.startswith('linux'):
'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'],
})

View File

@ -68,6 +68,16 @@ function log_must
(( $? != 0 )) && log_fail
}
# Execute a positive test (expecting no stderr) and exit $STF_FAIL
# if test fails
# $@ - command to execute
function log_must_nostderr
{
log_pos_nostderr "$@"
(( $? != 0 )) && log_fail
}
# Execute a positive test but retry the command on failure if the output
# matches an expected pattern. Otherwise behave like log_must and exit
# $STF_FAIL is test fails.
@ -292,6 +302,46 @@ function log_pos
return $status
}
# Execute and print command with status where success equals zero result
# and no stderr output
#
# $@ command to execute
#
# return 0 if command succeeds and no stderr output
# return 1 othersie
function log_pos_nostderr
{
typeset out=""
typeset logfile="/tmp/log.$$"
while [[ -e $logfile ]]; do
logfile="$logfile.$$"
done
"$@" 2>$logfile
typeset status=$?
out="cat $logfile"
typeset out_msg=$($out)
if (( $status != 0 )) ; then
print -u2 $out_msg
_printerror "$@" "exited $status"
else
if [[ ! -z "$out_msg" ]]; then
print -u2 $out_msg
_printerror "$@" "message in stderr" \
" exited $status"
status=1
else
[[ -n $LOGAPI_DEBUG ]] && cat $logfile
_printsuccess "$@"
fi
fi
_recursive_output $logfile "false"
return $status
}
# Set an exit handler
#
# $@ - function(s) to perform on exit

View File

@ -159,7 +159,7 @@ lzc_ioctl_run(zfs_ioc_t ioc, const char *name, nvlist_t *innvl, int expected)
zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024);
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)malloc(zc.zc_nvlist_dst_size);
if (zfs_ioctl_fd(zfs_fd, ioc, &zc) != 0)
if (lzc_ioctl_fd(zfs_fd, ioc, &zc) != 0)
error = errno;
if (error != expected) {
@ -692,7 +692,7 @@ zfs_destroy(const char *dataset)
(void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
zc.zc_name[sizeof (zc.zc_name) - 1] = '\0';
err = zfs_ioctl_fd(zfs_fd, ZFS_IOC_DESTROY, &zc);
err = lzc_ioctl_fd(zfs_fd, ZFS_IOC_DESTROY, &zc);
return (err == 0 ? 0 : errno);
}
@ -900,7 +900,7 @@ zfs_ioc_input_tests(const char *pool)
if (ioc_tested[cmd])
continue;
if (zfs_ioctl_fd(zfs_fd, ioc, &zc) != 0 &&
if (lzc_ioctl_fd(zfs_fd, ioc, &zc) != 0 &&
errno != ZFS_ERR_IOC_CMD_UNAVAIL) {
(void) fprintf(stderr, "cmd %d is missing a test case "
"(%d)\n", cmd, errno);

View File

@ -4,5 +4,3 @@ pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin
pkgexec_PROGRAMS = mkbusy
mkbusy_SOURCES = mkbusy.c
mkbusy_LDADD = $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la

View File

@ -29,7 +29,6 @@
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <libzutil.h>
static __attribute__((noreturn)) void
@ -64,6 +63,21 @@ daemonize(void)
(void) close(2);
}
static const char *
get_basename(const char *path)
{
const char *bn = strrchr(path, '/');
return (bn ? bn + 1 : path);
}
static ssize_t
get_dirnamelen(const char *path)
{
const char *end = strrchr(path, '/');
return (end ? end - path : -1);
}
int
main(int argc, char *argv[])
{
@ -103,9 +117,9 @@ main(int argc, char *argv[])
arg[arglen - 1] = '\0';
/* Get the directory and file names. */
fname = zfs_basename(arg);
fname = get_basename(arg);
dname = arg;
if ((dnamelen = zfs_dirnamelen(arg)) != -1)
if ((dnamelen = get_dirnamelen(arg)) != -1)
arg[dnamelen] = '\0';
else
dname = ".";

View File

@ -73,7 +73,7 @@ function scan_scsi_hosts
function block_device_wait
{
if is_linux; then
udevadm trigger $*
udevadm trigger $* 2>/dev/null
typeset start=$SECONDS
udevadm settle
typeset elapsed=$((SECONDS - start))

View File

@ -14,6 +14,7 @@ dist_pkgdata_SCRIPTS = \
zfs_share_010_neg.ksh \
zfs_share_011_pos.ksh \
zfs_share_012_pos.ksh \
zfs_share_013_pos.ksh \
zfs_share_concurrent_shares.ksh
dist_pkgdata_DATA = \

View File

@ -51,7 +51,7 @@ function cleanup {
set -A badopts \
"r0" "r0=machine1" "r0=machine1:machine2" \
"-g" "-b" "-c" "-d" "--invalid" \
"-g" "-b" "-c" "-d" "--invalid" "rw=[::1]a:[::2]" "rw=[::1" \
"$TESTPOOL" "$TESTPOOL/$TESTFS" "$TESTPOOL\$TESTCTR\$TESTFS1"
log_assert "Verify that invalid share parameters and options are caught."

View File

@ -0,0 +1,80 @@
#!/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 (c) 2020, Felix Dörre
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Verify that NFS share options including ipv6 literals are parsed and propagated correctly.
#
verify_runnable "global"
function cleanup
{
log_must zfs set sharenfs=off $TESTPOOL/$TESTFS
is_shared $TESTPOOL/$TESTFS && \
log_must unshare_fs $TESTPOOL/$TESTFS
}
log_onexit cleanup
cleanup
log_must zfs set sharenfs="rw=[::1]" $TESTPOOL/$TESTFS
output=$(showshares_nfs 2>&1)
log_must grep "::1(" <<< "$output" > /dev/null
log_must zfs set sharenfs="rw=[2::3]" $TESTPOOL/$TESTFS
output=$(showshares_nfs 2>&1)
log_must grep "2::3(" <<< "$output" > /dev/null
log_must zfs set sharenfs="rw=[::1]:[2::3]" $TESTPOOL/$TESTFS
output=$(showshares_nfs 2>&1)
log_must grep "::1(" <<< "$output" > /dev/null
log_must grep "2::3(" <<< "$output" > /dev/null
log_must zfs set sharenfs="rw=[::1]/64" $TESTPOOL/$TESTFS
output=$(showshares_nfs 2>&1)
log_must grep "::1/64(" <<< "$output" > /dev/null
log_must zfs set sharenfs="rw=[2::3]/128" $TESTPOOL/$TESTFS
output=$(showshares_nfs 2>&1)
log_must grep "2::3/128(" <<< "$output" > /dev/null
log_must zfs set sharenfs="rw=[::1]/32:[2::3]/128" $TESTPOOL/$TESTFS
output=$(showshares_nfs 2>&1)
log_must grep "::1/32(" <<< "$output" > /dev/null
log_must grep "2::3/128(" <<< "$output" > /dev/null
log_must zfs set sharenfs="rw=[::1]:[2::3]/64:[2a01:1234:1234:1234:aa34:234:1234:1234]:1.2.3.4/24" $TESTPOOL/$TESTFS
output=$(showshares_nfs 2>&1)
log_must grep "::1(" <<< "$output" > /dev/null
log_must grep "2::3/64(" <<< "$output" > /dev/null
log_must grep "2a01:1234:1234:1234:aa34:234:1234:1234(" <<< "$output" > /dev/null
log_must grep "1\\.2\\.3\\.4/24(" <<< "$output" > /dev/null
log_pass "NFS share ip address propagated correctly."

View File

@ -83,7 +83,7 @@ for d in ${test_depths[@]}; do
log_must zfs snapshot $TESTPOOL/$ds@snap
# force snapshot mount in .zfs
log_must ls /$TESTPOOL/$ds/.zfs/snapshot/snap
log_must zfs unmount $TESTPOOL/$ds
log_must_nostderr zfs unmount $TESTPOOL/$ds
if ! ismounted $TESTPOOL/$ds_pre; then
log_fail "$ds_pre is not mounted"
@ -113,7 +113,7 @@ for d in ${test_depths[@]}; do
log_must zfs snapshot $TESTPOOL/$ds@snap
# force snapshot mount in .zfs
log_must ls /$TESTPOOL/$ds/.zfs/snapshot/snap
log_must zfs unmount $TESTPOOL/$ds
log_must_nostderr zfs unmount $TESTPOOL/$ds
if ! ismounted $TESTPOOL/$ds_pre; then
log_fail "$TESTPOOL/$ds_pre (pre) not mounted"
@ -143,7 +143,7 @@ for d in ${test_depths[@]}; do
log_must zfs snapshot $TESTPOOL/$ds@snap
# force snapshot mount in .zfs
log_must ls /$TESTPOOL/$ds/.zfs/snapshot/snap
log_must zfs unmount $TESTPOOL/$ds
log_must_nostderr zfs unmount $TESTPOOL/$ds
if ! ismounted $TESTPOOL/$ds_pre; then
log_fail "$TESTPOOL/$ds_pre (pre) not mounted"
@ -173,7 +173,7 @@ for d in ${test_depths[@]}; do
log_must zfs snapshot $TESTPOOL/$ds@snap
# force snapshot mount in .zfs
log_must ls /$TESTPOOL/$ds/.zfs/snapshot/snap
log_must zfs unmount $TESTPOOL/$ds
log_must_nostderr zfs unmount $TESTPOOL/$ds
if ! ismounted $TESTPOOL/$ds_pre; then
log_fail "$ds_pre is not mounted"

View File

@ -6,10 +6,12 @@ dist_pkgdata_SCRIPTS = \
compress_002_pos.ksh \
compress_003_pos.ksh \
compress_004_pos.ksh \
compress_zstd_bswap.ksh \
l2arc_compressed_arc.ksh \
l2arc_compressed_arc_disabled.ksh \
l2arc_encrypted.ksh \
l2arc_encrypted_no_compressed_arc.ksh
dist_pkgdata_DATA = \
compress.cfg
compress.cfg \
testpool_zstd.tar.gz

View File

@ -0,0 +1,55 @@
#!/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 (c) 2007, Sun Microsystems Inc. All rights reserved.
# Copyright (c) 2021, Rich Ercolani.
# Use is subject to license terms.
#
. $STF_SUITE/include/properties.shlib
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Import a pool containing variously-permuted zstd-compressed files,
# then try to copy them out.
typeset TESTPOOL_ZSTD_FILE=$STF_SUITE/tests/functional/compression/testpool_zstd.tar.gz
verify_runnable "both"
function cleanup
{
destroy_pool testpool_zstd
rm -f $TEST_BASE_DIR/testpool_zstd
}
log_assert "Trying to read data from variously mangled zstd datasets"
log_onexit cleanup
log_must tar --directory $TEST_BASE_DIR -xzSf $TESTPOOL_ZSTD_FILE
log_must zpool import -d $TEST_BASE_DIR testpool_zstd
log_must dd if=/testpool_zstd/x86_64/zstd of=/dev/null
log_must dd if=/testpool_zstd/ppc64_fbsd/zstd of=/dev/null
log_pass "Reading from mangled zstd datasets works as expected."

View File

@ -11,5 +11,3 @@ pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/ctime
pkgexec_PROGRAMS = ctime
ctime_SOURCES = ctime.c
ctime_LDADD = $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la

View File

@ -37,7 +37,6 @@
#include <utime.h>
#include <stdio.h>
#include <stdlib.h>
#include <libzutil.h>
#include <unistd.h>
#include <strings.h>
#include <errno.h>
@ -98,6 +97,13 @@ get_file_time(const char *pfile, int what, time_t *ptr)
}
}
static ssize_t
get_dirnamelen(const char *path)
{
const char *end = strrchr(path, '/');
return (end ? end - path : -1);
}
static int
do_read(const char *pfile)
{
@ -161,7 +167,7 @@ do_link(const char *pfile)
* the link file in the same directory.
*/
(void) snprintf(link_file, sizeof (link_file),
"%.*s/%s", (int)zfs_dirnamelen(pfile), pfile, "link_file");
"%.*s/%s", (int)get_dirnamelen(pfile), pfile, "link_file");
if (link(pfile, link_file) == -1) {
(void) fprintf(stderr, "link(%s, %s) failed with errno %d\n",

View File

@ -80,10 +80,10 @@ else
fi
log_must zpool events
# Verify at least 5 deadman events were logged. The first after 5 seconds,
# Verify at least 4 deadman events were logged. The first after 5 seconds,
# and another each second thereafter until the delay is clearer.
events=$(zpool events | grep -c ereport.fs.zfs.deadman)
if [ "$events" -lt 5 ]; then
if [ "$events" -lt 4 ]; then
log_fail "Expect >=5 deadman events, $events found"
fi

View File

@ -24,10 +24,22 @@
#
# Strategy:
# 1. Perform a zfs incremental send from a bookmark that doesn't exist
# 2. Perform a zfs incremental replication send with incremental source
# same as target (#11121)
#
verify_runnable "both"
log_neg eval "zfs send -i \#bla $POOl/$FS@final > /dev/null"
function cleanup
{
rm -f $TEST_BASE_DIR/devnull
}
log_onexit cleanup
log_mustnot eval "zfs send -i \#bla $POOl/$FS@final > $TEST_BASE_DIR/devnull"
log_must eval "zfs send -R -i snapA $POOL/vol@snapA 2>&1 " \
"> $TEST_BASE_DIR/devnull | grep -q WARNING"
log_pass "Ensure that error conditions cause appropriate failures."

View File

@ -37,8 +37,6 @@
#
function udev_wait
{
sleep 1
is_linux || return 0
udevadm trigger --action=change
udevadm settle
for i in {1..3}; do
@ -58,7 +56,6 @@ function udev_wait
#
function udev_cleanup
{
is_linux || return 0
log_note "Pruning broken ZVOL symlinks ..."
udevadm settle
@ -79,7 +76,8 @@ function blockdev_exists # device
# because there are other commands (zfs snap, zfs inherit, zfs destroy)
# that can affect device nodes
for i in {1..3}; do
udev_wait
is_linux && udev_wait
block_device_wait "$device"
is_disk_device "$device" && return 0
done
log_fail "$device does not exist as a block device"
@ -96,8 +94,9 @@ function blockdev_missing # device
# because there are other commands (zfs snap, zfs inherit, zfs destroy)
# that can affect device nodes
for i in {1..3}; do
udev_wait
[[ ! -e "$device" ]] && return 0
is_linux && udev_wait
block_device_wait
is_disk_device "$device" || return 0
done
log_fail "$device exists when not expected"
}

View File

@ -39,7 +39,7 @@ function cleanup
for ds in "$SENDFS" "$ZVOL" "$ZVOL-renamed"; do
destroy_dataset "$ds" '-rf'
done
udev_wait
block_device_wait
}
log_assert "Verify 'zfs rename' works on a ZVOL already in use as block device"
@ -54,7 +54,7 @@ SENDFS="$TESTPOOL/sendfs.$$"
log_must zfs create -V $VOLSIZE "$ZVOL"
# 2. Create a filesystem on the ZVOL device and mount it
udev_wait
block_device_wait "$ZDEV"
log_must eval "new_fs $ZDEV >/dev/null 2>&1"
log_must mkdir "$MNTPFS"
log_must mount "$ZDEV" "$MNTPFS"

View File

@ -47,7 +47,7 @@ function cleanup
datasetexists $ZVOL && log_must zfs destroy -r $ZVOL
log_must zfs inherit snapdev $TESTPOOL
block_device_wait
udev_cleanup
is_linux && udev_cleanup
}
log_assert "Verify that ZFS volume property 'snapdev' works as expected."

View File

@ -44,19 +44,18 @@
# 8. Verify "volmode" behaves accordingly to zvol_inhibit_dev (Linux only)
#
# NOTE: changing volmode may need to remove minors, which could be open, so call
# udev_wait() before we "zfs set volmode=<value>".
# block_device_wait() before we "zfs set volmode=<value>".
verify_runnable "global"
function cleanup
{
datasetexists $VOLFS && log_must_busy zfs destroy -r $VOLFS
datasetexists $ZVOL && log_must_busy zfs destroy -r $ZVOL
log_must zfs inherit volmode $TESTPOOL
udev_wait
datasetexists $VOLFS && destroy_dataset $VOLFS -r
datasetexists $ZVOL && destroy_dataset $ZVOL -r
zfs inherit volmode $TESTPOOL
sysctl_inhibit_dev 0
sysctl_volmode 1
udev_cleanup
is_linux && udev_cleanup
}
#
@ -90,8 +89,8 @@ function test_io # dev
{
typeset dev=$1
log_must dd if=/dev/zero of=$dev count=1
log_must dd if=$dev of=/dev/null count=1
log_must dd if=/dev/zero of=$dev count=1
}
log_assert "Verify that ZFS volume property 'volmode' works as intended"
@ -99,14 +98,14 @@ log_onexit cleanup
VOLFS="$TESTPOOL/volfs"
ZVOL="$TESTPOOL/vol"
ZDEV="${ZVOL_DEVDIR}/$ZVOL"
ZDEV="$ZVOL_DEVDIR/$ZVOL"
SUBZVOL="$VOLFS/subvol"
SUBZDEV="${ZVOL_DEVDIR}/$SUBZVOL"
SUBZDEV="$ZVOL_DEVDIR/$SUBZVOL"
# 0. Verify basic ZVOL functionality
log_must zfs create -o mountpoint=none $VOLFS
log_must zfs create -V $VOLSIZE -s $SUBZVOL
log_must zfs create -V $VOLSIZE -s $ZVOL
udev_wait
blockdev_exists $ZDEV
blockdev_exists $SUBZDEV
test_io $ZDEV
@ -123,62 +122,63 @@ done
log_must zfs set volmode=none $ZVOL
blockdev_missing $ZDEV
log_must_busy zfs destroy $ZVOL
blockdev_missing $ZDEV
# 3. Verify "volmode=full" exposes a fully functional device
log_must zfs create -V $VOLSIZE -s $ZVOL
udev_wait
blockdev_exists $ZDEV
log_must zfs set volmode=full $ZVOL
blockdev_exists $ZDEV
test_io $ZDEV
log_must verify_partition $ZDEV
udev_wait
# 3.1 Verify "volmode=geom" is an alias for "volmode=full"
log_must zfs set volmode=geom $ZVOL
blockdev_exists $ZDEV
if [[ "$(get_prop 'volmode' $ZVOL)" != "full" ]]; then
log_fail " Volmode value 'geom' is not an alias for 'full'"
fi
udev_wait
log_must_busy zfs destroy $ZVOL
blockdev_missing $ZDEV
# 4. Verify "volmode=dev" hides partition info on the device
log_must zfs create -V $VOLSIZE -s $ZVOL
udev_wait
blockdev_exists $ZDEV
log_must zfs set volmode=dev $ZVOL
blockdev_exists $ZDEV
test_io $ZDEV
log_mustnot verify_partition $ZDEV
udev_wait
log_must_busy zfs destroy $ZVOL
blockdev_missing $ZDEV
# 5. Verify "volmode=default" behaves accordingly to "volmode" module parameter
# 5.1 Verify sysctl "volmode=full"
sysctl_volmode 1
log_must zfs create -V $VOLSIZE -s $ZVOL
udev_wait
blockdev_exists $ZDEV
log_must zfs set volmode=default $ZVOL
blockdev_exists $ZDEV
log_must verify_partition $ZDEV
udev_wait
log_must_busy zfs destroy $ZVOL
blockdev_missing $ZDEV
# 5.2 Verify sysctl "volmode=dev"
sysctl_volmode 2
log_must zfs create -V $VOLSIZE -s $ZVOL
udev_wait
blockdev_exists $ZDEV
log_must zfs set volmode=default $ZVOL
blockdev_exists $ZDEV
log_mustnot verify_partition $ZDEV
udev_wait
log_must_busy zfs destroy $ZVOL
blockdev_missing $ZDEV
# 5.2 Verify sysctl "volmode=none"
sysctl_volmode 3
log_must zfs create -V $VOLSIZE -s $ZVOL
udev_wait
blockdev_missing $ZDEV
log_must zfs set volmode=default $ZVOL
blockdev_missing $ZDEV
# 6. Verify "volmode" property is inherited correctly
log_must zfs inherit volmode $ZVOL
blockdev_missing $ZDEV
# 6.1 Check volmode=full case
log_must zfs set volmode=full $TESTPOOL
verify_inherited 'volmode' 'full' $ZVOL $TESTPOOL
@ -198,9 +198,7 @@ verify_inherited 'volmode' 'default' $ZVOL $TESTPOOL
blockdev_exists $ZDEV
# 6.5 Check inheritance on multiple levels
log_must zfs inherit volmode $SUBZVOL
udev_wait
log_must zfs set volmode=none $VOLFS
udev_wait
log_must zfs set volmode=full $TESTPOOL
verify_inherited 'volmode' 'none' $SUBZVOL $VOLFS
blockdev_missing $SUBZDEV
@ -215,6 +213,8 @@ blockdev_exists $ZDEV
blockdev_missing $SUBZDEV
log_must_busy zfs destroy $ZVOL
log_must_busy zfs destroy $SUBZVOL
blockdev_missing $ZDEV
blockdev_missing $SUBZDEV
# 8. Verify "volmode" behaves accordingly to zvol_inhibit_dev (Linux only)
if is_linux; then
@ -226,6 +226,7 @@ if is_linux; then
log_must zfs set volmode=full $ZVOL
blockdev_missing $ZDEV
log_must_busy zfs destroy $ZVOL
blockdev_missing $ZDEV
# 7.1 Verify device nodes not are not created with "volmode=dev"
sysctl_volmode 2
log_must zfs create -V $VOLSIZE -s $ZVOL
@ -233,6 +234,7 @@ if is_linux; then
log_must zfs set volmode=dev $ZVOL
blockdev_missing $ZDEV
log_must_busy zfs destroy $ZVOL
blockdev_missing $ZDEV
# 7.1 Verify device nodes not are not created with "volmode=none"
sysctl_volmode 3
log_must zfs create -V $VOLSIZE -s $ZVOL

View File

@ -42,8 +42,8 @@ verify_runnable "global"
function cleanup
{
datasetexists $ZVOL && log_must_busy zfs destroy $ZVOL
udev_wait
datasetexists $ZVOL && destroy_dataset $ZVOL
block_device_wait
}
log_assert "Verify ZIL functionality on ZVOLs"

View File

@ -21,7 +21,6 @@ export PERF_RUNTIME=${PERF_RUNTIME:-'180'}
export PERF_RANDSEED=${PERF_RANDSEED:-'1234'}
export PERF_COMPPERCENT=${PERF_COMPPERCENT:-'66'}
export PERF_COMPCHUNK=${PERF_COMPCHUNK:-'4096'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'1'}
# Default to JSON for fio output
export PERF_FIO_FORMAT=${PERF_FIO_FORMAT:-'json'}

View File

@ -59,6 +59,7 @@ export TOTAL_SIZE=$(($(get_prop avail $PERFPOOL) * 3 / 2))
export PERF_NTHREADS=${PERF_NTHREADS:-'16 32'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
export PERF_IOSIZES=${PERF_IOSIZES:-'8k'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'1'}
# Layout the files to be used by the read tests. Create as many files as the
# largest number of threads. An fio run with fewer threads will use a subset

View File

@ -59,6 +59,7 @@ export TOTAL_SIZE=$(($(get_prop avail $PERFPOOL) * 3 / 2))
export PERF_NTHREADS=${PERF_NTHREADS:-'32 64'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
export PERF_IOSIZES='' # bssplit used instead
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'1'}
# Layout the files to be used by the readwrite tests. Create as many files
# as the largest number of threads. An fio run with fewer threads will use

View File

@ -49,6 +49,7 @@ export TOTAL_SIZE=$(($(get_prop avail $PERFPOOL) * 3 / 2))
export PERF_NTHREADS=${PERF_NTHREADS:-'64 128'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
export PERF_IOSIZES=${PERF_IOSIZES:-'8k'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'0 1'}
# Layout the files to be used by the readwrite tests. Create as many files
# as the largest number of threads. An fio run with fewer threads will use

View File

@ -58,6 +58,7 @@ export TOTAL_SIZE=$(($(get_prop avail $PERFPOOL) * 3 / 2))
export PERF_NTHREADS=${PERF_NTHREADS:-'32 128'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
export PERF_IOSIZES=${PERF_IOSIZES:-'8k'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'0 1'}
# Set up the scripts and output files that will log performance data.
lun_list=$(pool_to_lun_list $PERFPOOL)

View File

@ -44,9 +44,10 @@ recreate_perf_pool
export TOTAL_SIZE=$(($(get_prop avail $PERFPOOL) * 3 / 2))
# Variables specific to this test for use by fio.
export PERF_NTHREADS=${PERF_NTHREADS:-'1 4 16 64'}
export PERF_NTHREADS=${PERF_NTHREADS:-'1 16 64'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0 1'}
export PERF_IOSIZES=${PERF_IOSIZES:-'8k'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'1'}
# Until the performance tests over NFS can deal with multiple file systems,
# force the use of only one file system when testing over NFS.

View File

@ -59,6 +59,7 @@ export TOTAL_SIZE=$(($(get_prop avail $PERFPOOL) * 3 / 2))
export PERF_NTHREADS=${PERF_NTHREADS:-'8 16'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
export PERF_IOSIZES=${PERF_IOSIZES:-'128k 1m'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'1'}
# Layout the files to be used by the read tests. Create as many files as the
# largest number of threads. An fio run with fewer threads will use a subset

View File

@ -48,7 +48,8 @@ export TOTAL_SIZE=$(($(get_max_arc_size) / 2))
# Variables specific to this test for use by fio.
export PERF_NTHREADS=${PERF_NTHREADS:-'64 128'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
export PERF_IOSIZES=${PERF_IOSIZES:-'128k 1m'}
export PERF_IOSIZES=${PERF_IOSIZES:-'128k'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'1'}
# Layout the files to be used by the read tests. Create as many files as the
# largest number of threads. An fio run with fewer threads will use a subset

View File

@ -54,7 +54,8 @@ export TOTAL_SIZE=$(($(get_max_arc_size) / 2))
# Variables specific to this test for use by fio.
export PERF_NTHREADS=${PERF_NTHREADS:-'64 128'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
export PERF_IOSIZES=${PERF_IOSIZES:-'128k 1m'}
export PERF_IOSIZES=${PERF_IOSIZES:-'128k'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'1'}
# Layout the files to be used by the read tests. Create as many files as the
# largest number of threads. An fio run with fewer threads will use a subset

View File

@ -53,6 +53,7 @@ export TOTAL_SIZE=$(($(get_dbuf_cache_size) * 3 / 4))
export PERF_NTHREADS=${PERF_NTHREADS:-'64'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
export PERF_IOSIZES=${PERF_IOSIZES:-'64k'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'1'}
# Layout the files to be used by the read tests. Create as many files as the
# largest number of threads. An fio run with fewer threads will use a subset

View File

@ -57,7 +57,8 @@ export TOTAL_SIZE=$(($(get_prop avail $PERFPOOL) * 3 / 2))
# Variables specific to this test for use by fio.
export PERF_NTHREADS=${PERF_NTHREADS:-'16 32'}
export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
export PERF_IOSIZES=${PERF_IOSIZES:-'8k 128k 1m'}
export PERF_IOSIZES=${PERF_IOSIZES:-'8k 1m'}
export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'0 1'}
# Set up the scripts and output files that will log performance data.
lun_list=$(pool_to_lun_list $PERFPOOL)

View File

@ -154,6 +154,9 @@
/* blk_queue_secure_erase() is available */
/* #undef HAVE_BLK_QUEUE_SECURE_ERASE */
/* blk_queue_update_readahead() exists */
/* #undef HAVE_BLK_QUEUE_UPDATE_READAHEAD */
/* blk_queue_write_cache() exists */
/* #undef HAVE_BLK_QUEUE_WRITE_CACHE */
@ -212,6 +215,9 @@
/* disk_*_io_acct() available */
/* #undef HAVE_DISK_IO_ACCT */
/* disk_update_readahead() exists */
/* #undef HAVE_DISK_UPDATE_READAHEAD */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
@ -272,6 +278,12 @@
/* Define if the GNU gettext() function is already present or preinstalled. */
/* #undef HAVE_GETTEXT */
/* iops->get_acl() exists */
/* #undef HAVE_GET_ACL */
/* iops->get_acl() takes rcu */
/* #undef HAVE_GET_ACL_RCU */
/* iops->get_link() cookie */
/* #undef HAVE_GET_LINK_COOKIE */
@ -589,6 +601,9 @@
/* STACK_FRAME_NON_STANDARD is defined */
/* #undef HAVE_STACK_FRAME_NON_STANDARD */
/* standalone <linux/stdarg.h> exists */
/* #undef HAVE_STANDALONE_LINUX_STDARG */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
@ -809,7 +824,7 @@
/* #undef ZFS_IS_GPL_COMPATIBLE */
/* Define the project alias string. */
#define ZFS_META_ALIAS "zfs-2.1.99-FreeBSD_g4a1195ca5"
#define ZFS_META_ALIAS "zfs-2.1.99-FreeBSD_gec64fdb93"
/* Define the project author. */
#define ZFS_META_AUTHOR "OpenZFS"
@ -818,7 +833,7 @@
/* #undef ZFS_META_DATA */
/* Define the maximum compatible kernel version. */
#define ZFS_META_KVER_MAX "5.13"
#define ZFS_META_KVER_MAX "5.14"
/* Define the minimum compatible kernel version. */
#define ZFS_META_KVER_MIN "3.10"
@ -839,7 +854,7 @@
#define ZFS_META_NAME "zfs"
/* Define the project release. */
#define ZFS_META_RELEASE "FreeBSD_g4a1195ca5"
#define ZFS_META_RELEASE "FreeBSD_gec64fdb93"
/* Define the project version. */
#define ZFS_META_VERSION "2.1.99"

View File

@ -2,4 +2,4 @@
* $FreeBSD$
*/
#define ZFS_META_GITREV "zfs-2.1.99-453-g4a1195ca50"
#define ZFS_META_GITREV "zfs-2.1.99-485-gec64fdb93"