Skip to content

Commit

Permalink
Fix build breakage due to ZCP Holds and Bookmarks API in ZoL (openzfs#68
Browse files Browse the repository at this point in the history
)

* Sort log spacemap tunables in alphabetical order

Beside the whole commit being a nit in reality it should
bring the diffs of the spa_log_spacemap.c source file
between ZoL and delphix/zfs to 0.

Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Chris Dunlop <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Serapheim Dimitropoulos <[email protected]>
Closes openzfs#9143

* Introduce getting holds and listing bookmarks through ZCP

Consumers of ZFS Channel Programs can now list bookmarks,
and get holds from datasets. A minor-refactoring was also
applied to distinguish between user and system properties
in ZCP.

Reviewed-by: Paul Dagnelie <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Matt Ahrens <[email protected]>
Reviewed-by: Serapheim Dimitropoulos <[email protected]>
Ported-by: Serapheim Dimitropoulos <[email protected]>
Signed-off-by: Dan Kimmel <[email protected]>

OpenZFS-issue: https://illumos.org/issues/8862
Closes openzfs#7902
  • Loading branch information
sdimitro authored and sebroy committed Aug 13, 2019
1 parent 3eebcae commit 18d0beb
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 3 deletions.
7 changes: 7 additions & 0 deletions man/man8/zfs-program.8
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,13 @@ snapshot (string)
.Bd -ragged -compact -offset "xxxx"
Must be a valid snapshot.
.Ed
.It Em zfs.list.properties(dataset)
An alias for zfs.list.user_properties (see relevant entry).
.Pp
dataset (string)
.Bd -ragged -compact -offset "xxxx"
Must be a valid filesystem, snapshot, or volume.
.Ed
.It Em zfs.list.user_properties(dataset)
Iterate through all user properties for the given dataset. For each
step of the iteration, output the property name, its value, and its source.
Expand Down
23 changes: 23 additions & 0 deletions module/zfs/zcp_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,28 @@ static zcp_list_info_t zcp_user_props_list_info = {
}
};

/*
* 'properties' was the initial name for 'user_properties' seen
* above. 'user_properties' is a better name as it distinguishes
* these properties from 'system_properties' which are different.
* In order to avoid breaking compatibility between different
* versions of ZFS, we declare 'properties' as an alias for
* 'user_properties'.
*/
static zcp_list_info_t zcp_props_list_info = {
.name = "properties",
.func = zcp_user_props_list,
.gc = zcp_user_props_list_gc,
.pargs = {
{ .za_name = "filesystem | snapshot | volume",
.za_lua_type = LUA_TSTRING},
{NULL, 0}
},
.kwargs = {
{NULL, 0}
}
};

static int
zcp_user_props_list(lua_State *state)
{
Expand Down Expand Up @@ -693,6 +715,7 @@ zcp_load_list_lib(lua_State *state)
&zcp_children_list_info,
&zcp_snapshots_list_info,
&zcp_user_props_list_info,
&zcp_props_list_info,
&zcp_clones_list_info,
&zcp_system_props_list_info,
&zcp_bookmarks_list_info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
. $STF_SUITE/include/libtest.shlib

default_cleanup
destroy_pool testpool2
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@

DISK=${DISKS%% *}

default_setup ${DISK}
TESTPOOLDISK=${DISKS%% *}
TESTPOOL2DISK=${DISKS##* }

default_setup ${TESTPOOLDISK}
create_pool testpool2 ${TESTPOOL2DISK}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ EOF

# Can't look in a different pool than the one specified on command line
log_mustnot_program $TESTPOOL - <<-EOF
zfs.list.bookmarks("rpool")
zfs.list.bookmarks("testpool2")
return 0
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ EOF

# Can't look in a different pool than the one specified on command line
log_mustnot_program $TESTPOOL - <<-EOF
zfs.list.holds("rpool")
zfs.list.holds("testpool2")
return 0
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
# DESCRIPTION:
# Listing zfs user properties should work correctly.
#
# Note, that this file tests both zfs.list.user_properties
# and it's alias zfs.list.properties.
#

verify_runnable "global"

Expand All @@ -45,6 +48,14 @@ log_must_program $TESTPOOL - <<-EOF
assert(n == 0)
return 0
EOF
log_must_program $TESTPOOL - <<-EOF
n = 0
for p in zfs.list.properties("$TESTPOOL/$TESTFS") do
n = n + 1
end
assert(n == 0)
return 0
EOF

# Add a single user property
log_must zfs set $TESTPROP="$TESTVAL" $TESTPOOL/$TESTFS
Expand All @@ -59,6 +70,16 @@ log_must_program $TESTPOOL - <<-EOF
assert(n == 1)
return 0
EOF
log_must_program $TESTPOOL - <<-EOF
n = 0
for p,v in zfs.list.properties("$TESTPOOL/$TESTFS") do
assert(p == "$TESTPROP")
assert(v == "$TESTVAL")
n = n + 1
end
assert(n == 1)
return 0
EOF

log_must zfs set $TESTPROP1="$TESTVAL1" $TESTPOOL/$TESTFS
log_must zfs set $TESTPROP2="$TESTVAL2" $TESTPOOL/$TESTFS
Expand Down Expand Up @@ -94,5 +115,33 @@ log_must_program $TESTPOOL - <<-EOF
a["$TESTPROP4"])
return 0
EOF
log_must_program $TESTPOOL - <<-EOF
a = {}
a["$TESTPROP"] = false
a["$TESTPROP1"] = false
a["$TESTPROP2"] = false
a["$TESTPROP3"] = false
a["$TESTPROP4"] = false
m = {}
m["$TESTPROP"] = "$TESTVAL"
m["$TESTPROP1"] = "$TESTVAL1"
m["$TESTPROP2"] = "$TESTVAL2"
m["$TESTPROP3"] = "$TESTVAL3"
m["$TESTPROP4"] = "$TESTVAL4"
n = 0
for p,v in zfs.list.properties("$TESTPOOL/$TESTFS") do
assert(not a[p])
a[p] = true
assert(v == m[p])
n = n + 1
end
assert(n == 5)
assert(a["$TESTPROP"] and
a["$TESTPROP1"] and
a["$TESTPROP2"] and
a["$TESTPROP3"] and
a["$TESTPROP4"])
return 0
EOF

log_pass "Listing zfs user properies should work correctly."

0 comments on commit 18d0beb

Please sign in to comment.