zfsonlinux/zfs — pull request #1492 by dweeezil (2013-06-03 03:01:44+00:00)
Title: Merge Illumos 4445fff, fixes #2882

Merge Illumos 4445fff. From the Illumos commit:

2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once
Reviewed by: George Wilson
Reviewed by: Chris Siden
Reviewed by: Garrett D'Amore
Reviewed by: Bill Pijewski
Reviewed by: Dan Kruchinin
Approved by: Eric Schrock

There are a number of other changes brought about by this commit that are a result
of the "libzfs_core way" of doing things. Among those change are:

ioctl overhaul as summarized in the comments from zfs_ioctl.c:

There are two ways that we handle ioctls: the legacy way where
almost all of the logic is in the ioctl callback, and the new
way where most of the marshalling is handled in the common entry
point, zfsdev_ioctl().

Non-legacy ioctls should be registered by calling
zfs_ioctl_register() from zfs_ioctl_init(). The ioctl is invoked
from userland by lzc_ioctl().

In addition to the ioctl registration and marshalling changes, the
way in which pool history is stored has been changed. Any ioctl can
now write a history record. A new TLD, zfs_allow_log_key has been added
which records the pool affected by the last ioctl.

Related to pool history, illumos 53089ab (and ad135b5), which added
asynchronous destructions, added the suite of "fnvpair" (forced
nvpair) functions. Illumos 4445fff uses the fnvpair functions in the
new-style pool history handling. Since the fnv* functions didn't
allow kmem_alloc flags to be specified, and because the history
functions are in the txg_sync call path, I added "nosleep" versions
of the fnvlist_dup, fnvlist_merge, fnvlist_alloc and fnvlist_pack
functions with a suffix of "_nosleep". They simply perform their
allocations with the KM_NOSLEEP flag.

The ZFS_IOC_SNAPSHOT ioctl now takes an nvlist of snapshots to create
and can return a list of errors as documented in zfs_ioctl.c:

innvl: {
"snaps" -> { snapshot1, snapshot2 }
(optional) "props" -> { prop -> value (string) }
}

outnvl: snapshot -> error code (int32)

The new snapshot semantics required a different scheme for creating
the minor nodes under ZoL when zvols are snapshotted. The zfs_snapshot_nvl
function now iterates through the list of snapshots and tries to create
the nodes for any zvol devices. Snapshot creation during pool import
is handled correctly.

There were also a number of unrelated things I fixed. Among them are:

Remove the logging of the "release" operation in
dsl_dataset_user_release_sync(). The logging caused a null dereference
because ds->ds_dir is zeroed in dsl_dataset_destroy_sync() and the
logging functions try to get the ds name via the dsl_dataset_name()
function. I've got no idea why this particular code would have worked
in Illumos. This code has subsequently been completely reworked in
Illumos commit 3b2aab1 (3464 zfs synctask code needs restructuring).

Squash some "may be used uninitialized" warning/erorrs.

Fix some printf format warnings for %lld and %llu.