Support inheriting properties in channel programs

This adds support in channel programs to inherit properties analogous
to `zfs inherit` by adding `zfs.sync.inherit` and `zfs.check.inherit`
functions to the ZFS LUA API.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jason King <jason.king@joyent.com>
Closes #9738
This commit is contained in:
Jason King
2020-01-22 19:03:17 -06:00
committed by Brian Behlendorf
parent 79add96766
commit e2ef1cbf04
7 changed files with 162 additions and 11 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ tags = ['functional', 'channel_program', 'lua_core']
tests = ['tst.destroy_fs', 'tst.destroy_snap', 'tst.get_count_and_limit',
'tst.get_index_props', 'tst.get_mountpoint', 'tst.get_neg',
'tst.get_number_props', 'tst.get_string_props', 'tst.get_type',
'tst.get_userquota', 'tst.get_written', 'tst.list_bookmarks',
'tst.get_userquota', 'tst.get_written', 'tst.inherit', 'tst.list_bookmarks',
'tst.list_children', 'tst.list_clones', 'tst.list_holds',
'tst.list_snapshots', 'tst.list_system_props',
'tst.list_user_props', 'tst.parse_args_neg','tst.promote_conflict',
@@ -13,6 +13,7 @@ dist_pkgdata_SCRIPTS = \
tst.get_type.ksh \
tst.get_userquota.ksh \
tst.get_written.ksh \
tst.inherit.ksh \
tst.list_bookmarks.ksh \
tst.list_children.ksh \
tst.list_clones.ksh \
@@ -0,0 +1,39 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2020 Joyent, Inc.
#
. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib
verify_runnable "global"
fs=$TESTPOOL/$TESTFS
testprop="com.joyent:testprop"
testval="testval"
log_must dataset_setprop $fs $testprop $testval
log_must_program_sync $TESTPOOL - $fs $testprop <<-EOF
arg = ...
fs = arg["argv"][1]
prop = arg["argv"][2]
err = zfs.sync.inherit(fs, prop)
msg = "resetting " .. prop .. " on " .. fs .. " err=" .. err
return msg
EOF
prop=$(get_prop $testprop $fs)
[[ "$prop" == "-" ]] || log_fail "Property still set after inheriting"
log_pass "Inherit/clear property with channel program works."