mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-06-25 02:28:01 +03:00
zcp_synctask: add zfs.sync.clone()
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Rob Norris <robn@despairlabs.com> Sponsored-by: https://despairlabs.com/sponsor/ Closes #17426
This commit is contained in:
parent
560e3170ef
commit
fbfda270d5
@ -18,6 +18,7 @@
|
|||||||
* Copyright (c) 2016, 2017 by Delphix. All rights reserved.
|
* Copyright (c) 2016, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2019, 2020 by Christian Schwarz. All rights reserved.
|
* Copyright (c) 2019, 2020 by Christian Schwarz. All rights reserved.
|
||||||
* Copyright 2020 Joyent, Inc.
|
* Copyright 2020 Joyent, Inc.
|
||||||
|
* Copyright (c) 2025, Rob Norris <robn@despairlabs.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/lua/lua.h>
|
#include <sys/lua/lua.h>
|
||||||
@ -113,6 +114,48 @@ zcp_sync_task(lua_State *state, dsl_checkfunc_t *checkfunc,
|
|||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int zcp_synctask_clone(lua_State *, boolean_t, nvlist_t *);
|
||||||
|
static const zcp_synctask_info_t zcp_synctask_clone_info = {
|
||||||
|
.name = "clone",
|
||||||
|
.func = zcp_synctask_clone,
|
||||||
|
.pargs = {
|
||||||
|
{.za_name = "snapshot", .za_lua_type = LUA_TSTRING },
|
||||||
|
{.za_name = "newdataset", .za_lua_type = LUA_TSTRING },
|
||||||
|
{NULL, 0}
|
||||||
|
},
|
||||||
|
.kwargs = {
|
||||||
|
{NULL, 0}
|
||||||
|
},
|
||||||
|
.space_check = ZFS_SPACE_CHECK_NORMAL,
|
||||||
|
.blocks_modified = 3
|
||||||
|
};
|
||||||
|
static int
|
||||||
|
zcp_synctask_clone(lua_State *state, boolean_t sync, nvlist_t *err_details)
|
||||||
|
{
|
||||||
|
(void) err_details;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
zcp_run_info_t *ri = zcp_run_info(state);
|
||||||
|
dsl_dataset_clone_arg_t ddca = {
|
||||||
|
.ddca_origin = lua_tostring(state, 1),
|
||||||
|
.ddca_clone = lua_tostring(state, 2),
|
||||||
|
.ddca_cred = ri->zri_cred,
|
||||||
|
};
|
||||||
|
|
||||||
|
err = zcp_sync_task(state, dsl_dataset_clone_check,
|
||||||
|
dsl_dataset_clone_sync, &ddca, sync, ddca.ddca_origin);
|
||||||
|
|
||||||
|
if (err == 0)
|
||||||
|
/*
|
||||||
|
* If the new dataset is a zvol, it will need a device
|
||||||
|
* node. Put it on the list to be considered in open context.
|
||||||
|
* We don't have to check the type here; if it's not a zvol,
|
||||||
|
* or has volmode=none, it will be ignored.
|
||||||
|
*/
|
||||||
|
fnvlist_add_boolean(ri->zri_new_zvols, ddca.ddca_clone);
|
||||||
|
|
||||||
|
return (err);
|
||||||
|
}
|
||||||
|
|
||||||
static int zcp_synctask_destroy(lua_State *, boolean_t, nvlist_t *);
|
static int zcp_synctask_destroy(lua_State *, boolean_t, nvlist_t *);
|
||||||
static const zcp_synctask_info_t zcp_synctask_destroy_info = {
|
static const zcp_synctask_info_t zcp_synctask_destroy_info = {
|
||||||
@ -561,6 +604,7 @@ zcp_load_synctask_lib(lua_State *state, boolean_t sync)
|
|||||||
{
|
{
|
||||||
const zcp_synctask_info_t *zcp_synctask_funcs[] = {
|
const zcp_synctask_info_t *zcp_synctask_funcs[] = {
|
||||||
&zcp_synctask_destroy_info,
|
&zcp_synctask_destroy_info,
|
||||||
|
&zcp_synctask_clone_info,
|
||||||
&zcp_synctask_promote_info,
|
&zcp_synctask_promote_info,
|
||||||
&zcp_synctask_rollback_info,
|
&zcp_synctask_rollback_info,
|
||||||
&zcp_synctask_snapshot_info,
|
&zcp_synctask_snapshot_info,
|
||||||
|
Loading…
Reference in New Issue
Block a user