Changeset View
Changeset View
Standalone View
Standalone View
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
Show First 20 Lines • Show All 1,566 Lines • ▼ Show 20 Lines | for (pair = nvlist_next_nvpair(ddsa->ddsa_snaps, NULL); | ||||
(void) strlcpy(dsname, name, atp - name + 1); | (void) strlcpy(dsname, name, atp - name + 1); | ||||
VERIFY0(dsl_dataset_hold(dp, dsname, FTAG, &ds)); | VERIFY0(dsl_dataset_hold(dp, dsname, FTAG, &ds)); | ||||
dsl_dataset_snapshot_sync_impl(ds, atp + 1, tx); | dsl_dataset_snapshot_sync_impl(ds, atp + 1, tx); | ||||
if (ddsa->ddsa_props != NULL) { | if (ddsa->ddsa_props != NULL) { | ||||
dsl_props_set_sync_impl(ds->ds_prev, | dsl_props_set_sync_impl(ds->ds_prev, | ||||
ZPROP_SRC_LOCAL, ddsa->ddsa_props, tx); | ZPROP_SRC_LOCAL, ddsa->ddsa_props, tx); | ||||
} | } | ||||
#if defined(__FreeBSD__) && defined(_KERNEL) | |||||
zvol_create_minors(dp->dp_spa, name); | |||||
#endif | |||||
dsl_dataset_rele(ds, FTAG); | dsl_dataset_rele(ds, FTAG); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* The snapshots must all be in the same pool. | * The snapshots must all be in the same pool. | ||||
* All-or-nothing: if there are any failures, nothing will be modified. | * All-or-nothing: if there are any failures, nothing will be modified. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | if (suspended != NULL) { | ||||
for (pair = nvlist_next_nvpair(suspended, NULL); pair != NULL; | for (pair = nvlist_next_nvpair(suspended, NULL); pair != NULL; | ||||
pair = nvlist_next_nvpair(suspended, pair)) { | pair = nvlist_next_nvpair(suspended, pair)) { | ||||
zil_resume((void *)(uintptr_t) | zil_resume((void *)(uintptr_t) | ||||
fnvpair_value_uint64(pair)); | fnvpair_value_uint64(pair)); | ||||
} | } | ||||
fnvlist_free(suspended); | fnvlist_free(suspended); | ||||
} | } | ||||
#ifdef __FreeBSD__ | |||||
#ifdef _KERNEL | |||||
if (error == 0) { | |||||
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL; | |||||
pair = nvlist_next_nvpair(snaps, pair)) { | |||||
char *snapname = nvpair_name(pair); | |||||
zvol_create_minors(snapname); | |||||
} | |||||
} | |||||
#endif | |||||
#endif | |||||
return (error); | return (error); | ||||
} | } | ||||
typedef struct dsl_dataset_snapshot_tmp_arg { | typedef struct dsl_dataset_snapshot_tmp_arg { | ||||
const char *ddsta_fsname; | const char *ddsta_fsname; | ||||
const char *ddsta_snapname; | const char *ddsta_snapname; | ||||
minor_t ddsta_cleanup_minor; | minor_t ddsta_cleanup_minor; | ||||
const char *ddsta_htag; | const char *ddsta_htag; | ||||
▲ Show 20 Lines • Show All 862 Lines • ▼ Show 20 Lines | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
oldname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); | oldname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); | ||||
newname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); | newname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); | ||||
snprintf(oldname, ZFS_MAX_DATASET_NAME_LEN, "%s@%s", | snprintf(oldname, ZFS_MAX_DATASET_NAME_LEN, "%s@%s", | ||||
ddrsa->ddrsa_fsname, ddrsa->ddrsa_oldsnapname); | ddrsa->ddrsa_fsname, ddrsa->ddrsa_oldsnapname); | ||||
snprintf(newname, ZFS_MAX_DATASET_NAME_LEN, "%s@%s", | snprintf(newname, ZFS_MAX_DATASET_NAME_LEN, "%s@%s", | ||||
ddrsa->ddrsa_fsname, ddrsa->ddrsa_newsnapname); | ddrsa->ddrsa_fsname, ddrsa->ddrsa_newsnapname); | ||||
zfsvfs_update_fromname(oldname, newname); | zfsvfs_update_fromname(oldname, newname); | ||||
zvol_rename_minors(oldname, newname); | zvol_rename_minors(dp->dp_spa, oldname, newname); | ||||
kmem_free(newname, ZFS_MAX_DATASET_NAME_LEN); | kmem_free(newname, ZFS_MAX_DATASET_NAME_LEN); | ||||
kmem_free(oldname, ZFS_MAX_DATASET_NAME_LEN); | kmem_free(oldname, ZFS_MAX_DATASET_NAME_LEN); | ||||
#endif | #endif | ||||
#endif | #endif | ||||
dsl_dataset_rele(ds, FTAG); | dsl_dataset_rele(ds, FTAG); | ||||
return (0); | return (0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 535 Lines • ▼ Show 20 Lines | if (dsl_dir_phys(dd)->dd_clones == 0) { | ||||
zap_create(dp->dp_meta_objset, DMU_OT_DSL_CLONES, | zap_create(dp->dp_meta_objset, DMU_OT_DSL_CLONES, | ||||
DMU_OT_NONE, 0, tx); | DMU_OT_NONE, 0, tx); | ||||
} | } | ||||
VERIFY0(zap_add_int(dp->dp_meta_objset, | VERIFY0(zap_add_int(dp->dp_meta_objset, | ||||
dsl_dir_phys(dd)->dd_clones, origin_head->ds_object, tx)); | dsl_dir_phys(dd)->dd_clones, origin_head->ds_object, tx)); | ||||
} | } | ||||
#if defined(__FreeBSD__) && defined(_KERNEL) | #if defined(__FreeBSD__) && defined(_KERNEL) | ||||
/* Take the spa_namespace_lock early so zvol renames don't deadlock. */ | |||||
mutex_enter(&spa_namespace_lock); | |||||
oldname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); | oldname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); | ||||
newname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); | newname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); | ||||
#endif | #endif | ||||
/* move snapshots to this dir */ | /* move snapshots to this dir */ | ||||
for (snap = list_head(&ddpa->shared_snaps); snap; | for (snap = list_head(&ddpa->shared_snaps); snap; | ||||
snap = list_next(&ddpa->shared_snaps, snap)) { | snap = list_next(&ddpa->shared_snaps, snap)) { | ||||
dsl_dataset_t *ds = snap->ds; | dsl_dataset_t *ds = snap->ds; | ||||
Show All 29 Lines | #endif | ||||
ASSERT3P(ds->ds_dir, ==, odd); | ASSERT3P(ds->ds_dir, ==, odd); | ||||
dsl_dir_rele(ds->ds_dir, ds); | dsl_dir_rele(ds->ds_dir, ds); | ||||
VERIFY0(dsl_dir_hold_obj(dp, dd->dd_object, | VERIFY0(dsl_dir_hold_obj(dp, dd->dd_object, | ||||
NULL, ds, &ds->ds_dir)); | NULL, ds, &ds->ds_dir)); | ||||
#if defined(__FreeBSD__) && defined(_KERNEL) | #if defined(__FreeBSD__) && defined(_KERNEL) | ||||
dsl_dataset_name(ds, newname); | dsl_dataset_name(ds, newname); | ||||
zfsvfs_update_fromname(oldname, newname); | zfsvfs_update_fromname(oldname, newname); | ||||
zvol_rename_minors(oldname, newname); | zvol_rename_minors(dp->dp_spa, oldname, newname); | ||||
#endif | #endif | ||||
/* move any clone references */ | /* move any clone references */ | ||||
if (dsl_dataset_phys(ds)->ds_next_clones_obj && | if (dsl_dataset_phys(ds)->ds_next_clones_obj && | ||||
spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) { | spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) { | ||||
zap_cursor_t zc; | zap_cursor_t zc; | ||||
zap_attribute_t za; | zap_attribute_t za; | ||||
Show All 25 Lines | if (dsl_dataset_phys(ds)->ds_next_clones_obj && | ||||
} | } | ||||
zap_cursor_fini(&zc); | zap_cursor_fini(&zc); | ||||
} | } | ||||
ASSERT(!dsl_prop_hascb(ds)); | ASSERT(!dsl_prop_hascb(ds)); | ||||
} | } | ||||
#if defined(__FreeBSD__) && defined(_KERNEL) | #if defined(__FreeBSD__) && defined(_KERNEL) | ||||
mutex_exit(&spa_namespace_lock); | |||||
kmem_free(newname, ZFS_MAX_DATASET_NAME_LEN); | kmem_free(newname, ZFS_MAX_DATASET_NAME_LEN); | ||||
kmem_free(oldname, ZFS_MAX_DATASET_NAME_LEN); | kmem_free(oldname, ZFS_MAX_DATASET_NAME_LEN); | ||||
#endif | #endif | ||||
/* | /* | ||||
* Change space accounting. | * Change space accounting. | ||||
* Note, pa->*usedsnap and dd_used_breakdown[SNAP] will either | * Note, pa->*usedsnap and dd_used_breakdown[SNAP] will either | ||||
* both be valid, or both be 0 (resulting in delta == 0). This | * both be valid, or both be 0 (resulting in delta == 0). This | ||||
* is true for each of {clone,origin} independently. | * is true for each of {clone,origin} independently. | ||||
▲ Show 20 Lines • Show All 1,076 Lines • Show Last 20 Lines |