aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/lib
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2023-09-21 09:25:53 +0000
committerMartin Matuska <mm@FreeBSD.org>2023-09-21 09:27:28 +0000
commitcbfe997563d24cdbfe77d1763f2582fbace3ee2f (patch)
tree28c75a1d3c1ad65bde0bc0ada613184013cf0195 /sys/contrib/openzfs/lib
parentc0e249d32c780ee8240fe8b3b8144078a8eec41f (diff)
parent4647353c8b2b5ca506da45bb9b01e1f3ef521847 (diff)
Diffstat (limited to 'sys/contrib/openzfs/lib')
-rw-r--r--sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c3
-rw-r--r--sys/contrib/openzfs/lib/libshare/os/linux/nfs.c47
-rw-r--r--sys/contrib/openzfs/lib/libspl/include/assert.h15
-rw-r--r--sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c19
-rw-r--r--sys/contrib/openzfs/lib/libzfs/libzfs_pool.c3
-rw-r--r--sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c10
6 files changed, 76 insertions, 21 deletions
diff --git a/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c b/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c
index 521631c51f07..d9fc66106369 100644
--- a/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c
+++ b/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c
@@ -161,7 +161,8 @@ nfs_is_shared(sa_share_impl_t impl_share)
static int
nfs_validate_shareopts(const char *shareopts)
{
- (void) shareopts;
+ if (strlen(shareopts) == 0)
+ return (SA_SYNTAX_ERR);
return (SA_OK);
}
diff --git a/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c b/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c
index c27e5564c1e1..004946b0cfe4 100644
--- a/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c
+++ b/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c
@@ -319,12 +319,49 @@ get_linux_shareopts_cb(const char *key, const char *value, void *cookie)
"wdelay" };
char **plinux_opts = (char **)cookie;
+ char *host, *val_dup, *literal, *next;
- /* host-specific options, these are taken care of elsewhere */
- if (strcmp(key, "ro") == 0 || strcmp(key, "rw") == 0 ||
- strcmp(key, "sec") == 0)
+ if (strcmp(key, "sec") == 0)
return (SA_OK);
+ if (strcmp(key, "ro") == 0 || strcmp(key, "rw") == 0) {
+ if (value == NULL || strlen(value) == 0)
+ return (SA_OK);
+ val_dup = strdup(value);
+ host = val_dup;
+ if (host == NULL)
+ return (SA_NO_MEMORY);
+ do {
+ if (*host == '[') {
+ host++;
+ literal = strchr(host, ']');
+ if (literal == NULL) {
+ free(val_dup);
+ return (SA_SYNTAX_ERR);
+ }
+ if (literal[1] == '\0')
+ next = NULL;
+ else if (literal[1] == '/') {
+ next = strchr(literal + 2, ':');
+ if (next != NULL)
+ ++next;
+ } else if (literal[1] == ':')
+ next = literal + 2;
+ else {
+ free(val_dup);
+ return (SA_SYNTAX_ERR);
+ }
+ } else {
+ next = strchr(host, ':');
+ if (next != NULL)
+ ++next;
+ }
+ host = next;
+ } while (host != NULL);
+ free(val_dup);
+ return (SA_OK);
+ }
+
if (strcmp(key, "anon") == 0)
key = "anonuid";
@@ -472,6 +509,10 @@ static int
nfs_validate_shareopts(const char *shareopts)
{
char *linux_opts = NULL;
+
+ if (strlen(shareopts) == 0)
+ return (SA_SYNTAX_ERR);
+
int error = get_linux_shareopts(shareopts, &linux_opts);
if (error != SA_OK)
return (error);
diff --git a/sys/contrib/openzfs/lib/libspl/include/assert.h b/sys/contrib/openzfs/lib/libspl/include/assert.h
index c5bf0f0cc8f1..d8c5e203f42f 100644
--- a/sys/contrib/openzfs/lib/libspl/include/assert.h
+++ b/sys/contrib/openzfs/lib/libspl/include/assert.h
@@ -107,8 +107,8 @@ do { \
const uintptr_t __right = (uintptr_t)(RIGHT); \
if (!(__left OP __right)) \
libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \
- "%s %s %s (0x%llx %s 0x%llx)", #LEFT, #OP, #RIGHT, \
- (u_longlong_t)__left, #OP, (u_longlong_t)__right); \
+ "%s %s %s (%p %s %p)", #LEFT, #OP, #RIGHT, \
+ (void *)__left, #OP, (void *)__right); \
} while (0)
#define VERIFY0(LEFT) \
@@ -120,6 +120,15 @@ do { \
(u_longlong_t)__left); \
} while (0)
+#define VERIFY0P(LEFT) \
+do { \
+ const uintptr_t __left = (uintptr_t)(LEFT); \
+ if (!(__left == 0)) \
+ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \
+ "%s == 0 (%p == 0)", #LEFT, \
+ (void *)__left); \
+} while (0)
+
#ifdef assert
#undef assert
#endif
@@ -134,6 +143,7 @@ do { \
#define ASSERT3P(x, y, z) \
((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z)))
#define ASSERT0(x) ((void) sizeof ((uintptr_t)(x)))
+#define ASSERT0P(x) ((void) sizeof ((uintptr_t)(x)))
#define ASSERT(x) ((void) sizeof ((uintptr_t)(x)))
#define assert(x) ((void) sizeof ((uintptr_t)(x)))
#define IMPLY(A, B) \
@@ -146,6 +156,7 @@ do { \
#define ASSERT3U VERIFY3U
#define ASSERT3P VERIFY3P
#define ASSERT0 VERIFY0
+#define ASSERT0P VERIFY0P
#define ASSERT VERIFY
#define assert VERIFY
#define IMPLY(A, B) \
diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c b/sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c
index dd14c570ec03..efe1c0c06035 100644
--- a/sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c
+++ b/sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c
@@ -174,7 +174,6 @@ changelist_postfix(prop_changelist_t *clp)
prop_changenode_t *cn;
uu_avl_walk_t *walk;
char shareopts[ZFS_MAXPROPLEN];
- int errors = 0;
boolean_t commit_smb_shares = B_FALSE;
boolean_t commit_nfs_shares = B_FALSE;
@@ -244,13 +243,13 @@ changelist_postfix(prop_changelist_t *clp)
zfs_is_mounted(cn->cn_handle, NULL);
if (!mounted && !needs_key && (cn->cn_mounted ||
- ((sharenfs || sharesmb || clp->cl_waslegacy) &&
+ (((clp->cl_prop == ZFS_PROP_MOUNTPOINT &&
+ clp->cl_prop == clp->cl_realprop) ||
+ sharenfs || sharesmb || clp->cl_waslegacy) &&
(zfs_prop_get_int(cn->cn_handle,
ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_ON)))) {
- if (zfs_mount(cn->cn_handle, NULL, 0) != 0)
- errors++;
- else
+ if (zfs_mount(cn->cn_handle, NULL, 0) == 0)
mounted = TRUE;
}
@@ -262,19 +261,19 @@ changelist_postfix(prop_changelist_t *clp)
const enum sa_protocol nfs[] =
{SA_PROTOCOL_NFS, SA_NO_PROTOCOL};
if (sharenfs && mounted) {
- errors += zfs_share(cn->cn_handle, nfs);
+ zfs_share(cn->cn_handle, nfs);
commit_nfs_shares = B_TRUE;
} else if (cn->cn_shared || clp->cl_waslegacy) {
- errors += zfs_unshare(cn->cn_handle, NULL, nfs);
+ zfs_unshare(cn->cn_handle, NULL, nfs);
commit_nfs_shares = B_TRUE;
}
const enum sa_protocol smb[] =
{SA_PROTOCOL_SMB, SA_NO_PROTOCOL};
if (sharesmb && mounted) {
- errors += zfs_share(cn->cn_handle, smb);
+ zfs_share(cn->cn_handle, smb);
commit_smb_shares = B_TRUE;
} else if (cn->cn_shared || clp->cl_waslegacy) {
- errors += zfs_unshare(cn->cn_handle, NULL, smb);
+ zfs_unshare(cn->cn_handle, NULL, smb);
commit_smb_shares = B_TRUE;
}
}
@@ -288,7 +287,7 @@ changelist_postfix(prop_changelist_t *clp)
zfs_commit_shares(proto);
uu_avl_walk_end(walk);
- return (errors ? -1 : 0);
+ return (0);
}
/*
diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_pool.c b/sys/contrib/openzfs/lib/libzfs/libzfs_pool.c
index 85564edfd862..4ebd112f452f 100644
--- a/sys/contrib/openzfs/lib/libzfs/libzfs_pool.c
+++ b/sys/contrib/openzfs/lib/libzfs/libzfs_pool.c
@@ -29,7 +29,7 @@
* Copyright (c) 2017, Intel Corporation.
* Copyright (c) 2018, loli10K <ezomori.nozomu@gmail.com>
* Copyright (c) 2021, Colm Buckley <colm@tuatha.org>
- * Copyright (c) 2021, Klara Inc.
+ * Copyright (c) 2021, 2023, Klara Inc.
*/
#include <errno.h>
@@ -255,6 +255,7 @@ zpool_get_state_str(zpool_handle_t *zhp)
if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) {
str = gettext("FAULTED");
} else if (status == ZPOOL_STATUS_IO_FAILURE_WAIT ||
+ status == ZPOOL_STATUS_IO_FAILURE_CONTINUE ||
status == ZPOOL_STATUS_IO_FAILURE_MMP) {
str = gettext("SUSPENDED");
} else {
diff --git a/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c b/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c
index c63a16de5ab6..01d803e21db0 100644
--- a/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c
+++ b/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c
@@ -650,10 +650,12 @@ send_worker(void *arg)
unsigned int bufsiz = max_pipe_buffer(ctx->from);
ssize_t rd;
- while ((rd = splice(ctx->from, NULL, ctx->to, NULL, bufsiz,
- SPLICE_F_MOVE | SPLICE_F_MORE)) > 0)
- ;
-
+ for (;;) {
+ rd = splice(ctx->from, NULL, ctx->to, NULL, bufsiz,
+ SPLICE_F_MOVE | SPLICE_F_MORE);
+ if ((rd == -1 && errno != EINTR) || rd == 0)
+ break;
+ }
int err = (rd == -1) ? errno : 0;
close(ctx->from);
return ((void *)(uintptr_t)err);