diff options
author | smh <smh@FreeBSD.org> | 2014-10-10 01:01:04 +0000 |
---|---|---|
committer | smh <smh@FreeBSD.org> | 2014-10-10 01:01:04 +0000 |
commit | 4347b3c38b4237555ff0fc5763cb47854bdf8d31 (patch) | |
tree | 4698971160d9cf1c54e2bdb1bd15e2002ec52084 /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c | |
parent | 303356caa9a2204687c43e218ab0b0b090dfd1fe (diff) | |
download | FreeBSD-src-4347b3c38b4237555ff0fc5763cb47854bdf8d31.zip FreeBSD-src-4347b3c38b4237555ff0fc5763cb47854bdf8d31.tar.gz |
MFC r272474:
Fix various issues with zvols
Sponsored by: Multiplay
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c')
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c index f05c90d..ab7d50f 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c @@ -883,7 +883,8 @@ zvol_remove_minors(const char *name) LIST_FOREACH_SAFE(zv, &all_zvols, zv_links, tzv) { if (strcmp(zv->zv_name, name) == 0 || (strncmp(zv->zv_name, name, namelen) == 0 && - zv->zv_name[namelen] == '/')) { + strlen(zv->zv_name) > namelen && (zv->zv_name[namelen] == '/' || + zv->zv_name[namelen] == '@'))) { (void) zvol_remove_zv(zv); } } @@ -2571,9 +2572,10 @@ zvol_create_minors(const char *name) if (dmu_objset_type(os) == DMU_OST_ZVOL) { dsl_dataset_long_hold(os->os_dsl_dataset, FTAG); dsl_pool_rele(dmu_objset_pool(os), FTAG); - if ((error = zvol_create_minor(name)) == 0) + error = zvol_create_minor(name); + if (error == 0 || error == EEXIST) { error = zvol_create_snapshots(os, name); - else { + } else { printf("ZFS WARNING: Unable to create ZVOL %s (error=%d).\n", name, error); } @@ -2674,12 +2676,17 @@ zvol_rename_minors(const char *oldname, const char *newname) size_t oldnamelen, newnamelen; zvol_state_t *zv; char *namebuf; + boolean_t locked = B_FALSE; oldnamelen = strlen(oldname); newnamelen = strlen(newname); DROP_GIANT(); - mutex_enter(&spa_namespace_lock); + /* See comment in zvol_open(). */ + if (!MUTEX_HELD(&spa_namespace_lock)) { + mutex_enter(&spa_namespace_lock); + locked = B_TRUE; + } LIST_FOREACH(zv, &all_zvols, zv_links) { if (strcmp(zv->zv_name, oldname) == 0) { @@ -2694,7 +2701,8 @@ zvol_rename_minors(const char *oldname, const char *newname) } } - mutex_exit(&spa_namespace_lock); + if (locked) + mutex_exit(&spa_namespace_lock); PICKUP_GIANT(); } |