summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorBrian Bennett <brian.bennett@mnx.io>2022-06-08 20:47:44 +0000
committerBrian Bennett <brian.bennett@mnx.io>2022-06-08 20:47:44 +0000
commitf5ec4d77349a1b62430af816d1f0b653b801aab8 (patch)
tree073ffad8eaa4bdafa0add5e0dc3797da1e11396e /usr
parent206b9fdf6e70ed0a13b2f76a1b0712f27fe17e12 (diff)
parentbaf9a8500e8914f180ede682c95a37266e1a4e37 (diff)
downloadillumos-joyent-f5ec4d77349a1b62430af816d1f0b653b801aab8.tar.gz
[illumos-gate merge]
commit baf9a8500e8914f180ede682c95a37266e1a4e37 14550 nvme_is_ignored_ns() needs less confusion 14709 nvmeadm list should be able to distinguish between inactive and ignored namespaces commit 0a4ff7c07705facb2cf0991453d0a3e20cdc50ce 14728 priv_set(3c) man page typo commit 38aced4fb3d60e34a44207b22d0b0dd4909bf4d1 14710 remove long obsolete/unused pyzfs helper script commit 22e991d5bb9d07bf7dd2a65bc080922753a3100b 14720 fac_prov_ipmi: missing thresholds should not be considered error
Diffstat (limited to 'usr')
-rw-r--r--usr/src/cmd/nvmeadm/nvmeadm.c61
-rw-r--r--usr/src/cmd/nvmeadm/nvmeadm.h4
-rw-r--r--usr/src/cmd/nvmeadm/nvmeadm_dev.c21
-rw-r--r--usr/src/cmd/pyzfs/Makefile48
-rw-r--r--usr/src/cmd/pyzfs/pyzfs.py83
-rw-r--r--usr/src/lib/brand/solaris10/zone/s10_boot.ksh20
-rw-r--r--usr/src/lib/fm/topo/modules/common/fac_prov_ipmi/fac_prov_ipmi.c11
-rw-r--r--usr/src/man/man3c/priv_set.3c288
-rw-r--r--usr/src/pkg/manifests/system-file-system-zfs.p5m2
-rwxr-xr-xusr/src/tools/quick/make-zfs5
-rw-r--r--usr/src/uts/common/io/nvme/nvme.c86
-rw-r--r--usr/src/uts/common/io/nvme/nvme_var.h2
-rw-r--r--usr/src/uts/common/sys/nvme.h28
13 files changed, 337 insertions, 322 deletions
diff --git a/usr/src/cmd/nvmeadm/nvmeadm.c b/usr/src/cmd/nvmeadm/nvmeadm.c
index 399631da88..18b1117a89 100644
--- a/usr/src/cmd/nvmeadm/nvmeadm.c
+++ b/usr/src/cmd/nvmeadm/nvmeadm.c
@@ -567,9 +567,10 @@ nvme_process(di_node_t node, di_minor_t minor, void *arg)
if (npa->npa_idns == NULL)
goto out;
+ npa->npa_dsk = NULL;
if (npa->npa_isns) {
- npa->npa_ignored = nvme_is_ignored_ns(fd);
- if (!npa->npa_ignored)
+ npa->npa_ns_state = nvme_namespace_state(fd);
+ if ((npa->npa_ns_state & NVME_NS_STATE_ATTACHED) != 0)
npa->npa_dsk = nvme_dskname(npa);
}
@@ -668,23 +669,38 @@ static int
do_list_nsid(int fd, const nvme_process_arg_t *npa)
{
_NOTE(ARGUNUSED(fd));
- const uint_t format = npa->npa_idns->id_flbas.lba_format;
- const uint_t bshift = npa->npa_idns->id_lbaf[format].lbaf_lbads;
+ char *dskname;
- /*
- * Some devices have extra namespaces with illegal block sizes and
- * zero blocks. Don't list them when verbose operation isn't requested.
- */
- if ((bshift < 9 || npa->npa_idns->id_nsize == 0) && verbose == 0)
+ if (!npa->npa_interactive &&
+ (npa->npa_ns_state & NVME_NS_STATE_IGNORED) != 0 &&
+ verbose == 0)
return (0);
- if (npa->npa_ofmt == NULL) {
+ if (npa->npa_ofmt != NULL) {
+ ofmt_print(npa->npa_ofmt, (void *)npa);
+ return (0);
+ }
+
+ if (npa->npa_ns_state == NVME_NS_STATE_IGNORED) {
+ (void) printf(" %s/%s (unallocated)\n", npa->npa_name,
+ di_minor_name(npa->npa_minor));
+ } else {
+ if ((npa->npa_ns_state & NVME_NS_STATE_ATTACHED) != 0) {
+ dskname = npa->npa_dsk;
+ } else if ((npa->npa_ns_state & NVME_NS_STATE_ACTIVE) != 0) {
+ if ((npa->npa_ns_state & NVME_NS_STATE_IGNORED) != 0) {
+ dskname = "ignored";
+ } else {
+ dskname = "unattached";
+ }
+ } else if ((npa->npa_ns_state & NVME_NS_STATE_ALLOCATED) != 0) {
+ dskname = "inactive";
+ } else {
+ dskname = "invalid state";
+ }
(void) printf(" %s/%s (%s): ", npa->npa_name,
- di_minor_name(npa->npa_minor),
- npa->npa_dsk != NULL ? npa->npa_dsk : "unattached");
+ di_minor_name(npa->npa_minor), dskname);
nvme_print_nsid_summary(npa->npa_idns);
- } else {
- ofmt_print(npa->npa_ofmt, (void *)npa);
}
return (0);
@@ -868,6 +884,10 @@ do_get_logpage(int fd, const nvme_process_arg_t *npa)
else
errx(-1, "invalid log page: %s", npa->npa_argv[0]);
+ if (npa->npa_isns &&
+ (npa->npa_ns_state & NVME_NS_STATE_ACTIVE) == 0)
+ errx(-1, "cannot get logpage: namespace is inactive");
+
ret = func(fd, npa);
return (ret);
}
@@ -1092,6 +1112,10 @@ do_get_features(int fd, const nvme_process_arg_t *npa)
if (npa->npa_argc > 1)
errx(-1, "unexpected arguments");
+ if (npa->npa_isns &&
+ (npa->npa_ns_state & NVME_NS_STATE_ACTIVE) == 0)
+ errx(-1, "cannot get feature: namespace is inactive");
+
/*
* No feature list given, print all supported features.
*/
@@ -1167,6 +1191,12 @@ do_format_common(int fd, const nvme_process_arg_t *npa, unsigned long lbaf,
nvme_process_arg_t ns_npa = { 0 };
nvmeadm_cmd_t cmd = { 0 };
+ if (npa->npa_isns &&
+ (npa->npa_ns_state & NVME_NS_STATE_ACTIVE) == 0) {
+ errx(-1, "cannot %s: namespace is inactive",
+ npa->npa_cmd->c_name);
+ }
+
cmd = *(npa->npa_cmd);
cmd.c_func = do_attach_detach;
cmd.c_name = "detach";
@@ -1316,7 +1346,8 @@ do_attach_detach(int fd, const nvme_process_arg_t *npa)
* that are ignored by the driver, thereby avoiding printing pointless
* error messages.
*/
- if (!npa->npa_interactive && npa->npa_ignored)
+ if (!npa->npa_interactive &&
+ (npa->npa_ns_state & NVME_NS_STATE_IGNORED))
return (0);
if ((c_name[0] == 'd' ? nvme_detach : nvme_attach)(fd)
diff --git a/usr/src/cmd/nvmeadm/nvmeadm.h b/usr/src/cmd/nvmeadm/nvmeadm.h
index ab4d4e4113..0be877305f 100644
--- a/usr/src/cmd/nvmeadm/nvmeadm.h
+++ b/usr/src/cmd/nvmeadm/nvmeadm.h
@@ -43,7 +43,6 @@ struct nvme_process_arg {
int npa_found;
boolean_t npa_excl;
boolean_t npa_isns;
- boolean_t npa_ignored;
boolean_t npa_interactive;
uint32_t npa_cmdflags;
const nvmeadm_cmd_t *npa_cmd;
@@ -51,6 +50,7 @@ struct nvme_process_arg {
di_minor_t npa_minor;
char *npa_path;
char *npa_dsk;
+ uint32_t npa_ns_state;
nvme_identify_ctrl_t *npa_idctl;
nvme_identify_nsid_t *npa_idns;
nvme_version_t *npa_version;
@@ -118,7 +118,7 @@ extern boolean_t nvme_detach(int);
extern boolean_t nvme_attach(int);
extern boolean_t nvme_firmware_load(int, void *, size_t, offset_t, uint16_t *);
extern boolean_t nvme_firmware_commit(int, int, int, uint16_t *);
-extern boolean_t nvme_is_ignored_ns(int);
+extern boolean_t nvme_namespace_state(int);
/*
* ofmt related
diff --git a/usr/src/cmd/nvmeadm/nvmeadm_dev.c b/usr/src/cmd/nvmeadm/nvmeadm_dev.c
index ce86a8d164..a86224c973 100644
--- a/usr/src/cmd/nvmeadm/nvmeadm_dev.c
+++ b/usr/src/cmd/nvmeadm/nvmeadm_dev.c
@@ -222,22 +222,23 @@ nvme_firmware_commit(int fd, int slot, int action, uint16_t *sc)
return (rv);
}
-boolean_t
-nvme_is_ignored_ns(int fd)
+uint32_t
+nvme_namespace_state(int fd)
{
- boolean_t ret;
uint64_t res = 0;
/*
- * The ioctl shouldn't fail. If it does, we treat it the same as if the
- * namespace was ignored.
+ * Ask the driver for the namespace state.
*/
- ret = nvme_ioctl(fd, NVME_IOC_IS_IGNORED_NS, NULL, NULL, 0, &res);
-
- if (ret)
- ret = (res == 0) ? B_FALSE : B_TRUE;
+ if (nvme_ioctl(fd, NVME_IOC_NS_STATE, NULL, NULL, 0, &res)) {
+ return (res);
+ }
- return (ret);
+ /*
+ * We're only here if the ioctl failed, which it really shouldnt. If so,
+ * we treat this the same as if the namespace was ignored.
+ */
+ return (NVME_NS_STATE_IGNORED);
}
int
diff --git a/usr/src/cmd/pyzfs/Makefile b/usr/src/cmd/pyzfs/Makefile
deleted file mode 100644
index 8895ccf525..0000000000
--- a/usr/src/cmd/pyzfs/Makefile
+++ /dev/null
@@ -1,48 +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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-include ../Makefile.cmd
-
-ROOTCMDDIR= $(ROOTLIB)/zfs
-
-PYSRCS= pyzfs.py
-PYOBJS= $(PYSRCS:%.py=%.pyc)
-PYFILES= $(PYSRCS) $(PYOBJS)
-POFILE= pyzfs.po
-
-ROOTLIBZFSFILES= $(PYFILES:%=$(ROOTLIB)/zfs/%)
-
-.KEEP_STATE:
-
-all: $(PYOBJS)
-
-install: all $(ROOTLIBZFSFILES)
-
-clean:
- $(RM) $(PYOBJS)
-
-$(ROOTLIB)/zfs/%: %
- $(INS.pyfile)
-
-include ../Makefile.targ
diff --git a/usr/src/cmd/pyzfs/pyzfs.py b/usr/src/cmd/pyzfs/pyzfs.py
deleted file mode 100644
index efcb4e8842..0000000000
--- a/usr/src/cmd/pyzfs/pyzfs.py
+++ /dev/null
@@ -1,83 +0,0 @@
-#!@PYTHON@ -Es
-#
-# 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) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
-#
-
-# Note, we want SIGINT (control-c) to exit the process quietly, to mimic
-# the standard behavior of C programs. The best we can do with pure
-# Python is to run with -S (to disable "import site"), and start our
-# program with a "try" statement. Hopefully nobody hits ^C before our
-# try statement is executed.
-
-try:
- import site
- import gettext
- import zfs.util
- import zfs.ioctl
- import sys
- import errno
- import solaris.misc
-
- """This is the main script for doing zfs subcommands. It doesn't know
- what subcommands there are, it just looks for a module zfs.<subcommand>
- that implements that subcommand."""
-
- try:
- _ = gettext.translation("SUNW_OST_OSCMD", "/usr/lib/locale",
- fallback=True).gettext
- except:
- _ = solaris.misc.gettext
-
- if len(sys.argv) < 2:
- sys.exit(_("missing subcommand argument"))
-
- zfs.ioctl.set_cmdstr(" ".join(["zfs"] + sys.argv[1:]))
-
- try:
- # import zfs.<subcommand>
- # subfunc = zfs.<subcommand>.do_<subcommand>
-
- subcmd = sys.argv[1]
- __import__("zfs." + subcmd)
- submod = getattr(zfs, subcmd)
- subfunc = getattr(submod, "do_" + subcmd)
- except (ImportError, AttributeError):
- sys.exit(_("invalid subcommand"))
-
- try:
- subfunc()
- except zfs.util.ZFSError as e:
- print(e)
- sys.exit(1)
-
-except IOError as e:
- import errno
- import sys
-
- if e.errno == errno.EPIPE:
- sys.exit(1)
- raise
-except KeyboardInterrupt:
- import sys
-
- sys.exit(1)
diff --git a/usr/src/lib/brand/solaris10/zone/s10_boot.ksh b/usr/src/lib/brand/solaris10/zone/s10_boot.ksh
index b167540087..76abb0991d 100644
--- a/usr/src/lib/brand/solaris10/zone/s10_boot.ksh
+++ b/usr/src/lib/brand/solaris10/zone/s10_boot.ksh
@@ -10,13 +10,13 @@
# 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
#
#
@@ -44,7 +44,7 @@ elif [ "$arch" = "sparc" ]; then
ARCH32=
ARCH64=sparcv9
else
- echo "Unsupported architecture: $arch"
+ echo "Unsupported architecture: $arch"
exit 2
fi
@@ -84,17 +84,6 @@ replace_with_native() {
fi
}
-replace_with_native_py() {
- path_dname=$ZONEROOT/`dirname $1`
-
- [ ! -f $1 ] && printf "$w_missing" "$1"
-
- if [ ! -h $path_dname -a -d $path_dname ]; then
- safe_replace $ZONEROOT/$1 $BRANDDIR/s10_python_wrapper $2 $3 \
- remove
- fi
-}
-
#
# Create a new wrapper script that invokes s10_isaexec_wrapper in the
# brand (for a non-existing s10c file) pointing to the native brand file.
@@ -241,7 +230,7 @@ if [ ! -h $ZONEROOT/usr/lib/inet -a -d $ZONEROOT/usr/lib/inet ]; then
/lib/inet/in.mpathd 0555 root:bin remove
fi
-#
+#
# Create wrapper at /lib/inet/in.mpathd as well because native ifconfig
# looks up in.mpathd under /lib/inet.
#
@@ -293,7 +282,6 @@ replace_with_native /usr/lib/fs/zfs/fstyp 0555 root:bin
replace_with_native /usr/lib/zfs/availdevs 0555 root:bin
replace_with_native /usr/sbin/df 0555 root:bin
replace_with_native /usr/sbin/zstreamdump 0555 root:bin
-replace_with_native_py /usr/lib/zfs/pyzfs.py 0555 root:bin
#
# Replace automount and automountd with native wrappers.
diff --git a/usr/src/lib/fm/topo/modules/common/fac_prov_ipmi/fac_prov_ipmi.c b/usr/src/lib/fm/topo/modules/common/fac_prov_ipmi/fac_prov_ipmi.c
index b3a81fdb51..55387afe12 100644
--- a/usr/src/lib/fm/topo/modules/common/fac_prov_ipmi/fac_prov_ipmi.c
+++ b/usr/src/lib/fm/topo/modules/common/fac_prov_ipmi/fac_prov_ipmi.c
@@ -24,7 +24,7 @@
*/
/*
* Copyright 2019 Joyent, Inc.
- * Copyright 2019 by Western Digital Corporation
+ * Copyright 2022 Tintri by DDN, Inc. All rights reserved.
*/
#include <unistd.h>
#include <stdio.h>
@@ -1606,6 +1606,15 @@ make_sensor_node(topo_mod_t *mod, tnode_t *pnode, struct sensor_data *sd,
if (ipmi_get_sensor_thresholds(hdl, &thresh,
sd->sd_fs_sdr->is_fs_number) != 0) {
+ /*
+ * Some sensors report supporting reading thresholds, but Get
+ * Sensor Thresholds returns Invalid Command. Do not consider
+ * this an error so we could continue enumerating sensors for
+ * the entity.
+ */
+ if (ipmi_errno(hdl) == EIPMI_INVALID_COMMAND)
+ return (0);
+
topo_mod_dprintf(mod, "Failed to get sensor thresholds for "
"node %s (%s)\n", topo_node_name(fnode), ipmi_errmsg(hdl));
return (topo_mod_seterrno(mod, EMOD_PARTIAL_ENUM));
diff --git a/usr/src/man/man3c/priv_set.3c b/usr/src/man/man3c/priv_set.3c
index 8bad51e32e..b748d4a1b7 100644
--- a/usr/src/man/man3c/priv_set.3c
+++ b/usr/src/man/man3c/priv_set.3c
@@ -1,134 +1,162 @@
-'\" te
.\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
-.\" 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]
-.TH PRIV_SET 3C "Sep 25, 2003"
-.SH NAME
-priv_set, priv_ineffect \- change privilege sets and check whether privileges
-are set
-.SH SYNOPSIS
-.LP
-.nf
-#include <priv.h>
-
-\fBint\fR \fBpriv_set\fR(\fBpriv_op_t\fR \fIop\fR, \fBpriv_ptype_t\fR \fIwhich\fR...);
-.fi
-
-.LP
-.nf
-\fBboolean_t\fR \fBpriv_ineffect\fR(\fBconst char *\fR\fIpriv\fR);
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBpriv_set()\fR function is a convenient wrapper for the \fBsetppriv\fR(2)
-function. It takes three or more arguments. The operation argument, \fIop\fR,
-can be one of \fBPRIV_OFF\fR, \fBPRIV_ON\fR or \fBPRIV_SET\fR. The \fIwhich\fR
-argument is the name of the privilege set to change. The third argument is a
-list of zero or more privilege names terminated with a null pointer. If
-\fIwhich\fR is the special pseudo set \fBPRIV_ALLSETS\fR, the operation should
-be applied to all privilege sets.
-.sp
-.LP
+.\" 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]
+.\"
+.\" Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
+.\"
+.Dd June 3, 2022
+.Dt PRIV_SET 3C
+.Os
+.Sh NAME
+.Nm priv_set ,
+.Nm priv_ineffect
+.Nd change privilege sets and check whether privileges are set
+.Sh SYNOPSIS
+.In priv.h
+.Ft int
+.Fo priv_set
+.Fa "priv_op_t op"
+.Fa "priv_ptype_t which"
+.Fa "..."
+.Fc
+.Ft boolean_t
+.Fo priv_ineffect
+.Fa "const char *priv"
+.Fc
+.Sh DESCRIPTION
+.Fn priv_set
+is a convenient wrapper for the
+.Xr setppriv 2
+function.
+It takes three or more arguments.
+The operation argument,
+.Ar op ,
+can be one of
+.Dv PRIV_OFF , PRIV_ON
+or
+.Dv PRIV_SET .
+The
+.Ar which
+argument is the name of the privilege set to change, one of
+.Dv PRIV_EFFECTIVE , PRIV_INHERITABLE , PRIV_PERMITTED , PRIV_LIMIT
+or the special pseudo set
+.Dv PRIV_ALLSETS
+if the operation should be applied to all privilege sets.
+Subsequent arguments provide zero or more privilege names, terminated with a
+.Dv NULL
+pointer.
+See
+.Sx EXAMPLES .
+.Pp
The specified privileges are converted to a binary privilege set and
-\fBsetppriv()\fR is called with the same \fIop\fR and \fIwhich\fR arguments.
-When called with \fBPRIV_ALLSETS\fR as the value for the \fIwhich\fR argument,
-\fBsetppriv()\fR is called for each set in turn, aborting on the first failed
-call.
-.sp
-.LP
-The \fBpriv_ineffect()\fR function is a conventient wrapper for the
-\fBgetppriv\fR(2) function. The \fIpriv\fR argument specifies the name of the
-privilege for which this function checks its presence in the effective set.
-.SH RETURN VALUES
-.sp
-.LP
-Upon successful completion, \fBpriv_set()\fR return 0. Otherwise, -1 is
-returned and \fBerrno\fR is set to indicate the error.
-.sp
-.LP
-If \fIpriv\fR is a valid privilege that is a member of the effective set,
-\fBpriv_ineffect()\fR returns \fBB_TRUE\fR. Otherwise, it returns \fBB_FALSE\fR
-and sets \fBerrno\fR to incicate the error.
-.SH ERRORS
-.sp
-.LP
-The \fBpriv_set()\fR function will fail if:
-.sp
-.ne 2
-.na
-\fB\fBEINVAL\fR\fR
-.ad
-.RS 10n
-The value of \fIop\fR or \fIwhich\fR is out of range.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOMEM\fR\fR
-.ad
-.RS 10n
+.Xr setppriv 2
+is called with the same
+.Ar op
+and
+.Ar which
+arguments.
+When called with
+.Dv PRIV_ALLSETS
+as the value for the
+.Ar which
+argument,
+.Xr setppriv 2
+is called for each set in turn, aborting on the first failed call.
+.Pp
+.Fn priv_ineffect
+is a convenient wrapper for the
+.Xr getppriv 2
+function.
+The
+.Ar priv
+argument specifies the name of a privilege, and this function checks for its
+presence in the effective set.
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn priv_set
+return 0.
+Otherwise, -1 is returned and
+.Dv errno
+is set to indicate the error.
+.Pp
+If
+.Ar priv
+is a valid privilege that is a member of the effective set,
+.Fn priv_ineffect
+returns
+.Dv B_TRUE .
+Otherwise, it returns
+.Dv B_FALSE
+and sets
+.Dv errno
+to indicate the error.
+.Sh EXAMPLES
+.Sy Example 1
+Using
+.Fn priv_set
+.Bd -literal -offset 6n
+#include <priv.h>
+\&...
+/* Remove basic privileges we don't need */
+(void) priv_set(PRIV_OFF, PRIV_PERMITTED, PRIV_PROC_EXEC,
+ PRIV_PROC_INFO, PRIV_FILE_LINK_ANY, PRIV_PROC_SESSION,
+ NULL);
+.Ed
+.Sh ERRORS
+The
+.Fn priv_set
+function will fail if:
+.Bl -tag -width Ds
+.It Er EINVAL
+The value of
+.Ar op
+or
+.Ar which
+is out of range.
+.It Er ENOMEM
Insufficient memory was allocated.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEPERM\fR\fR
-.ad
-.RS 10n
-The application attempted to add privileges to \fBPRIV_LIMIT\fR or
-\fBPRIV_PERMITTED\fR, or the application attempted to add privileges to
-\fBPRIV_INHERITABLE\fR or \fBPRIV_EFFECTIVE\fR that were not in
-\fBPRIV_PERMITTED\fR.
-.RE
-
-.sp
-.LP
-The \fBpriv_ineffect()\fR function will fail if:
-.sp
-.ne 2
-.na
-\fB\fBEINVAL\fR\fR
-.ad
-.RS 10n
-The privilege specified by \fIpriv\fR is invalid.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOMEM\fR\fR
-.ad
-.RS 10n
+.It Er EPERM
+The application attempted to add privileges to
+.Dv PRIV_LIMIT
+or
+.Dv PRIV_PERMITTED ,
+or the application attempted to add privileges to
+.Dv PRIV_INHERITABLE
+or
+.Dv PRIV_EFFECTIVE
+that were not in
+.Dv PRIV_PERMITTED .
+.El
+.Pp
+The
+.Fn priv_ineffect
+function will fail if:
+.Bl -tag -width Ds
+.It Er EINVAL
+The privilege specified by
+.Ar priv
+is invalid.
+.It Er ENOMEM
Insufficient memory was allocated.
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Evolving
-_
-MT-Level MT-Safe
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-.BR setppriv (2),
-.BR priv_str_to_set (3C),
-.BR attributes (7),
-.BR privileges (7)
+.El
+.Sh INTERFACE STABILITY
+.Sy Uncommitted
+.Sh MT-LEVEL
+.Sy MT-Safe
+.Sh SEE ALSO
+.Xr setppriv 2 ,
+.Xr priv_str_to_set 3C ,
+.Xr attributes 7 ,
+.Xr privileges 7
diff --git a/usr/src/pkg/manifests/system-file-system-zfs.p5m b/usr/src/pkg/manifests/system-file-system-zfs.p5m
index 111fe6b028..afe1c20709 100644
--- a/usr/src/pkg/manifests/system-file-system-zfs.p5m
+++ b/usr/src/pkg/manifests/system-file-system-zfs.p5m
@@ -128,8 +128,6 @@ dir path=usr/lib/sysevent/modules
file path=usr/lib/sysevent/modules/zfs_mod.so group=sys
dir path=usr/lib/zfs
file path=usr/lib/zfs/availdevs mode=0555
-file path=usr/lib/zfs/pyzfs.py mode=0555
-file path=usr/lib/zfs/pyzfs.pyc mode=0555
dir path=usr/sbin
$(i386_ONLY)dir path=usr/sbin/$(ARCH32)
dir path=usr/sbin/$(ARCH64)
diff --git a/usr/src/tools/quick/make-zfs b/usr/src/tools/quick/make-zfs
index 417745b8cf..b2052cad9b 100755
--- a/usr/src/tools/quick/make-zfs
+++ b/usr/src/tools/quick/make-zfs
@@ -201,8 +201,7 @@ for cmd in \
zinject \
zpool \
ztest \
- zstreamdump \
- pyzfs
+ zstreamdump
do
(cd $SRC/cmd/$cmd && $make $1)
done
@@ -336,8 +335,6 @@ sbin/zfs
sbin/zpool
usr/lib/sysevent/modules/zfs_mod.so
usr/lib/zfs/availdevs
-usr/lib/zfs/pyzfs.py
-usr/lib/zfs/pyzfs.pyc
usr/sbin/$arch32/zdb
usr/sbin/$arch64/zdb
usr/sbin/$arch32/zhack
diff --git a/usr/src/uts/common/io/nvme/nvme.c b/usr/src/uts/common/io/nvme/nvme.c
index e65a7a4139..a59564544f 100644
--- a/usr/src/uts/common/io/nvme/nvme.c
+++ b/usr/src/uts/common/io/nvme/nvme.c
@@ -2923,6 +2923,44 @@ nvme_prepare_devid(nvme_t *nvme, uint32_t nsid)
nvme->n_idctl->id_vid, model, serial, nsid);
}
+static boolean_t
+nvme_allocated_ns(nvme_namespace_t *ns)
+{
+ nvme_t *nvme = ns->ns_nvme;
+
+ ASSERT(MUTEX_HELD(&nvme->n_mgmt_mutex));
+
+ /*
+ * Since we don't know any better, we assume all namespaces to be
+ * allocated.
+ */
+ return (B_TRUE);
+}
+
+static boolean_t
+nvme_active_ns(nvme_namespace_t *ns)
+{
+ nvme_t *nvme = ns->ns_nvme;
+ boolean_t ret = B_FALSE;
+ uint64_t *ptr;
+
+ ASSERT(MUTEX_HELD(&nvme->n_mgmt_mutex));
+
+ /*
+ * Check whether the IDENTIFY NAMESPACE data is zero-filled.
+ */
+ for (ptr = (uint64_t *)ns->ns_idns;
+ ptr != (uint64_t *)(ns->ns_idns + 1);
+ ptr++) {
+ if (*ptr != 0) {
+ ret = B_TRUE;
+ break;
+ }
+ }
+
+ return (ret);
+}
+
static int
nvme_init_ns(nvme_t *nvme, int nsid)
{
@@ -2946,6 +2984,12 @@ nvme_init_ns(nvme_t *nvme, int nsid)
ns->ns_idns = idns;
ns->ns_id = nsid;
+
+ was_ignored = ns->ns_ignore;
+
+ ns->ns_allocated = nvme_allocated_ns(ns);
+ ns->ns_active = nvme_active_ns(ns);
+
ns->ns_block_count = idns->id_nsize;
ns->ns_block_size =
1 << idns->id_lbaf[idns->id_flbas.lba_format].lbaf_lbads;
@@ -3410,7 +3454,7 @@ nvme_init(nvme_t *nvme)
nvme->n_progress_supported = B_TRUE;
/*
- * Identify Namespaces
+ * Get number of supported namespaces and allocate namespace array.
*/
nvme->n_namespace_count = nvme->n_idctl->id_nn;
@@ -4884,6 +4928,9 @@ nvme_ioctl_get_logpage(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc,
if ((mode & FREAD) == 0)
return (EPERM);
+ if (nsid > 0 && !NVME_NSID2NS(nvme, nsid)->ns_active)
+ return (EINVAL);
+
switch (nioc->n_arg) {
case NVME_LOGPAGE_ERROR:
if (nsid != 0)
@@ -4949,6 +4996,9 @@ nvme_ioctl_get_features(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc,
if ((mode & FREAD) == 0)
return (EPERM);
+ if (nsid > 0 && !NVME_NSID2NS(nvme, nsid)->ns_active)
+ return (EINVAL);
+
if ((nioc->n_arg >> 32) > 0xff)
return (EINVAL);
@@ -5099,8 +5149,12 @@ nvme_ioctl_format(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, int mode,
if (nm->nm_oexcl != curthread)
return (EACCES);
- if (nsid != 0 && NVME_NSID2NS(nvme, nsid)->ns_attached)
- return (EBUSY);
+ if (nsid != 0) {
+ if (NVME_NSID2NS(nvme, nsid)->ns_attached)
+ return (EBUSY);
+ else if (!NVME_NSID2NS(nvme, nsid)->ns_active)
+ return (EINVAL);
+ }
frmt.r = nioc->n_arg & 0xffffffff;
@@ -5597,10 +5651,11 @@ out:
}
static int
-nvme_ioctl_is_ignored_ns(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, int mode,
+nvme_ioctl_ns_state(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, int mode,
cred_t *cred_p)
{
_NOTE(ARGUNUSED(cred_p));
+ nvme_namespace_t *ns = NVME_NSID2NS(nvme, nsid);
if ((mode & FREAD) == 0)
return (EPERM);
@@ -5608,10 +5663,23 @@ nvme_ioctl_is_ignored_ns(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, int mode,
if (nsid == 0)
return (EINVAL);
- if (NVME_NSID2NS(nvme, nsid)->ns_ignore)
- nioc->n_arg = 1;
- else
- nioc->n_arg = 0;
+ nioc->n_arg = 0;
+
+ mutex_enter(&nvme->n_mgmt_mutex);
+
+ if (ns->ns_allocated)
+ nioc->n_arg |= NVME_NS_STATE_ALLOCATED;
+
+ if (ns->ns_active)
+ nioc->n_arg |= NVME_NS_STATE_ACTIVE;
+
+ if (ns->ns_attached)
+ nioc->n_arg |= NVME_NS_STATE_ATTACHED;
+
+ if (ns->ns_ignore)
+ nioc->n_arg |= NVME_NS_STATE_IGNORED;
+
+ mutex_exit(&nvme->n_mgmt_mutex);
return (0);
}
@@ -5644,7 +5712,7 @@ nvme_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p,
nvme_ioctl_firmware_download,
nvme_ioctl_firmware_commit,
nvme_ioctl_passthru,
- nvme_ioctl_is_ignored_ns
+ nvme_ioctl_ns_state
};
if (nvme == NULL)
diff --git a/usr/src/uts/common/io/nvme/nvme_var.h b/usr/src/uts/common/io/nvme/nvme_var.h
index 0266f193dc..10cc529fd9 100644
--- a/usr/src/uts/common/io/nvme/nvme_var.h
+++ b/usr/src/uts/common/io/nvme/nvme_var.h
@@ -287,6 +287,8 @@ struct nvme_namespace {
size_t ns_block_size;
size_t ns_best_block_size;
+ boolean_t ns_allocated;
+ boolean_t ns_active;
boolean_t ns_ignore;
boolean_t ns_attached;
diff --git a/usr/src/uts/common/sys/nvme.h b/usr/src/uts/common/sys/nvme.h
index 9e154131b1..04f39057e2 100644
--- a/usr/src/uts/common/sys/nvme.h
+++ b/usr/src/uts/common/sys/nvme.h
@@ -54,8 +54,8 @@ extern "C" {
#define NVME_IOC_FIRMWARE_DOWNLOAD (NVME_IOC | 11)
#define NVME_IOC_FIRMWARE_COMMIT (NVME_IOC | 12)
#define NVME_IOC_PASSTHRU (NVME_IOC | 13)
-#define NVME_IOC_IS_IGNORED_NS (NVME_IOC | 14)
-#define NVME_IOC_MAX NVME_IOC_IS_IGNORED_NS
+#define NVME_IOC_NS_STATE (NVME_IOC | 14)
+#define NVME_IOC_MAX NVME_IOC_NS_STATE
#define IS_NVME_IOC(x) ((x) > NVME_IOC && (x) <= NVME_IOC_MAX)
#define NVME_IOC_CMD(x) ((x) & 0xff)
@@ -1029,6 +1029,30 @@ typedef struct {
} nvme_passthru_cmd32_t;
#endif
+/*
+ * NVME namespace state flags for NVME_IOC_NS_STATE ioctl
+ *
+ * The values are defined entirely by the driver. Some states correspond to
+ * namespace states described by the NVMe specification r1.3 section 6.1, others
+ * are specific to the implementation of this driver.
+ *
+ * The states are as follows:
+ * - ALLOCATED: the namespace exists in the controller as per the NVMe spec
+ * - ACTIVE: the namespace exists and is attached to this controller as per the
+ * NVMe spec. Any namespace that is ACTIVE is also ALLOCATED. This must not be
+ * confused with the ATTACHED state.
+ * - ATTACHED: the driver has attached a blkdev(4D) instance to this namespace.
+ * This state can be changed by userspace with the ioctls NVME_IOC_ATTACH and
+ * NVME_IOC_DETACH. A namespace can only be ATTACHED when it is not IGNORED.
+ * - IGNORED: the driver ignores this namespace, it never attaches a blkdev(4D).
+ * Namespaces are IGNORED when they are not ACTIVE, or if they are ACTIVE but
+ * have certain properties that the driver cannot handle.
+ */
+#define NVME_NS_STATE_ALLOCATED 0x1
+#define NVME_NS_STATE_ACTIVE 0x2
+#define NVME_NS_STATE_ATTACHED 0x4
+#define NVME_NS_STATE_IGNORED 0x8
+
#ifdef __cplusplus
}
#endif