path: root/cddl/usr.sbin/zfsd
diff options
authorMatt Macy <mmacy@FreeBSD.org>2020-08-25 02:21:27 +0000
committerMatt Macy <mmacy@FreeBSD.org>2020-08-25 02:21:27 +0000
commit9e5787d2284e187abb5b654d924394a65772e004 (patch)
tree2ebf833af6b1953d4a683e2da830fe87bf3435e1 /cddl/usr.sbin/zfsd
parent22df1ffd812f0395cdb7c0b1edae1f67b991562a (diff)
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared code base with the community allowing FreeBSD to receive new features sooner and with less effort. I would advise against doing 'zpool upgrade' or creating indispensable pools using new features until this change has had a month+ to soak. Work on merging FreeBSD support in to what was at the time "ZFS on Linux" began in August 2018. I first publicly proposed transitioning FreeBSD to (new) OpenZFS on December 18th, 2018. FreeBSD support in OpenZFS was finally completed in December 2019. A CFT for downstreaming OpenZFS support in to FreeBSD was first issued on July 8th. All issues that were reported have been addressed or, for a couple of less critical matters there are pull requests in progress with OpenZFS. iXsystems has tested and dogfooded extensively internally. The TrueNAS 12 release is based on OpenZFS with some additional features that have not yet made it upstream. Improvements include: project quotas, encrypted datasets, allocation classes, vectorized raidz, vectorized checksums, various command line improvements, zstd compression. Thanks to those who have helped along the way: Ryan Moeller, Allan Jude, Zack Welch, and many others. Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D25872
Notes: svn path=/head/; revision=364746
Diffstat (limited to 'cddl/usr.sbin/zfsd')
10 files changed, 29 insertions, 30 deletions
diff --git a/cddl/usr.sbin/zfsd/Makefile.common b/cddl/usr.sbin/zfsd/Makefile.common
index 7d45a3ed1695..95882dec175a 100644
--- a/cddl/usr.sbin/zfsd/Makefile.common
+++ b/cddl/usr.sbin/zfsd/Makefile.common
@@ -10,29 +10,24 @@ SRCS= callout.cc \
zpool_list.cc \
-WARNS?= 3
+WARNS?= 2
# Ignore warnings about Solaris specific pragmas.
-INCFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common
-INCFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
-INCFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem
-INCFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris
-INCFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/head
-INCFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libuutil/common
-INCFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libumem/common
-INCFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs_core/common
-INCFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common
-INCFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair
-INCFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs
-INCFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common
-INCFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
-INCFLAGS+= -I${SRCTOP}/cddl/usr.sbin
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include
+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/lib/libspl/include/os/freebsd/spl
+CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
+CFLAGS+= -I${SRCTOP}/cddl/usr.sbin
+# use issetugid(2)
-LIBADD+= devdctl zfs zfs_core util geom bsdxml sbuf nvpair uutil
+LIBADD+= devdctl zfs zfs_core util geom bsdxml sbuf nvpair avl uutil zutil
find ${.CURDIR} -type f -a \( -name "*.[ch]" -o -name "*.cc" \) \
diff --git a/cddl/usr.sbin/zfsd/callout.cc b/cddl/usr.sbin/zfsd/callout.cc
index 2671c5d3e783..3e5cd5779559 100644
--- a/cddl/usr.sbin/zfsd/callout.cc
+++ b/cddl/usr.sbin/zfsd/callout.cc
@@ -39,6 +39,7 @@
* timer services built on top of the POSIX interval timer.
+#include <sys/byteorder.h>
#include <sys/time.h>
#include <signal.h>
diff --git a/cddl/usr.sbin/zfsd/case_file.cc b/cddl/usr.sbin/zfsd/case_file.cc
index 19c4abe45fc9..da2125b4d716 100644
--- a/cddl/usr.sbin/zfsd/case_file.cc
+++ b/cddl/usr.sbin/zfsd/case_file.cc
@@ -39,11 +39,13 @@
* accumulate in order to mark a device as degraded.
#include <sys/cdefs.h>
+#include <sys/byteorder.h>
#include <sys/time.h>
#include <sys/fs/zfs.h>
#include <dirent.h>
+#include <fcntl.h>
#include <iomanip>
#include <fstream>
#include <functional>
@@ -75,7 +77,6 @@
/*============================ Namespace Control =============================*/
-using std::auto_ptr;
using std::hex;
using std::ifstream;
using std::stringstream;
@@ -239,8 +240,6 @@ CaseFile::ReEvaluate(const string &devPath, const string &physPath, Vdev *vdev)
ZpoolList zpl(ZpoolList::ZpoolByGUID, &m_poolGUID);
zpool_handle_t *pool(zpl.empty() ? NULL : zpl.front());
- zpool_boot_label_t boot_type;
- uint64_t boot_size;
if (pool == NULL || !RefreshVdevState()) {
@@ -333,13 +332,7 @@ CaseFile::ReEvaluate(const string &devPath, const string &physPath, Vdev *vdev)
/* Write a label on the newly inserted disk. */
- if (zpool_is_bootable(pool))
- boot_type = ZPOOL_COPY_BOOT_LABEL;
- else
- boot_type = ZPOOL_NO_BOOT_LABEL;
- boot_size = zpool_get_prop_int(pool, ZPOOL_PROP_BOOTSIZE, NULL);
- if (zpool_label_disk(g_zfsHandle, pool, devPath.c_str(),
- boot_type, boot_size, NULL) != 0) {
+ if (zpool_label_disk(g_zfsHandle, pool, devPath.c_str()) != 0) {
"Replace vdev(%s/%s) by physical path (label): %s: %s\n",
zpool_get_name(pool), VdevGUIDString().c_str(),
@@ -1118,7 +1111,7 @@ CaseFile::Replace(const char* vdev_type, const char* path, bool isspare) {
retval = (zpool_vdev_attach(zhp, oldstr.c_str(), path, nvroot,
- /*replace*/B_TRUE) == 0);
+ /*replace*/B_TRUE, /*rebuild*/ B_FALSE) == 0);
if (retval)
syslog(LOG_INFO, "Replacing vdev(%s/%s) with %s\n",
poolname, oldstr.c_str(), path);
diff --git a/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc b/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc
index d65295075c1f..e2833170f9ac 100644
--- a/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc
+++ b/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc
@@ -30,6 +30,7 @@
* Authors: Alan Somers (Spectra Logic Corporation)
#include <sys/cdefs.h>
+#include <sys/byteorder.h>
#include <stdarg.h>
#include <syslog.h>
diff --git a/cddl/usr.sbin/zfsd/vdev.cc b/cddl/usr.sbin/zfsd/vdev.cc
index 687b0647ceb5..508af8cda925 100644
--- a/cddl/usr.sbin/zfsd/vdev.cc
+++ b/cddl/usr.sbin/zfsd/vdev.cc
@@ -39,6 +39,7 @@
#include <syslog.h>
#include <sys/cdefs.h>
+#include <sys/byteorder.h>
#include <sys/fs/zfs.h>
#include <libzfs.h>
diff --git a/cddl/usr.sbin/zfsd/vdev_iterator.cc b/cddl/usr.sbin/zfsd/vdev_iterator.cc
index 31a4ce962970..b5a4f22c1c60 100644
--- a/cddl/usr.sbin/zfsd/vdev_iterator.cc
+++ b/cddl/usr.sbin/zfsd/vdev_iterator.cc
@@ -38,6 +38,7 @@
* Implementation of the VdevIterator class.
#include <sys/cdefs.h>
+#include <sys/byteorder.h>
#include <sys/fs/zfs.h>
#include <stdint.h>
diff --git a/cddl/usr.sbin/zfsd/zfsd.cc b/cddl/usr.sbin/zfsd/zfsd.cc
index 2f17b474e493..876cca836e9e 100644
--- a/cddl/usr.sbin/zfsd/zfsd.cc
+++ b/cddl/usr.sbin/zfsd/zfsd.cc
@@ -42,10 +42,12 @@
#include <sys/cdefs.h>
+#include <sys/byteorder.h>
#include <sys/param.h>
#include <sys/fs/zfs.h>
#include <err.h>
+#include <fcntl.h>
#include <libgeom.h>
#include <libutil.h>
#include <poll.h>
diff --git a/cddl/usr.sbin/zfsd/zfsd_event.cc b/cddl/usr.sbin/zfsd/zfsd_event.cc
index 707a868c67e8..688e7c0354a2 100644
--- a/cddl/usr.sbin/zfsd/zfsd_event.cc
+++ b/cddl/usr.sbin/zfsd/zfsd_event.cc
@@ -34,6 +34,7 @@
* \file zfsd_event.cc
#include <sys/cdefs.h>
+#include <sys/byteorder.h>
#include <sys/time.h>
#include <sys/fs/zfs.h>
#include <sys/vdev_impl.h>
@@ -41,12 +42,13 @@
#include <syslog.h>
#include <libzfs.h>
+#include <libzutil.h>
* Undefine flush, defined by cpufunc.h on sparc64, because it conflicts with
* C++ flush methods
#undef flush
+#undef __init
#include <list>
#include <map>
#include <sstream>
@@ -190,7 +192,8 @@ GeomEvent::ReadLabel(int devFd, bool &inUse, bool &degraded)
if (poolName != NULL)
- nlabels = zpool_read_all_labels(devFd, &devLabel);
+ if (zpool_read_label(devFd, &devLabel, &nlabels) != 0)
+ return (NULL);
* If we find a disk with fewer than the maximum number of
* labels, it might be the whole disk of a partitioned disk
diff --git a/cddl/usr.sbin/zfsd/zfsd_exception.cc b/cddl/usr.sbin/zfsd/zfsd_exception.cc
index 7859a654003e..7ebb74ca8c6a 100644
--- a/cddl/usr.sbin/zfsd/zfsd_exception.cc
+++ b/cddl/usr.sbin/zfsd/zfsd_exception.cc
@@ -36,6 +36,7 @@
* Implementation of the ZfsdException class.
#include <sys/cdefs.h>
+#include <sys/byteorder.h>
#include <sys/fs/zfs.h>
#include <syslog.h>
diff --git a/cddl/usr.sbin/zfsd/zpool_list.cc b/cddl/usr.sbin/zfsd/zpool_list.cc
index 1d1540b294a2..82c35736df13 100644
--- a/cddl/usr.sbin/zfsd/zpool_list.cc
+++ b/cddl/usr.sbin/zfsd/zpool_list.cc
@@ -38,6 +38,7 @@
* Implementation of the ZpoolList class.
#include <sys/cdefs.h>
+#include <sys/byteorder.h>
#include <sys/fs/zfs.h>
#include <stdint.h>