diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..0b7abb2c88 --- /dev/null +++ b/.gitignore @@ -0,0 +1,52 @@ +# +# N.B. +# This is the toplevel .gitignore file. +# This is not the place for entries that are specific to +# a subdirectory. Instead add those files to the +# .gitignore file in that subdirectory. +# +# N.B. +# Please use 'git ls-files -i --exclude-standard' +# command after changing this file, to see if there are +# any tracked files which get ignored after the change. + +# +# Normal rules +# +*.[oa] +*.ko +*.ko.unsigned +*.ko.out +*.ko.out.sig +*.lo +*.la +*.mod.c +*~ +*.swp +.*.cmd +.deps +.libs +.DS_Store +modules.order +Makefile + +# +# Top level generated files specific to this top level dir +# +/Makefile +/config.log +/config.status +/libtool +/zfs_config.h +/zfs.spec +/zfs-modules.spec +/stamp-h1 +/.script-config + +# +# Top level generic files +# +!.gitignore +tags +TAGS +cscope.* diff --git a/ChangeLog b/ChangeLog index 5730eb1c9e..63c7947cbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,127 @@ +2010-03-11 Brian Behlendorf + + * : Tag zfs-0.4.8 - Use 'git log --no-merges' for full change log. + + * : Build system improvements: + - Remove Module.markers and Module.symver{s} in clean target. + - Improved kernel source detection when none specified. + - Fix RPM definitions for the unknown distro/installation. + - Check for spl in ../spl if not found in install path. + - Include all headers regardless of depth in packages. + - Allow recursive configure/make. + + * lib/libzpool/kernel.c: Fixed several zdb bugs when opening a pool + - zdb wasn't getting the correct device size when the vdev is a + block device. In Solaris, fstat64() returns the device size but + in Linux an ioctl() is needed. + - make sure that we don't try to open a block device in write mode + from userspace. This shouldn't happen, because zdb opens devices + in read-only mode, and ztest only uses files. + + * lib/libspl/include/umem.h: Add umem_alloc_aligned() and honor + cache_align field for umem cache. Under linux we open block devices + with O_DIRECT which means we must provide aligned memory buffers. + + * lib/libzpool/kernel.c: Fix some incorrect error handling. In + vn_open(), if fstat64() returned an error, the real errno was being + obscured by calling close(). + + * scripts/*: Fix scripts to work when invoked from other directories. + + * module/zfs/arc.c: Fix struct ht_lock padding in arc.c. + + * lib/libefi/include/sys/uuid.h: Fix duplicate uuid_t typedef. + + * module/zfs/txg.c: Use CPU percentages for number of commit cb + threads. This doesn't change number of threads in the kernel, but it + reduces number of threads in ztest (important due to 32-bit address + limitations). + + * cmd/ztest/ztest.c: Clean up emulation of kernel threads in + userspace. Updated to use pthread thread specific data rather than + keeping a global list. This also fixes at least one easily + reproducible crash in ztest + + * META, config/kernel.m4: Add configure check for kernel build + options which are incompatible with the license. If your building + against a kernel deemed incompatible configure will fail and + suggest how you should rebuild your kernel. + + * config/kernel-fmode-t.m4: Linux 2.6.28 compat, add a check for the + fmode_t type. This typedef first appears in 2.6.28 kernels as part + of some block device operation reworking. + + * module/zfs/dmu_send.c: No inline to keep dmu_recv_stream() stack + frame less than 1024 bytes. Recent builds against 2.6.31 flagged + dmu_recv_stream() as stack heavy. Further analysis of this function + should be performed to further reduce its stack usage. + + * scripts/common.sh: Split the udev rule from a specific configuration + by providing a generic 60-zpool.rules file which uses a small helper + util 'zpool_id' to parse a configuration file by default located in + /etc/zfs/zdev.conf. The helper script maps a by-path udev name to a + more friendly name of for large configurations. + + Additionally, when running zpool-create.sh in-tree it will no longer + use udev because we would have to copy certain helper scripts in to + the installed system. To avoid this the config file in simply + parsed and symlinks are created in your working tree. The script + will use udev if it as run as part of an installed zfs-test package. + + * module/zfs/zvol.c: Use check_disk_change() instead of + revalidate_disk(). For 2.6.27 kernels are earlier revalidate_disk() + was not available. However, check_disk_change() has been available + for far longer and will properly inform the kernel of the volume + change for both older and newer kernels. + + * module/zfs/dmu.c: Fixed incorrect ASSERT3S() added by ZVOL. + + * module/zfs/vdev_raidz.c, module/zfs/zvol.c: Minor fixes for 32-bit. + + * scripts/zfs-update.sh, man/man8/*: Added man pages based on the + latest documentation and modified zfs-update.sh script to update them. + + * .gitignore: Updated .gitignore rules to exclude build products. + +2009-11-24 Brian Behlendorf + + * : Tag zfs-0.4.7 - Use 'git log --no-merges' for full change log. + + * module/zcommon/include/sys/fs/zfs.h, module/zfs/include/sys/blkdev.h, + module/zfs/include/sys/dmu.h, module/zfs/dmu.c, + module/zfs/include/sys/zvol.h, module/zfs/zvol.c, + module/zfs/zfs_ioctl.c: + Added the ZVOL block device, with the addition of the ZVOL real ZFS + based block devices are available and can be compared head to head + with Linux's MD and LVM block drivers. The Linux ZVOL has not yet + had any performance work done but from a user perspective it should + be functionally complete and behave like any other Linux block device. + The ZVOL has so far been tested using zconfig.sh on the following + x86_64 based platforms: FC11, CHAOS4, RHEL5, RHEL6, and SLES11. + However, more testing is required to ensure everything is working + as designed. + + * scripts/udev-rules/99-zpool.rules.promise, + scripts/zpool-config/promise-raid0-1x16.sh, + scripts/zpool-config/promise-raid10-8x2.sh, + scripts/zpool-config/promise-raidz-2x8.sh, + scripts/zpool-config/promise-raidz2-2x8.sh: + Additional test configurations for a small 16 drive JBOD. + + * module/zfs/arc.c: Linux 2.6.31 compat, mutexes can now exceed 64 + bytes depending on the the kernel build options. To account for + this increase the pad size to 256 bytes. + + * module/zfs/vdev_disk.c: Linux 2.6.31 compat, to get the hard + sector size use bdev_logical_block_size() this function replaces + bdev_hardsect_size(). + + * module/zfs/zfs_rlock.c: Prevent gcc uninit compiler warning in + zfs_range_unlock_reader(). + + * Makefile.am: Ensure *.order and *.markers build products are + removed by distclean rule. + 2009-11-02 Brian Behlendorf * : Tag zfs-0.4.6 - Use 'git log --no-merges' for full change log. @@ -333,7 +457,7 @@ - Minor build system improvements - Minor script improvements - Create a full copy and not a link tree with quilt - - KPIOS_MAJOR changed from 231 to 232 + - ZPIOS_MAJOR changed from 231 to 232 - BIO_RW_BARRIER flag removed from IO request 2008-06-30 Brian Behlendorf diff --git a/META b/META index 4f3feaaf95..43d256879f 100644 --- a/META +++ b/META @@ -1,6 +1,8 @@ Meta: 1 Name: zfs Branch: 1.0 -Version: 0.4.6 +Version: 0.4.8 Release: 1 Release-Tags: relext +License: CDDL +Author: Sun Microsystems/Oracle, Lawrence Livermore National Laboratory diff --git a/Makefile.am b/Makefile.am index cb1fefa0aa..d0a70b06cd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ include $(top_srcdir)/config/rpm.am if CONFIG_USER -USER_DIR = config doc scripts lib cmd +USER_DIR = config etc man scripts lib cmd endif if CONFIG_KERNEL KERNEL_DIR = module @@ -9,10 +9,11 @@ endif SUBDIRS = $(USER_DIR) $(KERNEL_DIR) AUTOMAKE_OPTIONS = foreign dist-zip -EXTRA_DIST = autogen.sh zfs.spec.in zfs-modules.spec.in +EXTRA_DIST = autogen.sh config/config.awk +EXTRA_DIST += zfs.spec.in zfs-modules.spec.in EXTRA_DIST += META DISCLAIMER GIT EXTRA_DIST += OPENSOLARIS.LICENSE ZFS.RELEASE -noinst_HEADERS = zfs_config.h zfs_unconfig.h +noinst_HEADERS = zfs_config.h distclean-local:: -$(RM) -R autom4te*.cache @@ -23,6 +24,7 @@ distclean-local:: -o -name '.*.rej' -o -name 'aclocal.m4' -o -size 0 \ -o -name '*%' -o -name '.*.cmd' -o -name 'core' \ -o -name 'Makefile' -o -name 'Module.symvers' \ + -o -name '*.order' -o -name '*.markers' \ -o -name '.script-config' \) \ -type f -print | xargs $(RM) diff --git a/cmd/Makefile.am b/cmd/Makefile.am index 86ec885bc2..98794d574e 100644 --- a/cmd/Makefile.am +++ b/cmd/Makefile.am @@ -1 +1 @@ -SUBDIRS = zfs zpool zdb zinject ztest +SUBDIRS = zfs zpool zpool_id zdb zinject ztest diff --git a/cmd/zdb/.gitignore b/cmd/zdb/.gitignore new file mode 100644 index 0000000000..f64a3fc5a1 --- /dev/null +++ b/cmd/zdb/.gitignore @@ -0,0 +1 @@ +/zdb diff --git a/cmd/zfs/.gitignore b/cmd/zfs/.gitignore new file mode 100644 index 0000000000..0fd9cc63af --- /dev/null +++ b/cmd/zfs/.gitignore @@ -0,0 +1 @@ +/zfs diff --git a/cmd/zinject/.gitignore b/cmd/zinject/.gitignore new file mode 100644 index 0000000000..bded840099 --- /dev/null +++ b/cmd/zinject/.gitignore @@ -0,0 +1 @@ +/zinject diff --git a/cmd/zpool/.gitignore b/cmd/zpool/.gitignore new file mode 100644 index 0000000000..8ea518af78 --- /dev/null +++ b/cmd/zpool/.gitignore @@ -0,0 +1 @@ +/zpool diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am index 3f30eff47d..ec9757bd62 100644 --- a/cmd/zpool/Makefile.am +++ b/cmd/zpool/Makefile.am @@ -7,6 +7,7 @@ DEFAULT_INCLUDES += \ -I${top_srcdir}/lib/libzfs/include \ -I${top_srcdir}/lib/libnvpair/include \ -I${top_srcdir}/module/zcommon/include \ + -I${top_srcdir}/module/zfs/include \ -I${top_srcdir}/module/nvpair/include \ -I${top_srcdir}/module/avl/include \ -I${top_srcdir}/module/unicode/include diff --git a/cmd/zpool_id/Makefile.am b/cmd/zpool_id/Makefile.am new file mode 100644 index 0000000000..023e1ab59a --- /dev/null +++ b/cmd/zpool_id/Makefile.am @@ -0,0 +1 @@ +dist_bin_SCRIPTS = zpool_id diff --git a/cmd/zpool_id/zpool_id b/cmd/zpool_id/zpool_id new file mode 100755 index 0000000000..c3637847a8 --- /dev/null +++ b/cmd/zpool_id/zpool_id @@ -0,0 +1,60 @@ +#!/bin/bash + +CONFIG=${CONFIG:-/etc/zfs/zdev.conf} +PATH_ID=${PATH_ID:-/lib/udev/path_id} +AWK=${AWK:-/bin/awk} + +die() { + echo "Error: $*" + exit 1 +} + +usage() { + cat << EOF +Usage: zpool_id [h] [-c configfile] + -c Alternate config file [default /etc/zfs/zdev.conf] + -d Use path_id from device as the mapping key + -h Show this message +EOF + exit 1 +} + +while getopts 'c:d:h' OPTION; do + case ${OPTION} in + c) + CONFIG=${OPTARG} + ;; + d) + DEVICE=${OPTARG} + ;; + h) + usage + ;; + esac +done + +# Check that a device was requested +[ -z ${DEVICE} ] && usage + +# Check for the existence of a configuration file +[ ! -f ${CONFIG} ] && die "Missing config file: ${CONFIG}" + +# Use udev's path_id to generate a unique persistent key +eval `${PATH_ID} ${DEVICE}` +[ -z ${ID_PATH} ] && die "Missing ID_PATH for ${DEVICE}" + +# Use the persistent key to lookup the zpool device id in the +# configuration file which is of the format . +# Lines starting with #'s are treated as comments and ignored. +# Exact matches are required, wild cards are not supported, +# and only the first match is returned. +ID_ZPOOL=`${AWK} "/${ID_PATH}\>/ && !/^#/ { print \\$1; exit }" ${CONFIG}` +[ -z ${ID_ZPOOL} ] && die "Missing ID_ZPOOL for ID_PATH: ${ID_PATH}" + +if [ ${ID_ZPOOL} ]; then + echo "ID_PATH=${ID_PATH}" + echo "ID_ZPOOL=${ID_ZPOOL}" + echo "ID_ZPOOL_PATH=disk/zpool/${ID_ZPOOL}" +fi + +exit 0 diff --git a/cmd/ztest/.gitignore b/cmd/ztest/.gitignore new file mode 100644 index 0000000000..d3d498dae6 --- /dev/null +++ b/cmd/ztest/.gitignore @@ -0,0 +1 @@ +/ztest diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index e106499191..d4f16692ff 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -58,6 +58,9 @@ * the transaction group number is less than the current, open txg. * If you add a new test, please do this if applicable. * + * (7) Threads are created with a reduced stack size, for sanity checking. + * Therefore, it's important not to allocate huge buffers on the stack. + * * When run with no arguments, ztest runs for about five minutes and * produces no output if successful. To get a little bit of information, * specify -V. To get more information, specify -VV, and so on. @@ -141,7 +144,6 @@ typedef struct ztest_args { objset_t *za_os; zilog_t *za_zilog; kthread_t *za_thread; - kt_did_t za_threadid; uint64_t za_instance; uint64_t za_random; uint64_t za_diroff; @@ -157,6 +159,7 @@ typedef struct ztest_args { ztest_block_tag_t za_wbt; dmu_object_info_t za_doi; dmu_buf_t *za_dbuf; + boolean_t za_exited; } ztest_args_t; typedef void ztest_func_t(ztest_args_t *); @@ -253,6 +256,8 @@ typedef struct ztest_shared { kmutex_t zs_sync_lock[ZTEST_SYNC_LOCKS]; uint64_t zs_seq[ZTEST_SYNC_LOCKS]; ztest_cb_list_t zs_cb_list; + kmutex_t zs_thr_lock; + kcondvar_t zs_thr_cv; } ztest_shared_t; static char ztest_dev_template[] = "%s/%s.%llua"; @@ -264,6 +269,7 @@ static int ztest_dump_core = 1; static uint64_t metaslab_sz; static boolean_t ztest_exiting; +static boolean_t resume_thr_exited; extern uint64_t metaslab_gang_bang; extern uint64_t metaslab_df_alloc_threshold; @@ -2571,7 +2577,7 @@ ztest_dmu_write_parallel(ztest_args_t *za) uint64_t off, txg, txg_how; kmutex_t *lp; char osname[MAXNAMELEN]; - char iobuf[SPA_MAXBLOCKSIZE]; + char *iobuf; blkptr_t blk; uint64_t blkoff; zbookmark_t zb; @@ -2741,6 +2747,8 @@ ztest_dmu_write_parallel(ztest_args_t *za) ASSERT3U(BP_GET_LEVEL(&blk), ==, 0); ASSERT3U(BP_GET_LSIZE(&blk), ==, bs); + iobuf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL); + /* * Read the block that dmu_sync() returned to make sure its contents * match what we wrote. We do this while still txg_suspend()ed @@ -2759,10 +2767,10 @@ ztest_dmu_write_parallel(ztest_args_t *za) bcopy(&iobuf[blkoff], rbt, btsize); if (rbt->bt_objset == 0) /* concurrent free */ - return; + goto out; if (wbt->bt_objset == 0) /* all-zero overwrite */ - return; + goto out; ASSERT3U(rbt->bt_objset, ==, wbt->bt_objset); ASSERT3U(rbt->bt_object, ==, wbt->bt_object); @@ -2778,6 +2786,8 @@ ztest_dmu_write_parallel(ztest_args_t *za) ASSERT3U(rbt->bt_seq, ==, wbt->bt_seq); else ASSERT3U(rbt->bt_seq, >, wbt->bt_seq); +out: + umem_free(iobuf, SPA_MAXBLOCKSIZE); } /* @@ -3819,6 +3829,8 @@ ztest_resume_thread(void *arg) ztest_resume(spa); } + resume_thr_exited = B_TRUE; + thread_exit(); return (NULL); } @@ -3884,6 +3896,13 @@ ztest_thread(void *arg) break; } + mutex_enter(&zs->zs_thr_lock); + za->za_exited = B_TRUE; + mutex_exit(&zs->zs_thr_lock); + + /* Announce that the thread has finished */ + cv_broadcast(&zs->zs_thr_cv); + thread_exit(); return (NULL); } @@ -3900,13 +3919,14 @@ ztest_run(char *pool) spa_t *spa; char name[100]; kthread_t *resume_thread; - kt_did_t resume_id; ztest_exiting = B_FALSE; mutex_init(&zs->zs_vdev_lock, NULL, MUTEX_DEFAULT, NULL); rw_init(&zs->zs_name_lock, NULL, RW_DEFAULT, NULL); mutex_init(&zs->zs_cb_list.zcl_callbacks_lock,NULL,MUTEX_DEFAULT,NULL); + mutex_init(&zs->zs_thr_lock, NULL, MUTEX_DEFAULT, NULL); + cv_init(&zs->zs_thr_cv, NULL, CV_DEFAULT, NULL); list_create(&zs->zs_cb_list.zcl_callbacks, sizeof (ztest_cb_data_t), offsetof(ztest_cb_data_t, zcd_node)); @@ -3979,9 +3999,9 @@ ztest_run(char *pool) /* * Create a thread to periodically resume suspended I/O. */ + resume_thr_exited = B_FALSE; VERIFY3P((resume_thread = thread_create(NULL, 0, ztest_resume_thread, - spa, THR_BOUND, NULL, 0, 0)), !=, NULL); - resume_id = resume_thread->t_tid; + spa, TS_RUN, NULL, 0, 0)), !=, NULL); /* * Verify that we can safely inquire about about any object, @@ -4057,13 +4077,18 @@ ztest_run(char *pool) za[d].za_zilog = zil_open(za[d].za_os, NULL); } + za[t].za_exited = B_FALSE; + VERIFY3P((za[t].za_thread = thread_create(NULL, 0, ztest_thread, - &za[t], THR_BOUND, NULL, 0, 0)), !=, NULL); - za[t].za_threadid = za[t].za_thread->t_tid; + &za[t], TS_RUN, NULL, 0, 0)), !=, NULL); } while (--t >= 0) { - VERIFY(thread_join(za[t].za_threadid, NULL, NULL) == 0); + mutex_enter(&zs->zs_thr_lock); + while (!za[t].za_exited) + cv_wait(&zs->zs_thr_cv, &zs->zs_thr_lock); + mutex_exit(&zs->zs_thr_lock); + if (t < zopt_datasets) { zil_close(za[t].za_zilog); dmu_objset_close(za[t].za_os); @@ -4102,7 +4127,11 @@ ztest_run(char *pool) /* Kill the resume thread */ ztest_exiting = B_TRUE; - VERIFY(thread_join(resume_id, NULL, NULL) == 0); + + /* Wait for the resume thread to exit */ + while (!resume_thr_exited) + (void) poll(NULL, 0, 200); + ztest_resume(spa); /* @@ -4118,6 +4147,8 @@ ztest_run(char *pool) list_destroy(&zs->zs_cb_list.zcl_callbacks); + cv_destroy(&zs->zs_thr_cv); + mutex_destroy(&zs->zs_thr_lock); mutex_destroy(&zs->zs_cb_list.zcl_callbacks_lock); rw_destroy(&zs->zs_name_lock); mutex_destroy(&zs->zs_vdev_lock); diff --git a/config/Rules.am b/config/Rules.am index e36860ee68..bb188427ea 100644 --- a/config/Rules.am +++ b/config/Rules.am @@ -1,9 +1,7 @@ -DEFAULT_INCLUDES = -I${top_srcdir} +DEFAULT_INCLUDES = -include ${top_srcdir}/zfs_config.h -# FIXME: Add -Wshadow once everything is working +AM_LIBTOOLFLAGS = --silent AM_CFLAGS = -Wall -Wstrict-prototypes -fno-strict-aliasing -Werror - -# Expected defines not covered by zfs_config.h or spl_config.h AM_CFLAGS += -D_GNU_SOURCE -D__EXTENSIONS__ -D_REENTRANT AM_CFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_FILE_OFFSET_BITS=64 AM_CFLAGS += -D_LARGEFILE64_SOURCE -DTEXT_DOMAIN=\"zfs-linux-user\" diff --git a/config/config.awk b/config/config.awk new file mode 100644 index 0000000000..cc4b7cc265 --- /dev/null +++ b/config/config.awk @@ -0,0 +1,15 @@ +# Remove default preprocessor define's from config.h +# PACKAGE +# PACKAGE_BUGREPORT +# PACKAGE_NAME +# PACKAGE_STRING +# PACKAGE_TARNAME +# PACKAGE_VERSION +# STDC_HEADERS +# VERSION + +BEGIN { RS = "" ; FS = "\n" } \ + !/.#define PACKAGE./ && \ + !/.#define VERSION./ && \ + !/.#define STDC_HEADERS./ \ + { print $0"\n" } diff --git a/config/kernel-bdev-block-device-operations.m4 b/config/kernel-bdev-block-device-operations.m4 new file mode 100644 index 0000000000..daf14f0f9e --- /dev/null +++ b/config/kernel-bdev-block-device-operations.m4 @@ -0,0 +1,33 @@ +dnl # +dnl # 2.6.x API change +dnl # +AC_DEFUN([ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS], [ + AC_MSG_CHECKING([block device operation prototypes]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + int (*blk_open) (struct block_device *, fmode_t) = NULL; + int (*blk_release) (struct gendisk *, fmode_t) = NULL; + int (*blk_ioctl) (struct block_device *, fmode_t, + unsigned, unsigned long) = NULL; + int (*blk_compat_ioctl) (struct block_device *, fmode_t, + unsigned, unsigned long) = NULL; + struct block_device_operations blk_ops = { + .open = blk_open, + .release = blk_release, + .ioctl = blk_ioctl, + .compat_ioctl = blk_compat_ioctl, + }; + + blk_ops.open(NULL, 0); + blk_ops.release(NULL, 0); + blk_ops.ioctl(NULL, 0, 0, 0); + blk_ops.compat_ioctl(NULL, 0, 0, 0); + ],[ + AC_MSG_RESULT(struct block_device) + AC_DEFINE(HAVE_BDEV_BLOCK_DEVICE_OPERATIONS, 1, + [struct block_device_operations use bdevs]) + ],[ + AC_MSG_RESULT(struct inode) + ]) +]) diff --git a/config/kernel-bio-rw-syncio.m4 b/config/kernel-bio-rw-syncio.m4 index 93a32e659f..2c80f5c0ea 100644 --- a/config/kernel-bio-rw-syncio.m4 +++ b/config/kernel-bio-rw-syncio.m4 @@ -7,7 +7,8 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_RW_SYNCIO], [ ZFS_LINUX_TRY_COMPILE([ #include ],[ - int flags = BIO_RW_SYNCIO; + int flags; + flags = BIO_RW_SYNCIO; ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_BIO_RW_SYNCIO, 1, diff --git a/config/kernel-blk-end-request.m4 b/config/kernel-blk-end-request.m4 new file mode 100644 index 0000000000..20ad1a9263 --- /dev/null +++ b/config/kernel-blk-end-request.m4 @@ -0,0 +1,37 @@ +dnl # +dnl # 2.6.31 API change +dnl # In 2.6.29 kernels blk_end_request() was a GPL-only symbol, this was +dnl # changed in 2.6.31 so it may be used by non-GPL modules. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_BLK_END_REQUEST], [ + AC_MSG_CHECKING([whether blk_end_request() is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct request *req = NULL; + (void) blk_end_request(req, 0, 0); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BLK_END_REQUEST, 1, + [blk_end_request() is available]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([whether blk_end_request() is GPL-only]) + ZFS_LINUX_TRY_COMPILE([ + #include + #include + + MODULE_LICENSE("CDDL"); + ],[ + struct request *req = NULL; + (void) blk_end_request(req, 0, 0); + ],[ + AC_MSG_RESULT(no) + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BLK_END_REQUEST_GPL_ONLY, 1, + [blk_end_request() is GPL-only]) + ]) +]) diff --git a/config/kernel-blk-fetch-request.m4 b/config/kernel-blk-fetch-request.m4 new file mode 100644 index 0000000000..34a5d2fa8f --- /dev/null +++ b/config/kernel-blk-fetch-request.m4 @@ -0,0 +1,22 @@ +dnl # +dnl # 2.6.31 API change +dnl # Request queue peek/retrieval interface cleanup, the blk_fetch_request() +dnl # function replaces the elv_next_request() and blk_fetch_request() +dnl # functions. The updated blk_fetch_request() function returns the +dnl # next available request and removed it from the request queue. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_BLK_FETCH_REQUEST], [ + AC_MSG_CHECKING([whether blk_fetch_request() is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct request_queue *q = NULL; + (void) blk_fetch_request(q); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BLK_FETCH_REQUEST, 1, + [blk_fetch_request() is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel-blk-requeue-request.m4 b/config/kernel-blk-requeue-request.m4 new file mode 100644 index 0000000000..f676f85cb2 --- /dev/null +++ b/config/kernel-blk-requeue-request.m4 @@ -0,0 +1,22 @@ +dnl # +dnl # 2.6.31 API change +dnl # Request queue peek/retrieval interface cleanup, the +dnl # elv_requeue_request() function has been replaced with the +dnl # blk_requeue_request() function. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_BLK_REQUEUE_REQUEST], [ + AC_MSG_CHECKING([whether blk_requeue_request() is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct request_queue *q = NULL; + struct request *req = NULL; + blk_requeue_request(q, req); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BLK_REQUEUE_REQUEST, 1, + [blk_requeue_request() is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel-blk-rq-bytes.m4 b/config/kernel-blk-rq-bytes.m4 new file mode 100644 index 0000000000..da83405cbe --- /dev/null +++ b/config/kernel-blk-rq-bytes.m4 @@ -0,0 +1,38 @@ +dnl # +dnl # 2.6.29 API change +dnl # In the 2.6.29 kernel blk_rq_bytes() was available as a GPL-only symbol. +dnl # So we need to check the symbol license as well. As of 2.6.31 the +dnl blk_rq_bytes() helper was changed to a static inline which we can use. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_BLK_RQ_BYTES], [ + AC_MSG_CHECKING([whether blk_rq_bytes() is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct request *req = NULL; + (void) blk_rq_bytes(req); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BLK_RQ_BYTES, 1, + [blk_rq_bytes() is available]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([whether blk_rq_bytes() is GPL-only]) + ZFS_LINUX_TRY_COMPILE([ + #include + #include + + MODULE_LICENSE("CDDL"); + ],[ + struct request *req = NULL; + (void) blk_rq_bytes(req); + ],[ + AC_MSG_RESULT(no) + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BLK_RQ_BYTES_GPL_ONLY, 1, + [blk_rq_bytes() is GPL-only]) + ]) +]) diff --git a/config/kernel-blk-rq-pos.m4 b/config/kernel-blk-rq-pos.m4 new file mode 100644 index 0000000000..aaa464665c --- /dev/null +++ b/config/kernel-blk-rq-pos.m4 @@ -0,0 +1,18 @@ +dnl # +dnl # 2.6.31 API change +dnl # +AC_DEFUN([ZFS_AC_KERNEL_BLK_RQ_POS], [ + AC_MSG_CHECKING([whether blk_rq_pos() is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct request *req = NULL; + (void) blk_rq_pos(req); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BLK_RQ_POS, 1, + [blk_rq_pos() is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel-blk-rq-sectors.m4 b/config/kernel-blk-rq-sectors.m4 new file mode 100644 index 0000000000..db8c43938d --- /dev/null +++ b/config/kernel-blk-rq-sectors.m4 @@ -0,0 +1,18 @@ +dnl # +dnl # 2.6.31 API change +dnl # +AC_DEFUN([ZFS_AC_KERNEL_BLK_RQ_SECTORS], [ + AC_MSG_CHECKING([whether blk_rq_sectors() is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct request *req = NULL; + (void) blk_rq_sectors(req); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BLK_RQ_SECTORS, 1, + [blk_rq_sectors() is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel-fmode-t.m4 b/config/kernel-fmode-t.m4 new file mode 100644 index 0000000000..cf25d81272 --- /dev/null +++ b/config/kernel-fmode-t.m4 @@ -0,0 +1,18 @@ +dnl # +dnl # 2.6.28 API change, +dnl # check if fmode_t typedef is defined +dnl # +AC_DEFUN([ZFS_AC_KERNEL_TYPE_FMODE_T], + [AC_MSG_CHECKING([whether kernel defines fmode_t]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + fmode_t *ptr; + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_FMODE_T, 1, + [kernel defines fmode_t]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) diff --git a/config/kernel-get-disk-ro.m4 b/config/kernel-get-disk-ro.m4 new file mode 100644 index 0000000000..365afdbc69 --- /dev/null +++ b/config/kernel-get-disk-ro.m4 @@ -0,0 +1,18 @@ +dnl # +dnl # 2.6.x API change +dnl # +AC_DEFUN([ZFS_AC_KERNEL_GET_DISK_RO], [ + AC_MSG_CHECKING([whether get_disk_ro() is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct gendisk *disk = NULL; + (void) get_disk_ro(disk); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GET_DISK_RO, 1, + [blk_disk_ro() is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel-rq-for-each_segment.m4 b/config/kernel-rq-for-each_segment.m4 new file mode 100644 index 0000000000..15f030f350 --- /dev/null +++ b/config/kernel-rq-for-each_segment.m4 @@ -0,0 +1,20 @@ +dnl # +dnl # 2.6.x API change +dnl # +AC_DEFUN([ZFS_AC_KERNEL_RQ_FOR_EACH_SEGMENT], [ + AC_MSG_CHECKING([whether rq_for_each_segment() is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct bio_vec *bv; + struct req_iterator iter; + struct request *req = NULL; + rq_for_each_segment(bv, req, iter) { } + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_RQ_FOR_EACH_SEGMENT, 1, + [rq_for_each_segment() is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel-rq-is_sync.m4 b/config/kernel-rq-is_sync.m4 new file mode 100644 index 0000000000..40d0de80cd --- /dev/null +++ b/config/kernel-rq-is_sync.m4 @@ -0,0 +1,18 @@ +dnl # +dnl # 2.6.x API change +dnl # +AC_DEFUN([ZFS_AC_KERNEL_RQ_IS_SYNC], [ + AC_MSG_CHECKING([whether rq_is_sync() is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct request *req = NULL; + (void) rq_is_sync(req); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_RQ_IS_SYNC, 1, + [rq_is_sync() is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index de0c8575a4..9906fc5a31 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -4,22 +4,33 @@ dnl # AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL ZFS_AC_SPL + ZFS_AC_KERNEL_CONFIG + ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS + ZFS_AC_KERNEL_TYPE_FMODE_T ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE + ZFS_AC_KERNEL_BIO_EMPTY_BARRIER ZFS_AC_KERNEL_BIO_END_IO_T_ARGS ZFS_AC_KERNEL_BIO_RW_SYNCIO - ZFS_AC_KERNEL_BIO_EMPTY_BARRIER - - dnl # Kernel build make options - dnl # KERNELMAKE_PARAMS="V=1" # Enable verbose module build - KERNELMAKE_PARAMS= + ZFS_AC_KERNEL_BLK_END_REQUEST + ZFS_AC_KERNEL_BLK_FETCH_REQUEST + ZFS_AC_KERNEL_BLK_REQUEUE_REQUEST + ZFS_AC_KERNEL_BLK_RQ_BYTES + ZFS_AC_KERNEL_BLK_RQ_POS + ZFS_AC_KERNEL_BLK_RQ_SECTORS + ZFS_AC_KERNEL_GET_DISK_RO + ZFS_AC_KERNEL_RQ_IS_SYNC + ZFS_AC_KERNEL_RQ_FOR_EACH_SEGMENT dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other dnl # compiler options are added by the kernel build system. KERNELCPPFLAGS="$KERNELCPPFLAGS -Werror -DHAVE_SPL -D_KERNEL" KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\"" - KERNELCPPFLAGS="$KERNELCPPFLAGS -I$TOPDIR -I$SPL -I$SPL/include" + KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL" + KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL/include" + KERNELCPPFLAGS="$KERNELCPPFLAGS -include $SPL/spl_config.h" + KERNELCPPFLAGS="$KERNELCPPFLAGS -include $TOPDIR/zfs_config.h" if test "$LINUX_OBJ" != "$LINUX"; then KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" @@ -30,7 +41,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ]) dnl # -dnl # Detect name used more Module.symvers file +dnl # Detect name used for Module.symvers file in kernel dnl # AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [ modpost=$LINUX/scripts/Makefile.modpost @@ -64,8 +75,14 @@ AC_DEFUN([ZFS_AC_KERNEL], [ AC_MSG_CHECKING([kernel source directory]) if test -z "$kernelsrc"; then - sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \ - 2>/dev/null | grep -v obj | tail -1` + headersdir="/lib/modules/$(uname -r)/build" + if test -e "$headersdir"; then + sourcelink=$(readlink -f "$headersdir") + else + sourcelink=$(ls -1d /usr/src/kernels/* \ + /usr/src/linux-* \ + 2>/dev/null | grep -v obj | tail -1) + fi if test -e $sourcelink; then kernelsrc=`readlink -f ${sourcelink}` @@ -135,7 +152,14 @@ AC_DEFUN([ZFS_AC_KERNEL], [ ]) dnl # -dnl # Detect name used for the additional SPL Module.symvers file +dnl # Detect name used for the additional SPL Module.symvers file. If one +dnl # does not exist this is likely because the SPL has been configured +dnl # but not built. To allow recursive builds a good guess is made as to +dnl # what this file will be named based on what it is named in the kernel +dnl # build products. This file will first be used at link time so if +dnl # the guess is wrong the build will fail then. This unfortunately +dnl # means the ZFS package does not contain a reliable mechanism to +dnl # detect symbols exported by the SPL at configure time. dnl # AC_DEFUN([ZFS_AC_SPL_MODULE_SYMVERS], [ AC_MSG_CHECKING([spl file name for module symbols]) @@ -144,7 +168,7 @@ AC_DEFUN([ZFS_AC_SPL_MODULE_SYMVERS], [ elif test -r $SPL_OBJ/Modules.symvers; then SPL_SYMBOLS=Modules.symvers else - SPL_SYMBOLS=NONE + SPL_SYMBOLS=$LINUX_SYMBOLS fi AC_MSG_RESULT([$SPL_SYMBOLS]) @@ -171,6 +195,10 @@ AC_DEFUN([ZFS_AC_SPL], [ sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \ 2>/dev/null | tail -1` + if test -z "$sourcelink" || test ! -e $sourcelink; then + sourcelink=../spl + fi + if test -e $sourcelink; then splsrc=`readlink -f ${sourcelink}` else @@ -227,6 +255,30 @@ AC_DEFUN([ZFS_AC_SPL], [ ZFS_AC_SPL_MODULE_SYMVERS ]) +dnl # +dnl # There are certain kernel build options which when enabled are +dnl # completely incompatible with non GPL kernel modules. It is best +dnl # to detect these at configure time and fail with a clear error +dnl # rather than build everything and fail during linking. +dnl # +dnl # CONFIG_DEBUG_LOCK_ALLOC - Maps mutex_lock() to mutex_lock_nested() +dnl # +AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [ + + if test "$ZFS_META_LICENSE" = CDDL; then + ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC], + AC_MSG_ERROR([ + *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is + *** incompatible with the CDDL license. You must rebuild + *** your kernel without this option.]), []) + fi + + if test "$ZFS_META_LICENSE" = GPL; then + AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1], + [Define to 1 if licensed under the GPL]) + fi +]) + dnl # dnl # ZFS_LINUX_CONFTEST dnl # @@ -307,7 +359,7 @@ dnl # AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [AC_MSG_CHECKING([whether symbol $1 is exported]) grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ - $LINUX_OBJ/Module*.symvers $SPL_OBJ/Module*.symvers 2>/dev/null + $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null rc=$? if test $rc -ne 0; then export=0 diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index ccfd2eda22..232736498a 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -1,13 +1,9 @@ AC_DEFUN([ZFS_AC_LICENSE], [ - AC_MSG_CHECKING([zfs license]) - LICENSE=`grep MODULE_LICENSE module/zfs/zfs_ioctl.c | cut -f2 -d'"'` - AC_MSG_RESULT([$LICENSE]) - if test "$LICENSE" = GPL; then - AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1], - [Define to 1 if module is licensed under the GPL]) - fi + AC_MSG_CHECKING([zfs author]) + AC_MSG_RESULT([$ZFS_META_AUTHOR]) - AC_SUBST(LICENSE) + AC_MSG_CHECKING([zfs license]) + AC_MSG_RESULT([$ZFS_META_LICENSE]) ]) AC_DEFUN([ZFS_AC_DEBUG], [ @@ -52,19 +48,22 @@ LIBDIR=${LIBDIR} CMDDIR=${CMDDIR} MODDIR=${MODDIR} SCRIPTDIR=${SCRIPTDIR} -UDEVDIR=\${TOPDIR}/scripts/udev-rules +ETCDIR=\${TOPDIR}/etc +DEVDIR=\${TOPDIR}/dev ZPOOLDIR=\${TOPDIR}/scripts/zpool-config ZDB=\${CMDDIR}/zdb/zdb ZFS=\${CMDDIR}/zfs/zfs ZINJECT=\${CMDDIR}/zinject/zinject ZPOOL=\${CMDDIR}/zpool/zpool +ZPOOL_ID=\${CMDDIR}/zpool_id/zpool_id ZTEST=\${CMDDIR}/ztest/ztest COMMON_SH=\${SCRIPTDIR}/common.sh ZFS_SH=\${SCRIPTDIR}/zfs.sh ZPOOL_CREATE_SH=\${SCRIPTDIR}/zpool-create.sh +INTREE=1 LDMOD=/sbin/insmod KERNEL_MODULES=( \\ @@ -98,6 +97,7 @@ AC_DEFUN([ZFS_AC_CONFIG], [ CMDDIR=$TOPDIR/cmd MODDIR=$TOPDIR/module SCRIPTDIR=$TOPDIR/scripts + TARGET_ASM_DIR=asm-generic AC_SUBST(TOPDIR) AC_SUBST(BUILDDIR) @@ -105,11 +105,12 @@ AC_DEFUN([ZFS_AC_CONFIG], [ AC_SUBST(CMDDIR) AC_SUBST(MODDIR) AC_SUBST(SCRIPTDIR) + AC_SUBST(TARGET_ASM_DIR) ZFS_CONFIG=all AC_ARG_WITH([config], AS_HELP_STRING([--with-config=CONFIG], - [Config file 'kernel|user|all']), + [Config file 'kernel|user|all|srpm']), [ZFS_CONFIG="$withval"]) AC_MSG_CHECKING([zfs config]) @@ -121,10 +122,11 @@ AC_DEFUN([ZFS_AC_CONFIG], [ user) ZFS_AC_CONFIG_USER ;; all) ZFS_AC_CONFIG_KERNEL ZFS_AC_CONFIG_USER ;; + srpm) ;; *) AC_MSG_RESULT([Error!]) AC_MSG_ERROR([Bad value "$ZFS_CONFIG" for --with-config, - user kernel|user|all]) ;; + user kernel|user|all|srpm]) ;; esac AM_CONDITIONAL([CONFIG_USER], diff --git a/config/zfs-meta.m4 b/config/zfs-meta.m4 index 393ced0dbe..8b3689af71 100644 --- a/config/zfs-meta.m4 +++ b/config/zfs-meta.m4 @@ -48,6 +48,14 @@ AC_DEFUN([ZFS_AC_META], [ AC_SUBST([ZFS_META_RELEASE]) fi + ZFS_META_LICENSE=_ZFS_AC_META_GETVAL([LICENSE]); + if test -n "$ZFS_META_LICENSE"; then + AC_DEFINE_UNQUOTED([ZFS_META_LICENSE], ["$ZFS_META_LICENSE"], + [Define the project license.] + ) + AC_SUBST([ZFS_META_LICENSE]) + fi + if test -n "$ZFS_META_NAME" -a -n "$ZFS_META_VERSION"; then ZFS_META_ALIAS="$ZFS_META_NAME-$ZFS_META_VERSION" test -n "$ZFS_META_RELEASE" && diff --git a/configure.ac b/configure.ac index 97ab137297..0d30f5e70a 100644 --- a/configure.ac +++ b/configure.ac @@ -35,10 +35,13 @@ AC_LANG(C) ZFS_AC_META AC_CONFIG_AUX_DIR([config]) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE([$ZFS_META_NAME], [$ZFS_META_VERSION]) -AC_CONFIG_HEADERS([zfs_config.h]) -AH_BOTTOM([#include ]) AM_MAINTAINER_MODE +AM_SILENT_RULES +AM_INIT_AUTOMAKE([$ZFS_META_NAME], [$ZFS_META_VERSION]) +AC_CONFIG_HEADERS([zfs_config.h], [ + (mv zfs_config.h zfs_config.h.tmp && + awk -f config/config.awk zfs_config.h.tmp >zfs_config.h && + rm zfs_config.h.tmp) || exit 1]) AC_PROG_INSTALL AC_PROG_CC @@ -52,7 +55,9 @@ ZFS_AC_DEBUG AC_CONFIG_FILES([ Makefile config/Makefile - doc/Makefile + etc/Makefile + man/Makefile + man/man8/Makefile lib/Makefile lib/libavl/Makefile lib/libefi/Makefile @@ -67,6 +72,7 @@ AC_CONFIG_FILES([ cmd/zfs/Makefile cmd/zinject/Makefile cmd/zpool/Makefile + cmd/zpool_id/Makefile cmd/ztest/Makefile module/Makefile module/avl/Makefile diff --git a/doc/LEGAL b/doc/LEGAL deleted file mode 100644 index 905141bcab..0000000000 --- a/doc/LEGAL +++ /dev/null @@ -1,113 +0,0 @@ -From: Chris Dunlap -To: tak1@llnl.gov (James Tak) -Cc: rogers11@llnl.gov (Leah Rogers), garlick@llnl.gov (Jim Garlick), - mgary@llnl.gov (Mark Gary), kimcupps@llnl.gov (Kim Cupps) -Date: Mon, 26 Mar 2007 15:37:07 -0700 -Subject: CDDL/GPL licensing issues for ZFS Linux port - -James, - -We want to port Sun's Zettabyte File System (ZFS) to Linux and -ultimately redistribute the source code of our work. We've been -talking with Leah about this and have a meeting scheduled with you -for this coming Thursday at 2pm. I just wanted to give you a summary -before the meeting of what we're proposing. - -ZFS is part of OpenSolaris which is licensed under the Common -Development and Distribution License (CDDL): - - http://www.opensolaris.org/os/licensing/cddllicense.txt - -The Linux kernel is licensed under the GNU General Public License (GPL) -(specifically, under version 2 of the license only): - - http://www.fsf.org/licensing/licenses/gpl.html - -While these are both Open-Source licenses, the Free Software Foundation -(FSF) states they are incompatible with one another: - - http://www.fsf.org/licensing/licenses/index_html - - "[CDDL] is a free software license which is not a strong copyleft; - it has some complex restrictions that make it incompatible with the - GNU GPL. It requires that all attribution notices be maintained, - while the GPL only requires certain types of notices. Also, it - terminates in retaliation for certain aggressive uses of patents. - So, a module covered by the GPL and a module covered by the CDDL - cannot legally be linked together." - -As an aside, Sun is reportedly considering releasing OpenSolaris under -GPL3 (i.e., the upcoming version 3 of the GNU General Public License): - - http://blogs.sun.com/jonathan/entry/hp_and_sun_partnering_around - - http://arstechnica.com/news.ars/post/20060130-6074.html - - http://news.com.com/Sun+considers+GPL+3+license+for+Solaris/2100-1016_3-6032893.html - -Since the GPL3 has not been finalized, it is unclear whether -incompatibilities will exist between GPL2 and GPL3. - -Linus Torvalds (the original creator of Linux) describes his views -on the licensing of Linux kernel modules in the following email thread: - - http://linuxmafia.com/faq/Kernel/proprietary-kernel-modules.html - -Most of this thread is in regards to proprietary closed-source -binary-only modules for Linux. Linus generally considers modules -written for Linux using the kernel infrastructures to be derived -works of Linux, even if they don't copy any existing Linux code. -However, he specifically singles out drivers and filesystems ported -from other operating systems as not being derived works: - - "It would be rather preposterous to call the Andrew FileSystem a - 'derived work' of Linux, for example, so I think it's perfectly - OK to have a AFS module, for example." - - "The original binary-only modules were for things that were - pre-existing works of code, i.e., drivers and filesystems ported - from other operating systems, which thus could clearly be argued - to not be derived works..." - -Based on this, it seems our port of Sun's ZFS filesystem to Linux -would not be considered a derived work of Linux, and therefore not -covered by the GPL. The issue of the CDDL/GPL license incompatibility -becomes moot. As such, we should be able to redistribute our changes -to ZFS in source-code form licensed under the CDDL since this will -be a derived work of the original ZFS code. There seems to be some -dissent as to whether a binary module could be redistributed as well, -but that issue does not concern us. In this instance, we are only -interested in redistribution of our work in source-code form. - --Chris - -To: Chris Dunlap -From: James Tak -Subject: Re: CDDL/GPL licensing issues for ZFS Linux port -Cc: rogers11@llnl.gov (Leah Rogers), garlick@llnl.gov (Jim Garlick), - mgary@llnl.gov (Mark Gary), kimcupps@llnl.gov (Kim Cupps) -Date: Thu, 29 Mar 2007 14:53:01 -0700 - -Hi Chris, -As per our discussion today, the ZFS port you are proposing releasing under -the CDDL license should be o.k. since it is a derivative work of the -original ZFS module (under CDDL) and is therefore also subject to CDDL -under the distribution terms of that license. While the issue of linking -has been greatly debated in the OS community, I think it is fair to say in -this instance the ZFS port is not a derivative work of Linux and thus not -subject to the GPL. Furthermore, it shouldn't be a problem especially -since even Linus Torvald has expressed that modules such as yours are not -derived works of Linux. - -Let me know if you have any further questions at x27274. Thanks. - -Regards, -James - -James S. Tak -Assistant Laboratory Counsel for Intellectual Property -Office of Laboratory Counsel -Lawrence Livermore National Laboratory -phone: (925) 422-7274 -fax: (925) 423-2231 -tak1@llnl.gov diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index 07f6386f45..0000000000 --- a/doc/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = LEGAL diff --git a/etc/Makefile.am b/etc/Makefile.am new file mode 100644 index 0000000000..1bc847d1a2 --- /dev/null +++ b/etc/Makefile.am @@ -0,0 +1,3 @@ +sysconfdir = /etc +nobase_dist_sysconf_DATA = zfs/* +nobase_dist_sysconf_DATA += udev/rules.d/* diff --git a/etc/udev/rules.d/60-zpool.rules b/etc/udev/rules.d/60-zpool.rules new file mode 100644 index 0000000000..0f4a356dd6 --- /dev/null +++ b/etc/udev/rules.d/60-zpool.rules @@ -0,0 +1,8 @@ +# +# /etc/udev/rules.d/99-zpool.rules +# + +ENV{DEVTYPE}=="disk", IMPORT{program}="/usr/bin/zpool_id -d %p" + +KERNEL=="*[!0-9]", ENV{SUBSYSTEM}=="block", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}" +KERNEL=="*[0-9]", ENV{SUBSYSTEM}=="block", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}-part%n" diff --git a/etc/zfs/zdev.conf b/etc/zfs/zdev.conf new file mode 100644 index 0000000000..236c342b3a --- /dev/null +++ b/etc/zfs/zdev.conf @@ -0,0 +1,9 @@ +# +# Custom by-path mapping for large JBOD configurations +# +# Example Config: Desktop +# + +# +#disk1 pci-0000:61:06.1-scsi-0:0:0:0 +#disk2 pci-0000:61:06.1-scsi-0:0:0:1 diff --git a/etc/zfs/zdev.conf.dragon.example b/etc/zfs/zdev.conf.dragon.example new file mode 100644 index 0000000000..23ef7f09d5 --- /dev/null +++ b/etc/zfs/zdev.conf.dragon.example @@ -0,0 +1,176 @@ +# +# Custom by-path mapping for large JBOD configurations +# +# Example Config: +# Quarter scale dragon drawer based SSU for RHEL6 +# + +# Channel A: PCI Bus 3, Enclosure 0x50001ff10e991000 +a1 pci-0000:03:00.0-sas-0x50001ff10e991000-34 +a2 pci-0000:03:00.0-sas-0x50001ff10e991000-35 +a3 pci-0000:03:00.0-sas-0x50001ff10e991000-39 +a4 pci-0000:03:00.0-sas-0x50001ff10e991000-40 +a5 pci-0000:03:00.0-sas-0x50001ff10e991000-44 +a6 pci-0000:03:00.0-sas-0x50001ff10e991000-45 +a7 pci-0000:03:00.0-sas-0x50001ff10e991000-48 +a8 pci-0000:03:00.0-sas-0x50001ff10e991000-49 +a9 pci-0000:03:00.0-sas-0x50001ff10e991000-50 +a10 pci-0000:03:00.0-sas-0x50001ff10e991000-53 +a11 pci-0000:03:00.0-sas-0x50001ff10e991000-54 +a12 pci-0000:03:00.0-sas-0x50001ff10e991000-55 +a13 pci-0000:03:00.0-sas-0x50001ff10e991000-58 +a14 pci-0000:03:00.0-sas-0x50001ff10e991000-59 +a15 pci-0000:03:00.0-sas-0x50001ff10e991000-60 + +# Channel B: PCI Bus 3, Enclosure 0x50001ff10e9d1000 +b1 pci-0000:03:00.0-sas-0x50001ff10e9d1000-34 +b2 pci-0000:03:00.0-sas-0x50001ff10e9d1000-35 +b3 pci-0000:03:00.0-sas-0x50001ff10e9d1000-39 +b4 pci-0000:03:00.0-sas-0x50001ff10e9d1000-40 +b5 pci-0000:03:00.0-sas-0x50001ff10e9d1000-44 +b6 pci-0000:03:00.0-sas-0x50001ff10e9d1000-45 +b7 pci-0000:03:00.0-sas-0x50001ff10e9d1000-48 +b8 pci-0000:03:00.0-sas-0x50001ff10e9d1000-49 +b9 pci-0000:03:00.0-sas-0x50001ff10e9d1000-50 +b10 pci-0000:03:00.0-sas-0x50001ff10e9d1000-53 +b11 pci-0000:03:00.0-sas-0x50001ff10e9d1000-54 +b12 pci-0000:03:00.0-sas-0x50001ff10e9d1000-55 +b13 pci-0000:03:00.0-sas-0x50001ff10e9d1000-58 +b14 pci-0000:03:00.0-sas-0x50001ff10e9d1000-59 +b15 pci-0000:03:00.0-sas-0x50001ff10e9d1000-60 + +# Channel C: PCI Bus 4, Enclosure 0x50001ff10e991000 +c1 pci-0000:04:00.0-sas-0x50001ff10e991000-31 +c2 pci-0000:04:00.0-sas-0x50001ff10e991000-32 +c3 pci-0000:04:00.0-sas-0x50001ff10e991000-33 +c4 pci-0000:04:00.0-sas-0x50001ff10e991000-36 +c5 pci-0000:04:00.0-sas-0x50001ff10e991000-37 +c6 pci-0000:04:00.0-sas-0x50001ff10e991000-38 +c7 pci-0000:04:00.0-sas-0x50001ff10e991000-41 +c8 pci-0000:04:00.0-sas-0x50001ff10e991000-42 +c9 pci-0000:04:00.0-sas-0x50001ff10e991000-43 +c10 pci-0000:04:00.0-sas-0x50001ff10e991000-46 +c11 pci-0000:04:00.0-sas-0x50001ff10e991000-47 +c12 pci-0000:04:00.0-sas-0x50001ff10e991000-51 +c13 pci-0000:04:00.0-sas-0x50001ff10e991000-52 +c14 pci-0000:04:00.0-sas-0x50001ff10e991000-56 +c15 pci-0000:04:00.0-sas-0x50001ff10e991000-57 + +# Channel D: PCI Bus 4, Enclosure 0x50001ff10e9d1000 +d1 pci-0000:04:00.0-sas-0x50001ff10e9d1000-31 +d2 pci-0000:04:00.0-sas-0x50001ff10e9d1000-32 +d3 pci-0000:04:00.0-sas-0x50001ff10e9d1000-33 +d4 pci-0000:04:00.0-sas-0x50001ff10e9d1000-36 +d5 pci-0000:04:00.0-sas-0x50001ff10e9d1000-37 +d6 pci-0000:04:00.0-sas-0x50001ff10e9d1000-38 +d7 pci-0000:04:00.0-sas-0x50001ff10e9d1000-41 +d8 pci-0000:04:00.0-sas-0x50001ff10e9d1000-42 +d9 pci-0000:04:00.0-sas-0x50001ff10e9d1000-43 +d10 pci-0000:04:00.0-sas-0x50001ff10e9d1000-46 +d11 pci-0000:04:00.0-sas-0x50001ff10e9d1000-47 +d12 pci-0000:04:00.0-sas-0x50001ff10e9d1000-51 +d13 pci-0000:04:00.0-sas-0x50001ff10e9d1000-52 +d14 pci-0000:04:00.0-sas-0x50001ff10e9d1000-56 +d15 pci-0000:04:00.0-sas-0x50001ff10e9d1000-57 + +# Channel E: PCI Bus 84, Enclosure 0x50001ff10e991000 +e1 pci-0000:84:00.0-sas-0x50001ff10e991000-3 +e2 pci-0000:84:00.0-sas-0x50001ff10e991000-4 +e3 pci-0000:84:00.0-sas-0x50001ff10e991000-5 +e4 pci-0000:84:00.0-sas-0x50001ff10e991000-8 +e5 pci-0000:84:00.0-sas-0x50001ff10e991000-9 +e6 pci-0000:84:00.0-sas-0x50001ff10e991000-10 +e7 pci-0000:84:00.0-sas-0x50001ff10e991000-13 +e8 pci-0000:84:00.0-sas-0x50001ff10e991000-14 +e9 pci-0000:84:00.0-sas-0x50001ff10e991000-15 +e10 pci-0000:84:00.0-sas-0x50001ff10e991000-19 +e11 pci-0000:84:00.0-sas-0x50001ff10e991000-20 +e12 pci-0000:84:00.0-sas-0x50001ff10e991000-24 +e13 pci-0000:84:00.0-sas-0x50001ff10e991000-25 +e14 pci-0000:84:00.0-sas-0x50001ff10e991000-29 +e15 pci-0000:84:00.0-sas-0x50001ff10e991000-30 + +# Channel F: PCI Bus 84, Enclosure 0x50001ff10e9d1000 +f1 pci-0000:84:00.0-sas-0x50001ff10e9d1000-3 +f2 pci-0000:84:00.0-sas-0x50001ff10e9d1000-4 +f3 pci-0000:84:00.0-sas-0x50001ff10e9d1000-5 +f4 pci-0000:84:00.0-sas-0x50001ff10e9d1000-8 +f5 pci-0000:84:00.0-sas-0x50001ff10e9d1000-9 +f6 pci-0000:84:00.0-sas-0x50001ff10e9d1000-10 +f7 pci-0000:84:00.0-sas-0x50001ff10e9d1000-13 +f8 pci-0000:84:00.0-sas-0x50001ff10e9d1000-14 +f9 pci-0000:84:00.0-sas-0x50001ff10e9d1000-15 +f10 pci-0000:84:00.0-sas-0x50001ff10e9d1000-19 +f11 pci-0000:84:00.0-sas-0x50001ff10e9d1000-20 +f12 pci-0000:84:00.0-sas-0x50001ff10e9d1000-24 +f13 pci-0000:84:00.0-sas-0x50001ff10e9d1000-25 +f14 pci-0000:84:00.0-sas-0x50001ff10e9d1000-29 +f15 pci-0000:84:00.0-sas-0x50001ff10e9d1000-30 + +# Channel G: PCI Bus 85, Enclosure 0x50001ff10e991000 +g1 pci-0000:85:00.0-sas-0x50001ff10e991000-1 +g2 pci-0000:85:00.0-sas-0x50001ff10e991000-2 +g3 pci-0000:85:00.0-sas-0x50001ff10e991000-6 +g4 pci-0000:85:00.0-sas-0x50001ff10e991000-7 +g5 pci-0000:85:00.0-sas-0x50001ff10e991000-11 +g6 pci-0000:85:00.0-sas-0x50001ff10e991000-12 +g7 pci-0000:85:00.0-sas-0x50001ff10e991000-16 +g8 pci-0000:85:00.0-sas-0x50001ff10e991000-17 +g9 pci-0000:85:00.0-sas-0x50001ff10e991000-18 +g10 pci-0000:85:00.0-sas-0x50001ff10e991000-21 +g11 pci-0000:85:00.0-sas-0x50001ff10e991000-22 +g12 pci-0000:85:00.0-sas-0x50001ff10e991000-23 +g13 pci-0000:85:00.0-sas-0x50001ff10e991000-26 +g14 pci-0000:85:00.0-sas-0x50001ff10e991000-27 +g15 pci-0000:85:00.0-sas-0x50001ff10e991000-28 + +# Channel H: PCI Bus 85, Enclosure 0x50001ff10e9d1000 +h1 pci-0000:85:00.0-sas-0x50001ff10e9d1000-1 +h2 pci-0000:85:00.0-sas-0x50001ff10e9d1000-2 +h3 pci-0000:85:00.0-sas-0x50001ff10e9d1000-6 +h4 pci-0000:85:00.0-sas-0x50001ff10e9d1000-7 +h5 pci-0000:85:00.0-sas-0x50001ff10e9d1000-11 +h6 pci-0000:85:00.0-sas-0x50001ff10e9d1000-12 +h7 pci-0000:85:00.0-sas-0x50001ff10e9d1000-16 +h8 pci-0000:85:00.0-sas-0x50001ff10e9d1000-17 +h9 pci-0000:85:00.0-sas-0x50001ff10e9d1000-18 +h10 pci-0000:85:00.0-sas-0x50001ff10e9d1000-21 +h11 pci-0000:85:00.0-sas-0x50001ff10e9d1000-22 +h12 pci-0000:85:00.0-sas-0x50001ff10e9d1000-23 +h13 pci-0000:85:00.0-sas-0x50001ff10e9d1000-26 +h14 pci-0000:85:00.0-sas-0x50001ff10e9d1000-27 +h15 pci-0000:85:00.0-sas-0x50001ff10e9d1000-28 + +# Channel I: PCI Bus 83, Enclosure 0x5000155359b8e33f +i1 pci-0000:83:00.0-sas-0x5000155359b8e33f-0 +i2 pci-0000:83:00.0-sas-0x5000155359b8e33f-1 +i3 pci-0000:83:00.0-sas-0x5000155359b8e33f-2 +i4 pci-0000:83:00.0-sas-0x5000155359b8e33f-3 +i5 pci-0000:83:00.0-sas-0x5000155359b8e33f-4 +i6 pci-0000:83:00.0-sas-0x5000155359b8e33f-5 +i7 pci-0000:83:00.0-sas-0x5000155359b8e33f-6 +i8 pci-0000:83:00.0-sas-0x5000155359b8e33f-7 +i9 pci-0000:83:00.0-sas-0x5000155359b8e33f-8 +i10 pci-0000:83:00.0-sas-0x5000155359b8e33f-9 +i11 pci-0000:83:00.0-sas-0x5000155359b8e33f-10 +i12 pci-0000:83:00.0-sas-0x5000155359b8e33f-11 +i13 pci-0000:83:00.0-sas-0x5000155359b8e33f-12 +i14 pci-0000:83:00.0-sas-0x5000155359b8e33f-13 +i15 pci-0000:83:00.0-sas-0x5000155359b8e33f-14 + +# Channel J: PCI Bus 83, Enclosure 0x5000155359dba33f +j1 pci-0000:83:00.0-sas-0x5000155359dba33f-0 +j2 pci-0000:83:00.0-sas-0x5000155359dba33f-1 +j3 pci-0000:83:00.0-sas-0x5000155359dba33f-2 +j4 pci-0000:83:00.0-sas-0x5000155359dba33f-3 +j5 pci-0000:83:00.0-sas-0x5000155359dba33f-4 +j6 pci-0000:83:00.0-sas-0x5000155359dba33f-5 +j7 pci-0000:83:00.0-sas-0x5000155359dba33f-6 +j8 pci-0000:83:00.0-sas-0x5000155359dba33f-7 +j9 pci-0000:83:00.0-sas-0x5000155359dba33f-8 +j10 pci-0000:83:00.0-sas-0x5000155359dba33f-9 +j11 pci-0000:83:00.0-sas-0x5000155359dba33f-10 +j12 pci-0000:83:00.0-sas-0x5000155359dba33f-11 +j13 pci-0000:83:00.0-sas-0x5000155359dba33f-12 +j14 pci-0000:83:00.0-sas-0x5000155359dba33f-13 +j15 pci-0000:83:00.0-sas-0x5000155359dba33f-14 diff --git a/etc/zfs/zdev.conf.supermicro.example b/etc/zfs/zdev.conf.supermicro.example new file mode 100644 index 0000000000..f20dcc081e --- /dev/null +++ b/etc/zfs/zdev.conf.supermicro.example @@ -0,0 +1,30 @@ +# +# Custom by-path mapping for large JBOD configurations +# +# Example Config: +# Single Supermicro JBOD for RHEL6 +# + +# Channel A: PCI Bus 7, Enclosure 0x500304800027367f +a1 pci-0000:07:00.0-sas-0x500304800027367f-0 +a2 pci-0000:07:00.0-sas-0x500304800027367f-1 +a3 pci-0000:07:00.0-sas-0x500304800027367f-2 +a4 pci-0000:07:00.0-sas-0x500304800027367f-3 + +# Channel B: PCI Bus 7, Enclosure 0x500304800027367f +b1 pci-0000:07:00.0-sas-0x500304800027367f-4 +b2 pci-0000:07:00.0-sas-0x500304800027367f-5 +b3 pci-0000:07:00.0-sas-0x500304800027367f-6 +b4 pci-0000:07:00.0-sas-0x500304800027367f-7 + +# Channel C: PCI Bus 7, Enclosure 0x500304800027367f +c1 pci-0000:07:00.0-sas-0x500304800027367f-8 +c2 pci-0000:07:00.0-sas-0x500304800027367f-9 +c3 pci-0000:07:00.0-sas-0x500304800027367f-10 +c4 pci-0000:07:00.0-sas-0x500304800027367f-11 + +# Channel D: PCI Bus 7, Enclosure 0x500304800027367f +d1 pci-0000:07:00.0-sas-0x500304800027367f-12 +d2 pci-0000:07:00.0-sas-0x500304800027367f-13 +d3 pci-0000:07:00.0-sas-0x500304800027367f-14 +d4 pci-0000:07:00.0-sas-0x500304800027367f-15 diff --git a/etc/zfs/zdev.conf.x4550.example b/etc/zfs/zdev.conf.x4550.example new file mode 100644 index 0000000000..9c611ed457 --- /dev/null +++ b/etc/zfs/zdev.conf.x4550.example @@ -0,0 +1,66 @@ +# +# Custom by-path mapping for large JBOD configurations +# +# Example Config: +# Sun x4550 for RHEL5 +# + +# Channel A: PCI Bus 2 +a1 pci-0000:02:00.0-sas-0x50062b0000000001:1:0-0xd6807184d601e192:0 +a2 pci-0000:02:00.0-sas-0x50062b0000000002:1:1-0xd4905378e6e3d592:1 +a3 pci-0000:02:00.0-sas-0x50062b0000000003:1:2-0xd3827673d806d392:2 +a4 pci-0000:02:00.0-sas-0x50062b0000000004:1:3-0xd6805385d6e3e192:3 +a5 pci-0000:02:00.0-sas-0x50062b0000000005:1:4-0xd680655bd6f5b792:4 +a6 pci-0000:02:00.0-sas-0x50062b0000000006:1:5-0x7a967598ec06d091:5 +a7 pci-0000:02:00.0-sas-0x50062b0000000007:1:6-0xd3826c60d8fcbf92:6 +a8 pci-0000:02:00.0-sas-0x50062b0000000008:1:7-0xd6805271d6e2cd92:7 + +# Channel B: PCI Bus 3 +b1 pci-0000:03:00.0-sas-0x50062b0000000002:1:0-0xd680685fd6f8bb92:0 +b2 pci-0000:03:00.0-sas-0x50062b0000000003:1:1-0xd58c706de200cb92:1 +b3 pci-0000:03:00.0-sas-0x50062b0000000004:1:2-0xd5897480df04de92:2 +b4 pci-0000:03:00.0-sas-0x50062b0000000005:1:3-0xd6805764d6e7c092:3 +b5 pci-0000:03:00.0-sas-0x50062b0000000006:1:4-0xd6806a6dd6fac992:4 +b6 pci-0000:03:00.0-sas-0x50062b0000000007:1:5-0xd58c6b84e2fbe192:5 +b7 pci-0000:03:00.0-sas-0x50062b0000000008:1:6-0xd58a576ee0e7cb92:6 +b8 pci-0000:03:00.0-sas-0x50062b0000000009:1:7-0xd5877871dd08cf92:7 + +# Channel C: PCI Bus 4 +c1 pci-0000:04:00.0-sas-0x50062b0000000003:1:0-0xd6806678d6f6d492:0 +c2 pci-0000:04:00.0-sas-0x50062b0000000004:1:1-0xd680696fd6f9cb92:1 +c3 pci-0000:04:00.0-sas-0x50062b0000000005:1:2-0xd3827182d801e292:2 +c4 pci-0000:04:00.0-sas-0x50062b0000000006:1:3-0xd680666fd6f6cb92:3 +c5 pci-0000:04:00.0-sas-0x50062b0000000007:1:4-0xd6806970d6f9cc92:4 +c6 pci-0000:04:00.0-sas-0x50062b0000000008:1:5-0xd6806b62d6fbbe92:5 +c7 pci-0000:04:00.0-sas-0x50062b0000000009:1:6-0xd58a5760e0e7bd92:6 +c8 pci-0000:04:00.0-sas-0x50062b000000000a:1:7-0xd680717fd601dc92:7 + +# Channel D: PCI Bus 41 +d1 pci-0000:41:00.0-sas-0x50062b0000000004:1:0-0xd6806572d6f5ce92:0 +d2 pci-0000:41:00.0-sas-0x50062b0000000005:1:1-0xd6806983d6f9df92:1 +d3 pci-0000:41:00.0-sas-0x50062b0000000006:1:2-0xd3826c69d8fcc892:2 +d4 pci-0000:41:00.0-sas-0x50062b0000000007:1:3-0xd680725fd602bc92:3 +d5 pci-0000:41:00.0-sas-0x50062b0000000008:1:4-0xd6806971d6f9cd92:4 +d6 pci-0000:41:00.0-sas-0x50062b0000000009:1:5-0xd680726dd602ca92:5 +d7 pci-0000:41:00.0-sas-0x50062b000000000a:1:6-0xd3827772d807d292:6 +d8 pci-0000:41:00.0-sas-0x50062b000000000b:1:7-0xd4955584ebe5e192:7 + +# Channel E: PCI Bus 42 +e1 pci-0000:42:00.0-sas-0x50062b0000000005:1:0-0xd4925676e8e6d392:0 +e2 pci-0000:42:00.0-sas-0x50062b0000000006:1:1-0xd6806b6ed6fbca92:1 +e3 pci-0000:42:00.0-sas-0x50062b0000000007:1:2-0xd382765fd806bf92:2 +e4 pci-0000:42:00.0-sas-0x50062b0000000008:1:3-0xd587786cdd08ca92:3 +e5 pci-0000:42:00.0-sas-0x50062b0000000009:1:4-0xd66f4e5bc5deb792:4 +e6 pci-0000:42:00.0-sas-0x50062b000000000a:1:5-0xd6806879d6f8d592:5 +e7 pci-0000:42:00.0-sas-0x50062b000000000b:1:6-0xd5885175dee1d292:6 +e8 pci-0000:42:00.0-sas-0x50062b000000000c:1:7-0xd588515fdee1bc92:7 + +# Channel F: PCI Bus 43 +f1 pci-0000:43:00.0-sas-0x50062b0000000006:1:0-0xd66d6978c3f9d492:0 +f2 pci-0000:43:00.0-sas-0x50062b0000000007:1:1-0xd6806a5cd6fab892:1 +f3 pci-0000:43:00.0-sas-0x50062b0000000008:1:2-0xd6806563d6f5bf92:2 +f4 pci-0000:43:00.0-sas-0x50062b0000000009:1:3-0xd6805664d6e6c092:3 +f5 pci-0000:43:00.0-sas-0x50062b000000000a:1:4-0xd58c707ee200dc92:4 +f6 pci-0000:43:00.0-sas-0x50062b000000000b:1:5-0xd5885781dee7de92:5 +f7 pci-0000:43:00.0-sas-0x50062b000000000c:1:6-0xd3827481d804e192:6 +f8 pci-0000:43:00.0-sas-0x50062b000000000d:1:7-0xd6806863d6f8bf92:7 diff --git a/lib/libnvpair/Makefile.am b/lib/libnvpair/Makefile.am index 8f80edd00d..31e0b6a0ce 100644 --- a/lib/libnvpair/Makefile.am +++ b/lib/libnvpair/Makefile.am @@ -11,6 +11,7 @@ libnvpair_la_SOURCES = \ ${top_srcdir}/lib/libnvpair/libnvpair.c \ ${top_srcdir}/lib/libnvpair/nvpair_alloc_system.c \ ${top_srcdir}/lib/libnvpair/include/libnvpair.h \ + ${top_srcdir}/module/nvpair/nvpair_alloc_fixed.c \ ${top_srcdir}/module/nvpair/nvpair.c \ ${top_srcdir}/module/nvpair/include/sys/nvpair.h \ ${top_srcdir}/module/nvpair/include/sys/nvpair_impl.h diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index e436c20ddd..039d7f60b8 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -23,7 +23,6 @@ libzpool_la_SOURCES = \ ${top_srcdir}/module/zcommon/zfs_prop.c \ ${top_srcdir}/module/zcommon/zpool_prop.c \ ${top_srcdir}/module/zcommon/zprop_common.c \ - ${top_srcdir}/module/zcommon/include/sys/fm/fs/zfs.h \ ${top_srcdir}/module/zcommon/include/sys/fs \ ${top_srcdir}/module/zcommon/include/sys/fs/zfs.h \ ${top_srcdir}/module/zcommon/include/zfs_comutil.h \ @@ -50,6 +49,7 @@ libzpool_la_SOURCES = \ ${top_srcdir}/module/zfs/dsl_scrub.c \ ${top_srcdir}/module/zfs/dsl_synctask.c \ ${top_srcdir}/module/zfs/fletcher.c \ + ${top_srcdir}/module/zfs/fm.c \ ${top_srcdir}/module/zfs/gzip.c \ ${top_srcdir}/module/zfs/lzjb.c \ ${top_srcdir}/module/zfs/metaslab.c \ @@ -85,4 +85,59 @@ libzpool_la_SOURCES = \ ${top_srcdir}/module/zfs/zio.c \ ${top_srcdir}/module/zfs/zio_checksum.c \ ${top_srcdir}/module/zfs/zio_compress.c \ - ${top_srcdir}/module/zfs/zio_inject.c + ${top_srcdir}/module/zfs/zio_inject.c \ + ${top_srcdir}/module/zfs/include/sys/arc.h \ + ${top_srcdir}/module/zfs/include/sys/bplist.h \ + ${top_srcdir}/module/zfs/include/sys/dbuf.h \ + ${top_srcdir}/module/zfs/include/sys/dmu.h \ + ${top_srcdir}/module/zfs/include/sys/dmu_impl.h \ + ${top_srcdir}/module/zfs/include/sys/dmu_objset.h \ + ${top_srcdir}/module/zfs/include/sys/dmu_traverse.h \ + ${top_srcdir}/module/zfs/include/sys/dmu_tx.h \ + ${top_srcdir}/module/zfs/include/sys/dmu_zfetch.h \ + ${top_srcdir}/module/zfs/include/sys/dnode.h \ + ${top_srcdir}/module/zfs/include/sys/dsl_dataset.h \ + ${top_srcdir}/module/zfs/include/sys/dsl_deleg.h \ + ${top_srcdir}/module/zfs/include/sys/dsl_dir.h \ + ${top_srcdir}/module/zfs/include/sys/dsl_pool.h \ + ${top_srcdir}/module/zfs/include/sys/dsl_prop.h \ + ${top_srcdir}/module/zfs/include/sys/dsl_synctask.h \ + ${top_srcdir}/module/zfs/include/sys/metaslab.h \ + ${top_srcdir}/module/zfs/include/sys/metaslab_impl.h \ + ${top_srcdir}/module/zfs/include/sys/refcount.h \ + ${top_srcdir}/module/zfs/include/sys/rrwlock.h \ + ${top_srcdir}/module/zfs/include/sys/spa_boot.h \ + ${top_srcdir}/module/zfs/include/sys/space_map.h \ + ${top_srcdir}/module/zfs/include/sys/spa.h \ + ${top_srcdir}/module/zfs/include/sys/spa_impl.h \ + ${top_srcdir}/module/zfs/include/sys/txg.h \ + ${top_srcdir}/module/zfs/include/sys/txg_impl.h \ + ${top_srcdir}/module/zfs/include/sys/uberblock.h \ + ${top_srcdir}/module/zfs/include/sys/uberblock_impl.h \ + ${top_srcdir}/module/zfs/include/sys/unique.h \ + ${top_srcdir}/module/zfs/include/sys/vdev_file.h \ + ${top_srcdir}/module/zfs/include/sys/vdev.h \ + ${top_srcdir}/module/zfs/include/sys/vdev_impl.h \ + ${top_srcdir}/module/zfs/include/sys/zap.h \ + ${top_srcdir}/module/zfs/include/sys/zap_impl.h \ + ${top_srcdir}/module/zfs/include/sys/zap_leaf.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_acl.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_context.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_ctldir.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_debug.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_dir.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_fuid.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_ioctl.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_rlock.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_vfsops.h \ + ${top_srcdir}/module/zfs/include/sys/zfs_znode.h \ + ${top_srcdir}/module/zfs/include/sys/zil.h \ + ${top_srcdir}/module/zfs/include/sys/zil_impl.h \ + ${top_srcdir}/module/zfs/include/sys/zio_checksum.h \ + ${top_srcdir}/module/zfs/include/sys/zio_compress.h \ + ${top_srcdir}/module/zfs/include/sys/zio.h \ + ${top_srcdir}/module/zfs/include/sys/zio_impl.h \ + ${top_srcdir}/module/zfs/include/sys/zvol.h \ + ${top_srcdir}/module/zfs/include/sys/fm/protocol.h \ + ${top_srcdir}/module/zfs/include/sys/fm/util.h \ + ${top_srcdir}/module/zfs/include/sys/fm/fs/zfs.h diff --git a/lib/libzpool/include/sys/zfs_context.h b/lib/libzpool/include/sys/zfs_context.h index 7c3c5e0d55..7cbac416e2 100644 --- a/lib/libzpool/include/sys/zfs_context.h +++ b/lib/libzpool/include/sys/zfs_context.h @@ -198,34 +198,34 @@ _NOTE(CONSTCOND) } while (0) /* * Threads */ -#define THR_BOUND 0x00000001 #define TS_RUN 0x00000002 -typedef void (*thread_func_t)(void *); +#define STACK_SIZE 8192 /* Linux x86 and amd64 */ + +typedef void (*thread_func_t)(void); +typedef void (*thread_func_arg_t)(void *); typedef pthread_t kt_did_t; typedef struct kthread { - list_node_t t_node; kt_did_t t_tid; - pthread_attr_t t_attr; + thread_func_t t_func; + void * t_arg; } kthread_t; +/* XXX tsd_create()/tsd_destroy() missing */ #define tsd_get(key) pthread_getspecific(key) #define tsd_set(key, val) pthread_setspecific(key, val) #define curthread zk_thread_current() #define thread_exit zk_thread_exit #define thread_create(stk, stksize, func, arg, len, pp, state, pri) \ - zk_thread_create(stk, stksize, (thread_func_t)func, arg, \ - len, NULL, state, pri) -#define thread_join(tid, dtid, status) \ - zk_thread_join(tid, dtid, status) + zk_thread_create(stk, stksize, (thread_func_t) func, arg, len, \ + NULL, state, pri) extern kthread_t *zk_thread_current(void); extern void zk_thread_exit(void); extern kthread_t *zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg, size_t len, void *pp, int state, pri_t pri); -extern int zk_thread_join(kt_did_t tid, kthread_t *dtid, void **status); #define issig(why) (FALSE) #define ISSIG(thr, why) (FALSE) @@ -357,7 +357,7 @@ extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t); extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t); extern void taskq_destroy(taskq_t *); extern void taskq_wait(taskq_t *); -extern int taskq_member(taskq_t *, void *); +extern int taskq_member(taskq_t *, kthread_t *); extern void system_taskq_init(void); extern void system_taskq_fini(void); diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index 97e1bc9d38..21e0393651 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -57,155 +57,141 @@ struct utsname utsname = { * ========================================================================= */ -/* NOTE: Tracking each tid on a list and using it for curthread lookups - * is slow at best but it provides an easy way to provide a kthread - * style API on top of pthreads. For now we just want ztest to work - * to validate correctness. Performance is not much of an issue - * since that is what the in-kernel version is for. That said - * reworking this to track the kthread_t structure as thread - * specific data would be probably the best way to speed this up. - */ - pthread_cond_t kthread_cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t kthread_lock = PTHREAD_MUTEX_INITIALIZER; -list_t kthread_list; - -static int -thread_count(void) -{ - kthread_t *kt; - int count = 0; - - for (kt = list_head(&kthread_list); kt != NULL; - kt = list_next(&kthread_list, kt)) - count++; - - return count; -} +pthread_key_t kthread_key; +int kthread_nr = 0; static void thread_init(void) { kthread_t *kt; - /* Initialize list for tracking kthreads */ - list_create(&kthread_list, sizeof (kthread_t), - offsetof(kthread_t, t_node)); + VERIFY3S(pthread_key_create(&kthread_key, NULL), ==, 0); /* Create entry for primary kthread */ kt = umem_zalloc(sizeof(kthread_t), UMEM_NOFAIL); - list_link_init(&kt->t_node); - VERIFY3U(kt->t_tid = pthread_self(), !=, 0); - VERIFY3S(pthread_attr_init(&kt->t_attr), ==, 0); - VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0); - list_insert_head(&kthread_list, kt); - VERIFY3S(pthread_mutex_unlock(&kthread_lock), ==, 0); + kt->t_tid = pthread_self(); + kt->t_func = NULL; + + VERIFY3S(pthread_setspecific(kthread_key, kt), ==, 0); + + /* Only the main thread should be running at the moment */ + ASSERT3S(kthread_nr, ==, 0); + kthread_nr = 1; } static void thread_fini(void) { - kthread_t *kt; - struct timespec ts = { 0 }; - int count; + kthread_t *kt = curthread; + + ASSERT(pthread_equal(kt->t_tid, pthread_self())); + ASSERT3P(kt->t_func, ==, NULL); + + umem_free(kt, sizeof(kthread_t)); /* Wait for all threads to exit via thread_exit() */ VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0); - while ((count = thread_count()) > 1) { - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec += 1; - pthread_cond_timedwait(&kthread_cond, &kthread_lock, &ts); - } - ASSERT3S(thread_count(), ==, 1); - kt = list_head(&kthread_list); - list_remove(&kthread_list, kt); + kthread_nr--; /* Main thread is exiting */ + + while (kthread_nr > 0) + VERIFY3S(pthread_cond_wait(&kthread_cond, &kthread_lock), ==, + 0); + + ASSERT3S(kthread_nr, ==, 0); VERIFY3S(pthread_mutex_unlock(&kthread_lock), ==, 0); - VERIFY(pthread_attr_destroy(&kt->t_attr) == 0); - umem_free(kt, sizeof(kthread_t)); - - /* Cleanup list for tracking kthreads */ - list_destroy(&kthread_list); + VERIFY3S(pthread_key_delete(kthread_key), ==, 0); } kthread_t * zk_thread_current(void) { - kt_did_t tid = pthread_self(); - kthread_t *kt; - int count = 1; + kthread_t *kt = pthread_getspecific(kthread_key); - /* - * Because a newly created thread may call zk_thread_current() - * before the thread parent has had time to add the thread's tid - * to our lookup list. We will loop as long as there are tid - * which have not yet been set which must be one of ours. - * Yes it's a hack, at some point we can just use native pthreads. - */ - while (count > 0) { - count = 0; - VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0); - for (kt = list_head(&kthread_list); kt != NULL; - kt = list_next(&kthread_list, kt)) { - - if (kt->t_tid == tid) { - VERIFY3S(pthread_mutex_unlock( - &kthread_lock), ==, 0); - return kt; - } - - if (kt->t_tid == (kt_did_t)-1) - count++; - } - VERIFY3S(pthread_mutex_unlock(&kthread_lock), ==, 0); - } - - /* Unreachable */ - ASSERT(0); - return NULL; -} - -kthread_t * -zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg, - size_t len, void *pp, int state, pri_t pri) -{ - kthread_t *kt; - - kt = umem_zalloc(sizeof(kthread_t), UMEM_NOFAIL); - kt->t_tid = (kt_did_t)-1; - list_link_init(&kt->t_node); - VERIFY(pthread_attr_init(&kt->t_attr) == 0); - - VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0); - list_insert_head(&kthread_list, kt); - VERIFY3S(pthread_mutex_unlock(&kthread_lock), ==, 0); - - VERIFY3U(pthread_create(&kt->t_tid, &kt->t_attr, - (void *(*)(void *))func, arg), ==, 0); + ASSERT3P(kt, !=, NULL); return kt; } -int -zk_thread_join(kt_did_t tid, kthread_t *dtid, void **status) +void * +zk_thread_helper(void *arg) { - return pthread_join(tid, status); + kthread_t *kt = (kthread_t *) arg; + + VERIFY3S(pthread_setspecific(kthread_key, kt), ==, 0); + + VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0); + kthread_nr++; + VERIFY3S(pthread_mutex_unlock(&kthread_lock), ==, 0); + + kt->t_tid = pthread_self(); + ((thread_func_arg_t) kt->t_func)(kt->t_arg); + + /* Unreachable, thread must exit with thread_exit() */ + abort(); + + return NULL; +} + +kthread_t * +zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg, + size_t len, void *pp, int state, pri_t pri) +{ + kthread_t *kt; + pthread_t tid; + pthread_attr_t attr; + size_t stack; + + /* + * Due to a race when getting/setting the thread ID, currently only + * detached threads are supported. + */ + ASSERT3S(state & ~TS_RUN, ==, 0); + + kt = umem_zalloc(sizeof(kthread_t), UMEM_NOFAIL); + kt->t_func = func; + kt->t_arg = arg; + + /* + * The Solaris kernel stack size in x86/x64 is 8K, so we reduce the + * default stack size in userspace, for sanity checking. + * + * PTHREAD_STACK_MIN is the stack required for a NULL procedure in + * userspace. + * + * XXX: Stack size for other architectures is not being taken into + * account. + */ + stack = PTHREAD_STACK_MIN + MAX(stksize, STACK_SIZE); + + VERIFY3S(pthread_attr_init(&attr), ==, 0); + VERIFY3S(pthread_attr_setstacksize(&attr, stack), ==, 0); + VERIFY3S(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED), + ==, 0); + + VERIFY3S(pthread_create(&tid, &attr, &zk_thread_helper, kt), ==, 0); + + VERIFY3S(pthread_attr_destroy(&attr), ==, 0); + + return kt; } void zk_thread_exit(void) { - kthread_t *kt; + kthread_t *kt = curthread; - VERIFY3P(kt = curthread, !=, NULL); - VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0); - list_remove(&kthread_list, kt); - VERIFY3S(pthread_mutex_unlock(&kthread_lock), ==, 0); + ASSERT(pthread_equal(kt->t_tid, pthread_self())); - VERIFY(pthread_attr_destroy(&kt->t_attr) == 0); umem_free(kt, sizeof(kthread_t)); + pthread_mutex_lock(&kthread_lock); + kthread_nr--; + pthread_mutex_unlock(&kthread_lock); + pthread_cond_broadcast(&kthread_cond); pthread_exit(NULL); } @@ -529,6 +515,7 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3) int old_umask; char real_path[MAXPATHLEN]; struct stat64 st; + int err; /* * If we're accessing a real disk from userland, we need to use @@ -577,8 +564,9 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3) return (errno); if (fstat64(fd, &st) == -1) { + err = errno; close(fd); - return (errno); + return (err); } (void) fcntl(fd, F_SETFD, FD_CLOEXEC); @@ -616,26 +604,32 @@ int vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset, int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp) { - ssize_t iolen, split; + ssize_t rc, done = 0, split; if (uio == UIO_READ) { - iolen = pread64(vp->v_fd, addr, len, offset); + rc = pread64(vp->v_fd, addr, len, offset); } else { /* * To simulate partial disk writes, we split writes into two * system calls so that the process can be killed in between. */ split = (len > 0 ? rand() % len : 0); - iolen = pwrite64(vp->v_fd, addr, split, offset); - iolen += pwrite64(vp->v_fd, (char *)addr + split, - len - split, offset + split); + rc = pwrite64(vp->v_fd, addr, split, offset); + if (rc != -1) { + done = rc; + rc = pwrite64(vp->v_fd, (char *)addr + split, + len - split, offset + split); + } } - if (iolen == -1) + if (rc == -1) return (errno); + + done += rc; + if (residp) - *residp = len - iolen; - else if (iolen != len) + *residp = len - done; + else if (done != len) return (EIO); return (0); } diff --git a/lib/libzpool/taskq.c b/lib/libzpool/taskq.c index 42e2dd3f43..1efdf1d6fa 100644 --- a/lib/libzpool/taskq.c +++ b/lib/libzpool/taskq.c @@ -43,7 +43,6 @@ struct taskq { kcondvar_t tq_dispatch_cv; kcondvar_t tq_wait_cv; kthread_t **tq_threadlist; - kt_did_t *tq_idlist; int tq_flags; int tq_active; int tq_nthreads; @@ -135,7 +134,7 @@ taskq_wait(taskq_t *tq) mutex_exit(&tq->tq_lock); } -static void * +static void taskq_thread(void *arg) { taskq_t *tq = arg; @@ -165,7 +164,6 @@ taskq_thread(void *arg) cv_broadcast(&tq->tq_wait_cv); mutex_exit(&tq->tq_lock); thread_exit(); - return (NULL); } /*ARGSUSED*/ @@ -200,10 +198,8 @@ taskq_create(const char *name, int nthreads, pri_t pri, tq->tq_maxalloc = maxalloc; tq->tq_task.task_next = &tq->tq_task; tq->tq_task.task_prev = &tq->tq_task; - VERIFY3P((tq->tq_threadlist = kmem_alloc(tq->tq_nthreads * - sizeof(kthread_t *), KM_SLEEP)), !=, NULL); - VERIFY3P((tq->tq_idlist = kmem_alloc(tq->tq_nthreads * - sizeof(kt_did_t), KM_SLEEP)), !=, NULL); + tq->tq_threadlist = kmem_alloc(tq->tq_nthreads * sizeof(kthread_t *), + KM_SLEEP); if (flags & TASKQ_PREPOPULATE) { mutex_enter(&tq->tq_lock); @@ -214,8 +210,7 @@ taskq_create(const char *name, int nthreads, pri_t pri, for (t = 0; t < tq->tq_nthreads; t++) { VERIFY((tq->tq_threadlist[t] = thread_create(NULL, 0, - taskq_thread, tq, THR_BOUND, NULL, 0, 0)) != NULL); - tq->tq_idlist[t] = tq->tq_threadlist[t]->t_tid; + taskq_thread, tq, TS_RUN, NULL, 0, 0)) != NULL); } return (tq); @@ -224,7 +219,6 @@ taskq_create(const char *name, int nthreads, pri_t pri, void taskq_destroy(taskq_t *tq) { - int t; int nthreads = tq->tq_nthreads; taskq_wait(tq); @@ -245,11 +239,7 @@ taskq_destroy(taskq_t *tq) mutex_exit(&tq->tq_lock); - for (t = 0; t < nthreads; t++) - VERIFY3S(thread_join(tq->tq_idlist[t], NULL, NULL), ==, 0); - kmem_free(tq->tq_threadlist, nthreads * sizeof(kthread_t *)); - kmem_free(tq->tq_idlist, nthreads * sizeof(kt_did_t)); rw_destroy(&tq->tq_threadlock); mutex_destroy(&tq->tq_lock); @@ -260,7 +250,7 @@ taskq_destroy(taskq_t *tq) } int -taskq_member(taskq_t *tq, void *t) +taskq_member(taskq_t *tq, kthread_t *t) { int i; @@ -268,7 +258,7 @@ taskq_member(taskq_t *tq, void *t) return (1); for (i = 0; i < tq->tq_nthreads; i++) - if (tq->tq_threadlist[i] == (kthread_t *)t) + if (tq->tq_threadlist[i] == t) return (1); return (0); diff --git a/man/Makefile.am b/man/Makefile.am new file mode 100644 index 0000000000..1602da1071 --- /dev/null +++ b/man/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = man8 diff --git a/man/man8/Makefile.am b/man/man8/Makefile.am new file mode 100644 index 0000000000..8f0227f884 --- /dev/null +++ b/man/man8/Makefile.am @@ -0,0 +1,5 @@ +man_MANS = zdb.8 zfs.8 zpool.8 +EXTRA_DIST = $(man_MANS) + +install-data-local: + $(INSTALL) -d -m 0755 "$(DESTDIR)$(mandir)/man8" diff --git a/man/man8/zdb.8 b/man/man8/zdb.8 new file mode 100644 index 0000000000..f6018256b4 --- /dev/null +++ b/man/man8/zdb.8 @@ -0,0 +1,84 @@ +'\" te +.\" Copyright (c) 2004, 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 zdb 1M "31 Oct 2005" "SunOS 5.11" "System Administration Commands" +.SH NAME +zdb \- ZFS debugger +.SH SYNOPSIS +.LP +.nf +\fBzdb\fR \fIpool\fR +.fi + +.SH DESCRIPTION +.sp +.LP +The \fBzdb\fR command is used by support engineers to diagnose failures and gather statistics. Since the \fBZFS\fR file system is always consistent on disk and is self-repairing, \fBzdb\fR should only be run under the direction by a support engineer. +.sp +.LP +If no arguments are specified, \fBzdb\fR, performs basic consistency checks on the pool and associated datasets, and report any problems detected. +.sp +.LP +Any options supported by this command are internal to Sun and subject to change at any time. +.SH EXIT STATUS +.sp +.LP +The following exit values are returned: +.sp +.ne 2 +.mk +.na +\fB\fB0\fR\fR +.ad +.RS 5n +.rt +The pool is consistent. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB1\fR\fR +.ad +.RS 5n +.rt +An error was detected. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB2\fR\fR +.ad +.RS 5n +.rt +Invalid command line options were specified. +.RE + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +AvailabilitySUNWzfsu +_ +Interface StabilityUnstable +.TE + +.SH SEE ALSO +.sp +.LP +\fBzfs\fR(1M), \fBzpool\fR(1M), \fBattributes\fR(5) diff --git a/man/man8/zfs.8 b/man/man8/zfs.8 new file mode 100644 index 0000000000..ecde1d98ad --- /dev/null +++ b/man/man8/zfs.8 @@ -0,0 +1,3065 @@ +'\" te +.\" Copyright (c) 2009 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] +.\" 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 zfs 1M "24 Sep 2009" "SunOS 5.11" "System Administration Commands" +.SH NAME +zfs \- configures ZFS file systems +.SH SYNOPSIS +.LP +.nf +\fBzfs\fR [\fB-?\fR] +.fi + +.LP +.nf +\fBzfs\fR \fBcreate\fR [\fB-p\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR] ... \fIfilesystem\fR +.fi + +.LP +.nf +\fBzfs\fR \fBcreate\fR [\fB-ps\fR] [\fB-b\fR \fIblocksize\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR] ... \fB-V\fR \fIsize\fR \fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBdestroy\fR [\fB-rRf\fR] \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBdestroy\fR [\fB-rRd\fR] \fIsnapshot\fR +.fi + +.LP +.nf +\fBzfs\fR \fBsnapshot\fR [\fB-r\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR]... + \fIfilesystem@snapname\fR|\fIvolume@snapname\fR +.fi + +.LP +.nf +\fBzfs\fR \fBrollback\fR [\fB-rRf\fR] \fIsnapshot\fR +.fi + +.LP +.nf +\fBzfs\fR \fBclone\fR [\fB-p\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR] ... \fIsnapshot\fR \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBpromote\fR \fIclone-filesystem\fR +.fi + +.LP +.nf +\fBzfs\fR \fBrename\fR \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR + \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR +.fi + +.LP +.nf +\fBzfs\fR \fBrename\fR [\fB-p\fR] \fIfilesystem\fR|\fIvolume\fR \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBrename\fR \fB-r\fR \fIsnapshot\fR \fIsnapshot\fR +.fi + +.LP +.nf +\fBzfs\fR \fBlist\fR [\fB-r\fR|\fB-d\fR \fIdepth\fR][\fB-H\fR][\fB-o\fR \fIproperty\fR[,...]] [\fB-t\fR \fItype\fR[,...]] + [\fB-s\fR \fIproperty\fR] ... [\fB-S\fR \fIproperty\fR] ... [\fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR] ... +.fi + +.LP +.nf +\fBzfs\fR \fBset\fR \fIproperty\fR=\fIvalue\fR \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR ... +.fi + +.LP +.nf +\fBzfs\fR \fBget\fR [\fB-r\fR|\fB-d\fR \fIdepth\fR][\fB-Hp\fR][\fB-o\fR \fIfield\fR[,...]] [\fB-s\fR \fIsource\fR[,...]] + "\fIall\fR" | \fIproperty\fR[,...] \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR ... +.fi + +.LP +.nf +\fBzfs\fR \fBinherit\fR [\fB-r\fR] \fIproperty\fR \fIfilesystem\fR|\fIvolume|snapshot\fR ... +.fi + +.LP +.nf +\fBzfs\fR \fBupgrade\fR [\fB-v\fR] +.fi + +.LP +.nf +\fBzfs\fR \fBupgrade\fR [\fB-r\fR] [\fB-V\fR \fIversion\fR] \fB-a\fR | \fIfilesystem\fR +.fi + +.LP +.nf +\fBzfs\fR \fBuserspace\fR [\fB-niHp\fR] [\fB-o\fR \fIfield\fR[,...]] [\fB-sS\fR \fIfield\fR] ... + [\fB-t\fR \fItype\fR [,...]] \fIfilesystem\fR|\fIsnapshot\fR +.fi + +.LP +.nf +\fBzfs\fR \fBgroupspace\fR [\fB-niHp\fR] [\fB-o\fR \fIfield\fR[,...]] [\fB-sS\fR \fIfield\fR] ... + [\fB-t\fR \fItype\fR [,...]] \fIfilesystem\fR|\fIsnapshot\fR +.fi + +.LP +.nf +\fBzfs\fR \fBmount\fR +.fi + +.LP +.nf +\fBzfs\fR \fBmount\fR [\fB-vO\fR] [\fB-o \fIoptions\fR\fR] \fB-a\fR | \fIfilesystem\fR +.fi + +.LP +.nf +\fBzfs\fR \fBunmount\fR [\fB-f\fR] \fB-a\fR | \fIfilesystem\fR|\fImountpoint\fR +.fi + +.LP +.nf +\fBzfs\fR \fBshare\fR \fB-a\fR | \fIfilesystem\fR +.fi + +.LP +.nf +\fBzfs\fR \fBunshare\fR \fB-a\fR \fIfilesystem\fR|\fImountpoint\fR +.fi + +.LP +.nf +\fBzfs\fR \fBsend\fR [\fB-vR\fR] [\fB-\fR[\fBiI\fR] \fIsnapshot\fR] \fIsnapshot\fR +.fi + +.LP +.nf +\fBzfs\fR \fBreceive\fR [\fB-vnFu\fR] \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR +.fi + +.LP +.nf +\fBzfs\fR \fBreceive\fR [\fB-vnFu\fR] \fB-d\fR \fIfilesystem\fR +.fi + +.LP +.nf +\fBzfs\fR \fBallow\fR \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBallow\fR [\fB-ldug\fR] "\fIeveryone\fR"|\fIuser\fR|\fIgroup\fR[,...] \fIperm\fR|\fI@setname\fR[,...] + \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBallow\fR [\fB-ld\fR] \fB-e\fR \fIperm\fR|@\fIsetname\fR[,...] \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBallow\fR \fB-c\fR \fIperm\fR|@\fIsetname\fR[,...] \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBallow\fR \fB-s\fR @\fIsetname\fR \fIperm\fR|@\fIsetname\fR[,...] \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBunallow\fR [\fB-rldug\fR] "\fIeveryone\fR"|\fIuser\fR|\fIgroup\fR[,...] [\fIperm\fR|@\fIsetname\fR[,... ]] + \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBunallow\fR [\fB-rld\fR] \fB-e\fR [\fIperm\fR|@\fIsetname\fR[,... ]] \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBunallow\fR [\fB-r\fR] \fB-c\fR [\fIperm\fR|@\fIsetname\fR[ ... ]] \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBunallow\fR [\fB-r\fR] \fB-s\fR @\fIsetname\fR [\fIperm\fR|@\fIsetname\fR[,... ]] \fIfilesystem\fR|\fIvolume\fR +.fi + +.LP +.nf +\fBzfs\fR \fBhold\fR [\fB-r\fR] \fItag\fR \fIsnapshot\fR... +.fi + +.LP +.nf +\fBzfs\fR \fBholds\fR [\fB-r\fR] \fIsnapshot\fR... +.fi + +.LP +.nf +\fBzfs\fR \fBrelease\fR [\fB-r\fR] \fItag\fR \fIsnapshot\fR... +.fi + +.SH DESCRIPTION +.sp +.LP +The \fBzfs\fR command configures \fBZFS\fR datasets within a \fBZFS\fR storage pool, as described in \fBzpool\fR(1M). A dataset is identified by a unique path within the \fBZFS\fR namespace. For example: +.sp +.in +2 +.nf +pool/{filesystem,volume,snapshot} +.fi +.in -2 +.sp + +.sp +.LP +where the maximum length of a dataset name is \fBMAXNAMELEN\fR (256 bytes). +.sp +.LP +A dataset can be one of the following: +.sp +.ne 2 +.mk +.na +\fB\fIfile system\fR\fR +.ad +.sp .6 +.RS 4n +A \fBZFS\fR dataset of type \fBfilesystem\fR can be mounted within the standard system namespace and behaves like other file systems. While \fBZFS\fR file systems are designed to be \fBPOSIX\fR compliant, known issues exist that prevent compliance in some cases. Applications that depend on standards conformance might fail due to nonstandard behavior when checking file system free space. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +A logical volume exported as a raw or block device. This type of dataset should only be used under special circumstances. File systems are typically used in most environments. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fIsnapshot\fR\fR +.ad +.sp .6 +.RS 4n +A read-only version of a file system or volume at a given point in time. It is specified as \fIfilesystem@name\fR or \fIvolume@name\fR. +.RE + +.SS "ZFS File System Hierarchy" +.sp +.LP +A \fBZFS\fR storage pool is a logical collection of devices that provide space for datasets. A storage pool is also the root of the \fBZFS\fR file system hierarchy. +.sp +.LP +The root of the pool can be accessed as a file system, such as mounting and unmounting, taking snapshots, and setting properties. The physical storage characteristics, however, are managed by the \fBzpool\fR(1M) command. +.sp +.LP +See \fBzpool\fR(1M) for more information on creating and administering pools. +.SS "Snapshots" +.sp +.LP +A snapshot is a read-only copy of a file system or volume. Snapshots can be created extremely quickly, and initially consume no additional space within the pool. As data within the active dataset changes, the snapshot consumes more data than would otherwise be shared with the active dataset. +.sp +.LP +Snapshots can have arbitrary names. Snapshots of volumes can be cloned or rolled back, but cannot be accessed independently. +.sp +.LP +File system snapshots can be accessed under the \fB\&.zfs/snapshot\fR directory in the root of the file system. Snapshots are automatically mounted on demand and may be unmounted at regular intervals. The visibility of the \fB\&.zfs\fR directory can be controlled by the \fBsnapdir\fR property. +.SS "Clones" +.sp +.LP +A clone is a writable volume or file system whose initial contents are the same as another dataset. As with snapshots, creating a clone is nearly instantaneous, and initially consumes no additional space. +.sp +.LP +Clones can only be created from a snapshot. When a snapshot is cloned, it creates an implicit dependency between the parent and child. Even though the clone is created somewhere else in the dataset hierarchy, the original snapshot cannot be destroyed as long as a clone exists. The \fBorigin\fR property exposes this dependency, and the \fBdestroy\fR command lists any such dependencies, if they exist. +.sp +.LP +The clone parent-child dependency relationship can be reversed by using the \fBpromote\fR subcommand. This causes the "origin" file system to become a clone of the specified file system, which makes it possible to destroy the file system that the clone was created from. +.SS "Mount Points" +.sp +.LP +Creating a \fBZFS\fR file system is a simple operation, so the number of file systems per system is likely to be numerous. To cope with this, \fBZFS\fR automatically manages mounting and unmounting file systems without the need to edit the \fB/etc/vfstab\fR file. All automatically managed file systems are mounted by \fBZFS\fR at boot time. +.sp +.LP +By default, file systems are mounted under \fB/\fIpath\fR\fR, where \fIpath\fR is the name of the file system in the \fBZFS\fR namespace. Directories are created and destroyed as needed. +.sp +.LP +A file system can also have a mount point set in the \fBmountpoint\fR property. This directory is created as needed, and \fBZFS\fR automatically mounts the file system when the \fBzfs mount -a\fR command is invoked (without editing \fB/etc/vfstab\fR). The \fBmountpoint\fR property can be inherited, so if \fBpool/home\fR has a mount point of \fB/export/stuff\fR, then \fBpool/home/user\fR automatically inherits a mount point of \fB/export/stuff/user\fR. +.sp +.LP +A file system \fBmountpoint\fR property of \fBnone\fR prevents the file system from being mounted. +.sp +.LP +If needed, \fBZFS\fR file systems can also be managed with traditional tools (\fBmount\fR, \fBumount\fR, \fB/etc/vfstab\fR). If a file system's mount point is set to \fBlegacy\fR, \fBZFS\fR makes no attempt to manage the file system, and the administrator is responsible for mounting and unmounting the file system. +.SS "Zones" +.sp +.LP +A \fBZFS\fR file system can be added to a non-global zone by using the \fBzonecfg\fR \fBadd fs\fR subcommand. A \fBZFS\fR file system that is added to a non-global zone must have its \fBmountpoint\fR property set to \fBlegacy\fR. +.sp +.LP +The physical properties of an added file system are controlled by the global administrator. However, the zone administrator can create, modify, or destroy files within the added file system, depending on how the file system is mounted. +.sp +.LP +A dataset can also be delegated to a non-global zone by using the \fBzonecfg\fR \fBadd dataset\fR subcommand. You cannot delegate a dataset to one zone and the children of the same dataset to another zone. The zone administrator can change properties of the dataset or any of its children. However, the \fBquota\fR property is controlled by the global administrator. +.sp +.LP +A \fBZFS\fR volume can be added as a device to a non-global zone by using the \fBzonecfg\fR \fBadd device\fR subcommand. However, its physical properties can be modified only by the global administrator. +.sp +.LP +For more information about \fBzonecfg\fR syntax, see \fBzonecfg\fR(1M). +.sp +.LP +After a dataset is delegated to a non-global zone, the \fBzoned\fR property is automatically set. A zoned file system cannot be mounted in the global zone, since the zone administrator might have to set the mount point to an unacceptable value. +.sp +.LP +The global administrator can forcibly clear the \fBzoned\fR property, though this should be done with extreme care. The global administrator should verify that all the mount points are acceptable before clearing the property. +.SS "Native Properties" +.sp +.LP +Properties are divided into two types, native properties and user-defined (or "user") properties. Native properties either export internal statistics or control \fBZFS\fR behavior. In addition, native properties are either editable or read-only. User properties have no effect on \fBZFS\fR behavior, but you can use them to annotate datasets in a way that is meaningful in your environment. For more information about user properties, see the "User Properties" section, below. +.sp +.LP +Every dataset has a set of properties that export statistics about the dataset as well as control various behaviors. Properties are inherited from the parent unless overridden by the child. Some properties apply only to certain types of datasets (file systems, volumes, or snapshots). +.sp +.LP +The values of numeric properties can be specified using human-readable suffixes (for example, \fBk\fR, \fBKB\fR, \fBM\fR, \fBGb\fR, and so forth, up to \fBZ\fR for zettabyte). The following are all valid (and equal) specifications: +.sp +.in +2 +.nf +1536M, 1.5g, 1.50GB +.fi +.in -2 +.sp + +.sp +.LP +The values of non-numeric properties are case sensitive and must be lowercase, except for \fBmountpoint\fR, \fBsharenfs\fR, and \fBsharesmb\fR. +.sp +.LP +The following native properties consist of read-only statistics about the dataset. These properties can be neither set, nor inherited. Native properties apply to all dataset types unless otherwise noted. +.sp +.ne 2 +.mk +.na +\fB\fBavailable\fR\fR +.ad +.sp .6 +.RS 4n +The amount of space available to the dataset and all its children, assuming that there is no other activity in the pool. Because space is shared within a pool, availability can be limited by any number of factors, including physical pool size, quotas, reservations, or other datasets within the pool. +.sp +This property can also be referred to by its shortened column name, \fBavail\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBcompressratio\fR\fR +.ad +.sp .6 +.RS 4n +The compression ratio achieved for this dataset, expressed as a multiplier. Compression can be turned on by running: \fBzfs set compression=on \fIdataset\fR\fR. The default value is \fBoff\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBcreation\fR\fR +.ad +.sp .6 +.RS 4n +The time this dataset was created. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBdefer_destroy\fR\fR +.ad +.sp .6 +.RS 4n +This property is \fBon\fR if the snapshot has been marked for deferred destroy by using the \fBzfs destroy\fR \fB-d\fR command. Otherwise, the property is \fBoff\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBmounted\fR\fR +.ad +.sp .6 +.RS 4n +For file systems, indicates whether the file system is currently mounted. This property can be either \fByes\fR or \fBno\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBorigin\fR\fR +.ad +.sp .6 +.RS 4n +For cloned file systems or volumes, the snapshot from which the clone was created. The origin cannot be destroyed (even with the \fB-r\fR or \fB-f\fR options) so long as a clone exists. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBreferenced\fR\fR +.ad +.sp .6 +.RS 4n +The amount of data that is accessible by this dataset, which may or may not be shared with other datasets in the pool. When a snapshot or clone is created, it initially references the same amount of space as the file system or snapshot it was created from, since its contents are identical. +.sp +This property can also be referred to by its shortened column name, \fBrefer\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBtype\fR\fR +.ad +.sp .6 +.RS 4n +The type of dataset: \fBfilesystem\fR, \fBvolume\fR, or \fBsnapshot\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBused\fR\fR +.ad +.sp .6 +.RS 4n +The amount of space consumed by this dataset and all its descendents. This is the value that is checked against this dataset's quota and reservation. The space used does not include this dataset's reservation, but does take into account the reservations of any descendent datasets. The amount of space that a dataset consumes from its parent, as well as the amount of space that are freed if this dataset is recursively destroyed, is the greater of its space used and its reservation. +.sp +When snapshots (see the "Snapshots" section) are created, their space is initially shared between the snapshot and the file system, and possibly with previous snapshots. As the file system changes, space that was previously shared becomes unique to the snapshot, and counted in the snapshot's space used. Additionally, deleting snapshots can increase the amount of space unique to (and used by) other snapshots. +.sp +The amount of space used, available, or referenced does not take into account pending changes. Pending changes are generally accounted for within a few seconds. Committing a change to a disk using \fBfsync\fR(3c) or \fBO_SYNC\fR does not necessarily guarantee that the space usage information is updated immediately. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBusedby*\fR\fR +.ad +.sp .6 +.RS 4n +The \fBusedby*\fR properties decompose the \fBused\fR properties into the various reasons that space is used. Specifically, \fBused\fR = \fBusedbychildren\fR + \fBusedbydataset\fR + \fBusedbyrefreservation\fR +, \fBusedbysnapshots\fR. These properties are only available for datasets created on \fBzpool\fR "version 13" pools. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBusedbychildren\fR\fR +.ad +.sp .6 +.RS 4n +The amount of space used by children of this dataset, which would be freed if all the dataset's children were destroyed. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBusedbydataset\fR\fR +.ad +.sp .6 +.RS 4n +The amount of space used by this dataset itself, which would be freed if the dataset were destroyed (after first removing any \fBrefreservation\fR and destroying any necessary snapshots or descendents). +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBusedbyrefreservation\fR\fR +.ad +.sp .6 +.RS 4n +The amount of space used by a \fBrefreservation\fR set on this dataset, which would be freed if the \fBrefreservation\fR was removed. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBusedbysnapshots\fR\fR +.ad +.sp .6 +.RS 4n +The amount of space consumed by snapshots of this dataset. In particular, it is the amount of space that would be freed if all of this dataset's snapshots were destroyed. Note that this is not simply the sum of the snapshots' \fBused\fR properties because space can be shared by multiple snapshots. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBuserused@\fR\fIuser\fR\fR +.ad +.sp .6 +.RS 4n +The amount of space consumed by the specified user in this dataset. Space is charged to the owner of each file, as displayed by \fBls\fR \fB-l\fR. The amount of space charged is displayed by \fBdu\fR and \fBls\fR \fB-s\fR. See the \fBzfs userspace\fR subcommand for more information. +.sp +Unprivileged users can access only their own space usage. The root user, or a user who has been granted the \fBuserused\fR privilege with \fBzfs allow\fR, can access everyone's usage. +.sp +The \fBuserused@\fR... properties are not displayed by \fBzfs get all\fR. The user's name must be appended after the \fB@\fR symbol, using one of the following forms: +.RS +4 +.TP +.ie t \(bu +.el o +\fIPOSIX name\fR (for example, \fBjoe\fR) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fIPOSIX numeric ID\fR (for example, \fB789\fR) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fISID name\fR (for example, \fBjoe.smith@mydomain\fR) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fISID numeric ID\fR (for example, \fBS-1-123-456-789\fR) +.RE +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBuserrefs\fR\fR +.ad +.sp .6 +.RS 4n +This property is set to the number of user holds on this snapshot. User holds are set by using the \fBzfs hold\fR command. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBgroupused@\fR\fIgroup\fR\fR +.ad +.sp .6 +.RS 4n +The amount of space consumed by the specified group in this dataset. Space is charged to the group of each file, as displayed by \fBls\fR \fB-l\fR. See the \fBuserused@\fR\fIuser\fR property for more information. +.sp +Unprivileged users can only access their own groups' space usage. The root user, or a user who has been granted the \fBgroupused\fR privilege with \fBzfs allow\fR, can access all groups' usage. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBvolblocksize\fR=\fIblocksize\fR\fR +.ad +.sp .6 +.RS 4n +For volumes, specifies the block size of the volume. The \fBblocksize\fR cannot be changed once the volume has been written, so it should be set at volume creation time. The default \fBblocksize\fR for volumes is 8 Kbytes. Any power of 2 from 512 bytes to 128 Kbytes is valid. +.sp +This property can also be referred to by its shortened column name, \fBvolblock\fR. +.RE + +.sp +.LP +The following native properties can be used to change the behavior of a \fBZFS\fR dataset. +.sp +.ne 2 +.mk +.na +\fB\fBaclinherit\fR=\fBdiscard\fR | \fBnoallow\fR | \fBrestricted\fR | \fBpassthrough\fR | \fBpassthrough-x\fR\fR +.ad +.sp .6 +.RS 4n +Controls how \fBACL\fR entries are inherited when files and directories are created. A file system with an \fBaclinherit\fR property of \fBdiscard\fR does not inherit any \fBACL\fR entries. A file system with an \fBaclinherit\fR property value of \fBnoallow\fR only inherits inheritable \fBACL\fR entries that specify "deny" permissions. The property value \fBrestricted\fR (the default) removes the \fBwrite_acl\fR and \fBwrite_owner\fR permissions when the \fBACL\fR entry is inherited. A file system with an \fBaclinherit\fR property value of \fBpassthrough\fR inherits all inheritable \fBACL\fR entries without any modifications made to the \fBACL\fR entries when they are inherited. A file system with an \fBaclinherit\fR property value of \fBpassthrough-x\fR has the same meaning as \fBpassthrough\fR, except that the \fBowner@\fR, \fBgroup@\fR, and \fBeveryone@\fR \fBACE\fRs inherit the execute permission only if the file creation mode also requests the execute bit. +.sp +When the property value is set to \fBpassthrough\fR, files are created with a mode determined by the inheritable \fBACE\fRs. If no inheritable \fBACE\fRs exist that affect the mode, then the mode is set in accordance to the requested mode from the application. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBaclmode\fR=\fBdiscard\fR | \fBgroupmask\fR | \fBpassthrough\fR\fR +.ad +.sp .6 +.RS 4n +Controls how an \fBACL\fR is modified during \fBchmod\fR(2). A file system with an \fBaclmode\fR property of \fBdiscard\fR deletes all \fBACL\fR entries that do not represent the mode of the file. An \fBaclmode\fR property of \fBgroupmask\fR (the default) reduces user or group permissions. The permissions are reduced, such that they are no greater than the group permission bits, unless it is a user entry that has the same \fBUID\fR as the owner of the file or directory. In this case, the \fBACL\fR permissions are reduced so that they are no greater than owner permission bits. A file system with an \fBaclmode\fR property of \fBpassthrough\fR indicates that no changes are made to the \fBACL\fR other than generating the necessary \fBACL\fR entries to represent the new mode of the file or directory. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBatime\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether the access time for files is updated when they are read. Turning this property off avoids producing write traffic when reading files and can result in significant performance gains, though it might confuse mailers and other similar utilities. The default value is \fBon\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBcanmount\fR=\fBon\fR | \fBoff\fR | \fBnoauto\fR\fR +.ad +.sp .6 +.RS 4n +If this property is set to \fBoff\fR, the file system cannot be mounted, and is ignored by \fBzfs mount -a\fR. Setting this property to \fBoff\fR is similar to setting the \fBmountpoint\fR property to \fBnone\fR, except that the dataset still has a normal \fBmountpoint\fR property, which can be inherited. Setting this property to \fBoff\fR allows datasets to be used solely as a mechanism to inherit properties. One example of setting \fBcanmount=\fR\fBoff\fR is to have two datasets with the same \fBmountpoint\fR, so that the children of both datasets appear in the same directory, but might have different inherited characteristics. +.sp +When the \fBnoauto\fR option is set, a dataset can only be mounted and unmounted explicitly. The dataset is not mounted automatically when the dataset is created or imported, nor is it mounted by the \fBzfs mount -a\fR command or unmounted by the \fBzfs unmount -a\fR command. +.sp +This property is not inherited. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBchecksum\fR=\fBon\fR | \fBoff\fR | \fBfletcher2,\fR| \fBfletcher4\fR | \fBsha256\fR\fR +.ad +.sp .6 +.RS 4n +Controls the checksum used to verify data integrity. The default value is \fBon\fR, which automatically selects an appropriate algorithm (currently, \fBfletcher2\fR, but this may change in future releases). The value \fBoff\fR disables integrity checking on user data. Disabling checksums is \fBNOT\fR a recommended practice. +.sp +Changing this property affects only newly-written data. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBcompression\fR=\fBon\fR | \fBoff\fR | \fBlzjb\fR | \fBgzip\fR | \fBgzip-\fR\fIN\fR\fR +.ad +.sp .6 +.RS 4n +Controls the compression algorithm used for this dataset. The \fBlzjb\fR compression algorithm is optimized for performance while providing decent data compression. Setting compression to \fBon\fR uses the \fBlzjb\fR compression algorithm. The \fBgzip\fR compression algorithm uses the same compression as the \fBgzip\fR(1) command. You can specify the \fBgzip\fR level by using the value \fBgzip-\fR\fIN\fR where \fIN\fR is an integer from 1 (fastest) to 9 (best compression ratio). Currently, \fBgzip\fR is equivalent to \fBgzip-6\fR (which is also the default for \fBgzip\fR(1)). +.sp +This property can also be referred to by its shortened column name \fBcompress\fR. Changing this property affects only newly-written data. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBcopies\fR=\fB1\fR | \fB2\fR | \fB3\fR\fR +.ad +.sp .6 +.RS 4n +Controls the number of copies of data stored for this dataset. These copies are in addition to any redundancy provided by the pool, for example, mirroring or RAID-Z. The copies are stored on different disks, if possible. The space used by multiple copies is charged to the associated file and dataset, changing the \fBused\fR property and counting against quotas and reservations. +.sp +Changing this property only affects newly-written data. Therefore, set this property at file system creation time by using the \fB-o\fR \fBcopies=\fR\fIN\fR option. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBdevices\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether device nodes can be opened on this file system. The default value is \fBon\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBexec\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether processes can be executed from within this file system. The default value is \fBon\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBmountpoint\fR=\fIpath\fR | \fBnone\fR | \fBlegacy\fR\fR +.ad +.sp .6 +.RS 4n +Controls the mount point used for this file system. See the "Mount Points" section for more information on how this property is used. +.sp +When the \fBmountpoint\fR property is changed for a file system, the file system and any children that inherit the mount point are unmounted. If the new value is \fBlegacy\fR, then they remain unmounted. Otherwise, they are automatically remounted in the new location if the property was previously \fBlegacy\fR or \fBnone\fR, or if they were mounted before the property was changed. In addition, any shared file systems are unshared and shared in the new location. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBnbmand\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether the file system should be mounted with \fBnbmand\fR (Non Blocking mandatory locks). This is used for \fBCIFS\fR clients. Changes to this property only take effect when the file system is umounted and remounted. See \fBmount\fR(1M) for more information on \fBnbmand\fR mounts. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBprimarycache\fR=\fBall\fR | \fBnone\fR | \fBmetadata\fR\fR +.ad +.sp .6 +.RS 4n +Controls what is cached in the primary cache (ARC). If this property is set to \fBall\fR, then both user data and metadata is cached. If this property is set to \fBnone\fR, then neither user data nor metadata is cached. If this property is set to \fBmetadata\fR, then only metadata is cached. The default value is \fBall\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBquota\fR=\fIsize\fR | \fBnone\fR\fR +.ad +.sp .6 +.RS 4n +Limits the amount of space a dataset and its descendents can consume. This property enforces a hard limit on the amount of space used. This includes all space consumed by descendents, including file systems and snapshots. Setting a quota on a descendent of a dataset that already has a quota does not override the ancestor's quota, but rather imposes an additional limit. +.sp +Quotas cannot be set on volumes, as the \fBvolsize\fR property acts as an implicit quota. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBuserquota@\fR\fIuser\fR=\fIsize\fR | \fBnone\fR\fR +.ad +.sp .6 +.RS 4n +Limits the amount of space consumed by the specified user. User space consumption is identified by the \fBuserspace@\fR\fIuser\fR property. +.sp +Enforcement of user quotas may be delayed by several seconds. This delay means that a user might exceed their quota before the system notices that they are over quota and begins to refuse additional writes with the \fBEDQUOT\fR error message . See the \fBzfs userspace\fR subcommand for more information. +.sp +Unprivileged users can only access their own groups' space usage. The root user, or a user who has been granted the \fBuserquota\fR privilege with \fBzfs allow\fR, can get and set everyone's quota. +.sp +This property is not available on volumes, on file systems before version 4, or on pools before version 15. The \fBuserquota@\fR... properties are not displayed by \fBzfs get all\fR. The user's name must be appended after the \fB@\fR symbol, using one of the following forms: +.RS +4 +.TP +.ie t \(bu +.el o +\fIPOSIX name\fR (for example, \fBjoe\fR) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fIPOSIX numeric ID\fR (for example, \fB789\fR) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fISID name\fR (for example, \fBjoe.smith@mydomain\fR) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fISID numeric ID\fR (for example, \fBS-1-123-456-789\fR) +.RE +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBgroupquota@\fR\fIgroup\fR=\fIsize\fR | \fBnone\fR\fR +.ad +.sp .6 +.RS 4n +Limits the amount of space consumed by the specified group. Group space consumption is identified by the \fBuserquota@\fR\fIuser\fR property. +.sp +Unprivileged users can access only their own groups' space usage. The root user, or a user who has been granted the \fBgroupquota\fR privilege with \fBzfs allow\fR, can get and set all groups' quotas. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBreadonly\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether this dataset can be modified. The default value is \fBoff\fR. +.sp +This property can also be referred to by its shortened column name, \fBrdonly\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBrecordsize\fR=\fIsize\fR\fR +.ad +.sp .6 +.RS 4n +Specifies a suggested block size for files in the file system. This property is designed solely for use with database workloads that access files in fixed-size records. \fBZFS\fR automatically tunes block sizes according to internal algorithms optimized for typical access patterns. +.sp +For databases that create very large files but access them in small random chunks, these algorithms may be suboptimal. Specifying a \fBrecordsize\fR greater than or equal to the record size of the database can result in significant performance gains. Use of this property for general purpose file systems is strongly discouraged, and may adversely affect performance. +.sp +The size specified must be a power of two greater than or equal to 512 and less than or equal to 128 Kbytes. +.sp +Changing the file system's \fBrecordsize\fR affects only files created afterward; existing files are unaffected. +.sp +This property can also be referred to by its shortened column name, \fBrecsize\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBrefquota\fR=\fIsize\fR | \fBnone\fR\fR +.ad +.sp .6 +.RS 4n +Limits the amount of space a dataset can consume. This property enforces a hard limit on the amount of space used. This hard limit does not include space used by descendents, including file systems and snapshots. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBrefreservation\fR=\fIsize\fR | \fBnone\fR\fR +.ad +.sp .6 +.RS 4n +The minimum amount of space guaranteed to a dataset, not including its descendents. When the amount of space used is below this value, the dataset is treated as if it were taking up the amount of space specified by \fBrefreservation\fR. The \fBrefreservation\fR reservation is accounted for in the parent datasets' space used, and counts against the parent datasets' quotas and reservations. +.sp +If \fBrefreservation\fR is set, a snapshot is only allowed if there is enough free pool space outside of this reservation to accommodate the current number of "referenced" bytes in the dataset. +.sp +This property can also be referred to by its shortened column name, \fBrefreserv\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBreservation\fR=\fIsize\fR | \fBnone\fR\fR +.ad +.sp .6 +.RS 4n +The minimum amount of space guaranteed to a dataset and its descendents. When the amount of space used is below this value, the dataset is treated as if it were taking up the amount of space specified by its reservation. Reservations are accounted for in the parent datasets' space used, and count against the parent datasets' quotas and reservations. +.sp +This property can also be referred to by its shortened column name, \fBreserv\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBsecondarycache\fR=\fBall\fR | \fBnone\fR | \fBmetadata\fR\fR +.ad +.sp .6 +.RS 4n +Controls what is cached in the secondary cache (L2ARC). If this property is set to \fBall\fR, then both user data and metadata is cached. If this property is set to \fBnone\fR, then neither user data nor metadata is cached. If this property is set to \fBmetadata\fR, then only metadata is cached. The default value is \fBall\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBsetuid\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether the set-\fBUID\fR bit is respected for the file system. The default value is \fBon\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBshareiscsi\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Like the \fBsharenfs\fR property, \fBshareiscsi\fR indicates whether a \fBZFS\fR volume is exported as an \fBiSCSI\fR target. The acceptable values for this property are \fBon\fR, \fBoff\fR, and \fBtype=disk\fR. The default value is \fBoff\fR. In the future, other target types might be supported. For example, \fBtape\fR. +.sp +You might want to set \fBshareiscsi=on\fR for a file system so that all \fBZFS\fR volumes within the file system are shared by default. However, setting this property on a file system has no direct effect. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBsharesmb\fR=\fBon\fR | \fBoff\fR | \fIopts\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether the file system is shared by using the Solaris \fBCIFS\fR service, and what options are to be used. A file system with the \fBsharesmb\fR property set to \fBoff\fR is managed through traditional tools such as \fBsharemgr\fR(1M). Otherwise, the file system is automatically shared and unshared with the \fBzfs share\fR and \fBzfs unshare\fR commands. If the property is set to \fBon\fR, the \fBsharemgr\fR(1M) command is invoked with no options. Otherwise, the \fBsharemgr\fR(1M) command is invoked with options equivalent to the contents of this property. +.sp +Because \fBSMB\fR shares requires a resource name, a unique resource name is constructed from the dataset name. The constructed name is a copy of the dataset name except that the characters in the dataset name, which would be illegal in the resource name, are replaced with underscore (\fB_\fR) characters. A pseudo property "name" is also supported that allows you to replace the data set name with a specified name. The specified name is then used to replace the prefix dataset in the case of inheritance. For example, if the dataset \fBdata/home/john\fR is set to \fBname=john\fR, then \fBdata/home/john\fR has a resource name of \fBjohn\fR. If a child dataset of \fBdata/home/john/backups\fR, it has a resource name of \fBjohn_backups\fR. +.sp +When SMB shares are created, the SMB share name appears as an entry in the \fB\&.zfs/shares\fR directory. You can use the \fBls\fR or \fBchmod\fR command to display the share-level ACLs on the entries in this directory. +.sp +When the \fBsharesmb\fR property is changed for a dataset, the dataset and any children inheriting the property are re-shared with the new options, only if the property was previously set to \fBoff\fR, or if they were shared before the property was changed. If the new property is set to \fBoff\fR, the file systems are unshared. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBsharenfs\fR=\fBon\fR | \fBoff\fR | \fIopts\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether the file system is shared via \fBNFS\fR, and what options are used. A file system with a \fBsharenfs\fR property of \fBoff\fR is managed through traditional tools such as \fBshare\fR(1M), \fBunshare\fR(1M), and \fBdfstab\fR(4). Otherwise, the file system is automatically shared and unshared with the \fBzfs share\fR and \fBzfs unshare\fR commands. If the property is set to \fBon\fR, the \fBshare\fR(1M) command is invoked with no options. Otherwise, the \fBshare\fR(1M) command is invoked with options equivalent to the contents of this property. +.sp +When the \fBsharenfs\fR property is changed for a dataset, the dataset and any children inheriting the property are re-shared with the new options, only if the property was previously \fBoff\fR, or if they were shared before the property was changed. If the new property is \fBoff\fR, the file systems are unshared. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBlogbias\fR = \fBlatency\fR | \fBthroughput\fR\fR +.ad +.sp .6 +.RS 4n +Provide a hint to ZFS about handling of synchronous requests in this dataset. If \fBlogbias\fR is set to \fBlatency\fR (the default), ZFS will use pool log devices (if configured) to handle the requests at low latency. If \fBlogbias\fR is set to \fBthroughput\fR, ZFS will not use configured pool log devices. ZFS will instead optimize synchronous operations for global pool throughput and efficient use of resources. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBsnapdir\fR=\fBhidden\fR | \fBvisible\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether the \fB\&.zfs\fR directory is hidden or visible in the root of the file system as discussed in the "Snapshots" section. The default value is \fBhidden\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBversion\fR=\fB1\fR | \fB2\fR | \fBcurrent\fR\fR +.ad +.sp .6 +.RS 4n +The on-disk version of this file system, which is independent of the pool version. This property can only be set to later supported versions. See the \fBzfs upgrade\fR command. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBvolsize\fR=\fIsize\fR\fR +.ad +.sp .6 +.RS 4n +For volumes, specifies the logical size of the volume. By default, creating a volume establishes a reservation of equal size. For storage pools with a version number of 9 or higher, a \fBrefreservation\fR is set instead. Any changes to \fBvolsize\fR are reflected in an equivalent change to the reservation (or \fBrefreservation\fR). The \fBvolsize\fR can only be set to a multiple of \fBvolblocksize\fR, and cannot be zero. +.sp +The reservation is kept equal to the volume's logical size to prevent unexpected behavior for consumers. Without the reservation, the volume could run out of space, resulting in undefined behavior or data corruption, depending on how the volume is used. These effects can also occur when the volume size is changed while it is in use (particularly when shrinking the size). Extreme care should be used when adjusting the volume size. +.sp +Though not recommended, a "sparse volume" (also known as "thin provisioning") can be created by specifying the \fB-s\fR option to the \fBzfs create -V\fR command, or by changing the reservation after the volume has been created. A "sparse volume" is a volume where the reservation is less then the volume size. Consequently, writes to a sparse volume can fail with \fBENOSPC\fR when the pool is low on space. For a sparse volume, changes to \fBvolsize\fR are not reflected in the reservation. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBvscan\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether regular files should be scanned for viruses when a file is opened and closed. In addition to enabling this property, the virus scan service must also be enabled for virus scanning to occur. The default value is \fBoff\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBxattr\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether extended attributes are enabled for this file system. The default value is \fBon\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzoned\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether the dataset is managed from a non-global zone. See the "Zones" section for more information. The default value is \fBoff\fR. +.RE + +.sp +.LP +The following three properties cannot be changed after the file system is created, and therefore, should be set when the file system is created. If the properties are not set with the \fBzfs create\fR or \fBzpool create\fR commands, these properties are inherited from the parent dataset. If the parent dataset lacks these properties due to having been created prior to these features being supported, the new file system will have the default values for these properties. +.sp +.ne 2 +.mk +.na +\fB\fBcasesensitivity\fR=\fBsensitive\fR | \fBinsensitive\fR | \fBmixed\fR\fR +.ad +.sp .6 +.RS 4n +Indicates whether the file name matching algorithm used by the file system should be case-sensitive, case-insensitive, or allow a combination of both styles of matching. The default value for the \fBcasesensitivity\fR property is \fBsensitive\fR. Traditionally, UNIX and POSIX file systems have case-sensitive file names. +.sp +The \fBmixed\fR value for the \fBcasesensitivity\fR property indicates that the file system can support requests for both case-sensitive and case-insensitive matching behavior. Currently, case-insensitive matching behavior on a file system that supports mixed behavior is limited to the Solaris CIFS server product. For more information about the \fBmixed\fR value behavior, see the \fISolaris ZFS Administration Guide\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBnormalization\fR = \fBnone\fR | \fBformC\fR | \fBformD\fR | \fBformKC\fR | \fBformKD\fR\fR +.ad +.sp .6 +.RS 4n +Indicates whether the file system should perform a \fBunicode\fR normalization of file names whenever two file names are compared, and which normalization algorithm should be used. File names are always stored unmodified, names are normalized as part of any comparison process. If this property is set to a legal value other than \fBnone\fR, and the \fButf8only\fR property was left unspecified, the \fButf8only\fR property is automatically set to \fBon\fR. The default value of the \fBnormalization\fR property is \fBnone\fR. This property cannot be changed after the file system is created. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fButf8only\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Indicates whether the file system should reject file names that include characters that are not present in the \fBUTF-8\fR character code set. If this property is explicitly set to \fBoff\fR, the normalization property must either not be explicitly set or be set to \fBnone\fR. The default value for the \fButf8only\fR property is \fBoff\fR. This property cannot be changed after the file system is created. +.RE + +.sp +.LP +The \fBcasesensitivity\fR, \fBnormalization\fR, and \fButf8only\fR properties are also new permissions that can be assigned to non-privileged users by using the \fBZFS\fR delegated administration feature. +.SS "Temporary Mount Point Properties" +.sp +.LP +When a file system is mounted, either through \fBmount\fR(1M) for legacy mounts or the \fBzfs mount\fR command for normal file systems, its mount options are set according to its properties. The correlation between properties and mount options is as follows: +.sp +.in +2 +.nf + PROPERTY MOUNT OPTION + devices devices/nodevices + exec exec/noexec + readonly ro/rw + setuid setuid/nosetuid + xattr xattr/noxattr +.fi +.in -2 +.sp + +.sp +.LP +In addition, these options can be set on a per-mount basis using the \fB-o\fR option, without affecting the property that is stored on disk. The values specified on the command line override the values stored in the dataset. The \fB-nosuid\fR option is an alias for \fBnodevices,nosetuid\fR. These properties are reported as "temporary" by the \fBzfs get\fR command. If the properties are changed while the dataset is mounted, the new setting overrides any temporary settings. +.SS "User Properties" +.sp +.LP +In addition to the standard native properties, \fBZFS\fR supports arbitrary user properties. User properties have no effect on \fBZFS\fR behavior, but applications or administrators can use them to annotate datasets (file systems, volumes, and snapshots). +.sp +.LP +User property names must contain a colon (\fB:\fR) character to distinguish them from native properties. They may contain lowercase letters, numbers, and the following punctuation characters: colon (\fB:\fR), dash (\fB-\fR), period (\fB\&.\fR), and underscore (\fB_\fR). The expected convention is that the property name is divided into two portions such as \fImodule\fR\fB:\fR\fIproperty\fR, but this namespace is not enforced by \fBZFS\fR. User property names can be at most 256 characters, and cannot begin with a dash (\fB-\fR). +.sp +.LP +When making programmatic use of user properties, it is strongly suggested to use a reversed \fBDNS\fR domain name for the \fImodule\fR component of property names to reduce the chance that two independently-developed packages use the same property name for different purposes. Property names beginning with \fBcom.sun\fR. are reserved for use by Sun Microsystems. +.sp +.LP +The values of user properties are arbitrary strings, are always inherited, and are never validated. All of the commands that operate on properties (\fBzfs list\fR, \fBzfs get\fR, \fBzfs set\fR, and so forth) can be used to manipulate both native properties and user properties. Use the \fBzfs inherit\fR command to clear a user property . If the property is not defined in any parent dataset, it is removed entirely. Property values are limited to 1024 characters. +.SS "ZFS Volumes as Swap or Dump Devices" +.sp +.LP +During an initial installation or a live upgrade from a \fBUFS\fR file system, a swap device and dump device are created on \fBZFS\fR volumes in the \fBZFS\fR root pool. By default, the swap area size is based on 1/2 the size of physical memory up to 2 Gbytes. The size of the dump device depends on the kernel's requirements at installation time. Separate \fBZFS\fR volumes must be used for the swap area and dump devices. Do not swap to a file on a \fBZFS\fR file system. A \fBZFS\fR swap file configuration is not supported. +.sp +.LP +If you need to change your swap area or dump device after the system is installed or upgraded, use the \fBswap\fR(1M) and \fBdumpadm\fR(1M) commands. If you need to change the size of your swap area or dump device, see the \fISolaris ZFS Administration Guide\fR. +.SH SUBCOMMANDS +.sp +.LP +All subcommands that modify state are logged persistently to the pool in their original form. +.sp +.ne 2 +.mk +.na +\fB\fBzfs ?\fR\fR +.ad +.sp .6 +.RS 4n +Displays a help message. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs create\fR [\fB-p\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR] ... \fIfilesystem\fR\fR +.ad +.sp .6 +.RS 4n +Creates a new \fBZFS\fR file system. The file system is automatically mounted according to the \fBmountpoint\fR property inherited from the parent. +.sp +.ne 2 +.mk +.na +\fB\fB-p\fR\fR +.ad +.sp .6 +.RS 4n +Creates all the non-existing parent datasets. Datasets created in this manner are automatically mounted according to the \fBmountpoint\fR property inherited from their parent. Any property specified on the command line using the \fB-o\fR option is ignored. If the target filesystem already exists, the operation completes successfully. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIproperty\fR=\fIvalue\fR\fR +.ad +.sp .6 +.RS 4n +Sets the specified property as if the command \fBzfs set\fR \fIproperty\fR=\fIvalue\fR was invoked at the same time the dataset was created. Any editable \fBZFS\fR property can also be set at creation time. Multiple \fB-o\fR options can be specified. An error results if the same property is specified in multiple \fB-o\fR options. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs create\fR [\fB-ps\fR] [\fB-b\fR \fIblocksize\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR] ... \fB-V\fR \fIsize\fR \fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Creates a volume of the given size. The volume is exported as a block device in \fB/dev/zvol/{dsk,rdsk}/\fR\fIpath\fR, where \fIpath\fR is the name of the volume in the \fBZFS\fR namespace. The size represents the logical size as exported by the device. By default, a reservation of equal size is created. +.sp +\fIsize\fR is automatically rounded up to the nearest 128 Kbytes to ensure that the volume has an integral number of blocks regardless of \fIblocksize\fR. +.sp +.ne 2 +.mk +.na +\fB\fB-p\fR\fR +.ad +.sp .6 +.RS 4n +Creates all the non-existing parent datasets. Datasets created in this manner are automatically mounted according to the \fBmountpoint\fR property inherited from their parent. Any property specified on the command line using the \fB-o\fR option is ignored. If the target filesystem already exists, the operation completes successfully. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-s\fR\fR +.ad +.sp .6 +.RS 4n +Creates a sparse volume with no reservation. See \fBvolsize\fR in the Native Properties section for more information about sparse volumes. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIproperty\fR=\fIvalue\fR\fR +.ad +.sp .6 +.RS 4n +Sets the specified property as if the \fBzfs set\fR \fIproperty\fR=\fIvalue\fR command was invoked at the same time the dataset was created. Any editable \fBZFS\fR property can also be set at creation time. Multiple \fB-o\fR options can be specified. An error results if the same property is specified in multiple \fB-o\fR options. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-b\fR \fIblocksize\fR\fR +.ad +.sp .6 +.RS 4n +Equivalent to \fB-o\fR \fBvolblocksize\fR=\fIblocksize\fR. If this option is specified in conjunction with \fB-o\fR \fBvolblocksize\fR, the resulting behavior is undefined. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs destroy\fR [\fB-rRf\fR] \fIfilesystem\fR|\fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Destroys the given dataset. By default, the command unshares any file systems that are currently shared, unmounts any file systems that are currently mounted, and refuses to destroy a dataset that has active dependents (children or clones). +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Recursively destroy all children. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-R\fR\fR +.ad +.sp .6 +.RS 4n +Recursively destroy all dependents, including cloned file systems outside the target hierarchy. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.sp .6 +.RS 4n +Force an unmount of any file systems using the \fBunmount -f\fR command. This option has no effect on non-file systems or unmounted file systems. +.RE + +Extreme care should be taken when applying either the \fB-r\fR or the \fB-f\fR options, as they can destroy large portions of a pool and cause unexpected behavior for mounted file systems in use. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs destroy\fR [\fB-rRd\fR] \fIsnapshot\fR\fR +.ad +.sp .6 +.RS 4n +The given snapshot is destroyed immediately if and only if the \fBzfs destroy\fR command without the \fB-d\fR option would have destroyed it. Such immediate destruction would occur, for example, if the snapshot had no clones and the user-initiated reference count were zero. +.sp +If the snapshot does not qualify for immediate destruction, it is marked for deferred deletion. In this state, it exists as a usable, visible snapshot until both of the preconditions listed above are met, at which point it is destroyed. +.sp +.ne 2 +.mk +.na +\fB\fB-d\fR\fR +.ad +.sp .6 +.RS 4n +Defer snapshot deletion. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Destroy (or mark for deferred deletion) all snapshots with this name in descendent file systems. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-R\fR\fR +.ad +.sp .6 +.RS 4n +Recursively destroy all dependents. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs snapshot\fR [\fB-r\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR] ... \fIfilesystem@snapname\fR|\fIvolume@snapname\fR\fR +.ad +.sp .6 +.RS 4n +Creates a snapshot with the given name. All previous modifications by successful system calls to the file system are part of the snapshot. See the "Snapshots" section for details. +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Recursively create snapshots of all descendent datasets. Snapshots are taken atomically, so that all recursive snapshots correspond to the same moment in time. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIproperty\fR=\fIvalue\fR\fR +.ad +.sp .6 +.RS 4n +Sets the specified property; see \fBzfs create\fR for details. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs rollback\fR [\fB-rRf\fR] \fIsnapshot\fR\fR +.ad +.sp .6 +.RS 4n +Roll back the given dataset to a previous snapshot. When a dataset is rolled back, all data that has changed since the snapshot is discarded, and the dataset reverts to the state at the time of the snapshot. By default, the command refuses to roll back to a snapshot other than the most recent one. In order to do so, all intermediate snapshots must be destroyed by specifying the \fB-r\fR option. +.sp +The \fB-rR\fR options do not recursively destroy the child snapshots of a recursive snapshot. Only the top-level recursive snapshot is destroyed by either of these options. To completely roll back a recursive snapshot, you must rollback the individual child snapshots. +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Recursively destroy any snapshots more recent than the one specified. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-R\fR\fR +.ad +.sp .6 +.RS 4n +Recursively destroy any more recent snapshots, as well as any clones of those snapshots. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.sp .6 +.RS 4n +Used with the \fB-R\fR option to force an unmount of any clone file systems that are to be destroyed. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs clone\fR [\fB-p\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR] ... \fIsnapshot\fR \fIfilesystem\fR|\fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Creates a clone of the given snapshot. See the "Clones" section for details. The target dataset can be located anywhere in the \fBZFS\fR hierarchy, and is created as the same type as the original. +.sp +.ne 2 +.mk +.na +\fB\fB-p\fR\fR +.ad +.sp .6 +.RS 4n +Creates all the non-existing parent datasets. Datasets created in this manner are automatically mounted according to the \fBmountpoint\fR property inherited from their parent. If the target filesystem or volume already exists, the operation completes successfully. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIproperty\fR=\fIvalue\fR\fR +.ad +.sp .6 +.RS 4n +Sets the specified property; see \fBzfs create\fR for details. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs promote\fR \fIclone-filesystem\fR\fR +.ad +.sp .6 +.RS 4n +Promotes a clone file system to no longer be dependent on its "origin" snapshot. This makes it possible to destroy the file system that the clone was created from. The clone parent-child dependency relationship is reversed, so that the origin file system becomes a clone of the specified file system. +.sp +The snapshot that was cloned, and any snapshots previous to this snapshot, are now owned by the promoted clone. The space they use moves from the origin file system to the promoted clone, so enough space must be available to accommodate these snapshots. No new space is consumed by this operation, but the space accounting is adjusted. The promoted clone must not have any conflicting snapshot names of its own. The \fBrename\fR subcommand can be used to rename any conflicting snapshots. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs rename\fR \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR\fR +.ad +.br +.na +\fB\fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR\fR +.ad +.br +.na +\fB\fBzfs rename\fR [\fB-p\fR] \fIfilesystem\fR|\fIvolume\fR \fIfilesystem\fR|\fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Renames the given dataset. The new target can be located anywhere in the \fBZFS\fR hierarchy, with the exception of snapshots. Snapshots can only be renamed within the parent file system or volume. When renaming a snapshot, the parent file system of the snapshot does not need to be specified as part of the second argument. Renamed file systems can inherit new mount points, in which case they are unmounted and remounted at the new mount point. +.sp +.ne 2 +.mk +.na +\fB\fB-p\fR\fR +.ad +.sp .6 +.RS 4n +Creates all the nonexistent parent datasets. Datasets created in this manner are automatically mounted according to the \fBmountpoint\fR property inherited from their parent. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs rename\fR \fB-r\fR \fIsnapshot\fR \fIsnapshot\fR\fR +.ad +.sp .6 +.RS 4n +Recursively rename the snapshots of all descendent datasets. Snapshots are the only dataset that can be renamed recursively. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs\fR \fBlist\fR [\fB-r\fR|\fB-d\fR \fIdepth\fR] [\fB-H\fR] [\fB-o\fR \fIproperty\fR[,\fI\&...\fR]] [ \fB-t\fR \fItype\fR[,\fI\&...\fR]] [ \fB-s\fR \fIproperty\fR ] ... [ \fB-S\fR \fIproperty\fR ] ... [\fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR] ...\fR +.ad +.sp .6 +.RS 4n +Lists the property information for the given datasets in tabular form. If specified, you can list property information by the absolute pathname or the relative pathname. By default, all file systems and volumes are displayed. Snapshots are displayed if the \fBlistsnaps\fR property is \fBon\fR (the default is \fBoff\fR) . The following fields are displayed, \fBname,used,available,referenced,mountpoint\fR. +.sp +.ne 2 +.mk +.na +\fB\fB-H\fR\fR +.ad +.sp .6 +.RS 4n +Used for scripting mode. Do not print headers and separate fields by a single tab instead of arbitrary white space. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Recursively display any children of the dataset on the command line. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-d\fR \fIdepth\fR\fR +.ad +.sp .6 +.RS 4n +Recursively display any children of the dataset, limiting the recursion to \fIdepth\fR. A depth of \fB1\fR will display only the dataset and its direct children. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIproperty\fR\fR +.ad +.sp .6 +.RS 4n +A comma-separated list of properties to display. The property must be: +.RS +4 +.TP +.ie t \(bu +.el o +One of the properties described in the "Native Properties" section +.RE +.RS +4 +.TP +.ie t \(bu +.el o +A user property +.RE +.RS +4 +.TP +.ie t \(bu +.el o +The value \fBname\fR to display the dataset name +.RE +.RS +4 +.TP +.ie t \(bu +.el o +The value \fBspace\fR to display space usage properties on file systems and volumes. This is a shortcut for specifying \fB-o name,avail,used,usedsnap,usedds,usedrefreserv,usedchild\fR \fB-t filesystem,volume\fR syntax. +.RE +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-s\fR \fIproperty\fR\fR +.ad +.sp .6 +.RS 4n +A property for sorting the output by column in ascending order based on the value of the property. The property must be one of the properties described in the "Properties" section, or the special value \fBname\fR to sort by the dataset name. Multiple properties can be specified at one time using multiple \fB-s\fR property options. Multiple \fB-s\fR options are evaluated from left to right in decreasing order of importance. +.sp +The following is a list of sorting criteria: +.RS +4 +.TP +.ie t \(bu +.el o +Numeric types sort in numeric order. +.RE +.RS +4 +.TP +.ie t \(bu +.el o +String types sort in alphabetical order. +.RE +.RS +4 +.TP +.ie t \(bu +.el o +Types inappropriate for a row sort that row to the literal bottom, regardless of the specified ordering. +.RE +.RS +4 +.TP +.ie t \(bu +.el o +If no sorting options are specified the existing behavior of \fBzfs list\fR is preserved. +.RE +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-S\fR \fIproperty\fR\fR +.ad +.sp .6 +.RS 4n +Same as the \fB-s\fR option, but sorts by property in descending order. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-t\fR \fItype\fR\fR +.ad +.sp .6 +.RS 4n +A comma-separated list of types to display, where \fItype\fR is one of \fBfilesystem\fR, \fBsnapshot\fR , \fBvolume\fR, or \fBall\fR. For example, specifying \fB-t snapshot\fR displays only snapshots. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs set\fR \fIproperty\fR=\fIvalue\fR \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR ...\fR +.ad +.sp .6 +.RS 4n +Sets the property to the given value for each dataset. Only some properties can be edited. See the "Properties" section for more information on what properties can be set and acceptable values. Numeric values can be specified as exact values, or in a human-readable form with a suffix of \fBB\fR, \fBK\fR, \fBM\fR, \fBG\fR, \fBT\fR, \fBP\fR, \fBE\fR, \fBZ\fR (for bytes, kilobytes, megabytes, gigabytes, terabytes, petabytes, exabytes, or zettabytes, respectively). User properties can be set on snapshots. For more information, see the "User Properties" section. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs get\fR [\fB-r\fR|\fB-d\fR \fIdepth\fR] [\fB-Hp\fR] [\fB-o\fR \fIfield\fR[,...] [\fB-s\fR \fIsource\fR[,...] "\fIall\fR" | \fIproperty\fR[,...] \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR ...\fR +.ad +.sp .6 +.RS 4n +Displays properties for the given datasets. If no datasets are specified, then the command displays properties for all datasets on the system. For each property, the following columns are displayed: +.sp +.in +2 +.nf + name Dataset name + property Property name + value Property value + source Property source. Can either be local, default, + temporary, inherited, or none (-). +.fi +.in -2 +.sp + +All columns are displayed by default, though this can be controlled by using the \fB-o\fR option. This command takes a comma-separated list of properties as described in the "Native Properties" and "User Properties" sections. +.sp +The special value \fBall\fR can be used to display all properties that apply to the given dataset's type (filesystem, volume, or snapshot). +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Recursively display properties for any children. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-d\fR \fIdepth\fR\fR +.ad +.sp .6 +.RS 4n +Recursively display any children of the dataset, limiting the recursion to \fIdepth\fR. A depth of \fB1\fR will display only the dataset and its direct children. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-H\fR\fR +.ad +.sp .6 +.RS 4n +Display output in a form more easily parsed by scripts. Any headers are omitted, and fields are explicitly separated by a single tab instead of an arbitrary amount of space. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIfield\fR\fR +.ad +.sp .6 +.RS 4n +A comma-separated list of columns to display. \fBname,property,value,source\fR is the default value. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-s\fR \fIsource\fR\fR +.ad +.sp .6 +.RS 4n +A comma-separated list of sources to display. Those properties coming from a source other than those in this list are ignored. Each source must be one of the following: \fBlocal,default,inherited,temporary,none\fR. The default value is all sources. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-p\fR\fR +.ad +.sp .6 +.RS 4n +Display numbers in parseable (exact) values. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs inherit\fR [\fB-r\fR] \fIproperty\fR \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR ...\fR +.ad +.sp .6 +.RS 4n +Clears the specified property, causing it to be inherited from an ancestor. If no ancestor has the property set, then the default value is used. See the "Properties" section for a listing of default values, and details on which properties can be inherited. +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Recursively inherit the given property for all children. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs upgrade\fR [\fB-v\fR]\fR +.ad +.sp .6 +.RS 4n +Displays a list of file systems that are not the most recent version. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs upgrade\fR [\fB-r\fR] [\fB-V\fR \fIversion\fR] [\fB-a\fR | \fIfilesystem\fR]\fR +.ad +.sp .6 +.RS 4n +Upgrades file systems to a new on-disk version. Once this is done, the file systems will no longer be accessible on systems running older versions of the software. \fBzfs send\fR streams generated from new snapshots of these file systems cannot be accessed on systems running older versions of the software. +.sp +In general, the file system version is independent of the pool version. See \fBzpool\fR(1M) for information on the \fBzpool upgrade\fR command. +.sp +In some cases, the file system version and the pool version are interrelated and the pool version must be upgraded before the file system version can be upgraded. +.sp +.ne 2 +.mk +.na +\fB\fB-a\fR\fR +.ad +.sp .6 +.RS 4n +Upgrade all file systems on all imported pools. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fIfilesystem\fR\fR +.ad +.sp .6 +.RS 4n +Upgrade the specified file system. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Upgrade the specified file system and all descendent file systems +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-V\fR \fIversion\fR\fR +.ad +.sp .6 +.RS 4n +Upgrade to the specified \fIversion\fR. If the \fB-V\fR flag is not specified, this command upgrades to the most recent version. This option can only be used to increase the version number, and only up to the most recent version supported by this software. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs userspace\fR [\fB-niHp\fR] [\fB-o\fR \fIfield\fR[,...]] [\fB-sS\fR \fIfield\fR]... [\fB-t\fR \fItype\fR [,...]] \fIfilesystem\fR | \fIsnapshot\fR\fR +.ad +.sp .6 +.RS 4n +Displays space consumed by, and quotas on, each user in the specified filesystem or snapshot. This corresponds to the \fBuserused@\fR\fIuser\fR and \fBuserquota@\fR\fIuser\fR properties. +.sp +.ne 2 +.mk +.na +\fB\fB-n\fR\fR +.ad +.sp .6 +.RS 4n +Print numeric ID instead of user/group name. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-H\fR\fR +.ad +.sp .6 +.RS 4n +Do not print headers, use tab-delimited output. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-p\fR\fR +.ad +.sp .6 +.RS 4n +Use exact (parseable) numeric output. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIfield\fR[,...]\fR +.ad +.sp .6 +.RS 4n +Display only the specified fields from the following set, \fBtype,name,used,quota\fR.The default is to display all fields. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-s\fR \fIfield\fR\fR +.ad +.sp .6 +.RS 4n +Sort output by this field. The \fIs\fR and \fIS\fR flags may be specified multiple times to sort first by one field, then by another. The default is \fB-s type\fR \fB-s name\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-S\fR \fIfield\fR\fR +.ad +.sp .6 +.RS 4n +Sort by this field in reverse order. See \fB-s\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-t\fR \fItype\fR[,...]\fR +.ad +.sp .6 +.RS 4n +Print only the specified types from the following set, \fBall,posixuser,smbuser,posixgroup,smbgroup\fR. +.sp +The default is \fB-t posixuser,smbuser\fR +.sp +The default can be changed to include group types. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-i\fR\fR +.ad +.sp .6 +.RS 4n +Translate SID to POSIX ID. The POSIX ID may be ephemeral if no mapping exists. Normal POSIX interfaces (for example, \fBstat\fR(2), \fBls\fR \fB-l\fR) perform this translation, so the \fB-i\fR option allows the output from \fBzfs userspace\fR to be compared directly with those utilities. However, \fB-i\fR may lead to confusion if some files were created by an SMB user before a SMB-to-POSIX name mapping was established. In such a case, some files are owned by the SMB entity and some by the POSIX entity. However, the \fB-i\fR option will report that the POSIX entity has the total usage and quota for both. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs groupspace\fR [\fB-niHp\fR] [\fB-o\fR \fIfield\fR[,...]] [\fB-sS\fR \fIfield\fR]... [\fB-t\fR \fItype\fR [,...]] \fIfilesystem\fR | \fIsnapshot\fR\fR +.ad +.sp .6 +.RS 4n +Displays space consumed by, and quotas on, each group in the specified filesystem or snapshot. This subcommand is identical to \fBzfs userspace\fR, except that the default types to display are \fB-t posixgroup,smbgroup\fR. +.sp +.in +2 +.nf +- +.fi +.in -2 +.sp + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs mount\fR\fR +.ad +.sp .6 +.RS 4n +Displays all \fBZFS\fR file systems currently mounted. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs mount\fR [\fB-vO\fR] [\fB-o\fR \fIoptions\fR] \fB-a\fR | \fIfilesystem\fR\fR +.ad +.sp .6 +.RS 4n +Mounts \fBZFS\fR file systems. Invoked automatically as part of the boot process. +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIoptions\fR\fR +.ad +.sp .6 +.RS 4n +An optional, comma-separated list of mount options to use temporarily for the duration of the mount. See the "Temporary Mount Point Properties" section for details. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-O\fR\fR +.ad +.sp .6 +.RS 4n +Perform an overlay mount. See \fBmount\fR(1M) for more information. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-v\fR\fR +.ad +.sp .6 +.RS 4n +Report mount progress. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-a\fR\fR +.ad +.sp .6 +.RS 4n +Mount all available \fBZFS\fR file systems. Invoked automatically as part of the boot process. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fIfilesystem\fR\fR +.ad +.sp .6 +.RS 4n +Mount the specified filesystem. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs unmount\fR [\fB-f\fR] \fB-a\fR | \fIfilesystem\fR|\fImountpoint\fR\fR +.ad +.sp .6 +.RS 4n +Unmounts currently mounted \fBZFS\fR file systems. Invoked automatically as part of the shutdown process. +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.sp .6 +.RS 4n +Forcefully unmount the file system, even if it is currently in use. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-a\fR\fR +.ad +.sp .6 +.RS 4n +Unmount all available \fBZFS\fR file systems. Invoked automatically as part of the boot process. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fIfilesystem\fR|\fImountpoint\fR\fR +.ad +.sp .6 +.RS 4n +Unmount the specified filesystem. The command can also be given a path to a \fBZFS\fR file system mount point on the system. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs share\fR \fB-a\fR | \fIfilesystem\fR\fR +.ad +.sp .6 +.RS 4n +Shares available \fBZFS\fR file systems. +.sp +.ne 2 +.mk +.na +\fB\fB-a\fR\fR +.ad +.sp .6 +.RS 4n +Share all available \fBZFS\fR file systems. Invoked automatically as part of the boot process. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fIfilesystem\fR\fR +.ad +.sp .6 +.RS 4n +Share the specified filesystem according to the \fBsharenfs\fR and \fBsharesmb\fR properties. File systems are shared when the \fBsharenfs\fR or \fBsharesmb\fR property is set. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs unshare\fR \fB-a\fR | \fIfilesystem\fR|\fImountpoint\fR\fR +.ad +.sp .6 +.RS 4n +Unshares currently shared \fBZFS\fR file systems. This is invoked automatically as part of the shutdown process. +.sp +.ne 2 +.mk +.na +\fB\fB-a\fR\fR +.ad +.sp .6 +.RS 4n +Unshare all available \fBZFS\fR file systems. Invoked automatically as part of the boot process. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fIfilesystem\fR|\fImountpoint\fR\fR +.ad +.sp .6 +.RS 4n +Unshare the specified filesystem. The command can also be given a path to a \fBZFS\fR file system shared on the system. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs send\fR [\fB-vR\fR] [\fB-\fR[\fBiI\fR] \fIsnapshot\fR] \fIsnapshot\fR\fR +.ad +.sp .6 +.RS 4n +Creates a stream representation of the second \fIsnapshot\fR, which is written to standard output. The output can be redirected to a file or to a different system (for example, using \fBssh\fR(1). By default, a full stream is generated. +.sp +.ne 2 +.mk +.na +\fB\fB-i\fR \fIsnapshot\fR\fR +.ad +.sp .6 +.RS 4n +Generate an incremental stream from the first \fIsnapshot\fR to the second \fIsnapshot\fR. The incremental source (the first \fIsnapshot\fR) can be specified as the last component of the snapshot name (for example, the part after the \fB@\fR), and it is assumed to be from the same file system as the second \fIsnapshot\fR. +.sp +If the destination is a clone, the source may be the origin snapshot, which must be fully specified (for example, \fBpool/fs@origin\fR, not just \fB@origin\fR). +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-I\fR \fIsnapshot\fR\fR +.ad +.sp .6 +.RS 4n +Generate a stream package that sends all intermediary snapshots from the first snapshot to the second snapshot. For example, \fB-I @a fs@d\fR is similar to \fB-i @a fs@b; -i @b fs@c; -i @c fs@d\fR. The incremental source snapshot may be specified as with the \fB-i\fR option. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-R\fR\fR +.ad +.sp .6 +.RS 4n +Generate a replication stream package, which will replicate the specified filesystem, and all descendent file systems, up to the named snapshot. When received, all properties, snapshots, descendent file systems, and clones are preserved. +.sp +If the \fB-i\fR or \fB-I\fR flags are used in conjunction with the \fB-R\fR flag, an incremental replication stream is generated. The current values of properties, and current snapshot and file system names are set when the stream is received. If the \fB-F\fR flag is specified when this stream is received, snapshots and file systems that do not exist on the sending side are destroyed. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-v\fR\fR +.ad +.sp .6 +.RS 4n +Print verbose information about the stream package generated. +.RE + +The format of the stream is committed. You will be able to receive your streams on future versions of \fBZFS\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs receive\fR [\fB-vnFu\fR] \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR\fR +.ad +.br +.na +\fB\fBzfs receive\fR [\fB-vnFu\fR] \fB-d\fR \fIfilesystem\fR\fR +.ad +.sp .6 +.RS 4n +Creates a snapshot whose contents are as specified in the stream provided on standard input. If a full stream is received, then a new file system is created as well. Streams are created using the \fBzfs send\fR subcommand, which by default creates a full stream. \fBzfs recv\fR can be used as an alias for \fBzfs receive\fR. +.sp +If an incremental stream is received, then the destination file system must already exist, and its most recent snapshot must match the incremental stream's source. For \fBzvols\fR, the destination device link is destroyed and recreated, which means the \fBzvol\fR cannot be accessed during the \fBreceive\fR operation. +.sp +When a snapshot replication package stream that is generated by using the \fBzfs send\fR \fB-R\fR command is received, any snapshots that do not exist on the sending location are destroyed by using the \fBzfs destroy\fR \fB-d\fR command. +.sp +The name of the snapshot (and file system, if a full stream is received) that this subcommand creates depends on the argument type and the \fB-d\fR option. +.sp +If the argument is a snapshot name, the specified \fIsnapshot\fR is created. If the argument is a file system or volume name, a snapshot with the same name as the sent snapshot is created within the specified \fIfilesystem\fR or \fIvolume\fR. If the \fB-d\fR option is specified, the snapshot name is determined by appending the sent snapshot's name to the specified \fIfilesystem\fR. If the \fB-d\fR option is specified, any required file systems within the specified one are created. +.sp +.ne 2 +.mk +.na +\fB\fB-d\fR\fR +.ad +.sp .6 +.RS 4n +Use the name of the sent snapshot to determine the name of the new snapshot as described in the paragraph above. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-u\fR\fR +.ad +.sp .6 +.RS 4n +File system that is associated with the received stream is not mounted. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-v\fR\fR +.ad +.sp .6 +.RS 4n +Print verbose information about the stream and the time required to perform the receive operation. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-n\fR\fR +.ad +.sp .6 +.RS 4n +Do not actually receive the stream. This can be useful in conjunction with the \fB-v\fR option to verify the name the receive operation would use. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-F\fR\fR +.ad +.sp .6 +.RS 4n +Force a rollback of the file system to the most recent snapshot before performing the receive operation. If receiving an incremental replication stream (for example, one generated by \fBzfs send -R -[iI]\fR), destroy snapshots and file systems that do not exist on the sending side. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs allow\fR \fIfilesystem\fR | \fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Displays permissions that have been delegated on the specified filesystem or volume. See the other forms of \fBzfs allow\fR for more information. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs allow\fR [\fB-ldug\fR] "\fIeveryone\fR"|\fIuser\fR|\fIgroup\fR[,...] \fIperm\fR|@\fIsetname\fR[,...] \fIfilesystem\fR| \fIvolume\fR\fR +.ad +.br +.na +\fB\fBzfs allow\fR [\fB-ld\fR] \fB-e\fR \fIperm\fR|@\fIsetname\fR[,...] \fIfilesystem\fR | \fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Delegates \fBZFS\fR administration permission for the file systems to non-privileged users. +.sp +.ne 2 +.mk +.na +\fB[\fB-ug\fR] "\fIeveryone\fR"|\fIuser\fR|\fIgroup\fR[,...]\fR +.ad +.sp .6 +.RS 4n +Specifies to whom the permissions are delegated. Multiple entities can be specified as a comma-separated list. If neither of the \fB-ug\fR options are specified, then the argument is interpreted preferentially as the keyword "everyone", then as a user name, and lastly as a group name. To specify a user or group named "everyone", use the \fB-u\fR or \fB-g\fR options. To specify a group with the same name as a user, use the \fB-g\fR options. +.RE + +.sp +.ne 2 +.mk +.na +\fB[\fB-e\fR] \fIperm\fR|@\fIsetname\fR[,...]\fR +.ad +.sp .6 +.RS 4n +Specifies that the permissions be delegated to "everyone." Multiple permissions may be specified as a comma-separated list. Permission names are the same as \fBZFS\fR subcommand and property names. See the property list below. Property set names, which begin with an at sign (\fB@\fR) , may be specified. See the \fB-s\fR form below for details. +.RE + +.sp +.ne 2 +.mk +.na +\fB[\fB-ld\fR] \fIfilesystem\fR|\fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Specifies where the permissions are delegated. If neither of the \fB-ld\fR options are specified, or both are, then the permissions are allowed for the file system or volume, and all of its descendents. If only the \fB-l\fR option is used, then is allowed "locally" only for the specified file system. If only the \fB-d\fR option is used, then is allowed only for the descendent file systems. +.RE + +.RE + +.sp +.LP +Permissions are generally the ability to use a \fBZFS\fR subcommand or change a \fBZFS\fR property. The following permissions are available: +.sp +.in +2 +.nf +NAME TYPE NOTES +allow subcommand Must also have the permission that is being + allowed +clone subcommand Must also have the 'create' ability and 'mount' + ability in the origin file system +create subcommand Must also have the 'mount' ability +destroy subcommand Must also have the 'mount' ability +mount subcommand Allows mount/umount of ZFS datasets +promote subcommand Must also have the 'mount' + and 'promote' ability in the origin file system +receive subcommand Must also have the 'mount' and 'create' ability +rename subcommand Must also have the 'mount' and 'create' + ability in the new parent +rollback subcommand Must also have the 'mount' ability +send subcommand +share subcommand Allows sharing file systems over NFS or SMB + protocols +snapshot subcommand Must also have the 'mount' ability +groupquota other Allows accessing any groupquota@... property +groupused other Allows reading any groupused@... property +userprop other Allows changing any user property +userquota other Allows accessing any userquota@... property +userused other Allows reading any userused@... property + +aclinherit property +aclmode property +atime property +canmount property +casesensitivity property +checksum property +compression property +copies property +devices property +exec property +mountpoint property +nbmand property +normalization property +primarycache property +quota property +readonly property +recordsize property +refquota property +refreservation property +reservation property +secondarycache property +setuid property +shareiscsi property +sharenfs property +sharesmb property +snapdir property +utf8only property +version property +volblocksize property +volsize property +vscan property +xattr property +zoned property +.fi +.in -2 +.sp + +.sp +.ne 2 +.mk +.na +\fB\fBzfs allow\fR \fB-c\fR \fIperm\fR|@\fIsetname\fR[,...] \fIfilesystem\fR|\fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Sets "create time" permissions. These permissions are granted (locally) to the creator of any newly-created descendent file system. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs allow\fR \fB-s\fR @\fIsetname\fR \fIperm\fR|@\fIsetname\fR[,...] \fIfilesystem\fR|\fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Defines or adds permissions to a permission set. The set can be used by other \fBzfs allow\fR commands for the specified file system and its descendents. Sets are evaluated dynamically, so changes to a set are immediately reflected. Permission sets follow the same naming restrictions as ZFS file systems, but the name must begin with an "at sign" (\fB@\fR), and can be no more than 64 characters long. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs unallow\fR [\fB-rldug\fR] "\fIeveryone\fR"|\fIuser\fR|\fIgroup\fR[,...] [\fIperm\fR|@\fIsetname\fR[, ...]] \fIfilesystem\fR|\fIvolume\fR\fR +.ad +.br +.na +\fB\fBzfs unallow\fR [\fB-rld\fR] \fB-e\fR [\fIperm\fR|@\fIsetname\fR [,...]] \fIfilesystem\fR|\fIvolume\fR\fR +.ad +.br +.na +\fB\fBzfs unallow\fR [\fB-r\fR] \fB-c\fR [\fIperm\fR|@\fIsetname\fR[,...]]\fR +.ad +.br +.na +\fB\fIfilesystem\fR|\fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Removes permissions that were granted with the \fBzfs allow\fR command. No permissions are explicitly denied, so other permissions granted are still in effect. For example, if the permission is granted by an ancestor. If no permissions are specified, then all permissions for the specified \fIuser\fR, \fIgroup\fR, or \fIeveryone\fR are removed. Specifying "everyone" (or using the \fB-e\fR option) only removes the permissions that were granted to "everyone", not all permissions for every user and group. See the \fBzfs allow\fR command for a description of the \fB-ldugec\fR options. +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Recursively remove the permissions from this file system and all descendents. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs unallow\fR [\fB-r\fR] \fB-s\fR @\fIsetname\fR [\fIperm\fR|@\fIsetname\fR[,...]]\fR +.ad +.br +.na +\fB\fIfilesystem\fR|\fIvolume\fR\fR +.ad +.sp .6 +.RS 4n +Removes permissions from a permission set. If no permissions are specified, then all permissions are removed, thus removing the set entirely. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs hold\fR [\fB-r\fR] \fItag\fR \fIsnapshot\fR...\fR +.ad +.sp .6 +.RS 4n +Adds a single reference, named with the \fItag\fR argument, to the specified snapshot or snapshots. Each snapshot has its own tag namespace, and tags must be unique within that space. +.sp +If a hold exists on a snapshot, attempts to destroy that snapshot by using the \fBzfs destroy\fR command return \fBEBUSY\fR. +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Specifies that a hold with the given tag is applied recursively to the snapshots of all descendent file systems. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs holds\fR [\fB-r\fR] \fIsnapshot\fR...\fR +.ad +.sp .6 +.RS 4n +Lists all existing user references for the given snapshot or snapshots. +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Lists the holds that are set on the named descendent snapshots, in addition to listing the holds on the named snapshot. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzfs release\fR [\fB-r\fR] \fItag\fR \fIsnapshot\fR...\fR +.ad +.sp .6 +.RS 4n +Removes a single reference, named with the \fItag\fR argument, from the specified snapshot or snapshots. The tag must already exist for each snapshot. +.sp +If a hold exists on a snapshot, attempts to destroy that snapshot by using the \fBzfs destroy\fR command return \fBEBUSY\fR. +.sp +.ne 2 +.mk +.na +\fB\fB-r\fR\fR +.ad +.sp .6 +.RS 4n +Recursively releases a hold with the given tag on the snapshots of all descendent file systems. +.RE + +.RE + +.SH EXAMPLES +.LP +\fBExample 1 \fRCreating a ZFS File System Hierarchy +.sp +.LP +The following commands create a file system named \fBpool/home\fR and a file system named \fBpool/home/bob\fR. The mount point \fB/export/home\fR is set for the parent file system, and is automatically inherited by the child file system. + +.sp +.in +2 +.nf +# \fBzfs create pool/home\fR +# \fBzfs set mountpoint=/export/home pool/home\fR +# \fBzfs create pool/home/bob\fR +.fi +.in -2 +.sp + +.LP +\fBExample 2 \fRCreating a ZFS Snapshot +.sp +.LP +The following command creates a snapshot named \fByesterday\fR. This snapshot is mounted on demand in the \fB\&.zfs/snapshot\fR directory at the root of the \fBpool/home/bob\fR file system. + +.sp +.in +2 +.nf +# \fBzfs snapshot pool/home/bob@yesterday\fR +.fi +.in -2 +.sp + +.LP +\fBExample 3 \fRCreating and Destroying Multiple Snapshots +.sp +.LP +The following command creates snapshots named \fByesterday\fR of \fBpool/home\fR and all of its descendent file systems. Each snapshot is mounted on demand in the \fB\&.zfs/snapshot\fR directory at the root of its file system. The second command destroys the newly created snapshots. + +.sp +.in +2 +.nf +# \fBzfs snapshot -r pool/home@yesterday\fR +# \fBzfs destroy -r pool/home@yesterday\fR +.fi +.in -2 +.sp + +.LP +\fBExample 4 \fRDisabling and Enabling File System Compression +.sp +.LP +The following command disables the \fBcompression\fR property for all file systems under \fBpool/home\fR. The next command explicitly enables \fBcompression\fR for \fBpool/home/anne\fR. + +.sp +.in +2 +.nf +# \fBzfs set compression=off pool/home\fR +# \fBzfs set compression=on pool/home/anne\fR +.fi +.in -2 +.sp + +.LP +\fBExample 5 \fRListing ZFS Datasets +.sp +.LP +The following command lists all active file systems and volumes in the system. Snapshots are displayed if the \fBlistsnaps\fR property is \fBon\fR. The default is \fBoff\fR. See \fBzpool\fR(1M) for more information on pool properties. + +.sp +.in +2 +.nf +# \fBzfs list\fR + NAME USED AVAIL REFER MOUNTPOINT + pool 450K 457G 18K /pool + pool/home 315K 457G 21K /export/home + pool/home/anne 18K 457G 18K /export/home/anne + pool/home/bob 276K 457G 276K /export/home/bob +.fi +.in -2 +.sp + +.LP +\fBExample 6 \fRSetting a Quota on a ZFS File System +.sp +.LP +The following command sets a quota of 50 Gbytes for \fBpool/home/bob\fR. + +.sp +.in +2 +.nf +# \fBzfs set quota=50G pool/home/bob\fR +.fi +.in -2 +.sp + +.LP +\fBExample 7 \fRListing ZFS Properties +.sp +.LP +The following command lists all properties for \fBpool/home/bob\fR. + +.sp +.in +2 +.nf +# \fBzfs get all pool/home/bob\fR +NAME PROPERTY VALUE SOURCE +pool/home/bob type filesystem - +pool/home/bob creation Tue Jul 21 15:53 2009 - +pool/home/bob used 21K - +pool/home/bob available 20.0G - +pool/home/bob referenced 21K - +pool/home/bob compressratio 1.00x - +pool/home/bob mounted yes - +pool/home/bob quota 20G local +pool/home/bob reservation none default +pool/home/bob recordsize 128K default +pool/home/bob mountpoint /pool/home/bob default +pool/home/bob sharenfs off default +pool/home/bob checksum on default +pool/home/bob compression on local +pool/home/bob atime on default +pool/home/bob devices on default +pool/home/bob exec on default +pool/home/bob setuid on default +pool/home/bob readonly off default +pool/home/bob zoned off default +pool/home/bob snapdir hidden default +pool/home/bob aclmode groupmask default +pool/home/bob aclinherit restricted default +pool/home/bob canmount on default +pool/home/bob shareiscsi off default +pool/home/bob xattr on default +pool/home/bob copies 1 default +pool/home/bob version 4 - +pool/home/bob utf8only off - +pool/home/bob normalization none - +pool/home/bob casesensitivity sensitive - +pool/home/bob vscan off default +pool/home/bob nbmand off default +pool/home/bob sharesmb off default +pool/home/bob refquota none default +pool/home/bob refreservation none default +pool/home/bob primarycache all default +pool/home/bob secondarycache all default +pool/home/bob usedbysnapshots 0 - +pool/home/bob usedbydataset 21K - +pool/home/bob usedbychildren 0 - +pool/home/bob usedbyrefreservation 0 - +.fi +.in -2 +.sp + +.sp +.LP +The following command gets a single property value. + +.sp +.in +2 +.nf +# \fBzfs get -H -o value compression pool/home/bob\fR +on +.fi +.in -2 +.sp + +.sp +.LP +The following command lists all properties with local settings for \fBpool/home/bob\fR. + +.sp +.in +2 +.nf +# \fBzfs get -r -s local -o name,property,value all pool/home/bob\fR +NAME PROPERTY VALUE +pool/home/bob quota 20G +pool/home/bob compression on +.fi +.in -2 +.sp + +.LP +\fBExample 8 \fRRolling Back a ZFS File System +.sp +.LP +The following command reverts the contents of \fBpool/home/anne\fR to the snapshot named \fByesterday\fR, deleting all intermediate snapshots. + +.sp +.in +2 +.nf +# \fBzfs rollback -r pool/home/anne@yesterday\fR +.fi +.in -2 +.sp + +.LP +\fBExample 9 \fRCreating a ZFS Clone +.sp +.LP +The following command creates a writable file system whose initial contents are the same as \fBpool/home/bob@yesterday\fR. + +.sp +.in +2 +.nf +# \fBzfs clone pool/home/bob@yesterday pool/clone\fR +.fi +.in -2 +.sp + +.LP +\fBExample 10 \fRPromoting a ZFS Clone +.sp +.LP +The following commands illustrate how to test out changes to a file system, and then replace the original file system with the changed one, using clones, clone promotion, and renaming: + +.sp +.in +2 +.nf +# \fBzfs create pool/project/production\fR + populate /pool/project/production with data +# \fBzfs snapshot pool/project/production@today\fR +# \fBzfs clone pool/project/production@today pool/project/beta\fR +make changes to /pool/project/beta and test them +# \fBzfs promote pool/project/beta\fR +# \fBzfs rename pool/project/production pool/project/legacy\fR +# \fBzfs rename pool/project/beta pool/project/production\fR +once the legacy version is no longer needed, it can be destroyed +# \fBzfs destroy pool/project/legacy\fR +.fi +.in -2 +.sp + +.LP +\fBExample 11 \fRInheriting ZFS Properties +.sp +.LP +The following command causes \fBpool/home/bob\fR and \fBpool/home/anne\fR to inherit the \fBchecksum\fR property from their parent. + +.sp +.in +2 +.nf +# \fBzfs inherit checksum pool/home/bob pool/home/anne\fR +.fi +.in -2 +.sp + +.LP +\fBExample 12 \fRRemotely Replicating ZFS Data +.sp +.LP +The following commands send a full stream and then an incremental stream to a remote machine, restoring them into \fBpoolB/received/fs@a\fRand \fBpoolB/received/fs@b\fR, respectively. \fBpoolB\fR must contain the file system \fBpoolB/received\fR, and must not initially contain \fBpoolB/received/fs\fR. + +.sp +.in +2 +.nf +# \fBzfs send pool/fs@a | \e\fR + \fBssh host zfs receive poolB/received/fs@a\fR +# \fBzfs send -i a pool/fs@b | ssh host \e\fR + \fBzfs receive poolB/received/fs\fR +.fi +.in -2 +.sp + +.LP +\fBExample 13 \fRUsing the \fBzfs receive\fR \fB-d\fR Option +.sp +.LP +The following command sends a full stream of \fBpoolA/fsA/fsB@snap\fR to a remote machine, receiving it into \fBpoolB/received/fsA/fsB@snap\fR. The \fBfsA/fsB@snap\fR portion of the received snapshot's name is determined from the name of the sent snapshot. \fBpoolB\fR must contain the file system \fBpoolB/received\fR. If \fBpoolB/received/fsA\fR does not exist, it is created as an empty file system. + +.sp +.in +2 +.nf +# \fBzfs send poolA/fsA/fsB@snap | \e + ssh host zfs receive -d poolB/received\fR +.fi +.in -2 +.sp + +.LP +\fBExample 14 \fRSetting User Properties +.sp +.LP +The following example sets the user-defined \fBcom.example:department\fR property for a dataset. + +.sp +.in +2 +.nf +# \fBzfs set com.example:department=12345 tank/accounting\fR +.fi +.in -2 +.sp + +.LP +\fBExample 15 \fRCreating a ZFS Volume as an iSCSI Target Device +.sp +.LP +The following example shows how to create a \fBZFS\fR volume as an \fBiSCSI\fR target. + +.sp +.in +2 +.nf +# \fBzfs create -V 2g pool/volumes/vol1\fR +# \fBzfs set shareiscsi=on pool/volumes/vol1\fR +# \fBiscsitadm list target\fR +Target: pool/volumes/vol1 + iSCSI Name: + iqn.1986-03.com.sun:02:7b4b02a6-3277-eb1b-e686-a24762c52a8c + Connections: 0 +.fi +.in -2 +.sp + +.sp +.LP +After the \fBiSCSI\fR target is created, set up the \fBiSCSI\fR initiator. For more information about the Solaris \fBiSCSI\fR initiator, see \fBiscsitadm\fR(1M). +.LP +\fBExample 16 \fRPerforming a Rolling Snapshot +.sp +.LP +The following example shows how to maintain a history of snapshots with a consistent naming scheme. To keep a week's worth of snapshots, the user destroys the oldest snapshot, renames the remaining snapshots, and then creates a new snapshot, as follows: + +.sp +.in +2 +.nf +# \fBzfs destroy -r pool/users@7daysago\fR +# \fBzfs rename -r pool/users@6daysago @7daysago\fR +# \fBzfs rename -r pool/users@5daysago @6daysago\fR +# \fBzfs rename -r pool/users@yesterday @5daysago\fR +# \fBzfs rename -r pool/users@yesterday @4daysago\fR +# \fBzfs rename -r pool/users@yesterday @3daysago\fR +# \fBzfs rename -r pool/users@yesterday @2daysago\fR +# \fBzfs rename -r pool/users@today @yesterday\fR +# \fBzfs snapshot -r pool/users@today\fR +.fi +.in -2 +.sp + +.LP +\fBExample 17 \fRSetting \fBsharenfs\fR Property Options on a ZFS File System +.sp +.LP +The following commands show how to set \fBsharenfs\fR property options to enable \fBrw\fR access for a set of \fBIP\fR addresses and to enable root access for system \fBneo\fR on the \fBtank/home\fR file system. + +.sp +.in +2 +.nf +# \fB# zfs set sharenfs='rw=@123.123.0.0/16,root=neo' tank/home\fR +.fi +.in -2 +.sp + +.sp +.LP +If you are using \fBDNS\fR for host name resolution, specify the fully qualified hostname. + +.LP +\fBExample 18 \fRDelegating ZFS Administration Permissions on a ZFS Dataset +.sp +.LP +The following example shows how to set permissions so that user \fBcindys\fR can create, destroy, mount, and take snapshots on \fBtank/cindys\fR. The permissions on \fBtank/cindys\fR are also displayed. + +.sp +.in +2 +.nf +# \fBzfs allow cindys create,destroy,mount,snapshot tank/cindys\fR +# \fBzfs allow tank/cindys\fR +------------------------------------------------------------- +Local+Descendent permissions on (tank/cindys) + user cindys create,destroy,mount,snapshot +------------------------------------------------------------- +.fi +.in -2 +.sp + +.sp +.LP +Because the \fBtank/cindys\fR mount point permission is set to 755 by default, user \fBcindys\fR will be unable to mount file systems under \fBtank/cindys\fR. Set an \fBACL\fR similar to the following syntax to provide mount point access: +.sp +.in +2 +.nf +# \fBchmod A+user:cindys:add_subdirectory:allow /tank/cindys\fR +.fi +.in -2 +.sp + +.LP +\fBExample 19 \fRDelegating Create Time Permissions on a ZFS Dataset +.sp +.LP +The following example shows how to grant anyone in the group \fBstaff\fR to create file systems in \fBtank/users\fR. This syntax also allows staff members to destroy their own file systems, but not destroy anyone else's file system. The permissions on \fBtank/users\fR are also displayed. + +.sp +.in +2 +.nf +# \fB# zfs allow staff create,mount tank/users\fR +# \fBzfs allow -c destroy tank/users\fR +# \fBzfs allow tank/users\fR +------------------------------------------------------------- +Create time permissions on (tank/users) + create,destroy +Local+Descendent permissions on (tank/users) + group staff create,mount +------------------------------------------------------------- +.fi +.in -2 +.sp + +.LP +\fBExample 20 \fRDefining and Granting a Permission Set on a ZFS Dataset +.sp +.LP +The following example shows how to define and grant a permission set on the \fBtank/users\fR file system. The permissions on \fBtank/users\fR are also displayed. + +.sp +.in +2 +.nf +# \fBzfs allow -s @pset create,destroy,snapshot,mount tank/users\fR +# \fBzfs allow staff @pset tank/users\fR +# \fBzfs allow tank/users\fR +------------------------------------------------------------- +Permission sets on (tank/users) + @pset create,destroy,mount,snapshot +Create time permissions on (tank/users) + create,destroy +Local+Descendent permissions on (tank/users) + group staff @pset,create,mount +------------------------------------------------------------- +.fi +.in -2 +.sp + +.LP +\fBExample 21 \fRDelegating Property Permissions on a ZFS Dataset +.sp +.LP +The following example shows to grant the ability to set quotas and reservations on the \fBusers/home\fR file system. The permissions on \fBusers/home\fR are also displayed. + +.sp +.in +2 +.nf +# \fBzfs allow cindys quota,reservation users/home\fR +# \fBzfs allow users/home\fR +------------------------------------------------------------- +Local+Descendent permissions on (users/home) + user cindys quota,reservation +------------------------------------------------------------- +cindys% \fBzfs set quota=10G users/home/marks\fR +cindys% \fBzfs get quota users/home/marks\fR +NAME PROPERTY VALUE SOURCE +users/home/marks quota 10G local +.fi +.in -2 +.sp + +.LP +\fBExample 22 \fRRemoving ZFS Delegated Permissions on a ZFS Dataset +.sp +.LP +The following example shows how to remove the snapshot permission from the \fBstaff\fR group on the \fBtank/users\fR file system. The permissions on \fBtank/users\fR are also displayed. + +.sp +.in +2 +.nf +# \fBzfs unallow staff snapshot tank/users\fR +# \fBzfs allow tank/users\fR +------------------------------------------------------------- +Permission sets on (tank/users) + @pset create,destroy,mount,snapshot +Create time permissions on (tank/users) + create,destroy +Local+Descendent permissions on (tank/users) + group staff @pset,create,mount +------------------------------------------------------------- +.fi +.in -2 +.sp + +.SH EXIT STATUS +.sp +.LP +The following exit values are returned: +.sp +.ne 2 +.mk +.na +\fB\fB0\fR\fR +.ad +.sp .6 +.RS 4n +Successful completion. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB1\fR\fR +.ad +.sp .6 +.RS 4n +An error occurred. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB2\fR\fR +.ad +.sp .6 +.RS 4n +Invalid command line options were specified. +.RE + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +AvailabilitySUNWzfsu +_ +Interface StabilityCommitted +.TE + +.SH SEE ALSO +.sp +.LP +\fBssh\fR(1), \fBiscsitadm\fR(1M), \fBmount\fR(1M), \fBshare\fR(1M), \fBsharemgr\fR(1M), \fBunshare\fR(1M), \fBzonecfg\fR(1M), \fBzpool\fR(1M), \fBchmod\fR(2), \fBstat\fR(2), \fBwrite\fR(2), \fBfsync\fR(3C), \fBdfstab\fR(4), \fBattributes\fR(5) +.sp +.LP +See the \fBgzip\fR(1) man page, which is not part of the SunOS man page collection. +.sp +.LP +For information about using the \fBZFS\fR web-based management tool and other \fBZFS\fR features, see the \fISolaris ZFS Administration Guide\fR. diff --git a/man/man8/zpool.8 b/man/man8/zpool.8 new file mode 100644 index 0000000000..ff71dff16c --- /dev/null +++ b/man/man8/zpool.8 @@ -0,0 +1,1799 @@ +'\" te +.\" Copyright (c) 2007, 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 zpool 1M "21 Sep 2009" "SunOS 5.11" "System Administration Commands" +.SH NAME +zpool \- configures ZFS storage pools +.SH SYNOPSIS +.LP +.nf +\fBzpool\fR [\fB-?\fR] +.fi + +.LP +.nf +\fBzpool add\fR [\fB-fn\fR] \fIpool\fR \fIvdev\fR ... +.fi + +.LP +.nf +\fBzpool attach\fR [\fB-f\fR] \fIpool\fR \fIdevice\fR \fInew_device\fR +.fi + +.LP +.nf +\fBzpool clear\fR \fIpool\fR [\fIdevice\fR] +.fi + +.LP +.nf +\fBzpool create\fR [\fB-fn\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-O\fR \fIfile-system-property=value\fR] + ... [\fB-m\fR \fImountpoint\fR] [\fB-R\fR \fIroot\fR] \fIpool\fR \fIvdev\fR ... +.fi + +.LP +.nf +\fBzpool destroy\fR [\fB-f\fR] \fIpool\fR +.fi + +.LP +.nf +\fBzpool detach\fR \fIpool\fR \fIdevice\fR +.fi + +.LP +.nf +\fBzpool export\fR [\fB-f\fR] \fIpool\fR ... +.fi + +.LP +.nf +\fBzpool get\fR "\fIall\fR" | \fIproperty\fR[,...] \fIpool\fR ... +.fi + +.LP +.nf +\fBzpool history\fR [\fB-il\fR] [\fIpool\fR] ... +.fi + +.LP +.nf +\fBzpool import\fR [\fB-d\fR \fIdir\fR] [\fB-D\fR] +.fi + +.LP +.nf +\fBzpool import\fR [\fB-o \fImntopts\fR\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-d\fR \fIdir\fR | \fB-c\fR \fIcachefile\fR] + [\fB-D\fR] [\fB-f\fR] [\fB-R\fR \fIroot\fR] \fB-a\fR +.fi + +.LP +.nf +\fBzpool import\fR [\fB-o \fImntopts\fR\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-d\fR \fIdir\fR | \fB-c\fR \fIcachefile\fR] + [\fB-D\fR] [\fB-f\fR] [\fB-R\fR \fIroot\fR] \fIpool\fR |\fIid\fR [\fInewpool\fR] +.fi + +.LP +.nf +\fBzpool iostat\fR [\fB-T\fR u | d ] [\fB-v\fR] [\fIpool\fR] ... [\fIinterval\fR[\fIcount\fR]] +.fi + +.LP +.nf +\fBzpool list\fR [\fB-H\fR] [\fB-o\fR \fIproperty\fR[,...]] [\fIpool\fR] ... +.fi + +.LP +.nf +\fBzpool offline\fR [\fB-t\fR] \fIpool\fR \fIdevice\fR ... +.fi + +.LP +.nf +\fBzpool online\fR \fIpool\fR \fIdevice\fR ... +.fi + +.LP +.nf +\fBzpool remove\fR \fIpool\fR \fIdevice\fR ... +.fi + +.LP +.nf +\fBzpool replace\fR [\fB-f\fR] \fIpool\fR \fIdevice\fR [\fInew_device\fR] +.fi + +.LP +.nf +\fBzpool scrub\fR [\fB-s\fR] \fIpool\fR ... +.fi + +.LP +.nf +\fBzpool set\fR \fIproperty\fR=\fIvalue\fR \fIpool\fR +.fi + +.LP +.nf +\fBzpool status\fR [\fB-xv\fR] [\fIpool\fR] ... +.fi + +.LP +.nf +\fBzpool upgrade\fR +.fi + +.LP +.nf +\fBzpool upgrade\fR \fB-v\fR +.fi + +.LP +.nf +\fBzpool upgrade\fR [\fB-V\fR \fIversion\fR] \fB-a\fR | \fIpool\fR ... +.fi + +.SH DESCRIPTION +.sp +.LP +The \fBzpool\fR command configures \fBZFS\fR storage pools. A storage pool is a collection of devices that provides physical storage and data replication for \fBZFS\fR datasets. +.sp +.LP +All datasets within a storage pool share the same space. See \fBzfs\fR(1M) for information on managing datasets. +.SS "Virtual Devices (\fBvdev\fRs)" +.sp +.LP +A "virtual device" describes a single device or a collection of devices organized according to certain performance and fault characteristics. The following virtual devices are supported: +.sp +.ne 2 +.mk +.na +\fB\fBdisk\fR\fR +.ad +.RS 10n +.rt +A block device, typically located under \fB/dev/dsk\fR. \fBZFS\fR can use individual slices or partitions, though the recommended mode of operation is to use whole disks. A disk can be specified by a full path, or it can be a shorthand name (the relative portion of the path under "/dev/dsk"). A whole disk can be specified by omitting the slice or partition designation. For example, "c0t0d0" is equivalent to "/dev/dsk/c0t0d0s2". When given a whole disk, \fBZFS\fR automatically labels the disk, if necessary. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBfile\fR\fR +.ad +.RS 10n +.rt +A regular file. The use of files as a backing store is strongly discouraged. It is designed primarily for experimental purposes, as the fault tolerance of a file is only as good as the file system of which it is a part. A file must be specified by a full path. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBmirror\fR\fR +.ad +.RS 10n +.rt +A mirror of two or more devices. Data is replicated in an identical fashion across all components of a mirror. A mirror with \fIN\fR disks of size \fIX\fR can hold \fIX\fR bytes and can withstand (\fIN-1\fR) devices failing before data integrity is compromised. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBraidz\fR\fR +.ad +.br +.na +\fB\fBraidz1\fR\fR +.ad +.br +.na +\fB\fBraidz2\fR\fR +.ad +.br +.na +\fB\fBraidz3\fR\fR +.ad +.RS 10n +.rt +A variation on \fBRAID-5\fR that allows for better distribution of parity and eliminates the "\fBRAID-5\fR write hole" (in which data and parity become inconsistent after a power loss). Data and parity is striped across all disks within a \fBraidz\fR group. +.sp +A \fBraidz\fR group can have single-, double- , or triple parity, meaning that the \fBraidz\fR group can sustain one, two, or three failures, respectively, without losing any data. The \fBraidz1\fR \fBvdev\fR type specifies a single-parity \fBraidz\fR group; the \fBraidz2\fR \fBvdev\fR type specifies a double-parity \fBraidz\fR group; and the \fBraidz3\fR \fBvdev\fR type specifies a triple-parity \fBraidz\fR group. The \fBraidz\fR \fBvdev\fR type is an alias for \fBraidz1\fR. +.sp +A \fBraidz\fR group with \fIN\fR disks of size \fIX\fR with \fIP\fR parity disks can hold approximately (\fIN-P\fR)*\fIX\fR bytes and can withstand \fIP\fR device(s) failing before data integrity is compromised. The minimum number of devices in a \fBraidz\fR group is one more than the number of parity disks. The recommended number is between 3 and 9 to help increase performance. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBspare\fR\fR +.ad +.RS 10n +.rt +A special pseudo-\fBvdev\fR which keeps track of available hot spares for a pool. For more information, see the "Hot Spares" section. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBlog\fR\fR +.ad +.RS 10n +.rt +A separate-intent log device. If more than one log device is specified, then writes are load-balanced between devices. Log devices can be mirrored. However, \fBraidz\fR \fBvdev\fR types are not supported for the intent log. For more information, see the "Intent Log" section. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBcache\fR\fR +.ad +.RS 10n +.rt +A device used to cache storage pool data. A cache device cannot be cannot be configured as a mirror or \fBraidz\fR group. For more information, see the "Cache Devices" section. +.RE + +.sp +.LP +Virtual devices cannot be nested, so a mirror or \fBraidz\fR virtual device can only contain files or disks. Mirrors of mirrors (or other combinations) are not allowed. +.sp +.LP +A pool can have any number of virtual devices at the top of the configuration (known as "root vdevs"). Data is dynamically distributed across all top-level devices to balance data among devices. As new virtual devices are added, \fBZFS\fR automatically places data on the newly available devices. +.sp +.LP +Virtual devices are specified one at a time on the command line, separated by whitespace. The keywords "mirror" and "raidz" are used to distinguish where a group ends and another begins. For example, the following creates two root vdevs, each a mirror of two disks: +.sp +.in +2 +.nf +# \fBzpool create mypool mirror c0t0d0 c0t1d0 mirror c1t0d0 c1t1d0\fR +.fi +.in -2 +.sp + +.SS "Device Failure and Recovery" +.sp +.LP +\fBZFS\fR supports a rich set of mechanisms for handling device failure and data corruption. All metadata and data is checksummed, and \fBZFS\fR automatically repairs bad data from a good copy when corruption is detected. +.sp +.LP +In order to take advantage of these features, a pool must make use of some form of redundancy, using either mirrored or \fBraidz\fR groups. While \fBZFS\fR supports running in a non-redundant configuration, where each root vdev is simply a disk or file, this is strongly discouraged. A single case of bit corruption can render some or all of your data unavailable. +.sp +.LP +A pool's health status is described by one of three states: online, degraded, or faulted. An online pool has all devices operating normally. A degraded pool is one in which one or more devices have failed, but the data is still available due to a redundant configuration. A faulted pool has corrupted metadata, or one or more faulted devices, and insufficient replicas to continue functioning. +.sp +.LP +The health of the top-level vdev, such as mirror or \fBraidz\fR device, is potentially impacted by the state of its associated vdevs, or component devices. A top-level vdev or component device is in one of the following states: +.sp +.ne 2 +.mk +.na +\fB\fBDEGRADED\fR\fR +.ad +.RS 12n +.rt +One or more top-level vdevs is in the degraded state because one or more component devices are offline. Sufficient replicas exist to continue functioning. +.sp +One or more component devices is in the degraded or faulted state, but sufficient replicas exist to continue functioning. The underlying conditions are as follows: +.RS +4 +.TP +.ie t \(bu +.el o +The number of checksum errors exceeds acceptable levels and the device is degraded as an indication that something may be wrong. \fBZFS\fR continues to use the device as necessary. +.RE +.RS +4 +.TP +.ie t \(bu +.el o +The number of I/O errors exceeds acceptable levels. The device could not be marked as faulted because there are insufficient replicas to continue functioning. +.RE +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBFAULTED\fR\fR +.ad +.RS 12n +.rt +One or more top-level vdevs is in the faulted state because one or more component devices are offline. Insufficient replicas exist to continue functioning. +.sp +One or more component devices is in the faulted state, and insufficient replicas exist to continue functioning. The underlying conditions are as follows: +.RS +4 +.TP +.ie t \(bu +.el o +The device could be opened, but the contents did not match expected values. +.RE +.RS +4 +.TP +.ie t \(bu +.el o +The number of I/O errors exceeds acceptable levels and the device is faulted to prevent further use of the device. +.RE +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBOFFLINE\fR\fR +.ad +.RS 12n +.rt +The device was explicitly taken offline by the "\fBzpool offline\fR" command. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBONLINE\fR\fR +.ad +.RS 12n +.rt +The device is online and functioning. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBREMOVED\fR\fR +.ad +.RS 12n +.rt +The device was physically removed while the system was running. Device removal detection is hardware-dependent and may not be supported on all platforms. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBUNAVAIL\fR\fR +.ad +.RS 12n +.rt +The device could not be opened. If a pool is imported when a device was unavailable, then the device will be identified by a unique identifier instead of its path since the path was never correct in the first place. +.RE + +.sp +.LP +If a device is removed and later re-attached to the system, \fBZFS\fR attempts to put the device online automatically. Device attach detection is hardware-dependent and might not be supported on all platforms. +.SS "Hot Spares" +.sp +.LP +\fBZFS\fR allows devices to be associated with pools as "hot spares". These devices are not actively used in the pool, but when an active device fails, it is automatically replaced by a hot spare. To create a pool with hot spares, specify a "spare" \fBvdev\fR with any number of devices. For example, +.sp +.in +2 +.nf +# zpool create pool mirror c0d0 c1d0 spare c2d0 c3d0 +.fi +.in -2 +.sp + +.sp +.LP +Spares can be shared across multiple pools, and can be added with the "\fBzpool add\fR" command and removed with the "\fBzpool remove\fR" command. Once a spare replacement is initiated, a new "spare" \fBvdev\fR is created within the configuration that will remain there until the original device is replaced. At this point, the hot spare becomes available again if another device fails. +.sp +.LP +If a pool has a shared spare that is currently being used, the pool can not be exported since other pools may use this shared spare, which may lead to potential data corruption. +.sp +.LP +An in-progress spare replacement can be cancelled by detaching the hot spare. If the original faulted device is detached, then the hot spare assumes its place in the configuration, and is removed from the spare list of all active pools. +.sp +.LP +Spares cannot replace log devices. +.SS "Intent Log" +.sp +.LP +The \fBZFS\fR Intent Log (\fBZIL\fR) satisfies \fBPOSIX\fR requirements for synchronous transactions. For instance, databases often require their transactions to be on stable storage devices when returning from a system call. \fBNFS\fR and other applications can also use \fBfsync\fR() to ensure data stability. By default, the intent log is allocated from blocks within the main pool. However, it might be possible to get better performance using separate intent log devices such as \fBNVRAM\fR or a dedicated disk. For example: +.sp +.in +2 +.nf +\fB# zpool create pool c0d0 c1d0 log c2d0\fR +.fi +.in -2 +.sp + +.sp +.LP +Multiple log devices can also be specified, and they can be mirrored. See the EXAMPLES section for an example of mirroring multiple log devices. +.sp +.LP +Log devices can be added, replaced, attached, detached, and imported and exported as part of the larger pool. Mirrored log devices can be removed by specifying the top-level mirror for the log. +.SS "Cache Devices" +.sp +.LP +Devices can be added to a storage pool as "cache devices." These devices provide an additional layer of caching between main memory and disk. For read-heavy workloads, where the working set size is much larger than what can be cached in main memory, using cache devices allow much more of this working set to be served from low latency media. Using cache devices provides the greatest performance improvement for random read-workloads of mostly static content. +.sp +.LP +To create a pool with cache devices, specify a "cache" \fBvdev\fR with any number of devices. For example: +.sp +.in +2 +.nf +\fB# zpool create pool c0d0 c1d0 cache c2d0 c3d0\fR +.fi +.in -2 +.sp + +.sp +.LP +Cache devices cannot be mirrored or part of a \fBraidz\fR configuration. If a read error is encountered on a cache device, that read \fBI/O\fR is reissued to the original storage pool device, which might be part of a mirrored or \fBraidz\fR configuration. +.sp +.LP +The content of the cache devices is considered volatile, as is the case with other system caches. +.SS "Properties" +.sp +.LP +Each pool has several properties associated with it. Some properties are read-only statistics while others are configurable and change the behavior of the pool. The following are read-only properties: +.sp +.ne 2 +.mk +.na +\fB\fBavailable\fR\fR +.ad +.RS 20n +.rt +Amount of storage available within the pool. This property can also be referred to by its shortened column name, "avail". +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBcapacity\fR\fR +.ad +.RS 20n +.rt +Percentage of pool space used. This property can also be referred to by its shortened column name, "cap". +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBhealth\fR\fR +.ad +.RS 20n +.rt +The current health of the pool. Health can be "\fBONLINE\fR", "\fBDEGRADED\fR", "\fBFAULTED\fR", " \fBOFFLINE\fR", "\fBREMOVED\fR", or "\fBUNAVAIL\fR". +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBguid\fR\fR +.ad +.RS 20n +.rt +A unique identifier for the pool. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBsize\fR\fR +.ad +.RS 20n +.rt +Total size of the storage pool. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBused\fR\fR +.ad +.RS 20n +.rt +Amount of storage space used within the pool. +.RE + +.sp +.LP +These space usage properties report actual physical space available to the storage pool. The physical space can be different from the total amount of space that any contained datasets can actually use. The amount of space used in a \fBraidz\fR configuration depends on the characteristics of the data being written. In addition, \fBZFS\fR reserves some space for internal accounting that the \fBzfs\fR(1M) command takes into account, but the \fBzpool\fR command does not. For non-full pools of a reasonable size, these effects should be invisible. For small pools, or pools that are close to being completely full, these discrepancies may become more noticeable. +.sp +.LP +The following property can be set at creation time and import time: +.sp +.ne 2 +.mk +.na +\fB\fBaltroot\fR\fR +.ad +.sp .6 +.RS 4n +Alternate root directory. If set, this directory is prepended to any mount points within the pool. This can be used when examining an unknown pool where the mount points cannot be trusted, or in an alternate boot environment, where the typical paths are not valid. \fBaltroot\fR is not a persistent property. It is valid only while the system is up. Setting \fBaltroot\fR defaults to using \fBcachefile\fR=none, though this may be overridden using an explicit setting. +.RE + +.sp +.LP +The following properties can be set at creation time and import time, and later changed with the \fBzpool set\fR command: +.sp +.ne 2 +.mk +.na +\fB\fBautoexpand\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls automatic pool expansion when the underlying LUN is grown. If set to \fBon\fR, the pool will be resized according to the size of the expanded device. If the device is part of a mirror or \fBraidz\fR then all devices within that mirror/\fBraidz\fR group must be expanded before the new space is made available to the pool. The default behavior is \fBoff\fR. This property can also be referred to by its shortened column name, \fBexpand\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBautoreplace\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls automatic device replacement. If set to "\fBoff\fR", device replacement must be initiated by the administrator by using the "\fBzpool replace\fR" command. If set to "\fBon\fR", any new device, found in the same physical location as a device that previously belonged to the pool, is automatically formatted and replaced. The default behavior is "\fBoff\fR". This property can also be referred to by its shortened column name, "replace". +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBbootfs\fR=\fIpool\fR/\fIdataset\fR\fR +.ad +.sp .6 +.RS 4n +Identifies the default bootable dataset for the root pool. This property is expected to be set mainly by the installation and upgrade programs. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBcachefile\fR=\fIpath\fR | \fBnone\fR\fR +.ad +.sp .6 +.RS 4n +Controls the location of where the pool configuration is cached. Discovering all pools on system startup requires a cached copy of the configuration data that is stored on the root file system. All pools in this cache are automatically imported when the system boots. Some environments, such as install and clustering, need to cache this information in a different location so that pools are not automatically imported. Setting this property caches the pool configuration in a different location that can later be imported with "\fBzpool import -c\fR". Setting it to the special value "\fBnone\fR" creates a temporary pool that is never cached, and the special value \fB\&''\fR (empty string) uses the default location. +.sp +Multiple pools can share the same cache file. Because the kernel destroys and recreates this file when pools are added and removed, care should be taken when attempting to access this file. When the last pool using a \fBcachefile\fR is exported or destroyed, the file is removed. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBdelegation\fR=\fBon\fR | \fBoff\fR\fR +.ad +.sp .6 +.RS 4n +Controls whether a non-privileged user is granted access based on the dataset permissions defined on the dataset. See \fBzfs\fR(1M) for more information on \fBZFS\fR delegated administration. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBfailmode\fR=\fBwait\fR | \fBcontinue\fR | \fBpanic\fR\fR +.ad +.sp .6 +.RS 4n +Controls the system behavior in the event of catastrophic pool failure. This condition is typically a result of a loss of connectivity to the underlying storage device(s) or a failure of all devices within the pool. The behavior of such an event is determined as follows: +.sp +.ne 2 +.mk +.na +\fB\fBwait\fR\fR +.ad +.RS 12n +.rt +Blocks all \fBI/O\fR access until the device connectivity is recovered and the errors are cleared. This is the default behavior. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBcontinue\fR\fR +.ad +.RS 12n +.rt +Returns \fBEIO\fR to any new write \fBI/O\fR requests but allows reads to any of the remaining healthy devices. Any write requests that have yet to be committed to disk would be blocked. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBpanic\fR\fR +.ad +.RS 12n +.rt +Prints out a message to the console and generates a system crash dump. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBlistsnaps\fR=on | off\fR +.ad +.sp .6 +.RS 4n +Controls whether information about snapshots associated with this pool is output when "\fBzfs list\fR" is run without the \fB-t\fR option. The default value is "off". +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBversion\fR=\fIversion\fR\fR +.ad +.sp .6 +.RS 4n +The current on-disk version of the pool. This can be increased, but never decreased. The preferred method of updating pools is with the "\fBzpool upgrade\fR" command, though this property can be used when a specific version is needed for backwards compatibility. This property can be any number between 1 and the current version reported by "\fBzpool upgrade -v\fR". +.RE + +.SS "Subcommands" +.sp +.LP +All subcommands that modify state are logged persistently to the pool in their original form. +.sp +.LP +The \fBzpool\fR command provides subcommands to create and destroy storage pools, add capacity to storage pools, and provide information about the storage pools. The following subcommands are supported: +.sp +.ne 2 +.mk +.na +\fB\fBzpool\fR \fB-?\fR\fR +.ad +.sp .6 +.RS 4n +Displays a help message. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool add\fR [\fB-fn\fR] \fIpool\fR \fIvdev\fR ...\fR +.ad +.sp .6 +.RS 4n +Adds the specified virtual devices to the given pool. The \fIvdev\fR specification is described in the "Virtual Devices" section. The behavior of the \fB-f\fR option, and the device checks performed are described in the "zpool create" subcommand. +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.RS 6n +.rt +Forces use of \fBvdev\fRs, even if they appear in use or specify a conflicting replication level. Not all devices can be overridden in this manner. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-n\fR\fR +.ad +.RS 6n +.rt +Displays the configuration that would be used without actually adding the \fBvdev\fRs. The actual pool creation can still fail due to insufficient privileges or device sharing. +.RE + +Do not add a disk that is currently configured as a quorum device to a zpool. After a disk is in the pool, that disk can then be configured as a quorum device. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool attach\fR [\fB-f\fR] \fIpool\fR \fIdevice\fR \fInew_device\fR\fR +.ad +.sp .6 +.RS 4n +Attaches \fInew_device\fR to an existing \fBzpool\fR device. The existing device cannot be part of a \fBraidz\fR configuration. If \fIdevice\fR is not currently part of a mirrored configuration, \fIdevice\fR automatically transforms into a two-way mirror of \fIdevice\fR and \fInew_device\fR. If \fIdevice\fR is part of a two-way mirror, attaching \fInew_device\fR creates a three-way mirror, and so on. In either case, \fInew_device\fR begins to resilver immediately. +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.RS 6n +.rt +Forces use of \fInew_device\fR, even if its appears to be in use. Not all devices can be overridden in this manner. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool clear\fR \fIpool\fR [\fIdevice\fR] ...\fR +.ad +.sp .6 +.RS 4n +Clears device errors in a pool. If no arguments are specified, all device errors within the pool are cleared. If one or more devices is specified, only those errors associated with the specified device or devices are cleared. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool create\fR [\fB-fn\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-O\fR \fIfile-system-property=value\fR] ... [\fB-m\fR \fImountpoint\fR] [\fB-R\fR \fIroot\fR] \fIpool\fR \fIvdev\fR ...\fR +.ad +.sp .6 +.RS 4n +Creates a new storage pool containing the virtual devices specified on the command line. The pool name must begin with a letter, and can only contain alphanumeric characters as well as underscore ("_"), dash ("-"), and period ("."). The pool names "mirror", "raidz", "spare" and "log" are reserved, as are names beginning with the pattern "c[0-9]". The \fBvdev\fR specification is described in the "Virtual Devices" section. +.sp +The command verifies that each device specified is accessible and not currently in use by another subsystem. There are some uses, such as being currently mounted, or specified as the dedicated dump device, that prevents a device from ever being used by \fBZFS\fR. Other uses, such as having a preexisting \fBUFS\fR file system, can be overridden with the \fB-f\fR option. +.sp +The command also checks that the replication strategy for the pool is consistent. An attempt to combine redundant and non-redundant storage in a single pool, or to mix disks and files, results in an error unless \fB-f\fR is specified. The use of differently sized devices within a single \fBraidz\fR or mirror group is also flagged as an error unless \fB-f\fR is specified. +.sp +Unless the \fB-R\fR option is specified, the default mount point is "/\fIpool\fR". The mount point must not exist or must be empty, or else the root dataset cannot be mounted. This can be overridden with the \fB-m\fR option. +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.sp .6 +.RS 4n +Forces use of \fBvdev\fRs, even if they appear in use or specify a conflicting replication level. Not all devices can be overridden in this manner. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-n\fR\fR +.ad +.sp .6 +.RS 4n +Displays the configuration that would be used without actually creating the pool. The actual pool creation can still fail due to insufficient privileges or device sharing. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIproperty=value\fR [\fB-o\fR \fIproperty=value\fR] ...\fR +.ad +.sp .6 +.RS 4n +Sets the given pool properties. See the "Properties" section for a list of valid properties that can be set. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-O\fR \fIfile-system-property=value\fR\fR +.ad +.br +.na +\fB[\fB-O\fR \fIfile-system-property=value\fR] ...\fR +.ad +.sp .6 +.RS 4n +Sets the given file system properties in the root file system of the pool. See the "Properties" section of \fBzfs\fR(1M) for a list of valid properties that can be set. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-R\fR \fIroot\fR\fR +.ad +.sp .6 +.RS 4n +Equivalent to "-o cachefile=none,altroot=\fIroot\fR" +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-m\fR \fImountpoint\fR\fR +.ad +.sp .6 +.RS 4n +Sets the mount point for the root dataset. The default mount point is "/\fIpool\fR" or "\fBaltroot\fR/\fIpool\fR" if \fBaltroot\fR is specified. The mount point must be an absolute path, "\fBlegacy\fR", or "\fBnone\fR". For more information on dataset mount points, see \fBzfs\fR(1M). +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool destroy\fR [\fB-f\fR] \fIpool\fR\fR +.ad +.sp .6 +.RS 4n +Destroys the given pool, freeing up any devices for other use. This command tries to unmount any active datasets before destroying the pool. +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.RS 6n +.rt +Forces any active datasets contained within the pool to be unmounted. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool detach\fR \fIpool\fR \fIdevice\fR\fR +.ad +.sp .6 +.RS 4n +Detaches \fIdevice\fR from a mirror. The operation is refused if there are no other valid replicas of the data. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool export\fR [\fB-f\fR] \fIpool\fR ...\fR +.ad +.sp .6 +.RS 4n +Exports the given pools from the system. All devices are marked as exported, but are still considered in use by other subsystems. The devices can be moved between systems (even those of different endianness) and imported as long as a sufficient number of devices are present. +.sp +Before exporting the pool, all datasets within the pool are unmounted. A pool can not be exported if it has a shared spare that is currently being used. +.sp +For pools to be portable, you must give the \fBzpool\fR command whole disks, not just slices, so that \fBZFS\fR can label the disks with portable \fBEFI\fR labels. Otherwise, disk drivers on platforms of different endianness will not recognize the disks. +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.RS 6n +.rt +Forcefully unmount all datasets, using the "\fBunmount -f\fR" command. +.sp +This command will forcefully export the pool even if it has a shared spare that is currently being used. This may lead to potential data corruption. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool get\fR "\fIall\fR" | \fIproperty\fR[,...] \fIpool\fR ...\fR +.ad +.sp .6 +.RS 4n +Retrieves the given list of properties (or all properties if "\fBall\fR" is used) for the specified storage pool(s). These properties are displayed with the following fields: +.sp +.in +2 +.nf + name Name of storage pool + property Property name + value Property value + source Property source, either 'default' or 'local'. +.fi +.in -2 +.sp + +See the "Properties" section for more information on the available pool properties. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool history\fR [\fB-il\fR] [\fIpool\fR] ...\fR +.ad +.sp .6 +.RS 4n +Displays the command history of the specified pools or all pools if no pool is specified. +.sp +.ne 2 +.mk +.na +\fB\fB-i\fR\fR +.ad +.RS 6n +.rt +Displays internally logged \fBZFS\fR events in addition to user initiated events. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-l\fR\fR +.ad +.RS 6n +.rt +Displays log records in long format, which in addition to standard format includes, the user name, the hostname, and the zone in which the operation was performed. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool import\fR [\fB-d\fR \fIdir\fR | \fB-c\fR \fIcachefile\fR] [\fB-D\fR]\fR +.ad +.sp .6 +.RS 4n +Lists pools available to import. If the \fB-d\fR option is not specified, this command searches for devices in "/dev/dsk". The \fB-d\fR option can be specified multiple times, and all directories are searched. If the device appears to be part of an exported pool, this command displays a summary of the pool with the name of the pool, a numeric identifier, as well as the \fIvdev\fR layout and current health of the device for each device or file. Destroyed pools, pools that were previously destroyed with the "\fBzpool destroy\fR" command, are not listed unless the \fB-D\fR option is specified. +.sp +The numeric identifier is unique, and can be used instead of the pool name when multiple exported pools of the same name are available. +.sp +.ne 2 +.mk +.na +\fB\fB-c\fR \fIcachefile\fR\fR +.ad +.RS 16n +.rt +Reads configuration from the given \fBcachefile\fR that was created with the "\fBcachefile\fR" pool property. This \fBcachefile\fR is used instead of searching for devices. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-d\fR \fIdir\fR\fR +.ad +.RS 16n +.rt +Searches for devices or files in \fIdir\fR. The \fB-d\fR option can be specified multiple times. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-D\fR\fR +.ad +.RS 16n +.rt +Lists destroyed pools only. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool import\fR [\fB-o\fR \fImntopts\fR] [ \fB-o\fR \fIproperty\fR=\fIvalue\fR] ... [\fB-d\fR \fIdir\fR | \fB-c\fR \fIcachefile\fR] [\fB-D\fR] [\fB-f\fR] [\fB-R\fR \fIroot\fR] \fB-a\fR\fR +.ad +.sp .6 +.RS 4n +Imports all pools found in the search directories. Identical to the previous command, except that all pools with a sufficient number of devices available are imported. Destroyed pools, pools that were previously destroyed with the "\fBzpool destroy\fR" command, will not be imported unless the \fB-D\fR option is specified. +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fImntopts\fR\fR +.ad +.RS 21n +.rt +Comma-separated list of mount options to use when mounting datasets within the pool. See \fBzfs\fR(1M) for a description of dataset properties and mount options. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIproperty=value\fR\fR +.ad +.RS 21n +.rt +Sets the specified property on the imported pool. See the "Properties" section for more information on the available pool properties. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-c\fR \fIcachefile\fR\fR +.ad +.RS 21n +.rt +Reads configuration from the given \fBcachefile\fR that was created with the "\fBcachefile\fR" pool property. This \fBcachefile\fR is used instead of searching for devices. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-d\fR \fIdir\fR\fR +.ad +.RS 21n +.rt +Searches for devices or files in \fIdir\fR. The \fB-d\fR option can be specified multiple times. This option is incompatible with the \fB-c\fR option. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-D\fR\fR +.ad +.RS 21n +.rt +Imports destroyed pools only. The \fB-f\fR option is also required. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.RS 21n +.rt +Forces import, even if the pool appears to be potentially active. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-a\fR\fR +.ad +.RS 21n +.rt +Searches for and imports all pools found. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-R\fR \fIroot\fR\fR +.ad +.RS 21n +.rt +Sets the "\fBcachefile\fR" property to "\fBnone\fR" and the "\fIaltroot\fR" property to "\fIroot\fR". +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool import\fR [\fB-o\fR \fImntopts\fR] [ \fB-o\fR \fIproperty\fR=\fIvalue\fR] ... [\fB-d\fR \fIdir\fR | \fB-c\fR \fIcachefile\fR] [\fB-D\fR] [\fB-f\fR] [\fB-R\fR \fIroot\fR] \fIpool\fR | \fIid\fR [\fInewpool\fR]\fR +.ad +.sp .6 +.RS 4n +Imports a specific pool. A pool can be identified by its name or the numeric identifier. If \fInewpool\fR is specified, the pool is imported using the name \fInewpool\fR. Otherwise, it is imported with the same name as its exported name. +.sp +If a device is removed from a system without running "\fBzpool export\fR" first, the device appears as potentially active. It cannot be determined if this was a failed export, or whether the device is really in use from another host. To import a pool in this state, the \fB-f\fR option is required. +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fImntopts\fR\fR +.ad +.sp .6 +.RS 4n +Comma-separated list of mount options to use when mounting datasets within the pool. See \fBzfs\fR(1M) for a description of dataset properties and mount options. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIproperty=value\fR\fR +.ad +.sp .6 +.RS 4n +Sets the specified property on the imported pool. See the "Properties" section for more information on the available pool properties. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-c\fR \fIcachefile\fR\fR +.ad +.sp .6 +.RS 4n +Reads configuration from the given \fBcachefile\fR that was created with the "\fBcachefile\fR" pool property. This \fBcachefile\fR is used instead of searching for devices. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-d\fR \fIdir\fR\fR +.ad +.sp .6 +.RS 4n +Searches for devices or files in \fIdir\fR. The \fB-d\fR option can be specified multiple times. This option is incompatible with the \fB-c\fR option. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-D\fR\fR +.ad +.sp .6 +.RS 4n +Imports destroyed pool. The \fB-f\fR option is also required. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.sp .6 +.RS 4n +Forces import, even if the pool appears to be potentially active. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-R\fR \fIroot\fR\fR +.ad +.sp .6 +.RS 4n +Sets the "\fBcachefile\fR" property to "\fBnone\fR" and the "\fIaltroot\fR" property to "\fIroot\fR". +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool iostat\fR [\fB-T\fR \fBu\fR | \fBd\fR] [\fB-v\fR] [\fIpool\fR] ... [\fIinterval\fR[\fIcount\fR]]\fR +.ad +.sp .6 +.RS 4n +Displays \fBI/O\fR statistics for the given pools. When given an interval, the statistics are printed every \fIinterval\fR seconds until \fBCtrl-C\fR is pressed. If no \fIpools\fR are specified, statistics for every pool in the system is shown. If \fIcount\fR is specified, the command exits after \fIcount\fR reports are printed. +.sp +.ne 2 +.mk +.na +\fB\fB-T\fR \fBu\fR | \fBd\fR\fR +.ad +.RS 12n +.rt +Display a time stamp. +.sp +Specify \fBu\fR for a printed representation of the internal representation of time. See \fBtime\fR(2). Specify \fBd\fR for standard date format. See \fBdate\fR(1). +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-v\fR\fR +.ad +.RS 12n +.rt +Verbose statistics. Reports usage statistics for individual \fIvdevs\fR within the pool, in addition to the pool-wide statistics. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool list\fR [\fB-H\fR] [\fB-o\fR \fIprops\fR[,...]] [\fIpool\fR] ...\fR +.ad +.sp .6 +.RS 4n +Lists the given pools along with a health status and space usage. When given no arguments, all pools in the system are listed. +.sp +.ne 2 +.mk +.na +\fB\fB-H\fR\fR +.ad +.RS 12n +.rt +Scripted mode. Do not display headers, and separate fields by a single tab instead of arbitrary space. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIprops\fR\fR +.ad +.RS 12n +.rt +Comma-separated list of properties to display. See the "Properties" section for a list of valid properties. The default list is "name, size, used, available, capacity, health, altroot" +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool offline\fR [\fB-t\fR] \fIpool\fR \fIdevice\fR ...\fR +.ad +.sp .6 +.RS 4n +Takes the specified physical device offline. While the \fIdevice\fR is offline, no attempt is made to read or write to the device. +.sp +This command is not applicable to spares or cache devices. +.sp +.ne 2 +.mk +.na +\fB\fB-t\fR\fR +.ad +.RS 6n +.rt +Temporary. Upon reboot, the specified physical device reverts to its previous state. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool online\fR [\fB-e\fR] \fIpool\fR \fIdevice\fR...\fR +.ad +.sp .6 +.RS 4n +Brings the specified physical device online. +.sp +This command is not applicable to spares or cache devices. +.sp +.ne 2 +.mk +.na +\fB\fB-e\fR\fR +.ad +.RS 6n +.rt +Expand the device to use all available space. If the device is part of a mirror or \fBraidz\fR then all devices must be expanded before the new space will become available to the pool. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool remove\fR \fIpool\fR \fIdevice\fR ...\fR +.ad +.sp .6 +.RS 4n +Removes the specified device from the pool. This command currently only supports removing hot spares, cache, and log devices. A mirrored log device can be removed by specifying the top-level mirror for the log. Non-log devices that are part of a mirrored configuration can be removed using the \fBzpool detach\fR command. Non-redundant and \fBraidz\fR devices cannot be removed from a pool. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool replace\fR [\fB-f\fR] \fIpool\fR \fIold_device\fR [\fInew_device\fR]\fR +.ad +.sp .6 +.RS 4n +Replaces \fIold_device\fR with \fInew_device\fR. This is equivalent to attaching \fInew_device\fR, waiting for it to resilver, and then detaching \fIold_device\fR. +.sp +The size of \fInew_device\fR must be greater than or equal to the minimum size of all the devices in a mirror or \fBraidz\fR configuration. +.sp +\fInew_device\fR is required if the pool is not redundant. If \fInew_device\fR is not specified, it defaults to \fIold_device\fR. This form of replacement is useful after an existing disk has failed and has been physically replaced. In this case, the new disk may have the same \fB/dev/dsk\fR path as the old device, even though it is actually a different disk. \fBZFS\fR recognizes this. +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fR +.ad +.RS 6n +.rt +Forces use of \fInew_device\fR, even if its appears to be in use. Not all devices can be overridden in this manner. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool scrub\fR [\fB-s\fR] \fIpool\fR ...\fR +.ad +.sp .6 +.RS 4n +Begins a scrub. The scrub examines all data in the specified pools to verify that it checksums correctly. For replicated (mirror or \fBraidz\fR) devices, \fBZFS\fR automatically repairs any damage discovered during the scrub. The "\fBzpool status\fR" command reports the progress of the scrub and summarizes the results of the scrub upon completion. +.sp +Scrubbing and resilvering are very similar operations. The difference is that resilvering only examines data that \fBZFS\fR knows to be out of date (for example, when attaching a new device to a mirror or replacing an existing device), whereas scrubbing examines all data to discover silent errors due to hardware faults or disk failure. +.sp +Because scrubbing and resilvering are \fBI/O\fR-intensive operations, \fBZFS\fR only allows one at a time. If a scrub is already in progress, the "\fBzpool scrub\fR" command terminates it and starts a new scrub. If a resilver is in progress, \fBZFS\fR does not allow a scrub to be started until the resilver completes. +.sp +.ne 2 +.mk +.na +\fB\fB-s\fR\fR +.ad +.RS 6n +.rt +Stop scrubbing. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool set\fR \fIproperty\fR=\fIvalue\fR \fIpool\fR\fR +.ad +.sp .6 +.RS 4n +Sets the given property on the specified pool. See the "Properties" section for more information on what properties can be set and acceptable values. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool status\fR [\fB-xv\fR] [\fIpool\fR] ...\fR +.ad +.sp .6 +.RS 4n +Displays the detailed health status for the given pools. If no \fIpool\fR is specified, then the status of each pool in the system is displayed. For more information on pool and device health, see the "Device Failure and Recovery" section. +.sp +If a scrub or resilver is in progress, this command reports the percentage done and the estimated time to completion. Both of these are only approximate, because the amount of data in the pool and the other workloads on the system can change. +.sp +.ne 2 +.mk +.na +\fB\fB-x\fR\fR +.ad +.RS 6n +.rt +Only display status for pools that are exhibiting errors or are otherwise unavailable. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-v\fR\fR +.ad +.RS 6n +.rt +Displays verbose data error information, printing out a complete list of all data errors since the last complete pool scrub. +.RE + +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool upgrade\fR\fR +.ad +.sp .6 +.RS 4n +Displays all pools formatted using a different \fBZFS\fR on-disk version. Older versions can continue to be used, but some features may not be available. These pools can be upgraded using "\fBzpool upgrade -a\fR". Pools that are formatted with a more recent version are also displayed, although these pools will be inaccessible on the system. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool upgrade\fR \fB-v\fR\fR +.ad +.sp .6 +.RS 4n +Displays \fBZFS\fR versions supported by the current software. The current \fBZFS\fR versions and all previous supported versions are displayed, along with an explanation of the features provided with each version. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBzpool upgrade\fR [\fB-V\fR \fIversion\fR] \fB-a\fR | \fIpool\fR ...\fR +.ad +.sp .6 +.RS 4n +Upgrades the given pool to the latest on-disk version. Once this is done, the pool will no longer be accessible on systems running older versions of the software. +.sp +.ne 2 +.mk +.na +\fB\fB-a\fR\fR +.ad +.RS 14n +.rt +Upgrades all pools. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-V\fR \fIversion\fR\fR +.ad +.RS 14n +.rt +Upgrade to the specified version. If the \fB-V\fR flag is not specified, the pool is upgraded to the most recent version. This option can only be used to increase the version number, and only up to the most recent version supported by this software. +.RE + +.RE + +.SH EXAMPLES +.LP +\fBExample 1 \fRCreating a RAID-Z Storage Pool +.sp +.LP +The following command creates a pool with a single \fBraidz\fR root \fIvdev\fR that consists of six disks. + +.sp +.in +2 +.nf +# \fBzpool create tank raidz c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0\fR +.fi +.in -2 +.sp + +.LP +\fBExample 2 \fRCreating a Mirrored Storage Pool +.sp +.LP +The following command creates a pool with two mirrors, where each mirror contains two disks. + +.sp +.in +2 +.nf +# \fBzpool create tank mirror c0t0d0 c0t1d0 mirror c0t2d0 c0t3d0\fR +.fi +.in -2 +.sp + +.LP +\fBExample 3 \fRCreating a ZFS Storage Pool by Using Slices +.sp +.LP +The following command creates an unmirrored pool using two disk slices. + +.sp +.in +2 +.nf +# \fBzpool create tank /dev/dsk/c0t0d0s1 c0t1d0s4\fR +.fi +.in -2 +.sp + +.LP +\fBExample 4 \fRCreating a ZFS Storage Pool by Using Files +.sp +.LP +The following command creates an unmirrored pool using files. While not recommended, a pool based on files can be useful for experimental purposes. + +.sp +.in +2 +.nf +# \fBzpool create tank /path/to/file/a /path/to/file/b\fR +.fi +.in -2 +.sp + +.LP +\fBExample 5 \fRAdding a Mirror to a ZFS Storage Pool +.sp +.LP +The following command adds two mirrored disks to the pool "\fItank\fR", assuming the pool is already made up of two-way mirrors. The additional space is immediately available to any datasets within the pool. + +.sp +.in +2 +.nf +# \fBzpool add tank mirror c1t0d0 c1t1d0\fR +.fi +.in -2 +.sp + +.LP +\fBExample 6 \fRListing Available ZFS Storage Pools +.sp +.LP +The following command lists all available pools on the system. In this case, the pool \fIzion\fR is faulted due to a missing device. + +.sp +.LP +The results from this command are similar to the following: + +.sp +.in +2 +.nf +# \fBzpool list\fR + NAME SIZE USED AVAIL CAP HEALTH ALTROOT + pool 67.5G 2.92M 67.5G 0% ONLINE - + tank 67.5G 2.92M 67.5G 0% ONLINE - + zion - - - 0% FAULTED - +.fi +.in -2 +.sp + +.LP +\fBExample 7 \fRDestroying a ZFS Storage Pool +.sp +.LP +The following command destroys the pool "\fItank\fR" and any datasets contained within. + +.sp +.in +2 +.nf +# \fBzpool destroy -f tank\fR +.fi +.in -2 +.sp + +.LP +\fBExample 8 \fRExporting a ZFS Storage Pool +.sp +.LP +The following command exports the devices in pool \fItank\fR so that they can be relocated or later imported. + +.sp +.in +2 +.nf +# \fBzpool export tank\fR +.fi +.in -2 +.sp + +.LP +\fBExample 9 \fRImporting a ZFS Storage Pool +.sp +.LP +The following command displays available pools, and then imports the pool "tank" for use on the system. + +.sp +.LP +The results from this command are similar to the following: + +.sp +.in +2 +.nf +# \fBzpool import\fR + pool: tank + id: 15451357997522795478 + state: ONLINE +action: The pool can be imported using its name or numeric identifier. +config: + + tank ONLINE + mirror ONLINE + c1t2d0 ONLINE + c1t3d0 ONLINE + +# \fBzpool import tank\fR +.fi +.in -2 +.sp + +.LP +\fBExample 10 \fRUpgrading All ZFS Storage Pools to the Current Version +.sp +.LP +The following command upgrades all ZFS Storage pools to the current version of the software. + +.sp +.in +2 +.nf +# \fBzpool upgrade -a\fR +This system is currently running ZFS version 2. +.fi +.in -2 +.sp + +.LP +\fBExample 11 \fRManaging Hot Spares +.sp +.LP +The following command creates a new pool with an available hot spare: + +.sp +.in +2 +.nf +# \fBzpool create tank mirror c0t0d0 c0t1d0 spare c0t2d0\fR +.fi +.in -2 +.sp + +.sp +.LP +If one of the disks were to fail, the pool would be reduced to the degraded state. The failed device can be replaced using the following command: + +.sp +.in +2 +.nf +# \fBzpool replace tank c0t0d0 c0t3d0\fR +.fi +.in -2 +.sp + +.sp +.LP +Once the data has been resilvered, the spare is automatically removed and is made available should another device fails. The hot spare can be permanently removed from the pool using the following command: + +.sp +.in +2 +.nf +# \fBzpool remove tank c0t2d0\fR +.fi +.in -2 +.sp + +.LP +\fBExample 12 \fRCreating a ZFS Pool with Mirrored Separate Intent Logs +.sp +.LP +The following command creates a ZFS storage pool consisting of two, two-way mirrors and mirrored log devices: + +.sp +.in +2 +.nf +# \fBzpool create pool mirror c0d0 c1d0 mirror c2d0 c3d0 log mirror \e + c4d0 c5d0\fR +.fi +.in -2 +.sp + +.LP +\fBExample 13 \fRAdding Cache Devices to a ZFS Pool +.sp +.LP +The following command adds two disks for use as cache devices to a ZFS storage pool: + +.sp +.in +2 +.nf +# \fBzpool add pool cache c2d0 c3d0\fR +.fi +.in -2 +.sp + +.sp +.LP +Once added, the cache devices gradually fill with content from main memory. Depending on the size of your cache devices, it could take over an hour for them to fill. Capacity and reads can be monitored using the \fBiostat\fR option as follows: + +.sp +.in +2 +.nf +# \fBzpool iostat -v pool 5\fR +.fi +.in -2 +.sp + +.LP +\fBExample 14 \fRRemoving a Mirrored Log Device +.sp +.LP +The following command removes the mirrored log device \fBmirror-2\fR. + +.sp +.LP +Given this configuration: + +.sp +.in +2 +.nf + pool: tank + state: ONLINE + scrub: none requested +config: + + NAME STATE READ WRITE CKSUM + tank ONLINE 0 0 0 + mirror-0 ONLINE 0 0 0 + c6t0d0 ONLINE 0 0 0 + c6t1d0 ONLINE 0 0 0 + mirror-1 ONLINE 0 0 0 + c6t2d0 ONLINE 0 0 0 + c6t3d0 ONLINE 0 0 0 + logs + mirror-2 ONLINE 0 0 0 + c4t0d0 ONLINE 0 0 0 + c4t1d0 ONLINE 0 0 0 +.fi +.in -2 +.sp + +.sp +.LP +The command to remove the mirrored log \fBmirror-2\fR is: + +.sp +.in +2 +.nf +# \fBzpool remove tank mirror-2\fR +.fi +.in -2 +.sp + +.SH EXIT STATUS +.sp +.LP +The following exit values are returned: +.sp +.ne 2 +.mk +.na +\fB\fB0\fR\fR +.ad +.RS 5n +.rt +Successful completion. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB1\fR\fR +.ad +.RS 5n +.rt +An error occurred. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB2\fR\fR +.ad +.RS 5n +.rt +Invalid command line options were specified. +.RE + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +AvailabilitySUNWzfsu +_ +Interface StabilityEvolving +.TE + +.SH SEE ALSO +.sp +.LP +\fBzfs\fR(1M), \fBattributes\fR(5) diff --git a/module/.gitignore b/module/.gitignore new file mode 100644 index 0000000000..611c51c426 --- /dev/null +++ b/module/.gitignore @@ -0,0 +1,3 @@ +/.tmp_versions +/Module.markers +/Module.symvers diff --git a/module/Makefile.in b/module/Makefile.in index 13a5a81333..cc8047a9ed 100644 --- a/module/Makefile.in +++ b/module/Makefile.in @@ -4,11 +4,17 @@ subdir-m += unicode subdir-m += zcommon subdir-m += zfs -modules clean: +modules: # Make the exported SPL symbols available to these modules. cp @SPL_OBJ@/@SPL_SYMBOLS@ . $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ +clean: + $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ + if [ -f @SPL_SYMBOLS@ ]; then $(RM) @SPL_SYMBOLS@; fi + if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi + if [ -f Module.markers ]; then $(RM) Module.markers; fi + modules_install: $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` \ INSTALL_MOD_PATH=$(DESTDIR) \ @@ -17,12 +23,8 @@ modules_install: # Install the required headers in to the kernel source destname=zfs-@ZFS_META_VERSION@/@LINUX_VERSION@; \ instdest=$(DESTDIR)/@prefix@/src/$$destname; \ - (mkdir -p $$instdest && \ - find . -mindepth 3 -maxdepth 3 -name '*.h' | \ - xargs cp -t $$instdest) || exit 1; \ - (mkdir -p $$instdest/sys && \ - find . -mindepth 4 -maxdepth 4 -name '*.h' | \ - xargs cp -t $$instdest/sys) || exit 1; + (find . -mindepth 3 -name '*.h' | xargs -Ihdr sh -c \ + "DEST=hdr && install -D hdr $$instdest/\$${DEST#*/*/*/}") || exit 1 distdir: distfiles=`find . -name '*.c' -o -name '*.h'`; \ diff --git a/module/avl/avl.c b/module/avl/avl.c index 728bd87234..cdcf2afa61 100644 --- a/module/avl/avl.c +++ b/module/avl/avl.c @@ -1033,15 +1033,16 @@ done: } #if defined(_KERNEL) && defined(HAVE_SPL) + static int avl_init(void) { return 0; } static int avl_fini(void) { return 0; } spl_module_init(avl_init); spl_module_exit(avl_fini); -MODULE_AUTHOR("Sun Microsystems, Inc"); MODULE_DESCRIPTION("Generic AVL tree implementation"); -MODULE_LICENSE("CDDL"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE(ZFS_META_LICENSE); EXPORT_SYMBOL(avl_create); EXPORT_SYMBOL(avl_find); diff --git a/module/nvpair/Makefile.in b/module/nvpair/Makefile.in index acd9ac4f99..3f643e724d 100644 --- a/module/nvpair/Makefile.in +++ b/module/nvpair/Makefile.in @@ -7,3 +7,4 @@ obj-m := ${MODULE}.o ${MODULE}-objs += nvpair.o ${MODULE}-objs += nvpair_alloc_spl.o +${MODULE}-objs += nvpair_alloc_fixed.o diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index 5bee964294..3492f23518 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -3246,15 +3246,16 @@ nvs_xdr(nvstream_t *nvs, nvlist_t *nvl, char *buf, size_t *buflen) } #if defined(_KERNEL) && defined(HAVE_SPL) + static int nvpair_init(void) { return 0; } static int nvpair_fini(void) { return 0; } spl_module_init(nvpair_init); spl_module_exit(nvpair_fini); -MODULE_AUTHOR("Sun Microsystems, Inc"); MODULE_DESCRIPTION("Generic name/value pair implementation"); -MODULE_LICENSE("CDDL"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE(ZFS_META_LICENSE); EXPORT_SYMBOL(nv_alloc_init); EXPORT_SYMBOL(nv_alloc_reset); diff --git a/module/nvpair/nvpair_alloc_fixed.c b/module/nvpair/nvpair_alloc_fixed.c new file mode 100644 index 0000000000..20081ba56c --- /dev/null +++ b/module/nvpair/nvpair_alloc_fixed.c @@ -0,0 +1,124 @@ +/* + * 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 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + + +#include +#include +#include +#include +#if defined(_KERNEL) && !defined(_BOOT) +#include +#else +#include +#include +#endif + +/* + * This allocator is very simple. + * - it uses a pre-allocated buffer for memory allocations. + * - it does _not_ free memory in the pre-allocated buffer. + * + * The reason for the selected implemention is simplicity. + * This allocator is designed for the usage in interrupt context when + * the caller may not wait for free memory. + */ + +/* pre-allocated buffer for memory allocations */ +typedef struct nvbuf { + uintptr_t nvb_buf; /* address of pre-allocated buffer */ + uintptr_t nvb_lim; /* limit address in the buffer */ + uintptr_t nvb_cur; /* current address in the buffer */ +} nvbuf_t; + +/* + * Initialize the pre-allocated buffer allocator. The caller needs to supply + * + * buf address of pre-allocated buffer + * bufsz size of pre-allocated buffer + * + * nv_fixed_init() calculates the remaining members of nvbuf_t. + */ +static int +nv_fixed_init(nv_alloc_t *nva, va_list valist) +{ + uintptr_t base = va_arg(valist, uintptr_t); + uintptr_t lim = base + va_arg(valist, size_t); + nvbuf_t *nvb = (nvbuf_t *)P2ROUNDUP(base, sizeof (uintptr_t)); + + if (base == 0 || (uintptr_t)&nvb[1] > lim) + return (EINVAL); + + nvb->nvb_buf = (uintptr_t)&nvb[0]; + nvb->nvb_cur = (uintptr_t)&nvb[1]; + nvb->nvb_lim = lim; + nva->nva_arg = nvb; + + return (0); +} + +static void * +nv_fixed_alloc(nv_alloc_t *nva, size_t size) +{ + nvbuf_t *nvb = nva->nva_arg; + uintptr_t new = nvb->nvb_cur; + + if (size == 0 || new + size > nvb->nvb_lim) + return (NULL); + + nvb->nvb_cur = P2ROUNDUP(new + size, sizeof (uintptr_t)); + + return ((void *)new); +} + +/*ARGSUSED*/ +static void +nv_fixed_free(nv_alloc_t *nva, void *buf, size_t size) +{ + /* don't free memory in the pre-allocated buffer */ +} + +static void +nv_fixed_reset(nv_alloc_t *nva) +{ + nvbuf_t *nvb = nva->nva_arg; + + nvb->nvb_cur = (uintptr_t)&nvb[1]; +} + +const nv_alloc_ops_t nv_fixed_ops_def = { + nv_fixed_init, /* nv_ao_init() */ + NULL, /* nv_ao_fini() */ + nv_fixed_alloc, /* nv_ao_alloc() */ + nv_fixed_free, /* nv_ao_free() */ + nv_fixed_reset /* nv_ao_reset() */ +}; + +const nv_alloc_ops_t *nv_fixed_ops = &nv_fixed_ops_def; + +#if defined(_KERNEL) && defined(HAVE_SPL) +EXPORT_SYMBOL(nv_fixed_ops); +#endif diff --git a/module/unicode/u8_textprep.c b/module/unicode/u8_textprep.c index 37fb2e5a46..df6dcf552b 100644 --- a/module/unicode/u8_textprep.c +++ b/module/unicode/u8_textprep.c @@ -2133,15 +2133,16 @@ u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen, } #if defined(_KERNEL) && defined(HAVE_SPL) + static int unicode_init(void) { return 0; } static int unicode_fini(void) { return 0; } spl_module_init(unicode_init); spl_module_exit(unicode_fini); -MODULE_AUTHOR("Sun Microsystems, Inc"); MODULE_DESCRIPTION("Unicode implementation"); -MODULE_LICENSE("CDDL"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE(ZFS_META_LICENSE); EXPORT_SYMBOL(u8_validate); EXPORT_SYMBOL(u8_strcmp); diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 45943602c0..bb73e7ee35 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -534,15 +534,16 @@ zfs_prop_align_right(zfs_prop_t prop) #endif #if defined(_KERNEL) && defined(HAVE_SPL) + static int zcommon_init(void) { return 0; } static int zcommon_fini(void) { return 0; } spl_module_init(zcommon_init); spl_module_exit(zcommon_fini); -MODULE_AUTHOR("Sun Microsystems, Inc"); MODULE_DESCRIPTION("Generic ZFS support"); -MODULE_LICENSE("CDDL"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE(ZFS_META_LICENSE); /* zfs dataset property functions */ EXPORT_SYMBOL(zfs_userquota_prop_prefixes); diff --git a/module/zfs/Makefile.in b/module/zfs/Makefile.in index 2bde8a89a0..2894008810 100644 --- a/module/zfs/Makefile.in +++ b/module/zfs/Makefile.in @@ -29,6 +29,7 @@ ${MODULE}-objs += dsl_prop.o ${MODULE}-objs += dsl_scrub.o ${MODULE}-objs += dsl_synctask.o ${MODULE}-objs += fletcher.o +${MODULE}-objs += fm.o ${MODULE}-objs += gzip.o ${MODULE}-objs += lzjb.o ${MODULE}-objs += metaslab.o diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index b977a2ff7c..ecb89b9fc6 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -689,7 +689,7 @@ restore_read(struct restorearg *ra, int len) return (rv); } -static void +noinline static void backup_byteswap(dmu_replay_record_t *drr) { #define DO64(X) (drr->drr_u.X = BSWAP_64(drr->drr_u.X)) @@ -740,7 +740,7 @@ backup_byteswap(dmu_replay_record_t *drr) #undef DO32 } -static int +noinline static int restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro) { int err; @@ -822,7 +822,7 @@ restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro) } /* ARGSUSED */ -static int +noinline static int restore_freeobjects(struct restorearg *ra, objset_t *os, struct drr_freeobjects *drrfo) { @@ -846,7 +846,7 @@ restore_freeobjects(struct restorearg *ra, objset_t *os, return (0); } -static int +noinline static int restore_write(struct restorearg *ra, objset_t *os, struct drr_write *drrw) { @@ -883,7 +883,7 @@ restore_write(struct restorearg *ra, objset_t *os, } /* ARGSUSED */ -static int +noinline static int restore_free(struct restorearg *ra, objset_t *os, struct drr_free *drrf) { diff --git a/module/zfs/fm.c b/module/zfs/fm.c new file mode 100644 index 0000000000..3cc979d41b --- /dev/null +++ b/module/zfs/fm.c @@ -0,0 +1,1266 @@ +/* + * 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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Fault Management Architecture (FMA) Resource and Protocol Support + * + * The routines contained herein provide services to support kernel subsystems + * in publishing fault management telemetry (see PSARC 2002/412 and 2003/089). + * + * Name-Value Pair Lists + * + * The embodiment of an FMA protocol element (event, fmri or authority) is a + * name-value pair list (nvlist_t). FMA-specific nvlist construtor and + * destructor functions, fm_nvlist_create() and fm_nvlist_destroy(), are used + * to create an nvpair list using custom allocators. Callers may choose to + * allocate either from the kernel memory allocator, or from a preallocated + * buffer, useful in constrained contexts like high-level interrupt routines. + * + * Protocol Event and FMRI Construction + * + * Convenience routines are provided to construct nvlist events according to + * the FMA Event Protocol and Naming Schema specification for ereports and + * FMRIs for the dev, cpu, hc, mem, legacy hc and de schemes. + * + * ENA Manipulation + * + * Routines to generate ENA formats 0, 1 and 2 are available as well as + * routines to increment formats 1 and 2. Individual fields within the + * ENA are extractable via fm_ena_time_get(), fm_ena_id_get(), + * fm_ena_format_get() and fm_ena_gen_get(). + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * URL and SUNW-MSG-ID value to display for fm_panic(), defined below. These + * values must be kept in sync with the FMA source code in usr/src/cmd/fm. + */ +static const char *fm_url = "http://www.sun.com/msg"; +static const char *fm_msgid = "SUNOS-8000-0G"; +static char *volatile fm_panicstr = NULL; + +errorq_t *ereport_errorq; +void *ereport_dumpbuf; +size_t ereport_dumplen; + +static uint_t ereport_chanlen = ERPT_EVCH_MAX; +static evchan_t *ereport_chan = NULL; +static ulong_t ereport_qlen = 0; +static size_t ereport_size = 0; +static int ereport_cols = 80; + +/* + * Common fault management kstats to record ereport generation + * failures + */ + +struct erpt_kstat { + kstat_named_t erpt_dropped; /* num erpts dropped on post */ + kstat_named_t erpt_set_failed; /* num erpt set failures */ + kstat_named_t fmri_set_failed; /* num fmri set failures */ + kstat_named_t payload_set_failed; /* num payload set failures */ +}; + +static struct erpt_kstat erpt_kstat_data = { + { "erpt-dropped", KSTAT_DATA_UINT64 }, + { "erpt-set-failed", KSTAT_DATA_UINT64 }, + { "fmri-set-failed", KSTAT_DATA_UINT64 }, + { "payload-set-failed", KSTAT_DATA_UINT64 } +}; + +/*ARGSUSED*/ +static void +fm_drain(void *private, void *data, errorq_elem_t *eep) +{ + nvlist_t *nvl = errorq_elem_nvl(ereport_errorq, eep); + + if (!panicstr) + (void) fm_ereport_post(nvl, EVCH_TRYHARD); + else + fm_nvprint(nvl); +} + +void +fm_init(void) +{ + kstat_t *ksp; + + (void) sysevent_evc_bind(FM_ERROR_CHAN, + &ereport_chan, EVCH_CREAT | EVCH_HOLD_PEND); + + (void) sysevent_evc_control(ereport_chan, + EVCH_SET_CHAN_LEN, &ereport_chanlen); + + if (ereport_qlen == 0) + ereport_qlen = ERPT_MAX_ERRS * MAX(max_ncpus, 4); + + if (ereport_size == 0) + ereport_size = ERPT_DATA_SZ; + + ereport_errorq = errorq_nvcreate("fm_ereport_queue", + (errorq_func_t)fm_drain, NULL, ereport_qlen, ereport_size, + FM_ERR_PIL, ERRORQ_VITAL); + if (ereport_errorq == NULL) + panic("failed to create required ereport error queue"); + + ereport_dumpbuf = kmem_alloc(ereport_size, KM_SLEEP); + ereport_dumplen = ereport_size; + + /* Initialize ereport allocation and generation kstats */ + ksp = kstat_create("unix", 0, "fm", "misc", KSTAT_TYPE_NAMED, + sizeof (struct erpt_kstat) / sizeof (kstat_named_t), + KSTAT_FLAG_VIRTUAL); + + if (ksp != NULL) { + ksp->ks_data = &erpt_kstat_data; + kstat_install(ksp); + } else { + cmn_err(CE_NOTE, "failed to create fm/misc kstat\n"); + + } +} + +/* + * Formatting utility function for fm_nvprintr. We attempt to wrap chunks of + * output so they aren't split across console lines, and return the end column. + */ +/*PRINTFLIKE4*/ +static int +fm_printf(int depth, int c, int cols, const char *format, ...) +{ + va_list ap; + int width; + char c1; + + va_start(ap, format); + width = vsnprintf(&c1, sizeof (c1), format, ap); + va_end(ap); + + if (c + width >= cols) { + console_printf("\n\r"); + c = 0; + if (format[0] != ' ' && depth > 0) { + console_printf(" "); + c++; + } + } + + va_start(ap, format); + console_vprintf(format, ap); + va_end(ap); + + return ((c + width) % cols); +} + +/* + * Recursively print a nvlist in the specified column width and return the + * column we end up in. This function is called recursively by fm_nvprint(), + * below. We generically format the entire nvpair using hexadecimal + * integers and strings, and elide any integer arrays. Arrays are basically + * used for cache dumps right now, so we suppress them so as not to overwhelm + * the amount of console output we produce at panic time. This can be further + * enhanced as FMA technology grows based upon the needs of consumers. All + * FMA telemetry is logged using the dump device transport, so the console + * output serves only as a fallback in case this procedure is unsuccessful. + */ +static int +fm_nvprintr(nvlist_t *nvl, int d, int c, int cols) +{ + nvpair_t *nvp; + + for (nvp = nvlist_next_nvpair(nvl, NULL); + nvp != NULL; nvp = nvlist_next_nvpair(nvl, nvp)) { + + data_type_t type = nvpair_type(nvp); + const char *name = nvpair_name(nvp); + + boolean_t b; + uint8_t i8; + uint16_t i16; + uint32_t i32; + uint64_t i64; + char *str; + nvlist_t *cnv; + + if (strcmp(name, FM_CLASS) == 0) + continue; /* already printed by caller */ + + c = fm_printf(d, c, cols, " %s=", name); + + switch (type) { + case DATA_TYPE_BOOLEAN: + c = fm_printf(d + 1, c, cols, " 1"); + break; + + case DATA_TYPE_BOOLEAN_VALUE: + (void) nvpair_value_boolean_value(nvp, &b); + c = fm_printf(d + 1, c, cols, b ? "1" : "0"); + break; + + case DATA_TYPE_BYTE: + (void) nvpair_value_byte(nvp, &i8); + c = fm_printf(d + 1, c, cols, "%x", i8); + break; + + case DATA_TYPE_INT8: + (void) nvpair_value_int8(nvp, (void *)&i8); + c = fm_printf(d + 1, c, cols, "%x", i8); + break; + + case DATA_TYPE_UINT8: + (void) nvpair_value_uint8(nvp, &i8); + c = fm_printf(d + 1, c, cols, "%x", i8); + break; + + case DATA_TYPE_INT16: + (void) nvpair_value_int16(nvp, (void *)&i16); + c = fm_printf(d + 1, c, cols, "%x", i16); + break; + + case DATA_TYPE_UINT16: + (void) nvpair_value_uint16(nvp, &i16); + c = fm_printf(d + 1, c, cols, "%x", i16); + break; + + case DATA_TYPE_INT32: + (void) nvpair_value_int32(nvp, (void *)&i32); + c = fm_printf(d + 1, c, cols, "%x", i32); + break; + + case DATA_TYPE_UINT32: + (void) nvpair_value_uint32(nvp, &i32); + c = fm_printf(d + 1, c, cols, "%x", i32); + break; + + case DATA_TYPE_INT64: + (void) nvpair_value_int64(nvp, (void *)&i64); + c = fm_printf(d + 1, c, cols, "%llx", + (u_longlong_t)i64); + break; + + case DATA_TYPE_UINT64: + (void) nvpair_value_uint64(nvp, &i64); + c = fm_printf(d + 1, c, cols, "%llx", + (u_longlong_t)i64); + break; + + case DATA_TYPE_HRTIME: + (void) nvpair_value_hrtime(nvp, (void *)&i64); + c = fm_printf(d + 1, c, cols, "%llx", + (u_longlong_t)i64); + break; + + case DATA_TYPE_STRING: + (void) nvpair_value_string(nvp, &str); + c = fm_printf(d + 1, c, cols, "\"%s\"", + str ? str : ""); + break; + + case DATA_TYPE_NVLIST: + c = fm_printf(d + 1, c, cols, "["); + (void) nvpair_value_nvlist(nvp, &cnv); + c = fm_nvprintr(cnv, d + 1, c, cols); + c = fm_printf(d + 1, c, cols, " ]"); + break; + + case DATA_TYPE_NVLIST_ARRAY: { + nvlist_t **val; + uint_t i, nelem; + + c = fm_printf(d + 1, c, cols, "["); + (void) nvpair_value_nvlist_array(nvp, &val, &nelem); + for (i = 0; i < nelem; i++) { + c = fm_nvprintr(val[i], d + 1, c, cols); + } + c = fm_printf(d + 1, c, cols, " ]"); + } + break; + + case DATA_TYPE_BOOLEAN_ARRAY: + case DATA_TYPE_BYTE_ARRAY: + case DATA_TYPE_INT8_ARRAY: + case DATA_TYPE_UINT8_ARRAY: + case DATA_TYPE_INT16_ARRAY: + case DATA_TYPE_UINT16_ARRAY: + case DATA_TYPE_INT32_ARRAY: + case DATA_TYPE_UINT32_ARRAY: + case DATA_TYPE_INT64_ARRAY: + case DATA_TYPE_UINT64_ARRAY: + case DATA_TYPE_STRING_ARRAY: + c = fm_printf(d + 1, c, cols, "[...]"); + break; + case DATA_TYPE_UNKNOWN: + c = fm_printf(d + 1, c, cols, ""); + break; + } + } + + return (c); +} + +void +fm_nvprint(nvlist_t *nvl) +{ + char *class; + int c = 0; + + console_printf("\r"); + + if (nvlist_lookup_string(nvl, FM_CLASS, &class) == 0) + c = fm_printf(0, c, ereport_cols, "%s", class); + + if (fm_nvprintr(nvl, 0, c, ereport_cols) != 0) + console_printf("\n"); + + console_printf("\n"); +} + +/* + * Wrapper for panic() that first produces an FMA-style message for admins. + * Normally such messages are generated by fmd(1M)'s syslog-msgs agent: this + * is the one exception to that rule and the only error that gets messaged. + * This function is intended for use by subsystems that have detected a fatal + * error and enqueued appropriate ereports and wish to then force a panic. + */ +/*PRINTFLIKE1*/ +void +fm_panic(const char *format, ...) +{ + va_list ap; + + (void) casptr((void *)&fm_panicstr, NULL, (void *)format); + va_start(ap, format); + vpanic(format, ap); + va_end(ap); +} + +/* + * Print any appropriate FMA banner message before the panic message. This + * function is called by panicsys() and prints the message for fm_panic(). + * We print the message here so that it comes after the system is quiesced. + * A one-line summary is recorded in the log only (cmn_err(9F) with "!" prefix). + * The rest of the message is for the console only and not needed in the log, + * so it is printed using console_printf(). We break it up into multiple + * chunks so as to avoid overflowing any small legacy prom_printf() buffers. + */ +void +fm_banner(void) +{ + timespec_t tod; + hrtime_t now; + + if (!fm_panicstr) + return; /* panic was not initiated by fm_panic(); do nothing */ + + if (panicstr) { + tod = panic_hrestime; + now = panic_hrtime; + } else { + gethrestime(&tod); + now = gethrtime_waitfree(); + } + + cmn_err(CE_NOTE, "!SUNW-MSG-ID: %s, " + "TYPE: Error, VER: 1, SEVERITY: Major\n", fm_msgid); + + console_printf( +"\n\rSUNW-MSG-ID: %s, TYPE: Error, VER: 1, SEVERITY: Major\n" +"EVENT-TIME: 0x%lx.0x%lx (0x%llx)\n", + fm_msgid, tod.tv_sec, tod.tv_nsec, (u_longlong_t)now); + + console_printf( +"PLATFORM: %s, CSN: -, HOSTNAME: %s\n" +"SOURCE: %s, REV: %s %s\n", + platform, utsname.nodename, utsname.sysname, + utsname.release, utsname.version); + + console_printf( +"DESC: Errors have been detected that require a reboot to ensure system\n" +"integrity. See %s/%s for more information.\n", + fm_url, fm_msgid); + + console_printf( +"AUTO-RESPONSE: Solaris will attempt to save and diagnose the error telemetry\n" +"IMPACT: The system will sync files, save a crash dump if needed, and reboot\n" +"REC-ACTION: Save the error summary below in case telemetry cannot be saved\n"); + + console_printf("\n"); +} + +/* + * Utility function to write all of the pending ereports to the dump device. + * This function is called at either normal reboot or panic time, and simply + * iterates over the in-transit messages in the ereport sysevent channel. + */ +void +fm_ereport_dump(void) +{ + evchanq_t *chq; + sysevent_t *sep; + erpt_dump_t ed; + + timespec_t tod; + hrtime_t now; + char *buf; + size_t len; + + if (panicstr) { + tod = panic_hrestime; + now = panic_hrtime; + } else { + if (ereport_errorq != NULL) + errorq_drain(ereport_errorq); + gethrestime(&tod); + now = gethrtime_waitfree(); + } + + /* + * In the panic case, sysevent_evc_walk_init() will return NULL. + */ + if ((chq = sysevent_evc_walk_init(ereport_chan, NULL)) == NULL && + !panicstr) + return; /* event channel isn't initialized yet */ + + while ((sep = sysevent_evc_walk_step(chq)) != NULL) { + if ((buf = sysevent_evc_event_attr(sep, &len)) == NULL) + break; + + ed.ed_magic = ERPT_MAGIC; + ed.ed_chksum = checksum32(buf, len); + ed.ed_size = (uint32_t)len; + ed.ed_pad = 0; + ed.ed_hrt_nsec = SE_TIME(sep); + ed.ed_hrt_base = now; + ed.ed_tod_base.sec = tod.tv_sec; + ed.ed_tod_base.nsec = tod.tv_nsec; + + dumpvp_write(&ed, sizeof (ed)); + dumpvp_write(buf, len); + } + + sysevent_evc_walk_fini(chq); +} + +/* + * Post an error report (ereport) to the sysevent error channel. The error + * channel must be established with a prior call to sysevent_evc_create() + * before publication may occur. + */ +void +fm_ereport_post(nvlist_t *ereport, int evc_flag) +{ + size_t nvl_size = 0; + evchan_t *error_chan; + + (void) nvlist_size(ereport, &nvl_size, NV_ENCODE_NATIVE); + if (nvl_size > ERPT_DATA_SZ || nvl_size == 0) { + atomic_add_64(&erpt_kstat_data.erpt_dropped.value.ui64, 1); + return; + } + + if (sysevent_evc_bind(FM_ERROR_CHAN, &error_chan, + EVCH_CREAT|EVCH_HOLD_PEND) != 0) { + atomic_add_64(&erpt_kstat_data.erpt_dropped.value.ui64, 1); + return; + } + + if (sysevent_evc_publish(error_chan, EC_FM, ESC_FM_ERROR, + SUNW_VENDOR, FM_PUB, ereport, evc_flag) != 0) { + atomic_add_64(&erpt_kstat_data.erpt_dropped.value.ui64, 1); + sysevent_evc_unbind(error_chan); + return; + } + sysevent_evc_unbind(error_chan); +} + +/* + * Wrapppers for FM nvlist allocators + */ +/* ARGSUSED */ +static void * +i_fm_alloc(nv_alloc_t *nva, size_t size) +{ + return (kmem_zalloc(size, KM_SLEEP)); +} + +/* ARGSUSED */ +static void +i_fm_free(nv_alloc_t *nva, void *buf, size_t size) +{ + kmem_free(buf, size); +} + +const nv_alloc_ops_t fm_mem_alloc_ops = { + NULL, + NULL, + i_fm_alloc, + i_fm_free, + NULL +}; + +/* + * Create and initialize a new nv_alloc_t for a fixed buffer, buf. A pointer + * to the newly allocated nv_alloc_t structure is returned upon success or NULL + * is returned to indicate that the nv_alloc structure could not be created. + */ +nv_alloc_t * +fm_nva_xcreate(char *buf, size_t bufsz) +{ + nv_alloc_t *nvhdl = kmem_zalloc(sizeof (nv_alloc_t), KM_SLEEP); + + if (bufsz == 0 || nv_alloc_init(nvhdl, nv_fixed_ops, buf, bufsz) != 0) { + kmem_free(nvhdl, sizeof (nv_alloc_t)); + return (NULL); + } + + return (nvhdl); +} + +/* + * Destroy a previously allocated nv_alloc structure. The fixed buffer + * associated with nva must be freed by the caller. + */ +void +fm_nva_xdestroy(nv_alloc_t *nva) +{ + nv_alloc_fini(nva); + kmem_free(nva, sizeof (nv_alloc_t)); +} + +/* + * Create a new nv list. A pointer to a new nv list structure is returned + * upon success or NULL is returned to indicate that the structure could + * not be created. The newly created nv list is created and managed by the + * operations installed in nva. If nva is NULL, the default FMA nva + * operations are installed and used. + * + * When called from the kernel and nva == NULL, this function must be called + * from passive kernel context with no locks held that can prevent a + * sleeping memory allocation from occurring. Otherwise, this function may + * be called from other kernel contexts as long a valid nva created via + * fm_nva_create() is supplied. + */ +nvlist_t * +fm_nvlist_create(nv_alloc_t *nva) +{ + int hdl_alloced = 0; + nvlist_t *nvl; + nv_alloc_t *nvhdl; + + if (nva == NULL) { + nvhdl = kmem_zalloc(sizeof (nv_alloc_t), KM_SLEEP); + + if (nv_alloc_init(nvhdl, &fm_mem_alloc_ops, NULL, 0) != 0) { + kmem_free(nvhdl, sizeof (nv_alloc_t)); + return (NULL); + } + hdl_alloced = 1; + } else { + nvhdl = nva; + } + + if (nvlist_xalloc(&nvl, NV_UNIQUE_NAME, nvhdl) != 0) { + if (hdl_alloced) { + kmem_free(nvhdl, sizeof (nv_alloc_t)); + nv_alloc_fini(nvhdl); + } + return (NULL); + } + + return (nvl); +} + +/* + * Destroy a previously allocated nvlist structure. flag indicates whether + * or not the associated nva structure should be freed (FM_NVA_FREE) or + * retained (FM_NVA_RETAIN). Retaining the nv alloc structure allows + * it to be re-used for future nvlist creation operations. + */ +void +fm_nvlist_destroy(nvlist_t *nvl, int flag) +{ + nv_alloc_t *nva = nvlist_lookup_nv_alloc(nvl); + + nvlist_free(nvl); + + if (nva != NULL) { + if (flag == FM_NVA_FREE) + fm_nva_xdestroy(nva); + } +} + +int +i_fm_payload_set(nvlist_t *payload, const char *name, va_list ap) +{ + int nelem, ret = 0; + data_type_t type; + + while (ret == 0 && name != NULL) { + type = va_arg(ap, data_type_t); + switch (type) { + case DATA_TYPE_BYTE: + ret = nvlist_add_byte(payload, name, + va_arg(ap, uint_t)); + break; + case DATA_TYPE_BYTE_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_byte_array(payload, name, + va_arg(ap, uchar_t *), nelem); + break; + case DATA_TYPE_BOOLEAN_VALUE: + ret = nvlist_add_boolean_value(payload, name, + va_arg(ap, boolean_t)); + break; + case DATA_TYPE_BOOLEAN_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_boolean_array(payload, name, + va_arg(ap, boolean_t *), nelem); + break; + case DATA_TYPE_INT8: + ret = nvlist_add_int8(payload, name, + va_arg(ap, int)); + break; + case DATA_TYPE_INT8_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_int8_array(payload, name, + va_arg(ap, int8_t *), nelem); + break; + case DATA_TYPE_UINT8: + ret = nvlist_add_uint8(payload, name, + va_arg(ap, uint_t)); + break; + case DATA_TYPE_UINT8_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_uint8_array(payload, name, + va_arg(ap, uint8_t *), nelem); + break; + case DATA_TYPE_INT16: + ret = nvlist_add_int16(payload, name, + va_arg(ap, int)); + break; + case DATA_TYPE_INT16_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_int16_array(payload, name, + va_arg(ap, int16_t *), nelem); + break; + case DATA_TYPE_UINT16: + ret = nvlist_add_uint16(payload, name, + va_arg(ap, uint_t)); + break; + case DATA_TYPE_UINT16_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_uint16_array(payload, name, + va_arg(ap, uint16_t *), nelem); + break; + case DATA_TYPE_INT32: + ret = nvlist_add_int32(payload, name, + va_arg(ap, int32_t)); + break; + case DATA_TYPE_INT32_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_int32_array(payload, name, + va_arg(ap, int32_t *), nelem); + break; + case DATA_TYPE_UINT32: + ret = nvlist_add_uint32(payload, name, + va_arg(ap, uint32_t)); + break; + case DATA_TYPE_UINT32_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_uint32_array(payload, name, + va_arg(ap, uint32_t *), nelem); + break; + case DATA_TYPE_INT64: + ret = nvlist_add_int64(payload, name, + va_arg(ap, int64_t)); + break; + case DATA_TYPE_INT64_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_int64_array(payload, name, + va_arg(ap, int64_t *), nelem); + break; + case DATA_TYPE_UINT64: + ret = nvlist_add_uint64(payload, name, + va_arg(ap, uint64_t)); + break; + case DATA_TYPE_UINT64_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_uint64_array(payload, name, + va_arg(ap, uint64_t *), nelem); + break; + case DATA_TYPE_STRING: + ret = nvlist_add_string(payload, name, + va_arg(ap, char *)); + break; + case DATA_TYPE_STRING_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_string_array(payload, name, + va_arg(ap, char **), nelem); + break; + case DATA_TYPE_NVLIST: + ret = nvlist_add_nvlist(payload, name, + va_arg(ap, nvlist_t *)); + break; + case DATA_TYPE_NVLIST_ARRAY: + nelem = va_arg(ap, int); + ret = nvlist_add_nvlist_array(payload, name, + va_arg(ap, nvlist_t **), nelem); + break; + default: + ret = EINVAL; + } + + name = va_arg(ap, char *); + } + return (ret); +} + +void +fm_payload_set(nvlist_t *payload, ...) +{ + int ret; + const char *name; + va_list ap; + + va_start(ap, payload); + name = va_arg(ap, char *); + ret = i_fm_payload_set(payload, name, ap); + va_end(ap); + + if (ret) + atomic_add_64( + &erpt_kstat_data.payload_set_failed.value.ui64, 1); +} + +/* + * Set-up and validate the members of an ereport event according to: + * + * Member name Type Value + * ==================================================== + * class string ereport + * version uint8_t 0 + * ena uint64_t + * detector nvlist_t + * ereport-payload nvlist_t + * + */ +void +fm_ereport_set(nvlist_t *ereport, int version, const char *erpt_class, + uint64_t ena, const nvlist_t *detector, ...) +{ + char ereport_class[FM_MAX_CLASS]; + const char *name; + va_list ap; + int ret; + + if (version != FM_EREPORT_VERS0) { + atomic_add_64(&erpt_kstat_data.erpt_set_failed.value.ui64, 1); + return; + } + + (void) snprintf(ereport_class, FM_MAX_CLASS, "%s.%s", + FM_EREPORT_CLASS, erpt_class); + if (nvlist_add_string(ereport, FM_CLASS, ereport_class) != 0) { + atomic_add_64(&erpt_kstat_data.erpt_set_failed.value.ui64, 1); + return; + } + + if (nvlist_add_uint64(ereport, FM_EREPORT_ENA, ena)) { + atomic_add_64(&erpt_kstat_data.erpt_set_failed.value.ui64, 1); + } + + if (nvlist_add_nvlist(ereport, FM_EREPORT_DETECTOR, + (nvlist_t *)detector) != 0) { + atomic_add_64(&erpt_kstat_data.erpt_set_failed.value.ui64, 1); + } + + va_start(ap, detector); + name = va_arg(ap, const char *); + ret = i_fm_payload_set(ereport, name, ap); + va_end(ap); + + if (ret) + atomic_add_64(&erpt_kstat_data.erpt_set_failed.value.ui64, 1); +} + +/* + * Set-up and validate the members of an hc fmri according to; + * + * Member name Type Value + * =================================================== + * version uint8_t 0 + * auth nvlist_t + * hc-name string + * hc-id string + * + * Note that auth and hc-id are optional members. + */ + +#define HC_MAXPAIRS 20 +#define HC_MAXNAMELEN 50 + +static int +fm_fmri_hc_set_common(nvlist_t *fmri, int version, const nvlist_t *auth) +{ + if (version != FM_HC_SCHEME_VERSION) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return (0); + } + + if (nvlist_add_uint8(fmri, FM_VERSION, version) != 0 || + nvlist_add_string(fmri, FM_FMRI_SCHEME, FM_FMRI_SCHEME_HC) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return (0); + } + + if (auth != NULL && nvlist_add_nvlist(fmri, FM_FMRI_AUTHORITY, + (nvlist_t *)auth) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return (0); + } + + return (1); +} + +void +fm_fmri_hc_set(nvlist_t *fmri, int version, const nvlist_t *auth, + nvlist_t *snvl, int npairs, ...) +{ + nv_alloc_t *nva = nvlist_lookup_nv_alloc(fmri); + nvlist_t *pairs[HC_MAXPAIRS]; + va_list ap; + int i; + + if (!fm_fmri_hc_set_common(fmri, version, auth)) + return; + + npairs = MIN(npairs, HC_MAXPAIRS); + + va_start(ap, npairs); + for (i = 0; i < npairs; i++) { + const char *name = va_arg(ap, const char *); + uint32_t id = va_arg(ap, uint32_t); + char idstr[11]; + + (void) snprintf(idstr, sizeof (idstr), "%u", id); + + pairs[i] = fm_nvlist_create(nva); + if (nvlist_add_string(pairs[i], FM_FMRI_HC_NAME, name) != 0 || + nvlist_add_string(pairs[i], FM_FMRI_HC_ID, idstr) != 0) { + atomic_add_64( + &erpt_kstat_data.fmri_set_failed.value.ui64, 1); + } + } + va_end(ap); + + if (nvlist_add_nvlist_array(fmri, FM_FMRI_HC_LIST, pairs, npairs) != 0) + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + + for (i = 0; i < npairs; i++) + fm_nvlist_destroy(pairs[i], FM_NVA_RETAIN); + + if (snvl != NULL) { + if (nvlist_add_nvlist(fmri, FM_FMRI_HC_SPECIFIC, snvl) != 0) { + atomic_add_64( + &erpt_kstat_data.fmri_set_failed.value.ui64, 1); + } + } +} + +/* + * Set-up and validate the members of an dev fmri according to: + * + * Member name Type Value + * ==================================================== + * version uint8_t 0 + * auth nvlist_t + * devpath string + * devid string + * + * Note that auth and devid are optional members. + */ +void +fm_fmri_dev_set(nvlist_t *fmri_dev, int version, const nvlist_t *auth, + const char *devpath, const char *devid) +{ + if (version != DEV_SCHEME_VERSION0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (nvlist_add_uint8(fmri_dev, FM_VERSION, version) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (nvlist_add_string(fmri_dev, FM_FMRI_SCHEME, + FM_FMRI_SCHEME_DEV) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (auth != NULL) { + if (nvlist_add_nvlist(fmri_dev, FM_FMRI_AUTHORITY, + (nvlist_t *)auth) != 0) { + atomic_add_64( + &erpt_kstat_data.fmri_set_failed.value.ui64, 1); + } + } + + if (nvlist_add_string(fmri_dev, FM_FMRI_DEV_PATH, devpath) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + } + + if (devid != NULL) + if (nvlist_add_string(fmri_dev, FM_FMRI_DEV_ID, devid) != 0) + atomic_add_64( + &erpt_kstat_data.fmri_set_failed.value.ui64, 1); +} + +/* + * Set-up and validate the members of an cpu fmri according to: + * + * Member name Type Value + * ==================================================== + * version uint8_t 0 + * auth nvlist_t + * cpuid uint32_t + * cpumask uint8_t + * serial uint64_t + * + * Note that auth, cpumask, serial are optional members. + * + */ +void +fm_fmri_cpu_set(nvlist_t *fmri_cpu, int version, const nvlist_t *auth, + uint32_t cpu_id, uint8_t *cpu_maskp, const char *serial_idp) +{ + uint64_t *failedp = &erpt_kstat_data.fmri_set_failed.value.ui64; + + if (version < CPU_SCHEME_VERSION1) { + atomic_add_64(failedp, 1); + return; + } + + if (nvlist_add_uint8(fmri_cpu, FM_VERSION, version) != 0) { + atomic_add_64(failedp, 1); + return; + } + + if (nvlist_add_string(fmri_cpu, FM_FMRI_SCHEME, + FM_FMRI_SCHEME_CPU) != 0) { + atomic_add_64(failedp, 1); + return; + } + + if (auth != NULL && nvlist_add_nvlist(fmri_cpu, FM_FMRI_AUTHORITY, + (nvlist_t *)auth) != 0) + atomic_add_64(failedp, 1); + + if (nvlist_add_uint32(fmri_cpu, FM_FMRI_CPU_ID, cpu_id) != 0) + atomic_add_64(failedp, 1); + + if (cpu_maskp != NULL && nvlist_add_uint8(fmri_cpu, FM_FMRI_CPU_MASK, + *cpu_maskp) != 0) + atomic_add_64(failedp, 1); + + if (serial_idp == NULL || nvlist_add_string(fmri_cpu, + FM_FMRI_CPU_SERIAL_ID, (char *)serial_idp) != 0) + atomic_add_64(failedp, 1); +} + +/* + * Set-up and validate the members of a mem according to: + * + * Member name Type Value + * ==================================================== + * version uint8_t 0 + * auth nvlist_t [optional] + * unum string + * serial string [optional*] + * offset uint64_t [optional] + * + * * serial is required if offset is present + */ +void +fm_fmri_mem_set(nvlist_t *fmri, int version, const nvlist_t *auth, + const char *unum, const char *serial, uint64_t offset) +{ + if (version != MEM_SCHEME_VERSION0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (!serial && (offset != (uint64_t)-1)) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (nvlist_add_uint8(fmri, FM_VERSION, version) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (nvlist_add_string(fmri, FM_FMRI_SCHEME, FM_FMRI_SCHEME_MEM) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (auth != NULL) { + if (nvlist_add_nvlist(fmri, FM_FMRI_AUTHORITY, + (nvlist_t *)auth) != 0) { + atomic_add_64( + &erpt_kstat_data.fmri_set_failed.value.ui64, 1); + } + } + + if (nvlist_add_string(fmri, FM_FMRI_MEM_UNUM, unum) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + } + + if (serial != NULL) { + if (nvlist_add_string_array(fmri, FM_FMRI_MEM_SERIAL_ID, + (char **)&serial, 1) != 0) { + atomic_add_64( + &erpt_kstat_data.fmri_set_failed.value.ui64, 1); + } + if (offset != (uint64_t)-1) { + if (nvlist_add_uint64(fmri, FM_FMRI_MEM_OFFSET, + offset) != 0) { + atomic_add_64(&erpt_kstat_data. + fmri_set_failed.value.ui64, 1); + } + } + } +} + +void +fm_fmri_zfs_set(nvlist_t *fmri, int version, uint64_t pool_guid, + uint64_t vdev_guid) +{ + if (version != ZFS_SCHEME_VERSION0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (nvlist_add_uint8(fmri, FM_VERSION, version) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (nvlist_add_string(fmri, FM_FMRI_SCHEME, FM_FMRI_SCHEME_ZFS) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + return; + } + + if (nvlist_add_uint64(fmri, FM_FMRI_ZFS_POOL, pool_guid) != 0) { + atomic_add_64(&erpt_kstat_data.fmri_set_failed.value.ui64, 1); + } + + if (vdev_guid != 0) { + if (nvlist_add_uint64(fmri, FM_FMRI_ZFS_VDEV, vdev_guid) != 0) { + atomic_add_64( + &erpt_kstat_data.fmri_set_failed.value.ui64, 1); + } + } +} + +uint64_t +fm_ena_increment(uint64_t ena) +{ + uint64_t new_ena; + + switch (ENA_FORMAT(ena)) { + case FM_ENA_FMT1: + new_ena = ena + (1 << ENA_FMT1_GEN_SHFT); + break; + case FM_ENA_FMT2: + new_ena = ena + (1 << ENA_FMT2_GEN_SHFT); + break; + default: + new_ena = 0; + } + + return (new_ena); +} + +uint64_t +fm_ena_generate_cpu(uint64_t timestamp, processorid_t cpuid, uchar_t format) +{ + uint64_t ena = 0; + + switch (format) { + case FM_ENA_FMT1: + if (timestamp) { + ena = (uint64_t)((format & ENA_FORMAT_MASK) | + ((cpuid << ENA_FMT1_CPUID_SHFT) & + ENA_FMT1_CPUID_MASK) | + ((timestamp << ENA_FMT1_TIME_SHFT) & + ENA_FMT1_TIME_MASK)); + } else { + ena = (uint64_t)((format & ENA_FORMAT_MASK) | + ((cpuid << ENA_FMT1_CPUID_SHFT) & + ENA_FMT1_CPUID_MASK) | + ((gethrtime_waitfree() << ENA_FMT1_TIME_SHFT) & + ENA_FMT1_TIME_MASK)); + } + break; + case FM_ENA_FMT2: + ena = (uint64_t)((format & ENA_FORMAT_MASK) | + ((timestamp << ENA_FMT2_TIME_SHFT) & ENA_FMT2_TIME_MASK)); + break; + default: + break; + } + + return (ena); +} + +uint64_t +fm_ena_generate(uint64_t timestamp, uchar_t format) +{ + return (fm_ena_generate_cpu(timestamp, CPU->cpu_id, format)); +} + +uint64_t +fm_ena_generation_get(uint64_t ena) +{ + uint64_t gen; + + switch (ENA_FORMAT(ena)) { + case FM_ENA_FMT1: + gen = (ena & ENA_FMT1_GEN_MASK) >> ENA_FMT1_GEN_SHFT; + break; + case FM_ENA_FMT2: + gen = (ena & ENA_FMT2_GEN_MASK) >> ENA_FMT2_GEN_SHFT; + break; + default: + gen = 0; + break; + } + + return (gen); +} + +uchar_t +fm_ena_format_get(uint64_t ena) +{ + + return (ENA_FORMAT(ena)); +} + +uint64_t +fm_ena_id_get(uint64_t ena) +{ + uint64_t id; + + switch (ENA_FORMAT(ena)) { + case FM_ENA_FMT1: + id = (ena & ENA_FMT1_ID_MASK) >> ENA_FMT1_ID_SHFT; + break; + case FM_ENA_FMT2: + id = (ena & ENA_FMT2_ID_MASK) >> ENA_FMT2_ID_SHFT; + break; + default: + id = 0; + } + + return (id); +} + +uint64_t +fm_ena_time_get(uint64_t ena) +{ + uint64_t time; + + switch (ENA_FORMAT(ena)) { + case FM_ENA_FMT1: + time = (ena & ENA_FMT1_TIME_MASK) >> ENA_FMT1_TIME_SHFT; + break; + case FM_ENA_FMT2: + time = (ena & ENA_FMT2_TIME_MASK) >> ENA_FMT2_TIME_SHFT; + break; + default: + time = 0; + } + + return (time); +} + +/* + * Convert a getpcstack() trace to symbolic name+offset, and add the resulting + * string array to a Fault Management ereport as FM_EREPORT_PAYLOAD_NAME_STACK. + */ +void +fm_payload_stack_add(nvlist_t *payload, const pc_t *stack, int depth) +{ + int i; + char *sym; + ulong_t off; + char *stkpp[FM_STK_DEPTH]; + char buf[FM_STK_DEPTH * FM_SYM_SZ]; + char *stkp = buf; + + for (i = 0; i < depth && i != FM_STK_DEPTH; i++, stkp += FM_SYM_SZ) { + if ((sym = kobj_getsymname(stack[i], &off)) != NULL) + (void) snprintf(stkp, FM_SYM_SZ, "%s+%lx", sym, off); + else + (void) snprintf(stkp, FM_SYM_SZ, "%lx", (long)stack[i]); + stkpp[i] = stkp; + } + + fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_STACK, + DATA_TYPE_STRING_ARRAY, depth, stkpp, NULL); +} + +void +print_msg_hwerr(ctid_t ct_id, proc_t *p) +{ + uprintf("Killed process %d (%s) in contract id %d " + "due to hardware error\n", p->p_pid, p->p_user.u_comm, ct_id); +} diff --git a/module/zcommon/include/sys/fm/fs/zfs.h b/module/zfs/include/sys/fm/fs/zfs.h similarity index 100% rename from module/zcommon/include/sys/fm/fs/zfs.h rename to module/zfs/include/sys/fm/fs/zfs.h diff --git a/module/zfs/include/sys/fm/protocol.h b/module/zfs/include/sys/fm/protocol.h new file mode 100644 index 0000000000..767fb07d81 --- /dev/null +++ b/module/zfs/include/sys/fm/protocol.h @@ -0,0 +1,336 @@ +/* + * 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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FM_PROTOCOL_H +#define _SYS_FM_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +#include +#include +#else +#include +#include +#endif +#include + +/* FM common member names */ +#define FM_CLASS "class" +#define FM_VERSION "version" + +/* FM event class values */ +#define FM_EREPORT_CLASS "ereport" +#define FM_FAULT_CLASS "fault" +#define FM_RSRC_CLASS "resource" +#define FM_LIST_EVENT "list" + +/* FM list.* event class values */ +#define FM_LIST_SUSPECT_CLASS FM_LIST_EVENT ".suspect" +#define FM_LIST_ISOLATED_CLASS FM_LIST_EVENT ".isolated" +#define FM_LIST_REPAIRED_CLASS FM_LIST_EVENT ".repaired" +#define FM_LIST_UPDATED_CLASS FM_LIST_EVENT ".updated" +#define FM_LIST_RESOLVED_CLASS FM_LIST_EVENT ".resolved" + +/* ereport class subcategory values */ +#define FM_ERROR_CPU "cpu" +#define FM_ERROR_IO "io" + +/* ereport version and payload member names */ +#define FM_EREPORT_VERS0 0 +#define FM_EREPORT_VERSION FM_EREPORT_VERS0 + +/* ereport payload member names */ +#define FM_EREPORT_DETECTOR "detector" +#define FM_EREPORT_ENA "ena" + +/* list.* event payload member names */ +#define FM_LIST_EVENT_SIZE "list-sz" + +/* + * list.suspect, isolated, updated, repaired and resolved + * versions/payload member names. + */ +#define FM_SUSPECT_UUID "uuid" +#define FM_SUSPECT_DIAG_CODE "code" +#define FM_SUSPECT_DIAG_TIME "diag-time" +#define FM_SUSPECT_DE "de" +#define FM_SUSPECT_FAULT_LIST "fault-list" +#define FM_SUSPECT_FAULT_SZ "fault-list-sz" +#define FM_SUSPECT_FAULT_STATUS "fault-status" +#define FM_SUSPECT_MESSAGE "message" +#define FM_SUSPECT_RETIRE "retire" +#define FM_SUSPECT_RESPONSE "response" +#define FM_SUSPECT_SEVERITY "severity" + +#define FM_SUSPECT_VERS0 0 +#define FM_SUSPECT_VERSION FM_SUSPECT_VERS0 + +#define FM_SUSPECT_FAULTY 0x1 +#define FM_SUSPECT_UNUSABLE 0x2 +#define FM_SUSPECT_NOT_PRESENT 0x4 +#define FM_SUSPECT_DEGRADED 0x8 +#define FM_SUSPECT_REPAIRED 0x10 +#define FM_SUSPECT_REPLACED 0x20 +#define FM_SUSPECT_ACQUITTED 0x40 + +/* fault event versions and payload member names */ +#define FM_FAULT_VERS0 0 +#define FM_FAULT_VERSION FM_FAULT_VERS0 + +#define FM_FAULT_ASRU "asru" +#define FM_FAULT_FRU "fru" +#define FM_FAULT_FRU_LABEL "fru-label" +#define FM_FAULT_CERTAINTY "certainty" +#define FM_FAULT_RESOURCE "resource" +#define FM_FAULT_LOCATION "location" + +/* resource event versions and payload member names */ +#define FM_RSRC_VERS0 0 +#define FM_RSRC_VERSION FM_RSRC_VERS0 +#define FM_RSRC_RESOURCE "resource" + +/* resource.fm.asru.* payload member names */ +#define FM_RSRC_ASRU_UUID "uuid" +#define FM_RSRC_ASRU_CODE "code" +#define FM_RSRC_ASRU_FAULTY "faulty" +#define FM_RSRC_ASRU_REPAIRED "repaired" +#define FM_RSRC_ASRU_REPLACED "replaced" +#define FM_RSRC_ASRU_ACQUITTED "acquitted" +#define FM_RSRC_ASRU_UNUSABLE "unusable" +#define FM_RSRC_ASRU_EVENT "event" + +/* resource.fm.xprt.* versions and payload member names */ +#define FM_RSRC_XPRT_VERS0 0 +#define FM_RSRC_XPRT_VERSION FM_RSRC_XPRT_VERS0 +#define FM_RSRC_XPRT_UUID "uuid" +#define FM_RSRC_XPRT_SUBCLASS "subclass" +#define FM_RSRC_XPRT_FAULT_STATUS "fault-status" +#define FM_RSRC_XPRT_FAULT_HAS_ASRU "fault-has-asru" + +/* + * FM ENA Format Macros + */ +#define ENA_FORMAT_MASK 0x3 +#define ENA_FORMAT(ena) ((ena) & ENA_FORMAT_MASK) + +/* ENA format types */ +#define FM_ENA_FMT0 0 +#define FM_ENA_FMT1 1 +#define FM_ENA_FMT2 2 + +/* Format 1 */ +#define ENA_FMT1_GEN_MASK 0x00000000000003FCull +#define ENA_FMT1_ID_MASK 0xFFFFFFFFFFFFFC00ull +#define ENA_FMT1_CPUID_MASK 0x00000000000FFC00ull +#define ENA_FMT1_TIME_MASK 0xFFFFFFFFFFF00000ull +#define ENA_FMT1_GEN_SHFT 2 +#define ENA_FMT1_ID_SHFT 10 +#define ENA_FMT1_CPUID_SHFT ENA_FMT1_ID_SHFT +#define ENA_FMT1_TIME_SHFT 20 + +/* Format 2 */ +#define ENA_FMT2_GEN_MASK 0x00000000000003FCull +#define ENA_FMT2_ID_MASK 0xFFFFFFFFFFFFFC00ull +#define ENA_FMT2_TIME_MASK ENA_FMT2_ID_MASK +#define ENA_FMT2_GEN_SHFT 2 +#define ENA_FMT2_ID_SHFT 10 +#define ENA_FMT2_TIME_SHFT ENA_FMT2_ID_SHFT + +/* Common FMRI type names */ +#define FM_FMRI_AUTHORITY "authority" +#define FM_FMRI_SCHEME "scheme" +#define FM_FMRI_SVC_AUTHORITY "svc-authority" +#define FM_FMRI_FACILITY "facility" + +/* FMRI authority-type member names */ +#define FM_FMRI_AUTH_CHASSIS "chassis-id" +#define FM_FMRI_AUTH_PRODUCT "product-id" +#define FM_FMRI_AUTH_DOMAIN "domain-id" +#define FM_FMRI_AUTH_SERVER "server-id" +#define FM_FMRI_AUTH_HOST "host-id" + +#define FM_AUTH_VERS0 0 +#define FM_FMRI_AUTH_VERSION FM_AUTH_VERS0 + +/* scheme name values */ +#define FM_FMRI_SCHEME_FMD "fmd" +#define FM_FMRI_SCHEME_DEV "dev" +#define FM_FMRI_SCHEME_HC "hc" +#define FM_FMRI_SCHEME_SVC "svc" +#define FM_FMRI_SCHEME_CPU "cpu" +#define FM_FMRI_SCHEME_MEM "mem" +#define FM_FMRI_SCHEME_MOD "mod" +#define FM_FMRI_SCHEME_PKG "pkg" +#define FM_FMRI_SCHEME_LEGACY "legacy-hc" +#define FM_FMRI_SCHEME_ZFS "zfs" + +/* Scheme versions */ +#define FMD_SCHEME_VERSION0 0 +#define FM_FMD_SCHEME_VERSION FMD_SCHEME_VERSION0 +#define DEV_SCHEME_VERSION0 0 +#define FM_DEV_SCHEME_VERSION DEV_SCHEME_VERSION0 +#define FM_HC_VERS0 0 +#define FM_HC_SCHEME_VERSION FM_HC_VERS0 +#define CPU_SCHEME_VERSION0 0 +#define CPU_SCHEME_VERSION1 1 +#define FM_CPU_SCHEME_VERSION CPU_SCHEME_VERSION1 +#define MEM_SCHEME_VERSION0 0 +#define FM_MEM_SCHEME_VERSION MEM_SCHEME_VERSION0 +#define MOD_SCHEME_VERSION0 0 +#define FM_MOD_SCHEME_VERSION MOD_SCHEME_VERSION0 +#define PKG_SCHEME_VERSION0 0 +#define FM_PKG_SCHEME_VERSION PKG_SCHEME_VERSION0 +#define LEGACY_SCHEME_VERSION0 0 +#define FM_LEGACY_SCHEME_VERSION LEGACY_SCHEME_VERSION0 +#define SVC_SCHEME_VERSION0 0 +#define FM_SVC_SCHEME_VERSION SVC_SCHEME_VERSION0 +#define ZFS_SCHEME_VERSION0 0 +#define FM_ZFS_SCHEME_VERSION ZFS_SCHEME_VERSION0 + +/* hc scheme member names */ +#define FM_FMRI_HC_SERIAL_ID "serial" +#define FM_FMRI_HC_PART "part" +#define FM_FMRI_HC_REVISION "revision" +#define FM_FMRI_HC_ROOT "hc-root" +#define FM_FMRI_HC_LIST_SZ "hc-list-sz" +#define FM_FMRI_HC_LIST "hc-list" +#define FM_FMRI_HC_SPECIFIC "hc-specific" + +/* facility member names */ +#define FM_FMRI_FACILITY_NAME "facility-name" +#define FM_FMRI_FACILITY_TYPE "facility-type" + +/* hc-list version and member names */ +#define FM_FMRI_HC_NAME "hc-name" +#define FM_FMRI_HC_ID "hc-id" + +#define HC_LIST_VERSION0 0 +#define FM_HC_LIST_VERSION HC_LIST_VERSION0 + +/* hc-specific member names */ +#define FM_FMRI_HC_SPECIFIC_OFFSET "offset" +#define FM_FMRI_HC_SPECIFIC_PHYSADDR "physaddr" + +/* fmd module scheme member names */ +#define FM_FMRI_FMD_NAME "mod-name" +#define FM_FMRI_FMD_VERSION "mod-version" + +/* dev scheme member names */ +#define FM_FMRI_DEV_ID "devid" +#define FM_FMRI_DEV_PATH "device-path" + +/* pkg scheme member names */ +#define FM_FMRI_PKG_BASEDIR "pkg-basedir" +#define FM_FMRI_PKG_INST "pkg-inst" +#define FM_FMRI_PKG_VERSION "pkg-version" + +/* svc scheme member names */ +#define FM_FMRI_SVC_NAME "svc-name" +#define FM_FMRI_SVC_INSTANCE "svc-instance" +#define FM_FMRI_SVC_CONTRACT_ID "svc-contract-id" + +/* svc-authority member names */ +#define FM_FMRI_SVC_AUTH_SCOPE "scope" +#define FM_FMRI_SVC_AUTH_SYSTEM_FQN "system-fqn" + +/* cpu scheme member names */ +#define FM_FMRI_CPU_ID "cpuid" +#define FM_FMRI_CPU_SERIAL_ID "serial" +#define FM_FMRI_CPU_MASK "cpumask" +#define FM_FMRI_CPU_VID "cpuvid" +#define FM_FMRI_CPU_CPUFRU "cpufru" +#define FM_FMRI_CPU_CACHE_INDEX "cacheindex" +#define FM_FMRI_CPU_CACHE_WAY "cacheway" +#define FM_FMRI_CPU_CACHE_BIT "cachebit" +#define FM_FMRI_CPU_CACHE_TYPE "cachetype" + +#define FM_FMRI_CPU_CACHE_TYPE_L2 0 +#define FM_FMRI_CPU_CACHE_TYPE_L3 1 + +/* legacy-hc scheme member names */ +#define FM_FMRI_LEGACY_HC "component" +#define FM_FMRI_LEGACY_HC_PREFIX FM_FMRI_SCHEME_HC":///" \ + FM_FMRI_LEGACY_HC"=" + +/* mem scheme member names */ +#define FM_FMRI_MEM_UNUM "unum" +#define FM_FMRI_MEM_SERIAL_ID "serial" +#define FM_FMRI_MEM_PHYSADDR "physaddr" +#define FM_FMRI_MEM_MEMCONFIG "memconfig" +#define FM_FMRI_MEM_OFFSET "offset" + +/* mod scheme member names */ +#define FM_FMRI_MOD_PKG "mod-pkg" +#define FM_FMRI_MOD_NAME "mod-name" +#define FM_FMRI_MOD_ID "mod-id" +#define FM_FMRI_MOD_DESC "mod-desc" + +/* zfs scheme member names */ +#define FM_FMRI_ZFS_POOL "pool" +#define FM_FMRI_ZFS_VDEV "vdev" + +extern nv_alloc_t *fm_nva_xcreate(char *, size_t); +extern void fm_nva_xdestroy(nv_alloc_t *); + +extern nvlist_t *fm_nvlist_create(nv_alloc_t *); +extern void fm_nvlist_destroy(nvlist_t *, int); + +#define FM_NVA_FREE 0 /* free allocator on nvlist_destroy */ +#define FM_NVA_RETAIN 1 /* keep allocator on nvlist_destroy */ + +extern void fm_ereport_set(nvlist_t *, int, const char *, uint64_t, + const nvlist_t *, ...); +extern void fm_payload_set(nvlist_t *, ...); +extern int i_fm_payload_set(nvlist_t *, const char *, va_list); +extern void fm_fmri_hc_set(nvlist_t *, int, const nvlist_t *, nvlist_t *, + int, ...); +extern void fm_fmri_dev_set(nvlist_t *, int, const nvlist_t *, const char *, + const char *); +extern void fm_fmri_de_set(nvlist_t *, int, const nvlist_t *, const char *); +extern void fm_fmri_cpu_set(nvlist_t *, int, const nvlist_t *, uint32_t, + uint8_t *, const char *); +extern void fm_fmri_mem_set(nvlist_t *, int, const nvlist_t *, const char *, + const char *, uint64_t); +extern void fm_authority_set(nvlist_t *, int, const char *, const char *, + const char *, const char *); +extern void fm_fmri_zfs_set(nvlist_t *, int, uint64_t, uint64_t); + +extern uint64_t fm_ena_increment(uint64_t); +extern uint64_t fm_ena_generate(uint64_t, uchar_t); +extern uint64_t fm_ena_generate_cpu(uint64_t, processorid_t, uchar_t); +extern uint64_t fm_ena_generation_get(uint64_t); +extern uchar_t fm_ena_format_get(uint64_t); +extern uint64_t fm_ena_id_get(uint64_t); +extern uint64_t fm_ena_time_get(uint64_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_PROTOCOL_H */ diff --git a/module/zfs/include/sys/fm/util.h b/module/zfs/include/sys/fm/util.h new file mode 100644 index 0000000000..4e19e4de09 --- /dev/null +++ b/module/zfs/include/sys/fm/util.h @@ -0,0 +1,105 @@ +/* + * 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 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FM_UTIL_H +#define _SYS_FM_UTIL_H + + + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Shared user/kernel definitions for class length, error channel name, + * and kernel event publisher string. + */ +#define FM_MAX_CLASS 100 +#define FM_ERROR_CHAN "com.sun:fm:error" +#define FM_PUB "fm" + +/* + * ereport dump device transport support + * + * Ereports are written out to the dump device at a proscribed offset from the + * end, similar to in-transit log messages. The ereports are represented as a + * erpt_dump_t header followed by ed_size bytes of packed native nvlist data. + * + * NOTE: All of these constants and the header must be defined so they have the + * same representation for *both* 32-bit and 64-bit producers and consumers. + */ +#define ERPT_MAGIC 0xf00d4eddU +#define ERPT_MAX_ERRS 16 +#define ERPT_DATA_SZ (6 * 1024) +#define ERPT_EVCH_MAX 256 +#define ERPT_HIWAT 64 + +typedef struct erpt_dump { + uint32_t ed_magic; /* ERPT_MAGIC or zero to indicate end */ + uint32_t ed_chksum; /* checksum32() of packed nvlist data */ + uint32_t ed_size; /* ereport (nvl) fixed buf size */ + uint32_t ed_pad; /* reserved for future use */ + hrtime_t ed_hrt_nsec; /* hrtime of this ereport */ + hrtime_t ed_hrt_base; /* hrtime sample corresponding to ed_tod_base */ + struct { + uint64_t sec; /* seconds since gettimeofday() Epoch */ + uint64_t nsec; /* nanoseconds past ed_tod_base.sec */ + } ed_tod_base; +} erpt_dump_t; + +#ifdef _KERNEL +#include + +#define FM_STK_DEPTH 20 /* maximum stack depth */ +#define FM_SYM_SZ 64 /* maximum symbol size */ +#define FM_ERR_PIL 2 /* PIL for ereport_errorq drain processing */ + +#define FM_EREPORT_PAYLOAD_NAME_STACK "stack" + +extern errorq_t *ereport_errorq; +extern void *ereport_dumpbuf; +extern size_t ereport_dumplen; + +extern void fm_init(void); +extern void fm_nvprint(nvlist_t *); +extern void fm_panic(const char *, ...); +extern void fm_banner(void); + +extern void fm_ereport_dump(void); +extern void fm_ereport_post(nvlist_t *, int); + +extern void fm_payload_stack_add(nvlist_t *, const pc_t *, int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_UTIL_H */ diff --git a/module/zfs/spa_errlog.c b/module/zfs/spa_errlog.c index 480ea9c86f..50ad22e9ef 100644 --- a/module/zfs/spa_errlog.c +++ b/module/zfs/spa_errlog.c @@ -438,9 +438,6 @@ spa_errlog_sync(spa_t *spa, uint64_t txg) #if defined(_KERNEL) && defined(HAVE_SPL) /* error handling */ EXPORT_SYMBOL(spa_log_error); -EXPORT_SYMBOL(zfs_ereport_post); -EXPORT_SYMBOL(zfs_post_remove); -EXPORT_SYMBOL(zfs_post_autoreplace); EXPORT_SYMBOL(spa_get_errlog_size); EXPORT_SYMBOL(spa_get_errlog); EXPORT_SYMBOL(spa_errlog_rotate); diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index 18c4359075..f350106c58 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -1487,7 +1487,6 @@ EXPORT_SYMBOL(spa_get_space); EXPORT_SYMBOL(spa_get_dspace); EXPORT_SYMBOL(spa_get_asize); EXPORT_SYMBOL(spa_max_replication); -EXPORT_SYMBOL(spa_busy); EXPORT_SYMBOL(spa_get_failmode); EXPORT_SYMBOL(spa_suspended); diff --git a/module/zfs/txg.c b/module/zfs/txg.c index b83f45b3b2..a4212fd8db 100644 --- a/module/zfs/txg.c +++ b/module/zfs/txg.c @@ -348,8 +348,8 @@ txg_dispatch_callbacks(dsl_pool_t *dp, uint64_t txg) * Commit callback taskq hasn't been created yet. */ tx->tx_commit_cb_taskq = taskq_create("tx_commit_cb", - max_ncpus, minclsyspri, max_ncpus, max_ncpus * 4, - TASKQ_PREPOPULATE); + 100, minclsyspri, max_ncpus, max_ncpus * 4, + TASKQ_PREPOPULATE | TASKQ_THREADS_CPU_PCT); } tcb = kmem_alloc(sizeof (tx_cb_t), KM_SLEEP); @@ -446,8 +446,6 @@ txg_sync_thread(dsl_pool_t *dp) rw_exit(&tx->tx_suspend); cv_broadcast(&tx->tx_sync_done_cv); } - - thread_exit(); } static void @@ -492,8 +490,6 @@ txg_quiesce_thread(dsl_pool_t *dp) cv_broadcast(&tx->tx_sync_more_cv); cv_broadcast(&tx->tx_quiesce_done_cv); } - - thread_exit(); } /* diff --git a/module/zfs/vdev_raidz.c b/module/zfs/vdev_raidz.c index c808cf3862..483009d7d0 100644 --- a/module/zfs/vdev_raidz.c +++ b/module/zfs/vdev_raidz.c @@ -139,7 +139,7 @@ typedef struct raidz_map { (mask) = (x) & 0x8080808080808080ULL; \ (mask) = ((mask) << 1) - ((mask) >> 7); \ (x) = (((x) << 1) & 0xfefefefefefefefeULL) ^ \ - ((mask) & 0x1d1d1d1d1d1d1d1d); \ + ((mask) & 0x1d1d1d1d1d1d1d1dULL); \ } #define VDEV_RAIDZ_64MUL_4(x, mask) \ diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index d73b83499c..b039414dbe 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -67,7 +67,6 @@ #include "zfs_namecheck.h" #include "zfs_prop.h" #include "zfs_deleg.h" -#include "zfs_config.h" extern struct modlfs zfs_modlfs; @@ -3796,27 +3795,15 @@ static struct dev_ops zfs_dev_ops = { }; static struct modldrv zfs_modldrv = { -#ifdef HAVE_SPL - NULL, -#else &mod_driverops, -#endif /* HAVE_SPL */ "ZFS storage pool", &zfs_dev_ops }; static struct modlinkage modlinkage = { MODREV_1, -#ifdef HAVE_ZPL (void *)&zfs_modlfs, -#else - NULL, -#endif /* HAVE_ZPL */ (void *)&zfs_modldrv, -#ifdef HAVE_SPL - ZFS_MAJOR, - ZFS_MINORS, -#endif /* HAVE_SPL */ NULL }; @@ -3847,8 +3834,6 @@ _init(void) ASSERT(error == 0); mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL); - printk(KERN_INFO "ZFS: Loaded ZFS Filesystem v%s\n", ZFS_META_VERSION); - return (0); } @@ -3881,17 +3866,8 @@ _fini(void) return (error); } -#ifdef HAVE_SPL -spl_module_init(_init); -spl_module_exit(_fini); - -MODULE_AUTHOR("Sun Microsystems, Inc"); -MODULE_DESCRIPTION("ZFS"); -MODULE_LICENSE("CDDL"); -#else int _info(struct modinfo *modinfop) { return (mod_info(&modlinkage, modinfop)); } -#endif /* HAVE_SPL */ diff --git a/module/zfs/zfs_rlock.c b/module/zfs/zfs_rlock.c index 4de8d8a2df..1e4988d7fd 100644 --- a/module/zfs/zfs_rlock.c +++ b/module/zfs/zfs_rlock.c @@ -460,7 +460,7 @@ static void zfs_range_unlock_reader(znode_t *zp, rl_t *remove) { avl_tree_t *tree = &zp->z_range_avl; - rl_t *rl, *next; + rl_t *rl, *next = NULL; uint64_t len; /* diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c deleted file mode 100644 index cfd3b3dbdb..0000000000 --- a/module/zfs/zvol.c +++ /dev/null @@ -1,1835 +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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * ZFS volume emulation driver. - * - * Makes a DMU object look like a volume of arbitrary size, up to 2^64 bytes. - * Volumes are accessed through the symbolic links named: - * - * /dev/zvol/dsk// - * /dev/zvol/rdsk// - * - * These links are created by the ZFS-specific devfsadm link generator. - * Volumes are persistent through reboot. No user command needs to be - * run before opening and using a device. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "zfs_namecheck.h" - -static void *zvol_state; - -#define ZVOL_DUMPSIZE "dumpsize" - -/* - * This lock protects the zvol_state structure from being modified - * while it's being used, e.g. an open that comes in before a create - * finishes. It also protects temporary opens of the dataset so that, - * e.g., an open doesn't get a spurious EBUSY. - */ -static kmutex_t zvol_state_lock; -static uint32_t zvol_minors; - -typedef struct zvol_extent { - list_node_t ze_node; - dva_t ze_dva; /* dva associated with this extent */ - uint64_t ze_nblks; /* number of blocks in extent */ -} zvol_extent_t; - -/* - * The in-core state of each volume. - */ -typedef struct zvol_state { - char zv_name[MAXPATHLEN]; /* pool/dd name */ - uint64_t zv_volsize; /* amount of space we advertise */ - uint64_t zv_volblocksize; /* volume block size */ - minor_t zv_minor; /* minor number */ - uint8_t zv_min_bs; /* minimum addressable block shift */ - uint8_t zv_flags; /* readonly, dumpified, etc. */ - objset_t *zv_objset; /* objset handle */ - uint32_t zv_mode; /* DS_MODE_* flags at open time */ - uint32_t zv_open_count[OTYPCNT]; /* open counts */ - uint32_t zv_total_opens; /* total open count */ - zilog_t *zv_zilog; /* ZIL handle */ - list_t zv_extents; /* List of extents for dump */ - znode_t zv_znode; /* for range locking */ -} zvol_state_t; - -/* - * zvol specific flags - */ -#define ZVOL_RDONLY 0x1 -#define ZVOL_DUMPIFIED 0x2 -#define ZVOL_EXCL 0x4 -#define ZVOL_WCE 0x8 - -/* - * zvol maximum transfer in one DMU tx. - */ -int zvol_maxphys = DMU_MAX_ACCESS/2; - -extern int zfs_set_prop_nvlist(const char *, nvlist_t *); -static int zvol_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio); -static int zvol_dumpify(zvol_state_t *zv); -static int zvol_dump_fini(zvol_state_t *zv); -static int zvol_dump_init(zvol_state_t *zv, boolean_t resize); - -static void -zvol_size_changed(zvol_state_t *zv, major_t maj) -{ - dev_t dev = makedevice(maj, zv->zv_minor); - - VERIFY(ddi_prop_update_int64(dev, zfs_dip, - "Size", zv->zv_volsize) == DDI_SUCCESS); - VERIFY(ddi_prop_update_int64(dev, zfs_dip, - "Nblocks", lbtodb(zv->zv_volsize)) == DDI_SUCCESS); - - /* Notify specfs to invalidate the cached size */ - spec_size_invalidate(dev, VBLK); - spec_size_invalidate(dev, VCHR); -} - -int -zvol_check_volsize(uint64_t volsize, uint64_t blocksize) -{ - if (volsize == 0) - return (EINVAL); - - if (volsize % blocksize != 0) - return (EINVAL); - -#ifdef _ILP32 - if (volsize - 1 > SPEC_MAXOFFSET_T) - return (EOVERFLOW); -#endif - return (0); -} - -int -zvol_check_volblocksize(uint64_t volblocksize) -{ - if (volblocksize < SPA_MINBLOCKSIZE || - volblocksize > SPA_MAXBLOCKSIZE || - !ISP2(volblocksize)) - return (EDOM); - - return (0); -} - -static void -zvol_readonly_changed_cb(void *arg, uint64_t newval) -{ - zvol_state_t *zv = arg; - - if (newval) - zv->zv_flags |= ZVOL_RDONLY; - else - zv->zv_flags &= ~ZVOL_RDONLY; -} - -int -zvol_get_stats(objset_t *os, nvlist_t *nv) -{ - int error; - dmu_object_info_t doi; - uint64_t val; - - - error = zap_lookup(os, ZVOL_ZAP_OBJ, "size", 8, 1, &val); - if (error) - return (error); - - dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_VOLSIZE, val); - - error = dmu_object_info(os, ZVOL_OBJ, &doi); - - if (error == 0) { - dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_VOLBLOCKSIZE, - doi.doi_data_block_size); - } - - return (error); -} - -/* - * Find a free minor number. - */ -static minor_t -zvol_minor_alloc(void) -{ - minor_t minor; - - ASSERT(MUTEX_HELD(&zvol_state_lock)); - - for (minor = 1; minor <= ZVOL_MAX_MINOR; minor++) - if (ddi_get_soft_state(zvol_state, minor) == NULL) - return (minor); - - return (0); -} - -static zvol_state_t * -zvol_minor_lookup(const char *name) -{ - minor_t minor; - zvol_state_t *zv; - - ASSERT(MUTEX_HELD(&zvol_state_lock)); - - for (minor = 1; minor <= ZVOL_MAX_MINOR; minor++) { - zv = ddi_get_soft_state(zvol_state, minor); - if (zv == NULL) - continue; - if (strcmp(zv->zv_name, name) == 0) - break; - } - - return (zv); -} - -/* extent mapping arg */ -struct maparg { - zvol_state_t *ma_zv; - uint64_t ma_blks; -}; - -/*ARGSUSED*/ -static int -zvol_map_block(spa_t *spa, blkptr_t *bp, const zbookmark_t *zb, - const dnode_phys_t *dnp, void *arg) -{ - struct maparg *ma = arg; - zvol_extent_t *ze; - int bs = ma->ma_zv->zv_volblocksize; - - if (bp == NULL || zb->zb_object != ZVOL_OBJ || zb->zb_level != 0) - return (0); - - VERIFY3U(ma->ma_blks, ==, zb->zb_blkid); - ma->ma_blks++; - - /* Abort immediately if we have encountered gang blocks */ - if (BP_IS_GANG(bp)) - return (EFRAGS); - - /* - * See if the block is at the end of the previous extent. - */ - ze = list_tail(&ma->ma_zv->zv_extents); - if (ze && - DVA_GET_VDEV(BP_IDENTITY(bp)) == DVA_GET_VDEV(&ze->ze_dva) && - DVA_GET_OFFSET(BP_IDENTITY(bp)) == - DVA_GET_OFFSET(&ze->ze_dva) + ze->ze_nblks * bs) { - ze->ze_nblks++; - return (0); - } - - dprintf_bp(bp, "%s", "next blkptr:"); - - /* start a new extent */ - ze = kmem_zalloc(sizeof (zvol_extent_t), KM_SLEEP); - ze->ze_dva = bp->blk_dva[0]; /* structure assignment */ - ze->ze_nblks = 1; - list_insert_tail(&ma->ma_zv->zv_extents, ze); - return (0); -} - -static void -zvol_free_extents(zvol_state_t *zv) -{ - zvol_extent_t *ze; - - while (ze = list_head(&zv->zv_extents)) { - list_remove(&zv->zv_extents, ze); - kmem_free(ze, sizeof (zvol_extent_t)); - } -} - -static int -zvol_get_lbas(zvol_state_t *zv) -{ - struct maparg ma; - int err; - - ma.ma_zv = zv; - ma.ma_blks = 0; - zvol_free_extents(zv); - - err = traverse_dataset(dmu_objset_ds(zv->zv_objset), 0, - TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA, zvol_map_block, &ma); - if (err || ma.ma_blks != (zv->zv_volsize / zv->zv_volblocksize)) { - zvol_free_extents(zv); - return (err ? err : EIO); - } - - return (0); -} - -/* ARGSUSED */ -void -zvol_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx) -{ - zfs_creat_t *zct = arg; - nvlist_t *nvprops = zct->zct_props; - int error; - uint64_t volblocksize, volsize; - - VERIFY(nvlist_lookup_uint64(nvprops, - zfs_prop_to_name(ZFS_PROP_VOLSIZE), &volsize) == 0); - if (nvlist_lookup_uint64(nvprops, - zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), &volblocksize) != 0) - volblocksize = zfs_prop_default_numeric(ZFS_PROP_VOLBLOCKSIZE); - - /* - * These properties must be removed from the list so the generic - * property setting step won't apply to them. - */ - VERIFY(nvlist_remove_all(nvprops, - zfs_prop_to_name(ZFS_PROP_VOLSIZE)) == 0); - (void) nvlist_remove_all(nvprops, - zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE)); - - error = dmu_object_claim(os, ZVOL_OBJ, DMU_OT_ZVOL, volblocksize, - DMU_OT_NONE, 0, tx); - ASSERT(error == 0); - - error = zap_create_claim(os, ZVOL_ZAP_OBJ, DMU_OT_ZVOL_PROP, - DMU_OT_NONE, 0, tx); - ASSERT(error == 0); - - error = zap_update(os, ZVOL_ZAP_OBJ, "size", 8, 1, &volsize, tx); - ASSERT(error == 0); -} - -/* - * Replay a TX_WRITE ZIL transaction that didn't get committed - * after a system failure - */ -static int -zvol_replay_write(zvol_state_t *zv, lr_write_t *lr, boolean_t byteswap) -{ - objset_t *os = zv->zv_objset; - char *data = (char *)(lr + 1); /* data follows lr_write_t */ - uint64_t off = lr->lr_offset; - uint64_t len = lr->lr_length; - dmu_tx_t *tx; - int error; - - if (byteswap) - byteswap_uint64_array(lr, sizeof (*lr)); - - tx = dmu_tx_create(os); - dmu_tx_hold_write(tx, ZVOL_OBJ, off, len); - error = dmu_tx_assign(tx, TXG_WAIT); - if (error) { - dmu_tx_abort(tx); - } else { - dmu_write(os, ZVOL_OBJ, off, len, data, tx); - dmu_tx_commit(tx); - } - - return (error); -} - -/* ARGSUSED */ -static int -zvol_replay_err(zvol_state_t *zv, lr_t *lr, boolean_t byteswap) -{ - return (ENOTSUP); -} - -/* - * Callback vectors for replaying records. - * Only TX_WRITE is needed for zvol. - */ -zil_replay_func_t *zvol_replay_vector[TX_MAX_TYPE] = { - zvol_replay_err, /* 0 no such transaction type */ - zvol_replay_err, /* TX_CREATE */ - zvol_replay_err, /* TX_MKDIR */ - zvol_replay_err, /* TX_MKXATTR */ - zvol_replay_err, /* TX_SYMLINK */ - zvol_replay_err, /* TX_REMOVE */ - zvol_replay_err, /* TX_RMDIR */ - zvol_replay_err, /* TX_LINK */ - zvol_replay_err, /* TX_RENAME */ - zvol_replay_write, /* TX_WRITE */ - zvol_replay_err, /* TX_TRUNCATE */ - zvol_replay_err, /* TX_SETATTR */ - zvol_replay_err, /* TX_ACL */ -}; - -/* - * Create a minor node (plus a whole lot more) for the specified volume. - */ -int -zvol_create_minor(const char *name, major_t maj) -{ - zvol_state_t *zv; - objset_t *os; - dmu_object_info_t doi; - uint64_t volsize; - minor_t minor = 0; - struct pathname linkpath; - int ds_mode = DS_MODE_OWNER; - vnode_t *vp = NULL; - char *devpath; - size_t devpathlen = strlen(ZVOL_FULL_DEV_DIR) + strlen(name) + 1; - char chrbuf[30], blkbuf[30]; - int error; - - mutex_enter(&zvol_state_lock); - - if ((zv = zvol_minor_lookup(name)) != NULL) { - mutex_exit(&zvol_state_lock); - return (EEXIST); - } - - if (strchr(name, '@') != 0) - ds_mode |= DS_MODE_READONLY; - - error = dmu_objset_open(name, DMU_OST_ZVOL, ds_mode, &os); - - if (error) { - mutex_exit(&zvol_state_lock); - return (error); - } - - error = zap_lookup(os, ZVOL_ZAP_OBJ, "size", 8, 1, &volsize); - - if (error) { - dmu_objset_close(os); - mutex_exit(&zvol_state_lock); - return (error); - } - - /* - * If there's an existing /dev/zvol symlink, try to use the - * same minor number we used last time. - */ - devpath = kmem_alloc(devpathlen, KM_SLEEP); - - (void) sprintf(devpath, "%s%s", ZVOL_FULL_DEV_DIR, name); - - error = lookupname(devpath, UIO_SYSSPACE, NO_FOLLOW, NULL, &vp); - - kmem_free(devpath, devpathlen); - - if (error == 0 && vp->v_type != VLNK) - error = EINVAL; - - if (error == 0) { - pn_alloc(&linkpath); - error = pn_getsymlink(vp, &linkpath, kcred); - if (error == 0) { - char *ms = strstr(linkpath.pn_path, ZVOL_PSEUDO_DEV); - if (ms != NULL) { - ms += strlen(ZVOL_PSEUDO_DEV); - minor = stoi(&ms); - } - } - pn_free(&linkpath); - } - - if (vp != NULL) - VN_RELE(vp); - - /* - * If we found a minor but it's already in use, we must pick a new one. - */ - if (minor != 0 && ddi_get_soft_state(zvol_state, minor) != NULL) - minor = 0; - - if (minor == 0) - minor = zvol_minor_alloc(); - - if (minor == 0) { - dmu_objset_close(os); - mutex_exit(&zvol_state_lock); - return (ENXIO); - } - - if (ddi_soft_state_zalloc(zvol_state, minor) != DDI_SUCCESS) { - dmu_objset_close(os); - mutex_exit(&zvol_state_lock); - return (EAGAIN); - } - - (void) ddi_prop_update_string(minor, zfs_dip, ZVOL_PROP_NAME, - (char *)name); - - (void) sprintf(chrbuf, "%uc,raw", minor); - - if (ddi_create_minor_node(zfs_dip, chrbuf, S_IFCHR, - minor, DDI_PSEUDO, 0) == DDI_FAILURE) { - ddi_soft_state_free(zvol_state, minor); - dmu_objset_close(os); - mutex_exit(&zvol_state_lock); - return (EAGAIN); - } - - (void) sprintf(blkbuf, "%uc", minor); - - if (ddi_create_minor_node(zfs_dip, blkbuf, S_IFBLK, - minor, DDI_PSEUDO, 0) == DDI_FAILURE) { - ddi_remove_minor_node(zfs_dip, chrbuf); - ddi_soft_state_free(zvol_state, minor); - dmu_objset_close(os); - mutex_exit(&zvol_state_lock); - return (EAGAIN); - } - - zv = ddi_get_soft_state(zvol_state, minor); - - (void) strcpy(zv->zv_name, name); - zv->zv_min_bs = DEV_BSHIFT; - zv->zv_minor = minor; - zv->zv_volsize = volsize; - zv->zv_objset = os; - zv->zv_mode = ds_mode; - zv->zv_zilog = zil_open(os, zvol_get_data); - mutex_init(&zv->zv_znode.z_range_lock, NULL, MUTEX_DEFAULT, NULL); - avl_create(&zv->zv_znode.z_range_avl, zfs_range_compare, - sizeof (rl_t), offsetof(rl_t, r_node)); - list_create(&zv->zv_extents, sizeof (zvol_extent_t), - offsetof(zvol_extent_t, ze_node)); - /* get and cache the blocksize */ - error = dmu_object_info(os, ZVOL_OBJ, &doi); - ASSERT(error == 0); - zv->zv_volblocksize = doi.doi_data_block_size; - - zil_replay(os, zv, zvol_replay_vector); - zvol_size_changed(zv, maj); - - /* XXX this should handle the possible i/o error */ - VERIFY(dsl_prop_register(dmu_objset_ds(zv->zv_objset), - "readonly", zvol_readonly_changed_cb, zv) == 0); - - zvol_minors++; - - mutex_exit(&zvol_state_lock); - - return (0); -} - -/* - * Remove minor node for the specified volume. - */ -int -zvol_remove_minor(const char *name) -{ - zvol_state_t *zv; - char namebuf[30]; - - mutex_enter(&zvol_state_lock); - - if ((zv = zvol_minor_lookup(name)) == NULL) { - mutex_exit(&zvol_state_lock); - return (ENXIO); - } - - if (zv->zv_total_opens != 0) { - mutex_exit(&zvol_state_lock); - return (EBUSY); - } - - (void) sprintf(namebuf, "%uc,raw", zv->zv_minor); - ddi_remove_minor_node(zfs_dip, namebuf); - - (void) sprintf(namebuf, "%uc", zv->zv_minor); - ddi_remove_minor_node(zfs_dip, namebuf); - - VERIFY(dsl_prop_unregister(dmu_objset_ds(zv->zv_objset), - "readonly", zvol_readonly_changed_cb, zv) == 0); - - zil_close(zv->zv_zilog); - zv->zv_zilog = NULL; - dmu_objset_close(zv->zv_objset); - zv->zv_objset = NULL; - avl_destroy(&zv->zv_znode.z_range_avl); - mutex_destroy(&zv->zv_znode.z_range_lock); - - ddi_soft_state_free(zvol_state, zv->zv_minor); - - zvol_minors--; - - mutex_exit(&zvol_state_lock); - - return (0); -} - -int -zvol_prealloc(zvol_state_t *zv) -{ - objset_t *os = zv->zv_objset; - dmu_tx_t *tx; - uint64_t refd, avail, usedobjs, availobjs; - uint64_t resid = zv->zv_volsize; - uint64_t off = 0; - - /* Check the space usage before attempting to allocate the space */ - dmu_objset_space(os, &refd, &avail, &usedobjs, &availobjs); - if (avail < zv->zv_volsize) - return (ENOSPC); - - /* Free old extents if they exist */ - zvol_free_extents(zv); - - while (resid != 0) { - int error; - uint64_t bytes = MIN(resid, SPA_MAXBLOCKSIZE); - - tx = dmu_tx_create(os); - dmu_tx_hold_write(tx, ZVOL_OBJ, off, bytes); - error = dmu_tx_assign(tx, TXG_WAIT); - if (error) { - dmu_tx_abort(tx); - (void) dmu_free_long_range(os, ZVOL_OBJ, 0, off); - return (error); - } - dmu_prealloc(os, ZVOL_OBJ, off, bytes, tx); - dmu_tx_commit(tx); - off += bytes; - resid -= bytes; - } - txg_wait_synced(dmu_objset_pool(os), 0); - - return (0); -} - -int -zvol_update_volsize(zvol_state_t *zv, major_t maj, uint64_t volsize) -{ - dmu_tx_t *tx; - int error; - - ASSERT(MUTEX_HELD(&zvol_state_lock)); - - tx = dmu_tx_create(zv->zv_objset); - dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); - error = dmu_tx_assign(tx, TXG_WAIT); - if (error) { - dmu_tx_abort(tx); - return (error); - } - - error = zap_update(zv->zv_objset, ZVOL_ZAP_OBJ, "size", 8, 1, - &volsize, tx); - dmu_tx_commit(tx); - - if (error == 0) - error = dmu_free_long_range(zv->zv_objset, - ZVOL_OBJ, volsize, DMU_OBJECT_END); - - /* - * If we are using a faked-up state (zv_minor == 0) then don't - * try to update the in-core zvol state. - */ - if (error == 0 && zv->zv_minor) { - zv->zv_volsize = volsize; - zvol_size_changed(zv, maj); - } - return (error); -} - -int -zvol_set_volsize(const char *name, major_t maj, uint64_t volsize) -{ - zvol_state_t *zv; - int error; - dmu_object_info_t doi; - uint64_t old_volsize = 0ULL; - zvol_state_t state = { 0 }; - - mutex_enter(&zvol_state_lock); - - if ((zv = zvol_minor_lookup(name)) == NULL) { - /* - * If we are doing a "zfs clone -o volsize=", then the - * minor node won't exist yet. - */ - error = dmu_objset_open(name, DMU_OST_ZVOL, DS_MODE_OWNER, - &state.zv_objset); - if (error != 0) - goto out; - zv = &state; - } - old_volsize = zv->zv_volsize; - - if ((error = dmu_object_info(zv->zv_objset, ZVOL_OBJ, &doi)) != 0 || - (error = zvol_check_volsize(volsize, - doi.doi_data_block_size)) != 0) - goto out; - - if (zv->zv_flags & ZVOL_RDONLY || (zv->zv_mode & DS_MODE_READONLY)) { - error = EROFS; - goto out; - } - - error = zvol_update_volsize(zv, maj, volsize); - - /* - * Reinitialize the dump area to the new size. If we - * failed to resize the dump area then restore the it back to - * it's original size. - */ - if (error == 0 && zv->zv_flags & ZVOL_DUMPIFIED) { - if ((error = zvol_dumpify(zv)) != 0 || - (error = dumpvp_resize()) != 0) { - (void) zvol_update_volsize(zv, maj, old_volsize); - error = zvol_dumpify(zv); - } - } - - /* - * Generate a LUN expansion event. - */ - if (error == 0) { - sysevent_id_t eid; - nvlist_t *attr; - char *physpath = kmem_zalloc(MAXPATHLEN, KM_SLEEP); - - (void) snprintf(physpath, MAXPATHLEN, "%s%uc", ZVOL_PSEUDO_DEV, - zv->zv_minor); - - VERIFY(nvlist_alloc(&attr, NV_UNIQUE_NAME, KM_SLEEP) == 0); - VERIFY(nvlist_add_string(attr, DEV_PHYS_PATH, physpath) == 0); - - (void) ddi_log_sysevent(zfs_dip, SUNW_VENDOR, EC_DEV_STATUS, - ESC_DEV_DLE, attr, &eid, DDI_SLEEP); - - nvlist_free(attr); - kmem_free(physpath, MAXPATHLEN); - } - -out: - if (state.zv_objset) - dmu_objset_close(state.zv_objset); - - mutex_exit(&zvol_state_lock); - - return (error); -} - -int -zvol_set_volblocksize(const char *name, uint64_t volblocksize) -{ - zvol_state_t *zv; - dmu_tx_t *tx; - int error; - boolean_t needlock; - - /* - * The lock may already be held if we are being called from - * zvol_dump_init(). - */ - needlock = !MUTEX_HELD(&zvol_state_lock); - if (needlock) - mutex_enter(&zvol_state_lock); - - if ((zv = zvol_minor_lookup(name)) == NULL) { - if (needlock) - mutex_exit(&zvol_state_lock); - return (ENXIO); - } - if (zv->zv_flags & ZVOL_RDONLY || (zv->zv_mode & DS_MODE_READONLY)) { - if (needlock) - mutex_exit(&zvol_state_lock); - return (EROFS); - } - - tx = dmu_tx_create(zv->zv_objset); - dmu_tx_hold_bonus(tx, ZVOL_OBJ); - error = dmu_tx_assign(tx, TXG_WAIT); - if (error) { - dmu_tx_abort(tx); - } else { - error = dmu_object_set_blocksize(zv->zv_objset, ZVOL_OBJ, - volblocksize, 0, tx); - if (error == ENOTSUP) - error = EBUSY; - dmu_tx_commit(tx); - if (error == 0) - zv->zv_volblocksize = volblocksize; - } - - if (needlock) - mutex_exit(&zvol_state_lock); - - return (error); -} - -/*ARGSUSED*/ -int -zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr) -{ - minor_t minor = getminor(*devp); - zvol_state_t *zv; - - if (minor == 0) /* This is the control device */ - return (0); - - mutex_enter(&zvol_state_lock); - - zv = ddi_get_soft_state(zvol_state, minor); - if (zv == NULL) { - mutex_exit(&zvol_state_lock); - return (ENXIO); - } - - ASSERT(zv->zv_objset != NULL); - - if ((flag & FWRITE) && - (zv->zv_flags & ZVOL_RDONLY || (zv->zv_mode & DS_MODE_READONLY))) { - mutex_exit(&zvol_state_lock); - return (EROFS); - } - if (zv->zv_flags & ZVOL_EXCL) { - mutex_exit(&zvol_state_lock); - return (EBUSY); - } - if (flag & FEXCL) { - if (zv->zv_total_opens != 0) { - mutex_exit(&zvol_state_lock); - return (EBUSY); - } - zv->zv_flags |= ZVOL_EXCL; - } - - if (zv->zv_open_count[otyp] == 0 || otyp == OTYP_LYR) { - zv->zv_open_count[otyp]++; - zv->zv_total_opens++; - } - - mutex_exit(&zvol_state_lock); - - return (0); -} - -/*ARGSUSED*/ -int -zvol_close(dev_t dev, int flag, int otyp, cred_t *cr) -{ - minor_t minor = getminor(dev); - zvol_state_t *zv; - - if (minor == 0) /* This is the control device */ - return (0); - - mutex_enter(&zvol_state_lock); - - zv = ddi_get_soft_state(zvol_state, minor); - if (zv == NULL) { - mutex_exit(&zvol_state_lock); - return (ENXIO); - } - - if (zv->zv_flags & ZVOL_EXCL) { - ASSERT(zv->zv_total_opens == 1); - zv->zv_flags &= ~ZVOL_EXCL; - } - - /* - * If the open count is zero, this is a spurious close. - * That indicates a bug in the kernel / DDI framework. - */ - ASSERT(zv->zv_open_count[otyp] != 0); - ASSERT(zv->zv_total_opens != 0); - - /* - * You may get multiple opens, but only one close. - */ - zv->zv_open_count[otyp]--; - zv->zv_total_opens--; - - mutex_exit(&zvol_state_lock); - - return (0); -} - -static void -zvol_get_done(dmu_buf_t *db, void *vzgd) -{ - zgd_t *zgd = (zgd_t *)vzgd; - rl_t *rl = zgd->zgd_rl; - - dmu_buf_rele(db, vzgd); - zfs_range_unlock(rl); - zil_add_block(zgd->zgd_zilog, zgd->zgd_bp); - kmem_free(zgd, sizeof (zgd_t)); -} - -/* - * Get data to generate a TX_WRITE intent log record. - */ -static int -zvol_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio) -{ - zvol_state_t *zv = arg; - objset_t *os = zv->zv_objset; - dmu_buf_t *db; - rl_t *rl; - zgd_t *zgd; - uint64_t boff; /* block starting offset */ - int dlen = lr->lr_length; /* length of user data */ - int error; - - ASSERT(zio); - ASSERT(dlen != 0); - - /* - * Write records come in two flavors: immediate and indirect. - * For small writes it's cheaper to store the data with the - * log record (immediate); for large writes it's cheaper to - * sync the data and get a pointer to it (indirect) so that - * we don't have to write the data twice. - */ - if (buf != NULL) /* immediate write */ - return (dmu_read(os, ZVOL_OBJ, lr->lr_offset, dlen, buf, - DMU_READ_NO_PREFETCH)); - - zgd = (zgd_t *)kmem_alloc(sizeof (zgd_t), KM_SLEEP); - zgd->zgd_zilog = zv->zv_zilog; - zgd->zgd_bp = &lr->lr_blkptr; - - /* - * Lock the range of the block to ensure that when the data is - * written out and its checksum is being calculated that no other - * thread can change the block. - */ - boff = P2ALIGN_TYPED(lr->lr_offset, zv->zv_volblocksize, uint64_t); - rl = zfs_range_lock(&zv->zv_znode, boff, zv->zv_volblocksize, - RL_READER); - zgd->zgd_rl = rl; - - VERIFY(0 == dmu_buf_hold(os, ZVOL_OBJ, lr->lr_offset, zgd, &db)); - error = dmu_sync(zio, db, &lr->lr_blkptr, - lr->lr_common.lrc_txg, zvol_get_done, zgd); - if (error == 0) - zil_add_block(zv->zv_zilog, &lr->lr_blkptr); - /* - * If we get EINPROGRESS, then we need to wait for a - * write IO initiated by dmu_sync() to complete before - * we can release this dbuf. We will finish everything - * up in the zvol_get_done() callback. - */ - if (error == EINPROGRESS) - return (0); - dmu_buf_rele(db, zgd); - zfs_range_unlock(rl); - kmem_free(zgd, sizeof (zgd_t)); - return (error); -} - -/* - * zvol_log_write() handles synchronous writes using TX_WRITE ZIL transactions. - * - * We store data in the log buffers if it's small enough. - * Otherwise we will later flush the data out via dmu_sync(). - */ -ssize_t zvol_immediate_write_sz = 32768; - -static void -zvol_log_write(zvol_state_t *zv, dmu_tx_t *tx, offset_t off, ssize_t resid, - boolean_t sync) -{ - uint32_t blocksize = zv->zv_volblocksize; - zilog_t *zilog = zv->zv_zilog; - boolean_t slogging; - - if (zil_disable) - return; - - if (zilog->zl_replay) { - dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); - zilog->zl_replayed_seq[dmu_tx_get_txg(tx) & TXG_MASK] = - zilog->zl_replaying_seq; - return; - } - - slogging = spa_has_slogs(zilog->zl_spa); - - while (resid) { - itx_t *itx; - lr_write_t *lr; - ssize_t len; - itx_wr_state_t write_state; - - /* - * Unlike zfs_log_write() we can be called with - * upto DMU_MAX_ACCESS/2 (5MB) writes. - */ - if (blocksize > zvol_immediate_write_sz && !slogging && - resid >= blocksize && off % blocksize == 0) { - write_state = WR_INDIRECT; /* uses dmu_sync */ - len = blocksize; - } else if (sync) { - write_state = WR_COPIED; - len = MIN(ZIL_MAX_LOG_DATA, resid); - } else { - write_state = WR_NEED_COPY; - len = MIN(ZIL_MAX_LOG_DATA, resid); - } - - itx = zil_itx_create(TX_WRITE, sizeof (*lr) + - (write_state == WR_COPIED ? len : 0)); - lr = (lr_write_t *)&itx->itx_lr; - if (write_state == WR_COPIED && dmu_read(zv->zv_objset, - ZVOL_OBJ, off, len, lr + 1, DMU_READ_NO_PREFETCH) != 0) { - kmem_free(itx, offsetof(itx_t, itx_lr) + - itx->itx_lr.lrc_reclen); - itx = zil_itx_create(TX_WRITE, sizeof (*lr)); - lr = (lr_write_t *)&itx->itx_lr; - write_state = WR_NEED_COPY; - } - - itx->itx_wr_state = write_state; - if (write_state == WR_NEED_COPY) - itx->itx_sod += len; - lr->lr_foid = ZVOL_OBJ; - lr->lr_offset = off; - lr->lr_length = len; - lr->lr_blkoff = off - P2ALIGN_TYPED(off, blocksize, uint64_t); - BP_ZERO(&lr->lr_blkptr); - - itx->itx_private = zv; - itx->itx_sync = sync; - - (void) zil_itx_assign(zilog, itx, tx); - - off += len; - resid -= len; - } -} - -static int -zvol_dumpio_vdev(vdev_t *vd, void *addr, uint64_t offset, uint64_t size, - boolean_t doread, boolean_t isdump) -{ - vdev_disk_t *dvd; - int c; - int numerrors = 0; - - for (c = 0; c < vd->vdev_children; c++) { - ASSERT(vd->vdev_ops == &vdev_mirror_ops || - vd->vdev_ops == &vdev_replacing_ops || - vd->vdev_ops == &vdev_spare_ops); - int err = zvol_dumpio_vdev(vd->vdev_child[c], - addr, offset, size, doread, isdump); - if (err != 0) { - numerrors++; - } else if (doread) { - break; - } - } - - if (!vd->vdev_ops->vdev_op_leaf) - return (numerrors < vd->vdev_children ? 0 : EIO); - - if (doread && !vdev_readable(vd)) - return (EIO); - else if (!doread && !vdev_writeable(vd)) - return (EIO); - - dvd = vd->vdev_tsd; - ASSERT3P(dvd, !=, NULL); - offset += VDEV_LABEL_START_SIZE; - - if (ddi_in_panic() || isdump) { - ASSERT(!doread); - if (doread) - return (EIO); - return (ldi_dump(dvd->vd_lh, addr, lbtodb(offset), - lbtodb(size))); - } else { - return (vdev_disk_physio(dvd->vd_lh, addr, size, offset, - doread ? B_READ : B_WRITE)); - } -} - -static int -zvol_dumpio(zvol_state_t *zv, void *addr, uint64_t offset, uint64_t size, - boolean_t doread, boolean_t isdump) -{ - vdev_t *vd; - int error; - zvol_extent_t *ze; - spa_t *spa = dmu_objset_spa(zv->zv_objset); - - /* Must be sector aligned, and not stradle a block boundary. */ - if (P2PHASE(offset, DEV_BSIZE) || P2PHASE(size, DEV_BSIZE) || - P2BOUNDARY(offset, size, zv->zv_volblocksize)) { - return (EINVAL); - } - ASSERT(size <= zv->zv_volblocksize); - - /* Locate the extent this belongs to */ - ze = list_head(&zv->zv_extents); - while (offset >= ze->ze_nblks * zv->zv_volblocksize) { - offset -= ze->ze_nblks * zv->zv_volblocksize; - ze = list_next(&zv->zv_extents, ze); - } - spa_config_enter(spa, SCL_STATE, FTAG, RW_READER); - vd = vdev_lookup_top(spa, DVA_GET_VDEV(&ze->ze_dva)); - offset += DVA_GET_OFFSET(&ze->ze_dva); - error = zvol_dumpio_vdev(vd, addr, offset, size, doread, isdump); - spa_config_exit(spa, SCL_STATE, FTAG); - return (error); -} - -int -zvol_strategy(buf_t *bp) -{ - zvol_state_t *zv = ddi_get_soft_state(zvol_state, getminor(bp->b_edev)); - uint64_t off, volsize; - size_t resid; - char *addr; - objset_t *os; - rl_t *rl; - int error = 0; - boolean_t doread = bp->b_flags & B_READ; - boolean_t is_dump = zv->zv_flags & ZVOL_DUMPIFIED; - boolean_t sync; - - if (zv == NULL) { - bioerror(bp, ENXIO); - biodone(bp); - return (0); - } - - if (getminor(bp->b_edev) == 0) { - bioerror(bp, EINVAL); - biodone(bp); - return (0); - } - - if (!(bp->b_flags & B_READ) && - (zv->zv_flags & ZVOL_RDONLY || - zv->zv_mode & DS_MODE_READONLY)) { - bioerror(bp, EROFS); - biodone(bp); - return (0); - } - - off = ldbtob(bp->b_blkno); - volsize = zv->zv_volsize; - - os = zv->zv_objset; - ASSERT(os != NULL); - - bp_mapin(bp); - addr = bp->b_un.b_addr; - resid = bp->b_bcount; - - if (resid > 0 && (off < 0 || off >= volsize)) { - bioerror(bp, EIO); - biodone(bp); - return (0); - } - - sync = !(bp->b_flags & B_ASYNC) && !doread && !is_dump && - !(zv->zv_flags & ZVOL_WCE) && !zil_disable; - - /* - * There must be no buffer changes when doing a dmu_sync() because - * we can't change the data whilst calculating the checksum. - */ - rl = zfs_range_lock(&zv->zv_znode, off, resid, - doread ? RL_READER : RL_WRITER); - - while (resid != 0 && off < volsize) { - size_t size = MIN(resid, zvol_maxphys); - if (is_dump) { - size = MIN(size, P2END(off, zv->zv_volblocksize) - off); - error = zvol_dumpio(zv, addr, off, size, - doread, B_FALSE); - } else if (doread) { - error = dmu_read(os, ZVOL_OBJ, off, size, addr, - DMU_READ_PREFETCH); - } else { - dmu_tx_t *tx = dmu_tx_create(os); - dmu_tx_hold_write(tx, ZVOL_OBJ, off, size); - error = dmu_tx_assign(tx, TXG_WAIT); - if (error) { - dmu_tx_abort(tx); - } else { - dmu_write(os, ZVOL_OBJ, off, size, addr, tx); - zvol_log_write(zv, tx, off, size, sync); - dmu_tx_commit(tx); - } - } - if (error) { - /* convert checksum errors into IO errors */ - if (error == ECKSUM) - error = EIO; - break; - } - off += size; - addr += size; - resid -= size; - } - zfs_range_unlock(rl); - - if ((bp->b_resid = resid) == bp->b_bcount) - bioerror(bp, off > volsize ? EINVAL : error); - - if (sync) - zil_commit(zv->zv_zilog, UINT64_MAX, ZVOL_OBJ); - biodone(bp); - - return (0); -} - -/* - * Set the buffer count to the zvol maximum transfer. - * Using our own routine instead of the default minphys() - * means that for larger writes we write bigger buffers on X86 - * (128K instead of 56K) and flush the disk write cache less often - * (every zvol_maxphys - currently 1MB) instead of minphys (currently - * 56K on X86 and 128K on sparc). - */ -void -zvol_minphys(struct buf *bp) -{ - if (bp->b_bcount > zvol_maxphys) - bp->b_bcount = zvol_maxphys; -} - -int -zvol_dump(dev_t dev, caddr_t addr, daddr_t blkno, int nblocks) -{ - minor_t minor = getminor(dev); - zvol_state_t *zv; - int error = 0; - uint64_t size; - uint64_t boff; - uint64_t resid; - - if (minor == 0) /* This is the control device */ - return (ENXIO); - - zv = ddi_get_soft_state(zvol_state, minor); - if (zv == NULL) - return (ENXIO); - - boff = ldbtob(blkno); - resid = ldbtob(nblocks); - - VERIFY3U(boff + resid, <=, zv->zv_volsize); - - while (resid) { - size = MIN(resid, P2END(boff, zv->zv_volblocksize) - boff); - error = zvol_dumpio(zv, addr, boff, size, B_FALSE, B_TRUE); - if (error) - break; - boff += size; - addr += size; - resid -= size; - } - - return (error); -} - -/*ARGSUSED*/ -int -zvol_read(dev_t dev, uio_t *uio, cred_t *cr) -{ - minor_t minor = getminor(dev); - zvol_state_t *zv; - uint64_t volsize; - rl_t *rl; - int error = 0; - - if (minor == 0) /* This is the control device */ - return (ENXIO); - - zv = ddi_get_soft_state(zvol_state, minor); - if (zv == NULL) - return (ENXIO); - - volsize = zv->zv_volsize; - if (uio->uio_resid > 0 && - (uio->uio_loffset < 0 || uio->uio_loffset >= volsize)) - return (EIO); - - if (zv->zv_flags & ZVOL_DUMPIFIED) { - error = physio(zvol_strategy, NULL, dev, B_READ, - zvol_minphys, uio); - return (error); - } - - rl = zfs_range_lock(&zv->zv_znode, uio->uio_loffset, uio->uio_resid, - RL_READER); - while (uio->uio_resid > 0 && uio->uio_loffset < volsize) { - uint64_t bytes = MIN(uio->uio_resid, DMU_MAX_ACCESS >> 1); - - /* don't read past the end */ - if (bytes > volsize - uio->uio_loffset) - bytes = volsize - uio->uio_loffset; - - error = dmu_read_uio(zv->zv_objset, ZVOL_OBJ, uio, bytes); - if (error) { - /* convert checksum errors into IO errors */ - if (error == ECKSUM) - error = EIO; - break; - } - } - zfs_range_unlock(rl); - return (error); -} - -/*ARGSUSED*/ -int -zvol_write(dev_t dev, uio_t *uio, cred_t *cr) -{ - minor_t minor = getminor(dev); - zvol_state_t *zv; - uint64_t volsize; - rl_t *rl; - int error = 0; - boolean_t sync; - - if (minor == 0) /* This is the control device */ - return (ENXIO); - - zv = ddi_get_soft_state(zvol_state, minor); - if (zv == NULL) - return (ENXIO); - - volsize = zv->zv_volsize; - if (uio->uio_resid > 0 && - (uio->uio_loffset < 0 || uio->uio_loffset >= volsize)) - return (EIO); - - if (zv->zv_flags & ZVOL_DUMPIFIED) { - error = physio(zvol_strategy, NULL, dev, B_WRITE, - zvol_minphys, uio); - return (error); - } - - sync = !(zv->zv_flags & ZVOL_WCE) && !zil_disable; - - rl = zfs_range_lock(&zv->zv_znode, uio->uio_loffset, uio->uio_resid, - RL_WRITER); - while (uio->uio_resid > 0 && uio->uio_loffset < volsize) { - uint64_t bytes = MIN(uio->uio_resid, DMU_MAX_ACCESS >> 1); - uint64_t off = uio->uio_loffset; - dmu_tx_t *tx = dmu_tx_create(zv->zv_objset); - - if (bytes > volsize - off) /* don't write past the end */ - bytes = volsize - off; - - dmu_tx_hold_write(tx, ZVOL_OBJ, off, bytes); - error = dmu_tx_assign(tx, TXG_WAIT); - if (error) { - dmu_tx_abort(tx); - break; - } - error = dmu_write_uio(zv->zv_objset, ZVOL_OBJ, uio, bytes, tx); - if (error == 0) - zvol_log_write(zv, tx, off, bytes, sync); - dmu_tx_commit(tx); - - if (error) - break; - } - zfs_range_unlock(rl); - if (sync) - zil_commit(zv->zv_zilog, UINT64_MAX, ZVOL_OBJ); - return (error); -} - -int -zvol_getefi(void *arg, int flag, uint64_t vs, uint8_t bs) -{ - struct uuid uuid = EFI_RESERVED; - efi_gpe_t gpe = { 0 }; - uint32_t crc; - dk_efi_t efi; - int length; - char *ptr; - - if (ddi_copyin(arg, &efi, sizeof (dk_efi_t), flag)) - return (EFAULT); - ptr = (char *)(uintptr_t)efi.dki_data_64; - length = efi.dki_length; - /* - * Some clients may attempt to request a PMBR for the - * zvol. Currently this interface will return EINVAL to - * such requests. These requests could be supported by - * adding a check for lba == 0 and consing up an appropriate - * PMBR. - */ - if (efi.dki_lba < 1 || efi.dki_lba > 2 || length <= 0) - return (EINVAL); - - gpe.efi_gpe_StartingLBA = LE_64(34ULL); - gpe.efi_gpe_EndingLBA = LE_64((vs >> bs) - 1); - UUID_LE_CONVERT(gpe.efi_gpe_PartitionTypeGUID, uuid); - - if (efi.dki_lba == 1) { - efi_gpt_t gpt = { 0 }; - - gpt.efi_gpt_Signature = LE_64(EFI_SIGNATURE); - gpt.efi_gpt_Revision = LE_32(EFI_VERSION_CURRENT); - gpt.efi_gpt_HeaderSize = LE_32(sizeof (gpt)); - gpt.efi_gpt_MyLBA = LE_64(1ULL); - gpt.efi_gpt_FirstUsableLBA = LE_64(34ULL); - gpt.efi_gpt_LastUsableLBA = LE_64((vs >> bs) - 1); - gpt.efi_gpt_PartitionEntryLBA = LE_64(2ULL); - gpt.efi_gpt_NumberOfPartitionEntries = LE_32(1); - gpt.efi_gpt_SizeOfPartitionEntry = - LE_32(sizeof (efi_gpe_t)); - CRC32(crc, &gpe, sizeof (gpe), -1U, crc32_table); - gpt.efi_gpt_PartitionEntryArrayCRC32 = LE_32(~crc); - CRC32(crc, &gpt, sizeof (gpt), -1U, crc32_table); - gpt.efi_gpt_HeaderCRC32 = LE_32(~crc); - if (ddi_copyout(&gpt, ptr, MIN(sizeof (gpt), length), - flag)) - return (EFAULT); - ptr += sizeof (gpt); - length -= sizeof (gpt); - } - if (length > 0 && ddi_copyout(&gpe, ptr, MIN(sizeof (gpe), - length), flag)) - return (EFAULT); - return (0); -} - -/* - * Dirtbag ioctls to support mkfs(1M) for UFS filesystems. See dkio(7I). - */ -/*ARGSUSED*/ -int -zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) -{ - zvol_state_t *zv; - struct dk_cinfo dki; - struct dk_minfo dkm; - struct dk_callback *dkc; - int error = 0; - rl_t *rl; - - mutex_enter(&zvol_state_lock); - - zv = ddi_get_soft_state(zvol_state, getminor(dev)); - - if (zv == NULL) { - mutex_exit(&zvol_state_lock); - return (ENXIO); - } - ASSERT(zv->zv_total_opens > 0); - - switch (cmd) { - - case DKIOCINFO: - bzero(&dki, sizeof (dki)); - (void) strcpy(dki.dki_cname, "zvol"); - (void) strcpy(dki.dki_dname, "zvol"); - dki.dki_ctype = DKC_UNKNOWN; - dki.dki_maxtransfer = 1 << (SPA_MAXBLOCKSHIFT - zv->zv_min_bs); - mutex_exit(&zvol_state_lock); - if (ddi_copyout(&dki, (void *)arg, sizeof (dki), flag)) - error = EFAULT; - return (error); - - case DKIOCGMEDIAINFO: - bzero(&dkm, sizeof (dkm)); - dkm.dki_lbsize = 1U << zv->zv_min_bs; - dkm.dki_capacity = zv->zv_volsize >> zv->zv_min_bs; - dkm.dki_media_type = DK_UNKNOWN; - mutex_exit(&zvol_state_lock); - if (ddi_copyout(&dkm, (void *)arg, sizeof (dkm), flag)) - error = EFAULT; - return (error); - - case DKIOCGETEFI: - { - uint64_t vs = zv->zv_volsize; - uint8_t bs = zv->zv_min_bs; - - mutex_exit(&zvol_state_lock); - error = zvol_getefi((void *)arg, flag, vs, bs); - return (error); - } - - case DKIOCFLUSHWRITECACHE: - dkc = (struct dk_callback *)arg; - mutex_exit(&zvol_state_lock); - zil_commit(zv->zv_zilog, UINT64_MAX, ZVOL_OBJ); - if ((flag & FKIOCTL) && dkc != NULL && dkc->dkc_callback) { - (*dkc->dkc_callback)(dkc->dkc_cookie, error); - error = 0; - } - return (error); - - case DKIOCGETWCE: - { - int wce = (zv->zv_flags & ZVOL_WCE) ? 1 : 0; - if (ddi_copyout(&wce, (void *)arg, sizeof (int), - flag)) - error = EFAULT; - break; - } - case DKIOCSETWCE: - { - int wce; - if (ddi_copyin((void *)arg, &wce, sizeof (int), - flag)) { - error = EFAULT; - break; - } - if (wce) { - zv->zv_flags |= ZVOL_WCE; - mutex_exit(&zvol_state_lock); - } else { - zv->zv_flags &= ~ZVOL_WCE; - mutex_exit(&zvol_state_lock); - zil_commit(zv->zv_zilog, UINT64_MAX, ZVOL_OBJ); - } - return (0); - } - - case DKIOCGGEOM: - case DKIOCGVTOC: - /* - * commands using these (like prtvtoc) expect ENOTSUP - * since we're emulating an EFI label - */ - error = ENOTSUP; - break; - - case DKIOCDUMPINIT: - rl = zfs_range_lock(&zv->zv_znode, 0, zv->zv_volsize, - RL_WRITER); - error = zvol_dumpify(zv); - zfs_range_unlock(rl); - break; - - case DKIOCDUMPFINI: - if (!(zv->zv_flags & ZVOL_DUMPIFIED)) - break; - rl = zfs_range_lock(&zv->zv_znode, 0, zv->zv_volsize, - RL_WRITER); - error = zvol_dump_fini(zv); - zfs_range_unlock(rl); - break; - - default: - error = ENOTTY; - break; - - } - mutex_exit(&zvol_state_lock); - return (error); -} - -int -zvol_busy(void) -{ - return (zvol_minors != 0); -} - -void -zvol_init(void) -{ - VERIFY(ddi_soft_state_init(&zvol_state, sizeof (zvol_state_t), 1) == 0); - mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL); -} - -void -zvol_fini(void) -{ - mutex_destroy(&zvol_state_lock); - ddi_soft_state_fini(&zvol_state); -} - -static boolean_t -zvol_is_swap(zvol_state_t *zv) -{ - vnode_t *vp; - boolean_t ret = B_FALSE; - char *devpath; - size_t devpathlen; - int error; - - devpathlen = strlen(ZVOL_FULL_DEV_DIR) + strlen(zv->zv_name) + 1; - devpath = kmem_alloc(devpathlen, KM_SLEEP); - (void) sprintf(devpath, "%s%s", ZVOL_FULL_DEV_DIR, zv->zv_name); - error = lookupname(devpath, UIO_SYSSPACE, FOLLOW, NULLVPP, &vp); - kmem_free(devpath, devpathlen); - - ret = !error && IS_SWAPVP(common_specvp(vp)); - - if (vp != NULL) - VN_RELE(vp); - - return (ret); -} - -static int -zvol_dump_init(zvol_state_t *zv, boolean_t resize) -{ - dmu_tx_t *tx; - int error = 0; - objset_t *os = zv->zv_objset; - nvlist_t *nv = NULL; - - ASSERT(MUTEX_HELD(&zvol_state_lock)); - - tx = dmu_tx_create(os); - dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); - error = dmu_tx_assign(tx, TXG_WAIT); - if (error) { - dmu_tx_abort(tx); - return (error); - } - - /* - * If we are resizing the dump device then we only need to - * update the refreservation to match the newly updated - * zvolsize. Otherwise, we save off the original state of the - * zvol so that we can restore them if the zvol is ever undumpified. - */ - if (resize) { - error = zap_update(os, ZVOL_ZAP_OBJ, - zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 8, 1, - &zv->zv_volsize, tx); - } else { - uint64_t checksum, compress, refresrv, vbs; - - error = dsl_prop_get_integer(zv->zv_name, - zfs_prop_to_name(ZFS_PROP_COMPRESSION), &compress, NULL); - error = error ? error : dsl_prop_get_integer(zv->zv_name, - zfs_prop_to_name(ZFS_PROP_CHECKSUM), &checksum, NULL); - error = error ? error : dsl_prop_get_integer(zv->zv_name, - zfs_prop_to_name(ZFS_PROP_REFRESERVATION), &refresrv, NULL); - error = error ? error : dsl_prop_get_integer(zv->zv_name, - zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), &vbs, NULL); - - error = error ? error : zap_update(os, ZVOL_ZAP_OBJ, - zfs_prop_to_name(ZFS_PROP_COMPRESSION), 8, 1, - &compress, tx); - error = error ? error : zap_update(os, ZVOL_ZAP_OBJ, - zfs_prop_to_name(ZFS_PROP_CHECKSUM), 8, 1, &checksum, tx); - error = error ? error : zap_update(os, ZVOL_ZAP_OBJ, - zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 8, 1, - &refresrv, tx); - error = error ? error : zap_update(os, ZVOL_ZAP_OBJ, - zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), 8, 1, - &vbs, tx); - } - dmu_tx_commit(tx); - - /* Truncate the file */ - if (!error) - error = dmu_free_long_range(zv->zv_objset, - ZVOL_OBJ, 0, DMU_OBJECT_END); - - if (error) - return (error); - - /* - * We only need update the zvol's property if we are initializing - * the dump area for the first time. - */ - if (!resize) { - VERIFY(nvlist_alloc(&nv, NV_UNIQUE_NAME, KM_SLEEP) == 0); - VERIFY(nvlist_add_uint64(nv, - zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 0) == 0); - VERIFY(nvlist_add_uint64(nv, - zfs_prop_to_name(ZFS_PROP_COMPRESSION), - ZIO_COMPRESS_OFF) == 0); - VERIFY(nvlist_add_uint64(nv, - zfs_prop_to_name(ZFS_PROP_CHECKSUM), - ZIO_CHECKSUM_OFF) == 0); - VERIFY(nvlist_add_uint64(nv, - zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), - SPA_MAXBLOCKSIZE) == 0); - - error = zfs_set_prop_nvlist(zv->zv_name, nv); - nvlist_free(nv); - - if (error) - return (error); - } - - /* Allocate the space for the dump */ - error = zvol_prealloc(zv); - return (error); -} - -static int -zvol_dumpify(zvol_state_t *zv) -{ - int error = 0; - uint64_t dumpsize = 0; - dmu_tx_t *tx; - objset_t *os = zv->zv_objset; - - if (zv->zv_flags & ZVOL_RDONLY || (zv->zv_mode & DS_MODE_READONLY)) - return (EROFS); - - /* - * We do not support swap devices acting as dump devices. - */ - if (zvol_is_swap(zv)) - return (ENOTSUP); - - if (zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, ZVOL_DUMPSIZE, - 8, 1, &dumpsize) != 0 || dumpsize != zv->zv_volsize) { - boolean_t resize = (dumpsize > 0) ? B_TRUE : B_FALSE; - - if ((error = zvol_dump_init(zv, resize)) != 0) { - (void) zvol_dump_fini(zv); - return (error); - } - } - - /* - * Build up our lba mapping. - */ - error = zvol_get_lbas(zv); - if (error) { - (void) zvol_dump_fini(zv); - return (error); - } - - tx = dmu_tx_create(os); - dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); - error = dmu_tx_assign(tx, TXG_WAIT); - if (error) { - dmu_tx_abort(tx); - (void) zvol_dump_fini(zv); - return (error); - } - - zv->zv_flags |= ZVOL_DUMPIFIED; - error = zap_update(os, ZVOL_ZAP_OBJ, ZVOL_DUMPSIZE, 8, 1, - &zv->zv_volsize, tx); - dmu_tx_commit(tx); - - if (error) { - (void) zvol_dump_fini(zv); - return (error); - } - - txg_wait_synced(dmu_objset_pool(os), 0); - return (0); -} - -static int -zvol_dump_fini(zvol_state_t *zv) -{ - dmu_tx_t *tx; - objset_t *os = zv->zv_objset; - nvlist_t *nv; - int error = 0; - uint64_t checksum, compress, refresrv, vbs; - - /* - * Attempt to restore the zvol back to its pre-dumpified state. - * This is a best-effort attempt as it's possible that not all - * of these properties were initialized during the dumpify process - * (i.e. error during zvol_dump_init). - */ - - tx = dmu_tx_create(os); - dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); - error = dmu_tx_assign(tx, TXG_WAIT); - if (error) { - dmu_tx_abort(tx); - return (error); - } - (void) zap_remove(os, ZVOL_ZAP_OBJ, ZVOL_DUMPSIZE, tx); - dmu_tx_commit(tx); - - (void) zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, - zfs_prop_to_name(ZFS_PROP_CHECKSUM), 8, 1, &checksum); - (void) zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, - zfs_prop_to_name(ZFS_PROP_COMPRESSION), 8, 1, &compress); - (void) zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, - zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 8, 1, &refresrv); - (void) zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, - zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), 8, 1, &vbs); - - VERIFY(nvlist_alloc(&nv, NV_UNIQUE_NAME, KM_SLEEP) == 0); - (void) nvlist_add_uint64(nv, - zfs_prop_to_name(ZFS_PROP_CHECKSUM), checksum); - (void) nvlist_add_uint64(nv, - zfs_prop_to_name(ZFS_PROP_COMPRESSION), compress); - (void) nvlist_add_uint64(nv, - zfs_prop_to_name(ZFS_PROP_REFRESERVATION), refresrv); - (void) nvlist_add_uint64(nv, - zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), vbs); - (void) zfs_set_prop_nvlist(zv->zv_name, nv); - nvlist_free(nv); - - zvol_free_extents(zv); - zv->zv_flags &= ~ZVOL_DUMPIFIED; - (void) dmu_free_long_range(os, ZVOL_OBJ, 0, DMU_OBJECT_END); - - return (0); -} diff --git a/scripts/common.sh b/scripts/common.sh index a5cfb53804..b7406b257e 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -5,9 +5,11 @@ # utilities will be used. If no .script-config can be found then the # installed kernel modules and utilities will be used. +basedir="$(dirname $0)" + SCRIPT_CONFIG=.script-config -if [ -f ../${SCRIPT_CONFIG} ]; then -. ../${SCRIPT_CONFIG} +if [ -f "${basedir}/../${SCRIPT_CONFIG}" ]; then +. "${basedir}/../${SCRIPT_CONFIG}" else MODULES=(zlib_deflate spl zavl znvpair zunicode zcommon zfs) fi @@ -19,19 +21,20 @@ FORCE= FORCE_FLAG= DUMP_LOG= ERROR= -UPATH="/dev/disk/zpool" RAID0S=() RAID10S=() RAIDZS=() RAIDZ2S=() -UDEVDIR=${UDEVDIR:-/usr/libexec/zfs/udev-rules} +ETCDIR=${ETCDIR:-/etc} +DEVDIR=${DEVDIR:-/dev/disk/zpool} ZPOOLDIR=${ZPOOLDIR:-/usr/libexec/zfs/zpool-config} ZDB=${ZDB:-/usr/sbin/zdb} ZFS=${ZFS:-/usr/sbin/zfs} ZINJECT=${ZINJECT:-/usr/sbin/zinject} ZPOOL=${ZPOOL:-/usr/sbin/zpool} +ZPOOL_ID=${ZPOOL_ID:-/usr/bin/zpool_id} ZTEST=${ZTEST:-/usr/sbin/ztest} COMMON_SH=${COMMON_SH:-/usr/libexec/zfs/common.sh} @@ -44,6 +47,8 @@ RMMOD=${RMMOD:-/sbin/rmmod} INFOMOD=${INFOMOD:-/sbin/modinfo} LOSETUP=${LOSETUP:-/sbin/losetup} SYSCTL=${SYSCTL:-/sbin/sysctl} +UDEVADM=${UDEVADM:-/sbin/udevadm} +AWK=${AWK:-/bin/awk} die() { echo -e "${PROG}: $1" >&2 @@ -159,7 +164,7 @@ unload_module() { unload_modules() { local MODULES_REVERSE=( $(echo ${MODULES[@]} | - awk '{for (i=NF;i>=1;i--) printf $i" "} END{print ""}') ) + ${AWK} '{for (i=NF;i>=1;i--) printf $i" "} END{print ""}') ) for MOD in ${MODULES_REVERSE[*]}; do local NAME=`basename ${MOD} .ko` @@ -205,13 +210,54 @@ unused_loop_device() { # udev_setup() { local SRC_PATH=$1 - local DST_FILE=`basename ${SRC_PATH} | cut -f1-2 -d'.'` - local DST_PATH=/etc/udev/rules.d/${DST_FILE} - cp -f ${SRC_PATH} ${DST_PATH} + # When running in tree manually contruct symlinks in tree to + # the proper devices. Symlinks are installed for all entires + # in the config file regardless of if that device actually + # exists. When installed as a package udev can be relied on for + # this and it will only create links for devices which exist. + if [ ${INTREE} ]; then + PWD=`pwd` + mkdir -p ${DEVDIR}/ + cd ${DEVDIR}/ + ${AWK} '!/^#/ && /./ { system( \ + "ln -f -s /dev/disk/by-path/"$2" "$1";" \ + "ln -f -s /dev/disk/by-path/"$2"-part1 "$1"p1;" \ + "ln -f -s /dev/disk/by-path/"$2"-part9 "$1"p9;" \ + ) }' $SRC_PATH + cd ${PWD} + else + DST_FILE=`basename ${SRC_PATH} | cut -f1-2 -d'.'` + DST_PATH=/etc/zfs/${DST_FILE} - udevadm trigger - udevadm settle + if [ -e ${DST_PATH} ]; then + die "Error: Config ${DST_PATH} already exists" + fi + + cp ${SRC_PATH} ${DST_PATH} + + if [ -f ${UDEVADM} ]; then + ${UDEVADM} trigger + ${UDEVADM} settle + else + /sbin/udevtrigger + /sbin/udevsettle + fi + fi + + return 0 +} + +udev_cleanup() { + local SRC_PATH=$1 + + if [ ${INTREE} ]; then + PWD=`pwd` + cd ${DEVDIR}/ + ${AWK} '!/^#/ && /./ { system( \ + "rm -f "$1" "$1"p1 "$1"p9") }' $SRC_PATH + cd ${PWD} + fi return 0 } @@ -232,7 +278,7 @@ udev_raid0_setup() { for RANK in `seq 1 ${RANKS}`; do for CHANNEL in `seq 1 ${CHANNELS}`; do DISK=`udev_cr2d ${CHANNEL} ${RANK}` - RAID0S[${IDX}]="${UPATH}/${DISK}" + RAID0S[${IDX}]="${DEVDIR}/${DISK}" let IDX=IDX+1 done done @@ -251,7 +297,7 @@ udev_raid10_setup() { let CHANNEL2=CHANNEL1+1 DISK1=`udev_cr2d ${CHANNEL1} ${RANK}` DISK2=`udev_cr2d ${CHANNEL2} ${RANK}` - GROUP="${UPATH}/${DISK1} ${UPATH}/${DISK2}" + GROUP="${DEVDIR}/${DISK1} ${DEVDIR}/${DISK2}" RAID10S[${IDX}]="mirror ${GROUP}" let IDX=IDX+1 done @@ -270,7 +316,7 @@ udev_raidz_setup() { for CHANNEL in `seq 1 ${CHANNELS}`; do DISK=`udev_cr2d ${CHANNEL} ${RANK}` - RAIDZ[${CHANNEL}]="${UPATH}/${DISK}" + RAIDZ[${CHANNEL}]="${DEVDIR}/${DISK}" done RAIDZS[${RANK}]="${RAIDZ[*]}" @@ -289,7 +335,7 @@ udev_raidz2_setup() { for CHANNEL in `seq 1 ${CHANNELS}`; do DISK=`udev_cr2d ${CHANNEL} ${RANK}` - RAIDZ2[${CHANNEL}]="${UPATH}/${DISK}" + RAIDZ2[${CHANNEL}]="${DEVDIR}/${DISK}" done RAIDZ2S[${RANK}]="${RAIDZ2[*]}" diff --git a/scripts/udev-rules/99-zpool.rules.dragon b/scripts/udev-rules/99-zpool.rules.dragon deleted file mode 100644 index 7c589f595f..0000000000 --- a/scripts/udev-rules/99-zpool.rules.dragon +++ /dev/null @@ -1,331 +0,0 @@ -# -# /etc/udev/rules.d/99-zpool.rules -# - -ENV{DEVTYPE}=="disk", IMPORT{program}="path_id %p" - -# Full devices (*:pci*port:*:id*) -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:3*", SYMLINK+="disk/zpool/a1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:4*", SYMLINK+="disk/zpool/a2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:5*", SYMLINK+="disk/zpool/a3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:6*", SYMLINK+="disk/zpool/a4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:7*", SYMLINK+="disk/zpool/a5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:8*", SYMLINK+="disk/zpool/a6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:9*", SYMLINK+="disk/zpool/a7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:10*", SYMLINK+="disk/zpool/a8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:11*", SYMLINK+="disk/zpool/a9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:12*", SYMLINK+="disk/zpool/a10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:13*", SYMLINK+="disk/zpool/a11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:14*", SYMLINK+="disk/zpool/a12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:15*", SYMLINK+="disk/zpool/a13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:16*", SYMLINK+="disk/zpool/a14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:17*", SYMLINK+="disk/zpool/a15" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:3*", SYMLINK+="disk/zpool/b1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:4*", SYMLINK+="disk/zpool/b2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:5*", SYMLINK+="disk/zpool/b3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:6*", SYMLINK+="disk/zpool/b4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:7*", SYMLINK+="disk/zpool/b5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:8*", SYMLINK+="disk/zpool/b6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:9*", SYMLINK+="disk/zpool/b7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:10*", SYMLINK+="disk/zpool/b8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:11*", SYMLINK+="disk/zpool/b9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:12*", SYMLINK+="disk/zpool/b10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:13*", SYMLINK+="disk/zpool/b11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:14*", SYMLINK+="disk/zpool/b12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:15*", SYMLINK+="disk/zpool/b13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:16*", SYMLINK+="disk/zpool/b14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*4:*:17*", SYMLINK+="disk/zpool/b15" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:3*", SYMLINK+="disk/zpool/c1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:4*", SYMLINK+="disk/zpool/c2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:5*", SYMLINK+="disk/zpool/c3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:6*", SYMLINK+="disk/zpool/c4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:7*", SYMLINK+="disk/zpool/c5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:8*", SYMLINK+="disk/zpool/c6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:9*", SYMLINK+="disk/zpool/c7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:10*", SYMLINK+="disk/zpool/c8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:11*", SYMLINK+="disk/zpool/c9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:12*", SYMLINK+="disk/zpool/c10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:13*", SYMLINK+="disk/zpool/c11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:14*", SYMLINK+="disk/zpool/c12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:15*", SYMLINK+="disk/zpool/c13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:16*", SYMLINK+="disk/zpool/c14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:17*", SYMLINK+="disk/zpool/c15" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:3*", SYMLINK+="disk/zpool/d1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:4*", SYMLINK+="disk/zpool/d2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:5*", SYMLINK+="disk/zpool/d3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:6*", SYMLINK+="disk/zpool/d4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:7*", SYMLINK+="disk/zpool/d5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:8*", SYMLINK+="disk/zpool/d6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:9*", SYMLINK+="disk/zpool/d7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:10*", SYMLINK+="disk/zpool/d8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:11*", SYMLINK+="disk/zpool/d9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:12*", SYMLINK+="disk/zpool/d10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:13*", SYMLINK+="disk/zpool/d11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:14*", SYMLINK+="disk/zpool/d12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:15*", SYMLINK+="disk/zpool/d13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:16*", SYMLINK+="disk/zpool/d14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*4:*:17*", SYMLINK+="disk/zpool/d15" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:3*", SYMLINK+="disk/zpool/e1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:4*", SYMLINK+="disk/zpool/e2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:5*", SYMLINK+="disk/zpool/e3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:6*", SYMLINK+="disk/zpool/e4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:7*", SYMLINK+="disk/zpool/e5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:8*", SYMLINK+="disk/zpool/e6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:9*", SYMLINK+="disk/zpool/e7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:10*", SYMLINK+="disk/zpool/e8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:11*", SYMLINK+="disk/zpool/e9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:12*", SYMLINK+="disk/zpool/e10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:13*", SYMLINK+="disk/zpool/e11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:14*", SYMLINK+="disk/zpool/e12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:15*", SYMLINK+="disk/zpool/e13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:16*", SYMLINK+="disk/zpool/e14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*0:*:17*", SYMLINK+="disk/zpool/e15" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:3*", SYMLINK+="disk/zpool/f1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:4*", SYMLINK+="disk/zpool/f2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:5*", SYMLINK+="disk/zpool/f3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:6*", SYMLINK+="disk/zpool/f4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:7*", SYMLINK+="disk/zpool/f5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:8*", SYMLINK+="disk/zpool/f6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:9*", SYMLINK+="disk/zpool/f7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:10*", SYMLINK+="disk/zpool/f8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:11*", SYMLINK+="disk/zpool/f9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:12*", SYMLINK+="disk/zpool/f10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:13*", SYMLINK+="disk/zpool/f11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:14*", SYMLINK+="disk/zpool/f12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:15*", SYMLINK+="disk/zpool/f13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:16*", SYMLINK+="disk/zpool/f14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:84:00.0*4:*:17*", SYMLINK+="disk/zpool/f15" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:3*", SYMLINK+="disk/zpool/g1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:4*", SYMLINK+="disk/zpool/g2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:5*", SYMLINK+="disk/zpool/g3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:6*", SYMLINK+="disk/zpool/g4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:7*", SYMLINK+="disk/zpool/g5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:8*", SYMLINK+="disk/zpool/g6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:9*", SYMLINK+="disk/zpool/g7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:10*", SYMLINK+="disk/zpool/g8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:11*", SYMLINK+="disk/zpool/g9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:12*", SYMLINK+="disk/zpool/g10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:13*", SYMLINK+="disk/zpool/g11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:14*", SYMLINK+="disk/zpool/g12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:15*", SYMLINK+="disk/zpool/g13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:16*", SYMLINK+="disk/zpool/g14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*0:*:17*", SYMLINK+="disk/zpool/g15" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:3*", SYMLINK+="disk/zpool/h1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:4*", SYMLINK+="disk/zpool/h2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:5*", SYMLINK+="disk/zpool/h3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:6*", SYMLINK+="disk/zpool/h4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:7*", SYMLINK+="disk/zpool/h5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:8*", SYMLINK+="disk/zpool/h6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:9*", SYMLINK+="disk/zpool/h7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:10*", SYMLINK+="disk/zpool/h8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:11*", SYMLINK+="disk/zpool/h9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:12*", SYMLINK+="disk/zpool/h10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:13*", SYMLINK+="disk/zpool/h11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:14*", SYMLINK+="disk/zpool/h12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:15*", SYMLINK+="disk/zpool/h13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:16*", SYMLINK+="disk/zpool/h14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:85:00.0*4:*:17*", SYMLINK+="disk/zpool/h15" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:0*", SYMLINK+="disk/zpool/i1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:1*", SYMLINK+="disk/zpool/i2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:2*", SYMLINK+="disk/zpool/i3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:3*", SYMLINK+="disk/zpool/i4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:4*", SYMLINK+="disk/zpool/i5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:5*", SYMLINK+="disk/zpool/i6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:6*", SYMLINK+="disk/zpool/i7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:7*", SYMLINK+="disk/zpool/i8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:8*", SYMLINK+="disk/zpool/i9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:9*", SYMLINK+="disk/zpool/i10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:10*", SYMLINK+="disk/zpool/i11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:11*", SYMLINK+="disk/zpool/i12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:12*", SYMLINK+="disk/zpool/i13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:13*", SYMLINK+="disk/zpool/i14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:14*", SYMLINK+="disk/zpool/i15" -#ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*0:*:15*", SYMLINK+="disk/zpool/i16" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:0*", SYMLINK+="disk/zpool/j1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:1*", SYMLINK+="disk/zpool/j2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:2*", SYMLINK+="disk/zpool/j3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:3*", SYMLINK+="disk/zpool/j4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:4*", SYMLINK+="disk/zpool/j5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:5*", SYMLINK+="disk/zpool/j6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:6*", SYMLINK+="disk/zpool/j7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:7*", SYMLINK+="disk/zpool/j8" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:8*", SYMLINK+="disk/zpool/j9" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:9*", SYMLINK+="disk/zpool/j10" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:10*", SYMLINK+="disk/zpool/j11" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:11*", SYMLINK+="disk/zpool/j12" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:12*", SYMLINK+="disk/zpool/j13" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:13*", SYMLINK+="disk/zpool/j14" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:14*", SYMLINK+="disk/zpool/j15" -#ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:83:00.0*4:*:15*", SYMLINK+="disk/zpool/j16" - -# Partitions (*:pci*port:*:id*) -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:3*", SYMLINK+="disk/zpool/a1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:4*", SYMLINK+="disk/zpool/a2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:5*", SYMLINK+="disk/zpool/a3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:6*", SYMLINK+="disk/zpool/a4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:7*", SYMLINK+="disk/zpool/a5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:8*", SYMLINK+="disk/zpool/a6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:9*", SYMLINK+="disk/zpool/a7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:10*", SYMLINK+="disk/zpool/a8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:11*", SYMLINK+="disk/zpool/a9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:12*", SYMLINK+="disk/zpool/a10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:13*", SYMLINK+="disk/zpool/a11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:14*", SYMLINK+="disk/zpool/a12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:15*", SYMLINK+="disk/zpool/a13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:16*", SYMLINK+="disk/zpool/a14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:17*", SYMLINK+="disk/zpool/a15-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:3*", SYMLINK+="disk/zpool/b1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:4*", SYMLINK+="disk/zpool/b2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:5*", SYMLINK+="disk/zpool/b3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:6*", SYMLINK+="disk/zpool/b4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:7*", SYMLINK+="disk/zpool/b5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:8*", SYMLINK+="disk/zpool/b6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:9*", SYMLINK+="disk/zpool/b7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:10*", SYMLINK+="disk/zpool/b8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:11*", SYMLINK+="disk/zpool/b9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:12*", SYMLINK+="disk/zpool/b10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:13*", SYMLINK+="disk/zpool/b11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:14*", SYMLINK+="disk/zpool/b12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:15*", SYMLINK+="disk/zpool/b13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:16*", SYMLINK+="disk/zpool/b14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*4:*:17*", SYMLINK+="disk/zpool/b15-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:3*", SYMLINK+="disk/zpool/c1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:4*", SYMLINK+="disk/zpool/c2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:5*", SYMLINK+="disk/zpool/c3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:6*", SYMLINK+="disk/zpool/c4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:7*", SYMLINK+="disk/zpool/c5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:8*", SYMLINK+="disk/zpool/c6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:9*", SYMLINK+="disk/zpool/c7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:10*", SYMLINK+="disk/zpool/c8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:11*", SYMLINK+="disk/zpool/c9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:12*", SYMLINK+="disk/zpool/c10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:13*", SYMLINK+="disk/zpool/c11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:14*", SYMLINK+="disk/zpool/c12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:15*", SYMLINK+="disk/zpool/c13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:16*", SYMLINK+="disk/zpool/c14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:17*", SYMLINK+="disk/zpool/c15-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:3*", SYMLINK+="disk/zpool/d1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:4*", SYMLINK+="disk/zpool/d2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:5*", SYMLINK+="disk/zpool/d3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:6*", SYMLINK+="disk/zpool/d4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:7*", SYMLINK+="disk/zpool/d5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:8*", SYMLINK+="disk/zpool/d6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:9*", SYMLINK+="disk/zpool/d7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:10*", SYMLINK+="disk/zpool/d8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:11*", SYMLINK+="disk/zpool/d9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:12*", SYMLINK+="disk/zpool/d10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:13*", SYMLINK+="disk/zpool/d11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:14*", SYMLINK+="disk/zpool/d12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:15*", SYMLINK+="disk/zpool/d13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:16*", SYMLINK+="disk/zpool/d14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*4:*:17*", SYMLINK+="disk/zpool/d15-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:3*", SYMLINK+="disk/zpool/e1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:4*", SYMLINK+="disk/zpool/e2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:5*", SYMLINK+="disk/zpool/e3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:6*", SYMLINK+="disk/zpool/e4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:7*", SYMLINK+="disk/zpool/e5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:8*", SYMLINK+="disk/zpool/e6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:9*", SYMLINK+="disk/zpool/e7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:10*", SYMLINK+="disk/zpool/e8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:11*", SYMLINK+="disk/zpool/e9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:12*", SYMLINK+="disk/zpool/e10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:13*", SYMLINK+="disk/zpool/e11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:14*", SYMLINK+="disk/zpool/e12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:15*", SYMLINK+="disk/zpool/e13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:16*", SYMLINK+="disk/zpool/e14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*0:*:17*", SYMLINK+="disk/zpool/e15-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:3*", SYMLINK+="disk/zpool/f1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:4*", SYMLINK+="disk/zpool/f2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:5*", SYMLINK+="disk/zpool/f3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:6*", SYMLINK+="disk/zpool/f4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:7*", SYMLINK+="disk/zpool/f5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:8*", SYMLINK+="disk/zpool/f6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:9*", SYMLINK+="disk/zpool/f7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:10*", SYMLINK+="disk/zpool/f8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:11*", SYMLINK+="disk/zpool/f9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:12*", SYMLINK+="disk/zpool/f10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:13*", SYMLINK+="disk/zpool/f11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:14*", SYMLINK+="disk/zpool/f12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:15*", SYMLINK+="disk/zpool/f13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:16*", SYMLINK+="disk/zpool/f14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:84:00.0*4:*:17*", SYMLINK+="disk/zpool/f15-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:3*", SYMLINK+="disk/zpool/g1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:4*", SYMLINK+="disk/zpool/g2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:5*", SYMLINK+="disk/zpool/g3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:6*", SYMLINK+="disk/zpool/g4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:7*", SYMLINK+="disk/zpool/g5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:8*", SYMLINK+="disk/zpool/g6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:9*", SYMLINK+="disk/zpool/g7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:10*", SYMLINK+="disk/zpool/g8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:11*", SYMLINK+="disk/zpool/g9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:12*", SYMLINK+="disk/zpool/g10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:13*", SYMLINK+="disk/zpool/g11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:14*", SYMLINK+="disk/zpool/g12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:15*", SYMLINK+="disk/zpool/g13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:16*", SYMLINK+="disk/zpool/g14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*0:*:17*", SYMLINK+="disk/zpool/g15-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:3*", SYMLINK+="disk/zpool/h1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:4*", SYMLINK+="disk/zpool/h2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:5*", SYMLINK+="disk/zpool/h3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:6*", SYMLINK+="disk/zpool/h4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:7*", SYMLINK+="disk/zpool/h5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:8*", SYMLINK+="disk/zpool/h6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:9*", SYMLINK+="disk/zpool/h7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:10*", SYMLINK+="disk/zpool/h8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:11*", SYMLINK+="disk/zpool/h9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:12*", SYMLINK+="disk/zpool/h10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:13*", SYMLINK+="disk/zpool/h11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:14*", SYMLINK+="disk/zpool/h12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:15*", SYMLINK+="disk/zpool/h13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:16*", SYMLINK+="disk/zpool/h14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:85:00.0*4:*:17*", SYMLINK+="disk/zpool/h15-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:0*", SYMLINK+="disk/zpool/i1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:1*", SYMLINK+="disk/zpool/i2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:2*", SYMLINK+="disk/zpool/i3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:3*", SYMLINK+="disk/zpool/i4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:4*", SYMLINK+="disk/zpool/i5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:5*", SYMLINK+="disk/zpool/i6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:6*", SYMLINK+="disk/zpool/i7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:7*", SYMLINK+="disk/zpool/i8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:8*", SYMLINK+="disk/zpool/i9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:9*", SYMLINK+="disk/zpool/i10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:10*", SYMLINK+="disk/zpool/i11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:11*", SYMLINK+="disk/zpool/i12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:12*", SYMLINK+="disk/zpool/i13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:13*", SYMLINK+="disk/zpool/i14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:14*", SYMLINK+="disk/zpool/i15-part%n" -#ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*0:*:15*", SYMLINK+="disk/zpool/i16-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:0*", SYMLINK+="disk/zpool/j1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:1*", SYMLINK+="disk/zpool/j2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:2*", SYMLINK+="disk/zpool/j3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:3*", SYMLINK+="disk/zpool/j4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:4*", SYMLINK+="disk/zpool/j5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:5*", SYMLINK+="disk/zpool/j6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:6*", SYMLINK+="disk/zpool/j7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:7*", SYMLINK+="disk/zpool/j8-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:8*", SYMLINK+="disk/zpool/j9-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:9*", SYMLINK+="disk/zpool/j10-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:10*", SYMLINK+="disk/zpool/j11-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:11*", SYMLINK+="disk/zpool/j12-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:12*", SYMLINK+="disk/zpool/j13-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:13*", SYMLINK+="disk/zpool/j14-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:14*", SYMLINK+="disk/zpool/j15-part%n" -#ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:83:00.0*4:*:15*", SYMLINK+="disk/zpool/j16-part%n" diff --git a/scripts/udev-rules/99-zpool.rules.x4550 b/scripts/udev-rules/99-zpool.rules.x4550 deleted file mode 100644 index b2b99513d3..0000000000 --- a/scripts/udev-rules/99-zpool.rules.x4550 +++ /dev/null @@ -1,115 +0,0 @@ -# -# /etc/udev/rules.d/99-zpool.rules -# - -ENV{DEVTYPE}=="disk", IMPORT{program}="path_id %p" - -# Full devices (*:pci*port:*:id*) -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:02:00.0*0:*:0*", SYMLINK+="disk/zpool/a1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:02:00.0*0:*:1*", SYMLINK+="disk/zpool/a2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:02:00.0*0:*:2*", SYMLINK+="disk/zpool/a3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:02:00.0*0:*:3*", SYMLINK+="disk/zpool/a4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:02:00.0*0:*:4*", SYMLINK+="disk/zpool/a5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:02:00.0*0:*:5*", SYMLINK+="disk/zpool/a6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:02:00.0*0:*:6*", SYMLINK+="disk/zpool/a7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:02:00.0*0:*:7*", SYMLINK+="disk/zpool/a8" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:0*", SYMLINK+="disk/zpool/b1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:1*", SYMLINK+="disk/zpool/b2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:2*", SYMLINK+="disk/zpool/b3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:3*", SYMLINK+="disk/zpool/b4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:4*", SYMLINK+="disk/zpool/b5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:5*", SYMLINK+="disk/zpool/b6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:6*", SYMLINK+="disk/zpool/b7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:03:00.0*0:*:7*", SYMLINK+="disk/zpool/b8" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:0*", SYMLINK+="disk/zpool/c1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:1*", SYMLINK+="disk/zpool/c2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:2*", SYMLINK+="disk/zpool/c3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:3*", SYMLINK+="disk/zpool/c4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:4*", SYMLINK+="disk/zpool/c5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:5*", SYMLINK+="disk/zpool/c6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:6*", SYMLINK+="disk/zpool/c7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:04:00.0*0:*:7*", SYMLINK+="disk/zpool/c8" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:41:00.0*0:*:0*", SYMLINK+="disk/zpool/d1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:41:00.0*0:*:1*", SYMLINK+="disk/zpool/d2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:41:00.0*0:*:2*", SYMLINK+="disk/zpool/d3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:41:00.0*0:*:3*", SYMLINK+="disk/zpool/d4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:41:00.0*0:*:4*", SYMLINK+="disk/zpool/d5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:41:00.0*0:*:5*", SYMLINK+="disk/zpool/d6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:41:00.0*0:*:6*", SYMLINK+="disk/zpool/d7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:41:00.0*0:*:7*", SYMLINK+="disk/zpool/d8" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:42:00.0*0:*:0*", SYMLINK+="disk/zpool/e1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:42:00.0*0:*:1*", SYMLINK+="disk/zpool/e2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:42:00.0*0:*:2*", SYMLINK+="disk/zpool/e3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:42:00.0*0:*:3*", SYMLINK+="disk/zpool/e4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:42:00.0*0:*:4*", SYMLINK+="disk/zpool/e5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:42:00.0*0:*:5*", SYMLINK+="disk/zpool/e6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:42:00.0*0:*:6*", SYMLINK+="disk/zpool/e7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:42:00.0*0:*:7*", SYMLINK+="disk/zpool/e8" - -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:43:00.0*0:*:0*", SYMLINK+="disk/zpool/f1" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:43:00.0*0:*:1*", SYMLINK+="disk/zpool/f2" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:43:00.0*0:*:2*", SYMLINK+="disk/zpool/f3" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:43:00.0*0:*:3*", SYMLINK+="disk/zpool/f4" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:43:00.0*0:*:4*", SYMLINK+="disk/zpool/f5" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:43:00.0*0:*:5*", SYMLINK+="disk/zpool/f6" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:43:00.0*0:*:6*", SYMLINK+="disk/zpool/f7" -ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="*:43:00.0*0:*:7*", SYMLINK+="disk/zpool/f8" - -# Partitions (*:pci*port:*:id*) -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:02:00.0*0:*:0*", SYMLINK+="disk/zpool/a1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:02:00.0*0:*:1*", SYMLINK+="disk/zpool/a2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:02:00.0*0:*:2*", SYMLINK+="disk/zpool/a3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:02:00.0*0:*:3*", SYMLINK+="disk/zpool/a4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:02:00.0*0:*:4*", SYMLINK+="disk/zpool/a5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:02:00.0*0:*:5*", SYMLINK+="disk/zpool/a6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:02:00.0*0:*:6*", SYMLINK+="disk/zpool/a7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:02:00.0*0:*:7*", SYMLINK+="disk/zpool/a8-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:0*", SYMLINK+="disk/zpool/b1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:1*", SYMLINK+="disk/zpool/b2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:2*", SYMLINK+="disk/zpool/b3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:3*", SYMLINK+="disk/zpool/b4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:4*", SYMLINK+="disk/zpool/b5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:5*", SYMLINK+="disk/zpool/b6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:6*", SYMLINK+="disk/zpool/b7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:03:00.0*0:*:7*", SYMLINK+="disk/zpool/b8-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:0*", SYMLINK+="disk/zpool/c1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:1*", SYMLINK+="disk/zpool/c2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:2*", SYMLINK+="disk/zpool/c3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:3*", SYMLINK+="disk/zpool/c4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:4*", SYMLINK+="disk/zpool/c5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:5*", SYMLINK+="disk/zpool/c6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:6*", SYMLINK+="disk/zpool/c7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:04:00.0*0:*:7*", SYMLINK+="disk/zpool/c8-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:41:00.0*0:*:0*", SYMLINK+="disk/zpool/d1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:41:00.0*0:*:1*", SYMLINK+="disk/zpool/d2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:41:00.0*0:*:2*", SYMLINK+="disk/zpool/d3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:41:00.0*0:*:3*", SYMLINK+="disk/zpool/d4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:41:00.0*0:*:4*", SYMLINK+="disk/zpool/d5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:41:00.0*0:*:5*", SYMLINK+="disk/zpool/d6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:41:00.0*0:*:6*", SYMLINK+="disk/zpool/d7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:41:00.0*0:*:7*", SYMLINK+="disk/zpool/d8-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:42:00.0*0:*:0*", SYMLINK+="disk/zpool/e1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:42:00.0*0:*:1*", SYMLINK+="disk/zpool/e2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:42:00.0*0:*:2*", SYMLINK+="disk/zpool/e3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:42:00.0*0:*:3*", SYMLINK+="disk/zpool/e4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:42:00.0*0:*:4*", SYMLINK+="disk/zpool/e5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:42:00.0*0:*:5*", SYMLINK+="disk/zpool/e6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:42:00.0*0:*:6*", SYMLINK+="disk/zpool/e7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:42:00.0*0:*:7*", SYMLINK+="disk/zpool/e8-part%n" - -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:43:00.0*0:*:0*", SYMLINK+="disk/zpool/f1-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:43:00.0*0:*:1*", SYMLINK+="disk/zpool/f2-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:43:00.0*0:*:2*", SYMLINK+="disk/zpool/f3-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:43:00.0*0:*:3*", SYMLINK+="disk/zpool/f4-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:43:00.0*0:*:4*", SYMLINK+="disk/zpool/f5-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:43:00.0*0:*:5*", SYMLINK+="disk/zpool/f6-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:43:00.0*0:*:6*", SYMLINK+="disk/zpool/f7-part%n" -ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="*:43:00.0*0:*:7*", SYMLINK+="disk/zpool/f8-part%n" diff --git a/scripts/zconfig.sh b/scripts/zconfig.sh index 7a215dcee3..52dfc6897a 100755 --- a/scripts/zconfig.sh +++ b/scripts/zconfig.sh @@ -2,9 +2,11 @@ # # ZFS/ZPOOL configuration test script. +basedir="$(dirname $0)" + SCRIPT_COMMON=common.sh -if [ -f ./${SCRIPT_COMMON} ]; then -. ./${SCRIPT_COMMON} +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then . /usr/libexec/zfs/${SCRIPT_COMMON} else @@ -115,4 +117,52 @@ zconfig_test2() { } zconfig_test2 +# ZVOL sanity check +zconfig_test3() { + POOL_NAME=tank + ZVOL_NAME=fish + FULL_NAME=${POOL_NAME}/${ZVOL_NAME} + SRC_DIR=/bin/ + TMP_FILE1=`mktemp` + TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX` + + echo -n "test 3 - ZVOL sanity: " + + # Create a pool and volume. + ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1 + ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2 + ${ZFS} create -V 400M ${FULL_NAME} || fail 3 + + # Partition the volume, for a 400M volume there will be + # 812 cylinders, 16 heads, and 63 sectors per track. + /sbin/sfdisk -q /dev/${FULL_NAME} << EOF &>${TMP_FILE1} || fail 4 +,812 +; +; +; +EOF + + # Format the partition with ext3. + /sbin/mkfs.ext3 /dev/${FULL_NAME}1 &>${TMP_FILE1} || fail 5 + + # Mount the ext3 filesystem and copy some data to it. + mkdir -p /tmp/${ZVOL_NAME} || fail 6 + mount /dev/${FULL_NAME}1 /tmp/${ZVOL_NAME} || fail 7 + cp -RL ${SRC_DIR} /tmp/${ZVOL_NAME} || fail 8 + + # Verify the copied files match the original files. + diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}${SRC_DIR} || fail 9 + + # Remove the files, umount, destroy the volume and pool. + rm -Rf /tmp/${ZVOL_NAME}${SRC_DIR}* || fail 10 + umount /tmp/${ZVOL_NAME} || fail 11 + ${ZFS} destroy ${FULL_NAME} || fail 12 + ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 13 + rm -f ${TMP_FILE1} || fail 14 + ${ZFS_SH} -u || fail 15 + + pass +} +zconfig_test3 + exit 0 diff --git a/scripts/zfs-update.sh b/scripts/zfs-update.sh index ea449e7b25..1b74b7e7ee 100755 --- a/scripts/zfs-update.sh +++ b/scripts/zfs-update.sh @@ -9,6 +9,8 @@ trap die_int INT RELEASE=$1 PROG=update-zfs.sh +REMOTE_DOC_FILE=man-sunosman-20090930.tar.bz2 +REMOTE_DOC=http://dlc.sun.com/osol/man/downloads/current/${REMOTE_DOC_FILE} REMOTE_SRC=http://dlc.sun.com/osol/on/downloads/${RELEASE}/on-src.tar.bz2 die() { @@ -26,36 +28,51 @@ if [ `basename $DST` != "scripts" ]; then die "Must be run from scripts directory" fi +if [ ! "$RELEASE" ]; then + die "Must specify ZFS release build" +fi + SRC=`mktemp -d /tmp/os-${RELEASE}.XXXXXXXXXX` DST=`dirname $DST` -echo "----------------------------------------------------------------------" +echo "----------------------------------------------------------------" echo "Remote Source: ${REMOTE_SRC}" +echo "Remote Docs: ${REMOTE_DOC}" echo "Local Source: ${SRC}" echo "Local Dest: ${DST}" echo echo "------------- Fetching OpenSolaris ${RELEASE} archive ----------------" -wget ${REMOTE_SRC} -P ${SRC} || +wget -q ${REMOTE_SRC} -P ${SRC} || die "Error 'wget ${REMOTE_SRC}'" +echo "------------- Fetching OpenSolaris documentation ---------------" +wget -q ${REMOTE_DOC} -P ${SRC} || + die "Error 'wget ${REMOTE_DOC}'" + echo "------------- Unpacking OpenSolaris ${RELEASE} archive ---------------" tar -xjf ${SRC}/on-src.tar.bz2 -C ${SRC} || die "Error 'tar -xjf ${SRC}/on-src.tar.bz2 -C ${SRC}'" +echo "------------- Unpacking OpenSolaris documentation --------------" +tar -xjf ${SRC}/${REMOTE_DOC_FILE} -C ${SRC} || + die "Error 'tar -xjf ${SRC}/${REMOTE_DOC_FILE} -C ${SRC}'" + SRC_LIB=${SRC}/usr/src/lib SRC_CMD=${SRC}/usr/src/cmd SRC_CM=${SRC}/usr/src/common SRC_UTS=${SRC}/usr/src/uts SRC_UCM=${SRC}/usr/src/uts/common SRC_ZLIB=${SRC}/usr/src/uts/common/fs/zfs +SRC_MAN=${SRC}/man DST_MOD=${DST}/module DST_LIB=${DST}/lib DST_CMD=${DST}/cmd +DST_MAN=${DST}/man +umask 022 rm -Rf ${DST}/zfs -echo echo "------------- Updating ZFS from OpenSolaris ${RELEASE} ---------------" echo "* module/avl" mkdir -p ${DST_MOD}/avl/include/sys/ @@ -66,6 +83,7 @@ cp ${SRC_UCM}/sys/avl_impl.h ${DST_MOD}/avl/include/sys/ echo "* module/nvpair" mkdir -p ${DST_MOD}/nvpair/include/sys/ cp ${SRC_CM}/nvpair/nvpair.c ${DST_MOD}/nvpair/ +cp ${SRC_CM}/nvpair/nvpair_alloc_fixed.c ${DST_MOD}/nvpair/ cp ${SRC_UCM}/sys/nvpair.h ${DST_MOD}/nvpair/include/sys/ cp ${SRC_UCM}/sys/nvpair_impl.h ${DST_MOD}/nvpair/include/sys/ @@ -77,18 +95,21 @@ cp ${SRC_UCM}/sys/u8_textprep_data.h ${DST_MOD}/unicode/include/sys/ echo "* module/zcommon" mkdir -p ${DST_MOD}/zcommon/include/sys/fs/ -mkdir -p ${DST_MOD}/zcommon/include/sys/fm/fs/ cp ${SRC_CM}/zfs/*.c ${DST_MOD}/zcommon/ cp ${SRC_CM}/zfs/*.h ${DST_MOD}/zcommon/include/ cp ${SRC_UCM}/sys/fs/zfs.h ${DST_MOD}/zcommon/include/sys/fs/ -cp ${SRC_UCM}/sys/fm/fs/zfs.h ${DST_MOD}/zcommon/include/sys/fm/fs/ echo "* module/zfs" -mkdir -p ${DST_MOD}/zpool/include/sys/ +mkdir -p ${DST_MOD}/zfs/include/sys/fm/fs/ cp ${SRC_UTS}/intel/zfs/spa_boot.c ${DST_MOD}/zfs/ cp ${SRC_ZLIB}/*.c ${DST_MOD}/zfs/ cp ${SRC_ZLIB}/sys/*.h ${DST_MOD}/zfs/include/sys/ +cp ${SRC_UCM}/os/fm.c ${DST_MOD}/zfs/ +cp ${SRC_UCM}/sys/fm/protocol.h ${DST_MOD}/zfs/include/sys/fm/ +cp ${SRC_UCM}/sys/fm/util.h ${DST_MOD}/zfs/include/sys/fm/ +cp ${SRC_UCM}/sys/fm/fs/zfs.h ${DST_MOD}/zfs/include/sys/fm/fs/ rm ${DST_MOD}/zfs/vdev_disk.c +rm ${DST_MOD}/zfs/zvol.c rm ${DST_MOD}/zfs/include/sys/vdev_disk.h echo "* lib/libavl" @@ -149,6 +170,13 @@ echo "* cmd/ztest" mkdir -p ${DST_CMD}/ztest cp ${SRC_CMD}/ztest/*.c ${DST_CMD}/ztest/ +echo "* man/" +mkdir -p ${DST_MAN}/man8 +cp ${SRC_MAN}/man1m/zfs.1m ${DST_MAN}/man8/zfs.8 +cp ${SRC_MAN}/man1m/zpool.1m ${DST_MAN}/man8/zpool.8 +cp ${SRC_MAN}/man1m/zdb.1m ${DST_MAN}/man8/zdb.8 +chmod -R 644 ${DST_MAN}/man8/* + echo "${REMOTE_SRC}" >${DST}/ZFS.RELEASE rm -Rf ${SRC} diff --git a/scripts/zfs.sh b/scripts/zfs.sh index 2906a54cf9..a342aad4dc 100755 --- a/scripts/zfs.sh +++ b/scripts/zfs.sh @@ -2,9 +2,11 @@ # # A simple script to simply the loading/unloading the ZFS module stack. +basedir="$(dirname $0)" + SCRIPT_COMMON=common.sh -if [ -f ./${SCRIPT_COMMON} ]; then -. ./${SCRIPT_COMMON} +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then . /usr/libexec/zfs/${SCRIPT_COMMON} else diff --git a/scripts/zpool-config/dragon-raid0-1x70.sh b/scripts/zpool-config/dragon-raid0-1x70.sh index 8caffc4c4e..dda9957002 100644 --- a/scripts/zpool-config/dragon-raid0-1x70.sh +++ b/scripts/zpool-config/dragon-raid0-1x70.sh @@ -7,7 +7,7 @@ RANKS=7 CHANNELS=10 zpool_create() { - udev_setup ${UDEVDIR}/99-zpool.rules.dragon + udev_setup ${ETCDIR}/zfs/zdev.conf.dragon.example udev_raid0_setup ${RANKS} ${CHANNELS} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]} @@ -17,4 +17,5 @@ zpool_create() { zpool_destroy() { msg ${ZPOOL} destroy ${ZPOOL_NAME} ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.dragon.example } diff --git a/scripts/zpool-config/dragon-raid10-35x2.sh b/scripts/zpool-config/dragon-raid10-35x2.sh index f197136fe5..37f2a539ac 100644 --- a/scripts/zpool-config/dragon-raid10-35x2.sh +++ b/scripts/zpool-config/dragon-raid10-35x2.sh @@ -7,7 +7,7 @@ RANKS=7 CHANNELS=10 zpool_create() { - udev_setup ${UDEVDIR}/99-zpool.rules.dragon + udev_setup ${ETCDIR}/zfs/zdev.conf.dragon.example udev_raid10_setup ${RANKS} ${CHANNELS} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]} @@ -17,4 +17,5 @@ zpool_create() { zpool_destroy() { msg ${ZPOOL} destroy ${ZPOOL_NAME} ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.dragon.example } diff --git a/scripts/zpool-config/dragon-raidz-7x10.sh b/scripts/zpool-config/dragon-raidz-7x10.sh index e7d793d3c3..9857cf1c02 100644 --- a/scripts/zpool-config/dragon-raidz-7x10.sh +++ b/scripts/zpool-config/dragon-raidz-7x10.sh @@ -7,7 +7,7 @@ RANKS=7 CHANNELS=10 zpool_create() { - udev_setup ${UDEVDIR}/99-zpool.rules.dragon + udev_setup ${ETCDIR}/zfs/zdev.conf.dragon.example udev_raidz_setup ${RANKS} ${CHANNELS} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]} @@ -17,4 +17,5 @@ zpool_create() { zpool_destroy() { msg ${ZPOOL} destroy ${ZPOOL_NAME} ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.dragon.example } diff --git a/scripts/zpool-config/dragon-raidz2-7x10.sh b/scripts/zpool-config/dragon-raidz2-7x10.sh index a3a2ef58ba..0dd07a19bd 100644 --- a/scripts/zpool-config/dragon-raidz2-7x10.sh +++ b/scripts/zpool-config/dragon-raidz2-7x10.sh @@ -7,7 +7,7 @@ RANKS=7 CHANNELS=10 zpool_create() { - udev_setup ${UDEVDIR}/99-zpool.rules.dragon + udev_setup ${ETCDIR}/zfs/zdev.conf.dragon.example udev_raidz2_setup ${RANKS} ${CHANNELS} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]} @@ -17,4 +17,5 @@ zpool_create() { zpool_destroy() { msg ${ZPOOL} destroy ${ZPOOL_NAME} ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.dragon.example } diff --git a/scripts/zpool-config/supermicro-raid0-1x16.sh b/scripts/zpool-config/supermicro-raid0-1x16.sh new file mode 100644 index 0000000000..efe48459df --- /dev/null +++ b/scripts/zpool-config/supermicro-raid0-1x16.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Supermicro (White Box) Raid-0 Configuration (1x16) +# + +RANKS=4 +CHANNELS=4 + +zpool_create() { + udev_setup ${ETCDIR}/zfs/zdev.conf.supermicro.example + udev_raid0_setup ${RANKS} ${CHANNELS} + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]} || exit 1 +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.supermicro.example +} diff --git a/scripts/zpool-config/supermicro-raid10-8x2.sh b/scripts/zpool-config/supermicro-raid10-8x2.sh new file mode 100644 index 0000000000..a6e6be6c02 --- /dev/null +++ b/scripts/zpool-config/supermicro-raid10-8x2.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Supermicro (White Box) Raid-10 Configuration (8x2(1+1)) +# + +RANKS=4 +CHANNELS=4 + +zpool_create() { + udev_setup ${ETCDIR}/zfs/zdev.conf.supermicro.example + udev_raid10_setup ${RANKS} ${CHANNELS} + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]} || exit 1 +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.supermicro.example +} diff --git a/scripts/zpool-config/supermicro-raidz-4x4.sh b/scripts/zpool-config/supermicro-raidz-4x4.sh new file mode 100644 index 0000000000..9ed2780e9d --- /dev/null +++ b/scripts/zpool-config/supermicro-raidz-4x4.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Supermicro (White Box) Raid-Z Configuration (4x4(3+1)) +# + +RANKS=4 +CHANNELS=4 + +zpool_create() { + udev_setup ${ETCDIR}/zfs/zdev.conf.supermicro.example + udev_raidz_setup ${RANKS} ${CHANNELS} + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]} || exit 1 +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.supermicro.example +} diff --git a/scripts/zpool-config/supermicro-raidz2-4x4.sh b/scripts/zpool-config/supermicro-raidz2-4x4.sh new file mode 100644 index 0000000000..ed3eedfdf0 --- /dev/null +++ b/scripts/zpool-config/supermicro-raidz2-4x4.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Supermicro (White Box) Raid-Z2 Configuration (4x4(2+2)) +# + +RANKS=4 +CHANNELS=4 + +zpool_create() { + udev_setup ${ETCDIR}/zfs/zdev.conf.supermicro.example + udev_raidz2_setup ${RANKS} ${CHANNELS} + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]} || exit 1 +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.supermicro.example +} diff --git a/scripts/zpool-config/x4550-raid0-1x48.sh b/scripts/zpool-config/x4550-raid0-1x48.sh index 8082fea204..16156aa097 100644 --- a/scripts/zpool-config/x4550-raid0-1x48.sh +++ b/scripts/zpool-config/x4550-raid0-1x48.sh @@ -7,7 +7,7 @@ RANKS=8 CHANNELS=6 zpool_create() { - udev_setup ${UDEVDIR}/99-zpool.rules.x4550 + udev_setup ${ETCDIR}/zfs/zdev.conf.x4550.example udev_raid0_setup ${RANKS} ${CHANNELS} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]} @@ -17,4 +17,5 @@ zpool_create() { zpool_destroy() { msg ${ZPOOL} destroy ${ZPOOL_NAME} ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.x4550.example } diff --git a/scripts/zpool-config/x4550-raid10-24x2.sh b/scripts/zpool-config/x4550-raid10-24x2.sh index fb323716d6..ec91f43e6e 100644 --- a/scripts/zpool-config/x4550-raid10-24x2.sh +++ b/scripts/zpool-config/x4550-raid10-24x2.sh @@ -7,7 +7,7 @@ RANKS=8 CHANNELS=6 zpool_create() { - udev_setup ${UDEVDIR}/99-zpool.rules.x4550 + udev_setup ${ETCDIR}/zfs/zdev.conf.x4550.example udev_raid10_setup ${RANKS} ${CHANNELS} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]} @@ -17,4 +17,5 @@ zpool_create() { zpool_destroy() { msg ${ZPOOL} destroy ${ZPOOL_NAME} ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.x4550.example } diff --git a/scripts/zpool-config/x4550-raidz-8x6.sh b/scripts/zpool-config/x4550-raidz-8x6.sh index d92974cff4..ed31a80e6b 100644 --- a/scripts/zpool-config/x4550-raidz-8x6.sh +++ b/scripts/zpool-config/x4550-raidz-8x6.sh @@ -7,7 +7,7 @@ RANKS=8 CHANNELS=6 zpool_create() { - udev_setup ${UDEVDIR}/99-zpool.rules.x4550 + udev_setup ${ETCDIR}/zfs/zdev.conf.x4550.example udev_raidz_setup ${RANKS} ${CHANNELS} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]} @@ -17,4 +17,5 @@ zpool_create() { zpool_destroy() { msg ${ZPOOL} destroy ${ZPOOL_NAME} ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.x4550.example } diff --git a/scripts/zpool-config/x4550-raidz2-8x6.sh b/scripts/zpool-config/x4550-raidz2-8x6.sh index 4b75ba222b..45ccd7474a 100644 --- a/scripts/zpool-config/x4550-raidz2-8x6.sh +++ b/scripts/zpool-config/x4550-raidz2-8x6.sh @@ -7,7 +7,7 @@ RANKS=8 CHANNELS=6 zpool_create() { - udev_setup ${UDEVDIR}/99-zpool.rules.x4550 + udev_setup ${ETCDIR}/zfs/zdev.conf.x4550.example udev_raidz2_setup ${RANKS} ${CHANNELS} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]} @@ -17,4 +17,5 @@ zpool_create() { zpool_destroy() { msg ${ZPOOL} destroy ${ZPOOL_NAME} ${ZPOOL} destroy ${ZPOOL_NAME} + udev_cleanup ${ETCDIR}/zfs/zdev.conf.x4550.example } diff --git a/scripts/zpool-create.sh b/scripts/zpool-create.sh index 2853f7d4e2..ac7ab9ad9a 100755 --- a/scripts/zpool-create.sh +++ b/scripts/zpool-create.sh @@ -1,8 +1,10 @@ #!/bin/bash +basedir="$(dirname $0)" + SCRIPT_COMMON=common.sh -if [ -f ./${SCRIPT_COMMON} ]; then -. ./${SCRIPT_COMMON} +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then . /usr/libexec/zfs/${SCRIPT_COMMON} else diff --git a/zfs-modules.spec.in b/zfs-modules.spec.in index 9b5e4716d9..836813ae5e 100644 --- a/zfs-modules.spec.in +++ b/zfs-modules.spec.in @@ -66,8 +66,8 @@ %endif %else -# CHAOS 4.x: -%if %{defined ch4} +# CHAOS 4.x/5.x: +%if %{defined ch4} || %{defined ch5} %if %{undefined kver} %define klnk %{_usrsrc}/kernels/*/include/config %define kver %((echo X; %{__cat} %{klnk}/kernel.release @@ -85,8 +85,8 @@ %endif %else -# RHEL 5: -%if %{defined el5} +# RHEL 5.x/6.x: +%if %{defined el5} || %{defined el6} %if %{undefined kver} %define klnk %{_usrsrc}/kernels/*/include/config %define kver %((echo X; %{__cat} %{klnk}/kernel.release @@ -125,14 +125,11 @@ # Unsupported distro: %if %{undefined kver} - %define kver X + %define kver %(uname -r) %endif - %define kpkg kernel - %define kdevpkg kernel-devel %define kverpkg %{kver} - %define koppkg = %if %{undefined kdir} - %define kdir %{_usrsrc}/kernels/%{kver} + %define kdir /lib/modules/%{kver}/build %endif %if %{undefined kobj} %define kobj %{kdir} @@ -183,7 +180,6 @@ %define version @VERSION@ %define debug_package %{nil} - # The kernel version should only be appended to a binary RPM. When # building a source RPM it must be kernel version agnostic. This means # the source RPM must never specify a required kernel version, but the @@ -195,7 +191,9 @@ %else %define relext %(echo %{kverpkg} | %{__sed} -e 's/-/_/g') %define release @ZFS_META_RELEASE@_%{relext} +%if %{defined kpkg} %define krequires %{kpkg} %{koppkg} %{kverpkg} +%endif %define splrequires %{splpkg} = %{splverpkg} %endif @@ -208,9 +206,13 @@ License: @LICENSE@ URL: git://eris.llnl.gov/zfs.git BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un) Source: @PACKAGE@-%{version}.tar.gz +%if %{defined krequires} Requires: %{krequires} -Requires: %{splrequires} +%endif +%if %{defined kdevpkg} BuildRequires: %{kdevpkg} +%endif +Requires: %{splrequires} BuildRequires: %{spldevpkg} %description @@ -220,9 +222,13 @@ the %{name} file system. %package devel Summary: ZFS File System Headers and Symbols Group: Development/Libraries +%if %{defined krequires} Requires: %{krequires} +%endif Requires: %{splrequires} +%if %{defined kdevpkg} BuildRequires: %{kdevpkg} +%endif BuildRequires: %{spldevpkg} %description devel diff --git a/zfs.spec.in b/zfs.spec.in index f397333987..bd8a20bc7a 100644 --- a/zfs.spec.in +++ b/zfs.spec.in @@ -22,8 +22,13 @@ for the zfs file system. %package devel Summary: ZFS File System User Headers Group: Development/Libraries +%if %{defined ch5} || %{defined el6} || %{defined fc12} +Requires: zlib libuuid libblkid +BuildRequires: zlib-devel libuuid-devel libblkid-devel +%else Requires: zlib e2fsprogs BuildRequires: zlib-devel e2fsprogs-devel +%endif %description devel The %{name}-devel package contains the header files needed for building @@ -42,7 +47,7 @@ various system profiling tools to facilitate an in depth analysis. %prep %setup %build -%configure --with-config=user --with-blkid +%configure --with-config=user --without-blkid make %install @@ -57,7 +62,10 @@ rm -rf $RPM_BUILD_ROOT %doc AUTHORS ChangeLog COPYING DISCLAIMER GIT %doc OPENSOLARIS.LICENSE README TODO ZFS.RELEASE %{_sbindir}/* +%{_bindir}/* %{_libdir}/* +%{_mandir}/man8/* +%{_sysconfdir}/* %files devel %defattr(-,root,root) diff --git a/zfs_unconfig.h b/zfs_unconfig.h deleted file mode 100644 index eee3b87adc..0000000000 --- a/zfs_unconfig.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Undefine these symbols to allow other autoheader enabled packages - * to leverage the ZFS configure checks without a header conflict. - */ -#undef PACKAGE -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION -#undef VERSION -#undef STDC_HEADERS