]> git.proxmox.com Git - mirror_zfs.git/commit - lib/libzfs_core/libzfs_core.c
OpenZFS 8677 - Open-Context Channel Programs
authorSerapheim Dimitropoulos <serapheim@delphix.com>
Thu, 8 Feb 2018 16:35:09 +0000 (09:35 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 9 Feb 2018 00:05:57 +0000 (16:05 -0800)
commit5b72a38d68453c91bf57cba11789a240199b695d
tree12ba69543984c249d85949efb4abab68cde5a244
parent8d103d88565efa90e545de57210c12edef77c938
OpenZFS 8677 - Open-Context Channel Programs

Authored by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Chris Williamson <chris.williamson@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Ported-by: Don Brady <don.brady@delphix.com>
We want to be able to run channel programs outside of synching
context. This would greatly improve performance for channel programs
that just gather information, as they won't have to wait for synching
context anymore.

=== What is implemented?

This feature introduces the following:
- A new command line flag in "zfs program" to specify our intention
  to run in open context. (The -n option)
- A new flag/option within the channel program ioctl which selects
  the context.
- Appropriate error handling whenever we try a channel program in
  open-context that contains zfs.sync* expressions.
- Documentation for the new feature in the manual pages.

=== How do we handle zfs.sync functions in open context?

When such a function is found by the interpreter and we are running
in open context we abort the script and we spit out a descriptive
runtime error. For example, given the script below ...

arg = ...
fs = arg["argv"][1]
err = zfs.sync.destroy(fs)
msg = "destroying " .. fs .. " err=" .. err
return msg

if we run it in open context, we will get back the following error:

Channel program execution failed:
[string "channel program"]:3: running functions from the zfs.sync
submodule requires passing sync=TRUE to lzc_channel_program()
(i.e. do not specify the "-n" command line argument)
stack traceback:
            [C]: in function 'destroy'
            [string "channel program"]:3: in main chunk

=== What about testing?

We've introduced new wrappers for all channel program tests that
run each channel program as both (startard & open-context) and
expect the appropriate behavior depending on the program using
the zfs.sync module.

OpenZFS-issue: https://www.illumos.org/issues/8677
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/17a49e15
Closes #6558
26 files changed:
cmd/zfs/zfs_main.c
include/libzfs_core.h
include/sys/fs/zfs.h
include/sys/zcp.h
lib/libzfs/libzfs_dataset.c
lib/libzfs_core/libzfs_core.c
man/man8/zfs-program.8
man/man8/zfs.8
module/zfs/dsl_destroy.c
module/zfs/zcp.c
module/zfs/zcp_synctask.c
module/zfs/zfs_ioctl.c
tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib
tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_large.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.destroy_fs.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.destroy_snap.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.parse_args_neg.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.promote_conflict.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.promote_multiple.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.promote_simple.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.rollback_mult.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.rollback_one.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.snapshot_destroy.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.snapshot_neg.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.snapshot_recursive.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.snapshot_simple.ksh