Bug #12877
Updated by Jason King about 2 years ago
From the OpenZFS commit msg:
>We want newer versions of libzfs_core to run against an existing zfs kernel module (i.e. a deferred reboot or module reload after an update).
>
>Programmatically document, via a zfs_ioc_key_t, the valid arguments for the ioc commands that rely on nvpair input arguments (i.e. nonlegacy commands from libzfs_core). Automatically verify the expected pairs before dispatching a command.
>
>This initial phase focuses on the non-legacy ioctls. A follow-on change can address the legacy ioctl input from the zfs_cmd_t.
>
>The zfs_ioc_key_t for zfs_keys_channel_program looks like:
>
><pre>
static const zfs_ioc_key_t zfs_keys_channel_program[] = {
{"program", DATA_TYPE_STRING, 0},
{"arg", DATA_TYPE_UNKNOWN, 0},
{"sync", DATA_TYPE_BOOLEAN_VALUE, ZK_OPTIONAL},
{"instrlimit", DATA_TYPE_UINT64, ZK_OPTIONAL},
{"memlimit", DATA_TYPE_UINT64, ZK_OPTIONAL},
};
</pre>
>
>Introduce four input errors to identify specific input failures (in addition to generic argument value errors like EINVAL, ERANGE, EBADF, and E2BIG).
>
> * ZFS_ERR_IOC_CMD_UNAVAIL the ioctl number is not supported by kernel
> * ZFS_ERR_IOC_ARG_UNAVAIL an input argument is not supported by kernel
> * ZFS_ERR_IOC_ARG_REQUIRED a required input argument is missing
> * ZFS_ERR_IOC_ARG_BADTYPE an input argument has an invalid type
>
>Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
>Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
>Signed-off-by: Don Brady <don.brady@delphix.com>
>Closes #7780
While we don't need to be concerned about mismatched kernel module/userland bits, the centralized (and consistent) ioctl validation is useful without regard to mismatched bits, it also simplifies the ioctl processing, and having this will make porting additional OpenZFS features easier.
Additionally, we need part of:
<pre>
commit 2e0358cbcab49f7be18762e8cb51e642188709e7
Author: Brian Behlendorf <behlendorf1@llnl.gov>
Date: Fri Dec 13 14:49:33 2013 -0800
Sync /dev/zfs ioctl ordering
In order to minimize any future disruption caused by the addition
and removal /dev/zfs ioctls this patch makes the following changes.
1) Sync ZoL's ioctl ordering such that it matches Illumos. For
historic reasons the ZFS_IOC_DESTROY_SNAPS and ZFS_IOC_POOL_REGUID
ioctls were out of order.
2) Move Linux and FreeBSD specific ioctls in to their own reserved
ranges. This allows us to preserve the existing ordering when
new ioctls are added by either Illumos or FreeBSD. When an
ioctl is no longer needed it should be retired in place.
This change alters the ZFS user/kernel ABI so make sure you rebuild
both your user and kernel modules. However, it should allow for a
much stabler interface going forward.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Closes #1973
</pre>
Obviously the ioctl resync bit is superfluous, but it includes support for a sparse IOC space which is useful in trying to avoid divergence with OpenZFS.