diff options
author | Andriy Gapon <[email protected]> | 2018-06-28 00:37:54 +0300 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-12-14 09:49:45 -0800 |
commit | dc1c630b8abf2db4ce78b583b441bd0c74f42936 (patch) | |
tree | 99b6a2915f304ad28532346c37190bcebfe7bc28 /module | |
parent | eff7d78f8a1e2c8c8a151b99ee7e66ad619b201c (diff) |
OpenZFS 9630 - add lzc_rename and lzc_destroy to libzfs_core
Porting Notes:
* Additional changes to recv_rename_impl() were required due to
encryption code not being merged in OpenZFS yet.
* libzfs_core python bindings (pyzfs) were updated to fully support
both lzc_rename() and lzc_destroy()
Authored by: Andriy Gapon <[email protected]>
Reviewed by: Andy Stormont <[email protected]>
Reviewed by: Matt Ahrens <[email protected]>
Reviewed by: Serapheim Dimitropoulos <[email protected]>
Reviewed by: Brian Behlendorf <[email protected]>
Approved by: Dan McDonald <[email protected]>
Ported-by: loli10K <[email protected]>
OpenZFS-issue: https://www.illumos.org/issues/9630
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/049ba63
Closes #8207
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/zfs_ioctl.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 7c469246d..a71da2837 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -3785,7 +3785,6 @@ zfs_ioc_pool_discard_checkpoint(const char *poolname, nvlist_t *innvl, /* * inputs: * zc_name name of dataset to destroy - * zc_objset_type type of objset * zc_defer_destroy mark for deferred destroy * * outputs: none @@ -3793,9 +3792,17 @@ zfs_ioc_pool_discard_checkpoint(const char *poolname, nvlist_t *innvl, static int zfs_ioc_destroy(zfs_cmd_t *zc) { + objset_t *os; + dmu_objset_type_t ost; int err; - if (zc->zc_objset_type == DMU_OST_ZFS) + err = dmu_objset_hold(zc->zc_name, FTAG, &os); + if (err != 0) + return (err); + ost = dmu_objset_type(os); + dmu_objset_rele(os, FTAG); + + if (ost == DMU_OST_ZFS) zfs_unmount_snap(zc->zc_name); if (strchr(zc->zc_name, '@')) { @@ -3917,8 +3924,11 @@ recursive_unmount(const char *fsname, void *arg) static int zfs_ioc_rename(zfs_cmd_t *zc) { + objset_t *os; + dmu_objset_type_t ost; boolean_t recursive = zc->zc_cookie & 1; char *at; + int err; /* "zfs rename" from and to ...%recv datasets should both fail */ zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; @@ -3928,6 +3938,12 @@ zfs_ioc_rename(zfs_cmd_t *zc) strchr(zc->zc_name, '%') || strchr(zc->zc_value, '%')) return (SET_ERROR(EINVAL)); + err = dmu_objset_hold(zc->zc_name, FTAG, &os); + if (err != 0) + return (err); + ost = dmu_objset_type(os); + dmu_objset_rele(os, FTAG); + at = strchr(zc->zc_name, '@'); if (at != NULL) { /* snaps must be in same fs */ @@ -3936,7 +3952,7 @@ zfs_ioc_rename(zfs_cmd_t *zc) if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1)) return (SET_ERROR(EXDEV)); *at = '\0'; - if (zc->zc_objset_type == DMU_OST_ZFS) { + if (ost == DMU_OST_ZFS) { error = dmu_objset_find(zc->zc_name, recursive_unmount, at + 1, recursive ? DS_FIND_CHILDREN : 0); |