Skip to content

Commit

Permalink
Merge pull request openzfs#8 from lundman/master
Browse files Browse the repository at this point in the history
Fix import panic, and loading/unloading volumes
  • Loading branch information
zfsrogue committed Nov 24, 2012
2 parents 90fddfb + f6ab86c commit acad975
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 0 additions & 2 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6335,8 +6335,6 @@ zfs_key_callback(zfs_handle_t *zhp, int depth, void *data)
return (0);
}

fprintf(stderr, "zfs_key_callback\r\n");

switch (cb->keycmd) {
case KEY_LOAD:
ret = zfs_key_load(zhp, B_TRUE, B_TRUE, cb->recurse);
Expand Down
20 changes: 20 additions & 0 deletions module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4851,6 +4851,7 @@ zfs_ioc_crypto_key_load(zfs_cmd_t *zc)
spa_t *spa;
zcrypt_key_t *wrappingkey = NULL;
int error;
objset_t *os;

if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
return (error);
Expand All @@ -4868,6 +4869,15 @@ zfs_ioc_crypto_key_load(zfs_cmd_t *zc)
if (error == EEXIST)
zcrypt_key_free(wrappingkey);
spa_close(spa, FTAG);

if (!dmu_objset_hold(zc->zc_name, FTAG, &os)) {
if (dmu_objset_type(os) == DMU_OST_ZVOL) {
/* returns EEXISTS if already mounted */
zvol_create_minor(zc->zc_name);
}
dmu_objset_rele(os, FTAG);
}

return (error);
}

Expand All @@ -4887,6 +4897,7 @@ zfs_ioc_crypto_key_inherit(zfs_cmd_t *zc)

error = dsl_crypto_key_inherit(zc->zc_name);
spa_close(spa, FTAG);

return (error);
}

Expand All @@ -4895,6 +4906,7 @@ zfs_ioc_crypto_key_unload(zfs_cmd_t *zc)
{
spa_t *spa;
int error;
objset_t *os;

if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
return (error);
Expand All @@ -4906,6 +4918,14 @@ zfs_ioc_crypto_key_unload(zfs_cmd_t *zc)

error = dsl_crypto_key_unload(zc->zc_name);
spa_close(spa, FTAG);

if (!dmu_objset_hold(zc->zc_name, FTAG, &os)) {
if (dmu_objset_type(os) == DMU_OST_ZVOL) {
zvol_remove_minor(zc->zc_name);
}
dmu_objset_rele(os, FTAG);
}

return (error);
}

Expand Down
4 changes: 2 additions & 2 deletions module/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ zvol_free(zvol_state_t *zv)
static int
__zvol_create_minor(const char *name)
{
zvol_state_t *zv;
zvol_state_t *zv = NULL;
objset_t *os;
dmu_object_info_t *doi;
uint64_t volsize;
Expand Down Expand Up @@ -1315,7 +1315,7 @@ __zvol_create_minor(const char *name)

out_dmu_objset_disown:
dmu_objset_disown(os, zvol_tag);
zv->zv_objset = NULL;
if (zv) zv->zv_objset = NULL;
out_doi:
kmem_free(doi, sizeof(dmu_object_info_t));
out:
Expand Down

0 comments on commit acad975

Please sign in to comment.