Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Show First 20 Lines • Show All 1,635 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
zfs_ioc_pool_destroy(zfs_cmd_t *zc) | zfs_ioc_pool_destroy(zfs_cmd_t *zc) | ||||
{ | { | ||||
int error; | int error; | ||||
zfs_log_history(zc); | zfs_log_history(zc); | ||||
error = spa_destroy(zc->zc_name); | error = spa_destroy(zc->zc_name); | ||||
#ifndef __FreeBSD__ | |||||
if (error == 0) | if (error == 0) | ||||
zvol_remove_minors(zc->zc_name); | zvol_remove_minors(zc->zc_name); | ||||
#endif | |||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
zfs_ioc_pool_import(zfs_cmd_t *zc) | zfs_ioc_pool_import(zfs_cmd_t *zc) | ||||
{ | { | ||||
nvlist_t *config, *props = NULL; | nvlist_t *config, *props = NULL; | ||||
uint64_t guid; | uint64_t guid; | ||||
Show All 34 Lines | |||||
zfs_ioc_pool_export(zfs_cmd_t *zc) | zfs_ioc_pool_export(zfs_cmd_t *zc) | ||||
{ | { | ||||
int error; | int error; | ||||
boolean_t force = (boolean_t)zc->zc_cookie; | boolean_t force = (boolean_t)zc->zc_cookie; | ||||
boolean_t hardforce = (boolean_t)zc->zc_guid; | boolean_t hardforce = (boolean_t)zc->zc_guid; | ||||
zfs_log_history(zc); | zfs_log_history(zc); | ||||
error = spa_export(zc->zc_name, NULL, force, hardforce); | error = spa_export(zc->zc_name, NULL, force, hardforce); | ||||
#ifndef __FreeBSD__ | |||||
if (error == 0) | if (error == 0) | ||||
zvol_remove_minors(zc->zc_name); | zvol_remove_minors(zc->zc_name); | ||||
#endif | |||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
zfs_ioc_pool_configs(zfs_cmd_t *zc) | zfs_ioc_pool_configs(zfs_cmd_t *zc) | ||||
{ | { | ||||
nvlist_t *configs; | nvlist_t *configs; | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 1,686 Lines • ▼ Show 20 Lines | zfs_ioc_create(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl) | ||||
nvlist_free(zct.zct_zplprops); | nvlist_free(zct.zct_zplprops); | ||||
/* | /* | ||||
* It would be nice to do this atomically. | * It would be nice to do this atomically. | ||||
*/ | */ | ||||
if (error == 0) { | if (error == 0) { | ||||
error = zfs_set_prop_nvlist(fsname, ZPROP_SRC_LOCAL, | error = zfs_set_prop_nvlist(fsname, ZPROP_SRC_LOCAL, | ||||
nvprops, outnvl); | nvprops, outnvl); | ||||
#if defined(__FreeBSD__) && defined(_KERNEL) | |||||
/* | |||||
* Wait for ZVOL operations to settle down before destroying. | |||||
*/ | |||||
if (error != 0) { | |||||
spa_t *spa; | |||||
if (spa_open(fsname, &spa, FTAG) == 0) { | |||||
taskqueue_drain_all( | |||||
spa->spa_zvol_taskq->tq_queue); | |||||
spa_close(spa, FTAG); | |||||
} | |||||
} | |||||
#endif | |||||
if (error != 0) | if (error != 0) | ||||
(void) dsl_destroy_head(fsname); | (void) dsl_destroy_head(fsname); | ||||
} | } | ||||
#ifdef __FreeBSD__ | |||||
if (error == 0 && type == DMU_OST_ZVOL) | |||||
zvol_create_minors(fsname); | |||||
#endif | |||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* innvl: { | * innvl: { | ||||
* "origin" -> name of origin snapshot | * "origin" -> name of origin snapshot | ||||
* (optional) "props" -> { prop -> value } | * (optional) "props" -> { prop -> value } | ||||
* } | * } | ||||
Show All 25 Lines | zfs_ioc_clone(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl) | ||||
* It would be nice to do this atomically. | * It would be nice to do this atomically. | ||||
*/ | */ | ||||
if (error == 0) { | if (error == 0) { | ||||
error = zfs_set_prop_nvlist(fsname, ZPROP_SRC_LOCAL, | error = zfs_set_prop_nvlist(fsname, ZPROP_SRC_LOCAL, | ||||
nvprops, outnvl); | nvprops, outnvl); | ||||
if (error != 0) | if (error != 0) | ||||
(void) dsl_destroy_head(fsname); | (void) dsl_destroy_head(fsname); | ||||
} | } | ||||
#ifdef __FreeBSD__ | |||||
if (error == 0) | |||||
zvol_create_minors(fsname); | |||||
#endif | |||||
return (error); | return (error); | ||||
} | } | ||||
/* ARGSUSED */ | /* ARGSUSED */ | ||||
static int | static int | ||||
zfs_ioc_remap(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl) | zfs_ioc_remap(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl) | ||||
{ | { | ||||
if (strchr(fsname, '@') || | if (strchr(fsname, '@') || | ||||
▲ Show 20 Lines • Show All 275 Lines • ▼ Show 20 Lines | for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL; | ||||
* The snap must be in the specified pool to prevent the | * The snap must be in the specified pool to prevent the | ||||
* invalid removal of zvol minors below. | * invalid removal of zvol minors below. | ||||
*/ | */ | ||||
if (strncmp(name, poolname, poollen) != 0 || | if (strncmp(name, poolname, poollen) != 0 || | ||||
(name[poollen] != '/' && name[poollen] != '@')) | (name[poollen] != '/' && name[poollen] != '@')) | ||||
return (SET_ERROR(EXDEV)); | return (SET_ERROR(EXDEV)); | ||||
zfs_unmount_snap(nvpair_name(pair)); | zfs_unmount_snap(nvpair_name(pair)); | ||||
#if defined(__FreeBSD__) | |||||
zvol_remove_minors(name); | |||||
#endif | |||||
} | } | ||||
return (dsl_destroy_snapshots_nvl(snaps, defer, outnvl)); | return (dsl_destroy_snapshots_nvl(snaps, defer, outnvl)); | ||||
} | } | ||||
/* | /* | ||||
* Create bookmarks. Bookmark names are of the form <fs>#<bmark>. | * Create bookmarks. Bookmark names are of the form <fs>#<bmark>. | ||||
* All bookmarks must be in the same pool. | * All bookmarks must be in the same pool. | ||||
▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | zfs_ioc_destroy(zfs_cmd_t *zc) | ||||
if (ost == DMU_OST_ZFS) | if (ost == DMU_OST_ZFS) | ||||
zfs_unmount_snap(zc->zc_name); | zfs_unmount_snap(zc->zc_name); | ||||
if (strchr(zc->zc_name, '@')) | if (strchr(zc->zc_name, '@')) | ||||
err = dsl_destroy_snapshot(zc->zc_name, zc->zc_defer_destroy); | err = dsl_destroy_snapshot(zc->zc_name, zc->zc_defer_destroy); | ||||
else | else | ||||
err = dsl_destroy_head(zc->zc_name); | err = dsl_destroy_head(zc->zc_name); | ||||
#ifndef __FreeBSD__ | |||||
if (ost == DMU_OST_ZVOL && err == 0) | if (ost == DMU_OST_ZVOL && err == 0) | ||||
#ifdef __FreeBSD__ | |||||
zvol_remove_minors(zc->zc_name); | |||||
#else | |||||
(void) zvol_remove_minor(zc->zc_name); | (void) zvol_remove_minor(zc->zc_name); | ||||
#endif | #endif | ||||
return (err); | return (err); | ||||
} | } | ||||
/* | /* | ||||
* innvl: { | * innvl: { | ||||
* vdevs: { | * vdevs: { | ||||
▲ Show 20 Lines • Show All 878 Lines • ▼ Show 20 Lines | |||||
#ifdef DEBUG | #ifdef DEBUG | ||||
if (zfs_ioc_recv_inject_err) { | if (zfs_ioc_recv_inject_err) { | ||||
zfs_ioc_recv_inject_err = B_FALSE; | zfs_ioc_recv_inject_err = B_FALSE; | ||||
error = 1; | error = 1; | ||||
} | } | ||||
#endif | #endif | ||||
#ifdef __FreeBSD__ | |||||
if (error == 0) | |||||
zvol_create_minors(tofs); | |||||
#endif | |||||
/* | /* | ||||
* On error, restore the original props. | * On error, restore the original props. | ||||
*/ | */ | ||||
if (error != 0 && props != NULL && !drc.drc_newfs) { | if (error != 0 && props != NULL && !drc.drc_newfs) { | ||||
if (clear_received_props(tofs, props, NULL) != 0) { | if (clear_received_props(tofs, props, NULL) != 0) { | ||||
/* | /* | ||||
* We failed to clear the received properties. | * We failed to clear the received properties. | ||||
* Since we may have left a $recvd value on the | * Since we may have left a $recvd value on the | ||||
▲ Show 20 Lines • Show All 2,125 Lines • ▼ Show 20 Lines | if (vec->zvec_func != NULL) { | ||||
nvlist_free(outnvl); | nvlist_free(outnvl); | ||||
} else { | } else { | ||||
error = vec->zvec_legacy_func(zc); | error = vec->zvec_legacy_func(zc); | ||||
} | } | ||||
out: | out: | ||||
nvlist_free(innvl); | nvlist_free(innvl); | ||||
#if defined(__FreeBSD__) && defined(_KERNEL) | |||||
/* | |||||
* Wait for ZVOL changes to get applied. | |||||
* NB: taskqueue_drain_all() does less than taskq_wait(), | |||||
* but enough for what we want. | |||||
* And there is no equivalent illumos API. | |||||
*/ | |||||
if (error == 0) { | |||||
spa_t *spa; | |||||
if (spa_open(saved_poolname, &spa, FTAG) == 0) { | |||||
taskqueue_drain_all( | |||||
spa->spa_zvol_taskq->tq_queue); | |||||
spa_close(spa, FTAG); | |||||
} | |||||
} | |||||
#endif | |||||
#ifdef illumos | #ifdef illumos | ||||
rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag); | rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag); | ||||
if (error == 0 && rc != 0) | if (error == 0 && rc != 0) | ||||
error = SET_ERROR(EFAULT); | error = SET_ERROR(EFAULT); | ||||
#else | #else | ||||
if (compat) { | if (compat) { | ||||
zfs_ioctl_compat_post(zc, cmd, cflag); | zfs_ioctl_compat_post(zc, cmd, cflag); | ||||
▲ Show 20 Lines • Show All 361 Lines • Show Last 20 Lines |