From dc1c630b8abf2db4ce78b583b441bd0c74f42936 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Thu, 28 Jun 2018 00:37:54 +0300 Subject: 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 Reviewed by: Andy Stormont Reviewed by: Matt Ahrens Reviewed by: Serapheim Dimitropoulos Reviewed by: Brian Behlendorf Approved by: Dan McDonald Ported-by: loli10K OpenZFS-issue: https://www.illumos.org/issues/9630 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/049ba63 Closes #8207 --- module/zfs/zfs_ioctl.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'module') 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); -- cgit v1.2.3