Merge commit 'refs/top-bases/linux-configure-branch' into linux-configure-branch
This commit is contained in:
commit
f0ff2eddbe
|
@ -40,10 +40,11 @@ extern int zvol_check_volblocksize(uint64_t volblocksize);
|
||||||
extern int zvol_get_stats(objset_t *os, nvlist_t *nv);
|
extern int zvol_get_stats(objset_t *os, nvlist_t *nv);
|
||||||
extern void zvol_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx);
|
extern void zvol_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx);
|
||||||
extern int zvol_create_minor(const char *);
|
extern int zvol_create_minor(const char *);
|
||||||
|
extern int zvol_create_minors(const char *);
|
||||||
extern int zvol_remove_minor(const char *);
|
extern int zvol_remove_minor(const char *);
|
||||||
|
extern int zvol_remove_minors(const char *);
|
||||||
extern int zvol_set_volsize(const char *, uint64_t);
|
extern int zvol_set_volsize(const char *, uint64_t);
|
||||||
extern int zvol_set_volblocksize(const char *, uint64_t);
|
extern int zvol_set_volblocksize(const char *, uint64_t);
|
||||||
extern void zvol_remove_minors(const char *);
|
|
||||||
|
|
||||||
extern int zvol_init(void);
|
extern int zvol_init(void);
|
||||||
extern void zvol_fini(void);
|
extern void zvol_fini(void);
|
||||||
|
|
|
@ -1135,9 +1135,9 @@ zfs_ioc_pool_destroy(struct file *filp, zfs_cmd_t *zc)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
zfs_log_history(zc);
|
zfs_log_history(zc);
|
||||||
error = spa_destroy(zc->zc_name);
|
error = zvol_remove_minors(zc->zc_name);
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
zvol_remove_minors(zc->zc_name);
|
error = spa_destroy(zc->zc_name);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1167,6 +1167,9 @@ zfs_ioc_pool_import(struct file *filp, zfs_cmd_t *zc)
|
||||||
else
|
else
|
||||||
error = spa_import(zc->zc_name, config, props);
|
error = spa_import(zc->zc_name, config, props);
|
||||||
|
|
||||||
|
if (error == 0)
|
||||||
|
error = zvol_create_minors(zc->zc_name);
|
||||||
|
|
||||||
if (zc->zc_nvlist_dst != 0)
|
if (zc->zc_nvlist_dst != 0)
|
||||||
(void) put_nvlist(zc, config);
|
(void) put_nvlist(zc, config);
|
||||||
|
|
||||||
|
@ -1186,9 +1189,10 @@ zfs_ioc_pool_export(struct file *filp, zfs_cmd_t *zc)
|
||||||
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 = zvol_remove_minors(zc->zc_name);
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
zvol_remove_minors(zc->zc_name);
|
error = spa_export(zc->zc_name, NULL, force, hardforce);
|
||||||
|
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2998,7 +3002,7 @@ zfs_ioc_destroy(struct file *filp, zfs_cmd_t *zc)
|
||||||
|
|
||||||
err = dmu_objset_destroy(zc->zc_name, zc->zc_defer_destroy);
|
err = dmu_objset_destroy(zc->zc_name, zc->zc_defer_destroy);
|
||||||
if (zc->zc_objset_type == DMU_OST_ZVOL && err == 0)
|
if (zc->zc_objset_type == DMU_OST_ZVOL && err == 0)
|
||||||
(void) zvol_remove_minor(zc->zc_name);
|
err = zvol_remove_minor(zc->zc_name);
|
||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3102,6 +3106,7 @@ static int
|
||||||
zfs_ioc_rename(struct file *filp, zfs_cmd_t *zc)
|
zfs_ioc_rename(struct file *filp, zfs_cmd_t *zc)
|
||||||
{
|
{
|
||||||
boolean_t recursive = zc->zc_cookie & 1;
|
boolean_t recursive = zc->zc_cookie & 1;
|
||||||
|
int err;
|
||||||
|
|
||||||
zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
|
zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
|
||||||
if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
|
if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
|
||||||
|
@ -3115,12 +3120,16 @@ zfs_ioc_rename(struct file *filp, zfs_cmd_t *zc)
|
||||||
*/
|
*/
|
||||||
if (!recursive && strchr(zc->zc_name, '@') != NULL &&
|
if (!recursive && strchr(zc->zc_name, '@') != NULL &&
|
||||||
zc->zc_objset_type == DMU_OST_ZFS) {
|
zc->zc_objset_type == DMU_OST_ZFS) {
|
||||||
int err = zfs_unmount_snap(zc->zc_name, NULL);
|
err = zfs_unmount_snap(zc->zc_name, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
if (zc->zc_objset_type == DMU_OST_ZVOL)
|
if (zc->zc_objset_type == DMU_OST_ZVOL) {
|
||||||
(void) zvol_remove_minor(zc->zc_name);
|
err = zvol_remove_minor(zc->zc_name);
|
||||||
|
if (err)
|
||||||
|
return (err);
|
||||||
|
}
|
||||||
|
|
||||||
return (dmu_objset_rename(zc->zc_name, zc->zc_value, recursive));
|
return (dmu_objset_rename(zc->zc_name, zc->zc_value, recursive));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -342,11 +342,15 @@ zvol_set_volblocksize(const char *name, uint64_t volblocksize)
|
||||||
mutex_enter(&zvol_state_lock);
|
mutex_enter(&zvol_state_lock);
|
||||||
|
|
||||||
zv = zvol_find_by_name(name);
|
zv = zvol_find_by_name(name);
|
||||||
if (zv == NULL)
|
if (zv == NULL) {
|
||||||
return (ENXIO);
|
error = ENXIO;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (get_disk_ro(zv->zv_disk) || (zv->zv_flags & ZVOL_RDONLY))
|
if (get_disk_ro(zv->zv_disk) || (zv->zv_flags & ZVOL_RDONLY)) {
|
||||||
return (EROFS);
|
error = EROFS;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
tx = dmu_tx_create(zv->zv_objset);
|
tx = dmu_tx_create(zv->zv_objset);
|
||||||
dmu_tx_hold_bonus(tx, ZVOL_OBJ);
|
dmu_tx_hold_bonus(tx, ZVOL_OBJ);
|
||||||
|
@ -362,6 +366,8 @@ zvol_set_volblocksize(const char *name, uint64_t volblocksize)
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
zv->zv_volblocksize = volblocksize;
|
zv->zv_volblocksize = volblocksize;
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
|
mutex_exit(&zvol_state_lock);
|
||||||
|
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
@ -1127,25 +1133,6 @@ out:
|
||||||
return (-error);
|
return (-error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
zvol_create_minors_cb(spa_t *spa, uint64_t dsobj,
|
|
||||||
const char *dsname, void *arg)
|
|
||||||
{
|
|
||||||
return zvol_create_minor(dsname);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
zvol_create_minors(void)
|
|
||||||
{
|
|
||||||
spa_t *spa = NULL;
|
|
||||||
|
|
||||||
mutex_enter(&spa_namespace_lock);
|
|
||||||
while ((spa = spa_next(spa)) != NULL)
|
|
||||||
(void) dmu_objset_find_spa(NULL, spa_name(spa), zvol_create_minors_cb,
|
|
||||||
NULL, DS_FIND_CHILDREN | DS_FIND_SNAPSHOTS);
|
|
||||||
mutex_exit(&spa_namespace_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove a block device minor node for the specified volume.
|
* Remove a block device minor node for the specified volume.
|
||||||
*/
|
*/
|
||||||
|
@ -1173,26 +1160,69 @@ zvol_remove_minor(const char *name)
|
||||||
out:
|
out:
|
||||||
mutex_exit(&zvol_state_lock);
|
mutex_exit(&zvol_state_lock);
|
||||||
|
|
||||||
return (-error);
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
zvol_create_minors_cb(spa_t *spa, uint64_t dsobj,
|
||||||
|
const char *dsname, void *arg)
|
||||||
|
{
|
||||||
|
if (strchr(dsname, '/') == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return zvol_create_minor(dsname);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
zvol_remove_minors_cb(spa_t *spa, uint64_t dsobj,
|
||||||
|
const char *dsname, void *arg)
|
||||||
|
{
|
||||||
|
if (strchr(dsname, '/') == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return zvol_remove_minor(dsname);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
zvol_cr_minors_common(const char *pool,
|
||||||
|
int func(spa_t *, uint64_t, const char *, void *), void *arg)
|
||||||
|
{
|
||||||
|
spa_t *spa = NULL;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
if (pool) {
|
||||||
|
error = dmu_objset_find_spa(NULL, pool, func, arg,
|
||||||
|
DS_FIND_CHILDREN | DS_FIND_SNAPSHOTS);
|
||||||
|
} else {
|
||||||
|
mutex_enter(&spa_namespace_lock);
|
||||||
|
while ((spa = spa_next(spa)) != NULL) {
|
||||||
|
error = dmu_objset_find_spa(NULL, spa_name(spa),
|
||||||
|
func, arg, DS_FIND_CHILDREN | DS_FIND_SNAPSHOTS);
|
||||||
|
if (error)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mutex_exit(&spa_namespace_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove all minors from the system. This is only called from
|
* Create minors for specified pool, or if NULL create all minors.
|
||||||
* zvol_fini() which means the module reference count must have
|
|
||||||
* dropped to zero and none of the zvol devices may be open.
|
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
zvol_remove_minors(const char *name)
|
zvol_create_minors(const char *pool)
|
||||||
{
|
{
|
||||||
zvol_state_t *zv;
|
return zvol_cr_minors_common(pool, zvol_create_minors_cb, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
mutex_enter(&zvol_state_lock);
|
/*
|
||||||
while ((zv = list_head(&zvol_state_list)) != NULL) {
|
* Remove minors for specified pool, or if NULL remove all minors.
|
||||||
ASSERT3U(zv->zv_open_count, ==, 0);
|
*/
|
||||||
zvol_remove(zv);
|
int
|
||||||
zvol_free(zv);
|
zvol_remove_minors(const char *pool)
|
||||||
}
|
{
|
||||||
mutex_exit(&zvol_state_lock);
|
return zvol_cr_minors_common(pool, zvol_remove_minors_cb, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1224,7 +1254,7 @@ zvol_init(void)
|
||||||
list_create(&zvol_state_list, sizeof (zvol_state_t),
|
list_create(&zvol_state_list, sizeof (zvol_state_t),
|
||||||
offsetof(zvol_state_t, zv_next));
|
offsetof(zvol_state_t, zv_next));
|
||||||
|
|
||||||
zvol_create_minors();
|
(void) zvol_create_minors(NULL);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1232,6 +1262,8 @@ zvol_init(void)
|
||||||
void
|
void
|
||||||
zvol_fini(void)
|
zvol_fini(void)
|
||||||
{
|
{
|
||||||
|
(void) zvol_remove_minors(NULL);
|
||||||
|
|
||||||
blk_unregister_region(MKDEV(zvol_major, 0), 1UL << MINORBITS);
|
blk_unregister_region(MKDEV(zvol_major, 0), 1UL << MINORBITS);
|
||||||
unregister_blkdev(zvol_major, ZVOL_DRIVER);
|
unregister_blkdev(zvol_major, ZVOL_DRIVER);
|
||||||
taskq_destroy(zvol_taskq);
|
taskq_destroy(zvol_taskq);
|
||||||
|
|
|
@ -161,4 +161,52 @@ EOF
|
||||||
}
|
}
|
||||||
zconfig_test3
|
zconfig_test3
|
||||||
|
|
||||||
|
# zpool import/export check
|
||||||
|
zconfig_test4() {
|
||||||
|
POOL_NAME=test4
|
||||||
|
ZVOL_NAME1=fish1
|
||||||
|
ZVOL_NAME2=fish2
|
||||||
|
FULL_NAME1=${POOL_NAME}/${ZVOL_NAME1}
|
||||||
|
FULL_NAME2=${POOL_NAME}/${ZVOL_NAME2}
|
||||||
|
TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
|
||||||
|
|
||||||
|
echo -n "test 4 - zpool import/export: "
|
||||||
|
|
||||||
|
# Create a pool and volume.
|
||||||
|
${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
|
||||||
|
${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
|
||||||
|
${ZFS} create -V 100M ${FULL_NAME1} || fail 3
|
||||||
|
${ZFS} create -V 100M ${FULL_NAME2} || fail 4
|
||||||
|
|
||||||
|
# Verify the devices were created
|
||||||
|
stat /dev/${FULL_NAME1} &>/dev/null || fail 5
|
||||||
|
stat /dev/${FULL_NAME2} &>/dev/null || fail 6
|
||||||
|
|
||||||
|
# Export the pool
|
||||||
|
${ZPOOL} export ${POOL_NAME} || fail 7
|
||||||
|
|
||||||
|
# Verify the devices were removed
|
||||||
|
stat /dev/${FULL_NAME1} &>/dev/null && fail 8
|
||||||
|
stat /dev/${FULL_NAME2} &>/dev/null && fail 9
|
||||||
|
|
||||||
|
# Import the pool
|
||||||
|
${ZPOOL} import ${POOL_NAME} || fail 10
|
||||||
|
|
||||||
|
# Verify the devices were created
|
||||||
|
stat /dev/${FULL_NAME1} &>/dev/null || fail 11
|
||||||
|
stat /dev/${FULL_NAME2} &>/dev/null || fail 12
|
||||||
|
|
||||||
|
# Destroy the pool and consequently the devices
|
||||||
|
${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 15
|
||||||
|
|
||||||
|
# Verify the devices were removed
|
||||||
|
stat /dev/${FULL_NAME1} &>/dev/null && fail 16
|
||||||
|
stat /dev/${FULL_NAME2} &>/dev/null && fail 17
|
||||||
|
|
||||||
|
${ZFS_SH} -u || fail 18
|
||||||
|
|
||||||
|
pass
|
||||||
|
}
|
||||||
|
zconfig_test4
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue