Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/module/zfs/dsl_destroy.c
Show First 20 Lines • Show All 594 Lines • ▼ Show 20 Lines | dsl_destroy_snapshots_nvl(nvlist_t *snaps, boolean_t defer, | ||||
nvlist_t *errlist) | nvlist_t *errlist) | ||||
{ | { | ||||
if (nvlist_next_nvpair(snaps, NULL) == NULL) | if (nvlist_next_nvpair(snaps, NULL) == NULL) | ||||
return (0); | return (0); | ||||
/* | /* | ||||
* lzc_destroy_snaps() is documented to take an nvlist whose | * lzc_destroy_snaps() is documented to take an nvlist whose | ||||
* values "don't matter". We need to convert that nvlist to | * values "don't matter". We need to convert that nvlist to | ||||
* one that we know can be converted to LUA. We also don't | * one that we know can be converted to LUA. | ||||
* care about any duplicate entries because the nvlist will | |||||
* be converted to a LUA table which should take care of this. | |||||
*/ | */ | ||||
nvlist_t *snaps_normalized; | nvlist_t *snaps_normalized = fnvlist_alloc(); | ||||
VERIFY0(nvlist_alloc(&snaps_normalized, 0, KM_SLEEP)); | |||||
for (nvpair_t *pair = nvlist_next_nvpair(snaps, NULL); | for (nvpair_t *pair = nvlist_next_nvpair(snaps, NULL); | ||||
pair != NULL; pair = nvlist_next_nvpair(snaps, pair)) { | pair != NULL; pair = nvlist_next_nvpair(snaps, pair)) { | ||||
fnvlist_add_boolean_value(snaps_normalized, | fnvlist_add_boolean_value(snaps_normalized, | ||||
nvpair_name(pair), B_TRUE); | nvpair_name(pair), B_TRUE); | ||||
} | } | ||||
nvlist_t *arg; | nvlist_t *arg = fnvlist_alloc(); | ||||
VERIFY0(nvlist_alloc(&arg, 0, KM_SLEEP)); | |||||
fnvlist_add_nvlist(arg, "snaps", snaps_normalized); | fnvlist_add_nvlist(arg, "snaps", snaps_normalized); | ||||
fnvlist_free(snaps_normalized); | fnvlist_free(snaps_normalized); | ||||
fnvlist_add_boolean_value(arg, "defer", defer); | fnvlist_add_boolean_value(arg, "defer", defer); | ||||
nvlist_t *wrapper; | nvlist_t *wrapper = fnvlist_alloc(); | ||||
VERIFY0(nvlist_alloc(&wrapper, 0, KM_SLEEP)); | |||||
fnvlist_add_nvlist(wrapper, ZCP_ARG_ARGLIST, arg); | fnvlist_add_nvlist(wrapper, ZCP_ARG_ARGLIST, arg); | ||||
fnvlist_free(arg); | fnvlist_free(arg); | ||||
const char *program = | const char *program = | ||||
"arg = ...\n" | "arg = ...\n" | ||||
"snaps = arg['snaps']\n" | "snaps = arg['snaps']\n" | ||||
"defer = arg['defer']\n" | "defer = arg['defer']\n" | ||||
"errors = { }\n" | "errors = { }\n" | ||||
Show All 18 Lines | const char *program = | ||||
"return { }\n"; | "return { }\n"; | ||||
nvlist_t *result = fnvlist_alloc(); | nvlist_t *result = fnvlist_alloc(); | ||||
int error = zcp_eval(nvpair_name(nvlist_next_nvpair(snaps, NULL)), | int error = zcp_eval(nvpair_name(nvlist_next_nvpair(snaps, NULL)), | ||||
program, | program, | ||||
B_TRUE, | B_TRUE, | ||||
0, | 0, | ||||
zfs_lua_max_memlimit, | zfs_lua_max_memlimit, | ||||
nvlist_next_nvpair(wrapper, NULL), result); | fnvlist_lookup_nvpair(wrapper, ZCP_ARG_ARGLIST), result); | ||||
if (error != 0) { | if (error != 0) { | ||||
char *errorstr = NULL; | char *errorstr = NULL; | ||||
(void) nvlist_lookup_string(result, ZCP_RET_ERROR, &errorstr); | (void) nvlist_lookup_string(result, ZCP_RET_ERROR, &errorstr); | ||||
if (errorstr != NULL) { | if (errorstr != NULL) { | ||||
zfs_dbgmsg(errorstr); | zfs_dbgmsg(errorstr); | ||||
} | } | ||||
fnvlist_free(wrapper); | fnvlist_free(wrapper); | ||||
fnvlist_free(result); | fnvlist_free(result); | ||||
▲ Show 20 Lines • Show All 621 Lines • Show Last 20 Lines |