mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 02:20:59 +03:00
zvol_os: Tidy up asserts
Using more specific assert variants gives better messages on failure. No functional change. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Matt Macy <mmacy@FreeBSD.org> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #11117
This commit is contained in:
parent
52f1ef3b2d
commit
00a27515f0
@ -248,7 +248,7 @@ retry:
|
|||||||
}
|
}
|
||||||
mutex_enter(&zv->zv_state_lock);
|
mutex_enter(&zv->zv_state_lock);
|
||||||
|
|
||||||
ASSERT(zv->zv_zso->zso_volmode == ZFS_VOLMODE_GEOM);
|
ASSERT3S(zv->zv_zso->zso_volmode, ==, ZFS_VOLMODE_GEOM);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make sure zvol is not suspended during first open
|
* make sure zvol is not suspended during first open
|
||||||
@ -342,17 +342,17 @@ zvol_geom_close(struct g_provider *pp, int flag, int count)
|
|||||||
|
|
||||||
mutex_enter(&zv->zv_state_lock);
|
mutex_enter(&zv->zv_state_lock);
|
||||||
if (zv->zv_flags & ZVOL_EXCL) {
|
if (zv->zv_flags & ZVOL_EXCL) {
|
||||||
ASSERT(zv->zv_open_count == 1);
|
ASSERT3U(zv->zv_open_count, ==, 1);
|
||||||
zv->zv_flags &= ~ZVOL_EXCL;
|
zv->zv_flags &= ~ZVOL_EXCL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(zv->zv_zso->zso_volmode == ZFS_VOLMODE_GEOM);
|
ASSERT3S(zv->zv_zso->zso_volmode, ==, ZFS_VOLMODE_GEOM);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the open count is zero, this is a spurious close.
|
* If the open count is zero, this is a spurious close.
|
||||||
* That indicates a bug in the kernel / DDI framework.
|
* That indicates a bug in the kernel / DDI framework.
|
||||||
*/
|
*/
|
||||||
ASSERT(zv->zv_open_count > 0);
|
ASSERT3U(zv->zv_open_count, >, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make sure zvol is not suspended during last close
|
* make sure zvol is not suspended during last close
|
||||||
@ -400,7 +400,7 @@ zvol_geom_run(zvol_state_t *zv)
|
|||||||
struct zvol_state_geom *zsg = &zv->zv_zso->zso_geom;
|
struct zvol_state_geom *zsg = &zv->zv_zso->zso_geom;
|
||||||
struct g_provider *pp = zsg->zsg_provider;
|
struct g_provider *pp = zsg->zsg_provider;
|
||||||
|
|
||||||
ASSERT(zv->zv_zso->zso_volmode == ZFS_VOLMODE_GEOM);
|
ASSERT3S(zv->zv_zso->zso_volmode, ==, ZFS_VOLMODE_GEOM);
|
||||||
|
|
||||||
g_error_provider(pp, 0);
|
g_error_provider(pp, 0);
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ zvol_geom_destroy(zvol_state_t *zv)
|
|||||||
struct zvol_state_geom *zsg = &zv->zv_zso->zso_geom;
|
struct zvol_state_geom *zsg = &zv->zv_zso->zso_geom;
|
||||||
struct g_provider *pp = zsg->zsg_provider;
|
struct g_provider *pp = zsg->zsg_provider;
|
||||||
|
|
||||||
ASSERT(zv->zv_zso->zso_volmode == ZFS_VOLMODE_GEOM);
|
ASSERT3S(zv->zv_zso->zso_volmode, ==, ZFS_VOLMODE_GEOM);
|
||||||
|
|
||||||
g_topology_assert();
|
g_topology_assert();
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ zvol_geom_worker(void *arg)
|
|||||||
struct zvol_state_geom *zsg = &zv->zv_zso->zso_geom;
|
struct zvol_state_geom *zsg = &zv->zv_zso->zso_geom;
|
||||||
struct bio *bp;
|
struct bio *bp;
|
||||||
|
|
||||||
ASSERT(zv->zv_zso->zso_volmode == ZFS_VOLMODE_GEOM);
|
ASSERT3S(zv->zv_zso->zso_volmode, ==, ZFS_VOLMODE_GEOM);
|
||||||
|
|
||||||
thread_lock(curthread);
|
thread_lock(curthread);
|
||||||
sched_prio(curthread, PRIBIO);
|
sched_prio(curthread, PRIBIO);
|
||||||
@ -540,7 +540,7 @@ zvol_geom_bio_getattr(struct bio *bp)
|
|||||||
zvol_state_t *zv;
|
zvol_state_t *zv;
|
||||||
|
|
||||||
zv = bp->bio_to->private;
|
zv = bp->bio_to->private;
|
||||||
ASSERT(zv != NULL);
|
ASSERT3P(zv, !=, NULL);
|
||||||
|
|
||||||
spa_t *spa = dmu_objset_spa(zv->zv_objset);
|
spa_t *spa = dmu_objset_spa(zv->zv_objset);
|
||||||
uint64_t refd, avail, usedobjs, availobjs;
|
uint64_t refd, avail, usedobjs, availobjs;
|
||||||
@ -621,7 +621,7 @@ zvol_geom_bio_strategy(struct bio *bp)
|
|||||||
volsize = zv->zv_volsize;
|
volsize = zv->zv_volsize;
|
||||||
|
|
||||||
os = zv->zv_objset;
|
os = zv->zv_objset;
|
||||||
ASSERT(os != NULL);
|
ASSERT3P(os, !=, NULL);
|
||||||
|
|
||||||
addr = bp->bio_data;
|
addr = bp->bio_data;
|
||||||
resid = bp->bio_length;
|
resid = bp->bio_length;
|
||||||
@ -836,7 +836,7 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
|
|||||||
|
|
||||||
mutex_enter(&zv->zv_state_lock);
|
mutex_enter(&zv->zv_state_lock);
|
||||||
|
|
||||||
ASSERT(zv->zv_zso->zso_volmode == ZFS_VOLMODE_DEV);
|
ASSERT3S(zv->zv_zso->zso_volmode, ==, ZFS_VOLMODE_DEV);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make sure zvol is not suspended during first open
|
* make sure zvol is not suspended during first open
|
||||||
@ -925,17 +925,17 @@ zvol_cdev_close(struct cdev *dev, int flags, int fmt, struct thread *td)
|
|||||||
|
|
||||||
mutex_enter(&zv->zv_state_lock);
|
mutex_enter(&zv->zv_state_lock);
|
||||||
if (zv->zv_flags & ZVOL_EXCL) {
|
if (zv->zv_flags & ZVOL_EXCL) {
|
||||||
ASSERT(zv->zv_open_count == 1);
|
ASSERT3U(zv->zv_open_count, ==, 1);
|
||||||
zv->zv_flags &= ~ZVOL_EXCL;
|
zv->zv_flags &= ~ZVOL_EXCL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(zv->zv_zso->zso_volmode == ZFS_VOLMODE_DEV);
|
ASSERT3S(zv->zv_zso->zso_volmode, ==, ZFS_VOLMODE_DEV);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the open count is zero, this is a spurious close.
|
* If the open count is zero, this is a spurious close.
|
||||||
* That indicates a bug in the kernel / DDI framework.
|
* That indicates a bug in the kernel / DDI framework.
|
||||||
*/
|
*/
|
||||||
ASSERT(zv->zv_open_count > 0);
|
ASSERT3U(zv->zv_open_count, >, 0);
|
||||||
/*
|
/*
|
||||||
* make sure zvol is not suspended during last close
|
* make sure zvol is not suspended during last close
|
||||||
* (hold zv_suspend_lock) and respect proper lock acquisition
|
* (hold zv_suspend_lock) and respect proper lock acquisition
|
||||||
@ -1150,7 +1150,7 @@ zvol_rename_minor(zvol_state_t *zv, const char *newname)
|
|||||||
|
|
||||||
g_topology_lock();
|
g_topology_lock();
|
||||||
gp = pp->geom;
|
gp = pp->geom;
|
||||||
ASSERT(gp != NULL);
|
ASSERT3P(gp, !=, NULL);
|
||||||
|
|
||||||
zsg->zsg_provider = NULL;
|
zsg->zsg_provider = NULL;
|
||||||
g_wither_provider(pp, ENXIO);
|
g_wither_provider(pp, ENXIO);
|
||||||
@ -1205,7 +1205,7 @@ zvol_free(zvol_state_t *zv)
|
|||||||
{
|
{
|
||||||
ASSERT(!RW_LOCK_HELD(&zv->zv_suspend_lock));
|
ASSERT(!RW_LOCK_HELD(&zv->zv_suspend_lock));
|
||||||
ASSERT(!MUTEX_HELD(&zv->zv_state_lock));
|
ASSERT(!MUTEX_HELD(&zv->zv_state_lock));
|
||||||
ASSERT(zv->zv_open_count == 0);
|
ASSERT0(zv->zv_open_count);
|
||||||
|
|
||||||
ZFS_LOG(1, "ZVOL %s destroyed.", zv->zv_name);
|
ZFS_LOG(1, "ZVOL %s destroyed.", zv->zv_name);
|
||||||
|
|
||||||
|
@ -107,8 +107,9 @@ zvol_write(void *arg)
|
|||||||
uio_from_bio(&uio, bio);
|
uio_from_bio(&uio, bio);
|
||||||
|
|
||||||
zvol_state_t *zv = zvr->zv;
|
zvol_state_t *zv = zvr->zv;
|
||||||
ASSERT(zv && zv->zv_open_count > 0);
|
ASSERT3P(zv, !=, NULL);
|
||||||
ASSERT(zv->zv_zilog != NULL);
|
ASSERT3U(zv->zv_open_count, >, 0);
|
||||||
|
ASSERT3P(zv->zv_zilog, !=, NULL);
|
||||||
|
|
||||||
/* bio marked as FLUSH need to flush before write */
|
/* bio marked as FLUSH need to flush before write */
|
||||||
if (bio_is_flush(bio))
|
if (bio_is_flush(bio))
|
||||||
@ -189,8 +190,9 @@ zvol_discard(void *arg)
|
|||||||
dmu_tx_t *tx;
|
dmu_tx_t *tx;
|
||||||
unsigned long start_jif;
|
unsigned long start_jif;
|
||||||
|
|
||||||
ASSERT(zv && zv->zv_open_count > 0);
|
ASSERT3P(zv, !=, NULL);
|
||||||
ASSERT(zv->zv_zilog != NULL);
|
ASSERT3U(zv->zv_open_count, >, 0);
|
||||||
|
ASSERT3P(zv->zv_zilog, !=, NULL);
|
||||||
|
|
||||||
start_jif = jiffies;
|
start_jif = jiffies;
|
||||||
blk_generic_start_io_acct(zv->zv_zso->zvo_queue, WRITE,
|
blk_generic_start_io_acct(zv->zv_zso->zvo_queue, WRITE,
|
||||||
@ -256,7 +258,8 @@ zvol_read(void *arg)
|
|||||||
uio_from_bio(&uio, bio);
|
uio_from_bio(&uio, bio);
|
||||||
|
|
||||||
zvol_state_t *zv = zvr->zv;
|
zvol_state_t *zv = zvr->zv;
|
||||||
ASSERT(zv && zv->zv_open_count > 0);
|
ASSERT3P(zv, !=, NULL);
|
||||||
|
ASSERT3U(zv->zv_open_count, >, 0);
|
||||||
|
|
||||||
ssize_t start_resid = uio.uio_resid;
|
ssize_t start_resid = uio.uio_resid;
|
||||||
unsigned long start_jif = jiffies;
|
unsigned long start_jif = jiffies;
|
||||||
@ -482,9 +485,9 @@ zvol_open(struct block_device *bdev, fmode_t flag)
|
|||||||
rw_exit(&zvol_state_lock);
|
rw_exit(&zvol_state_lock);
|
||||||
|
|
||||||
ASSERT(MUTEX_HELD(&zv->zv_state_lock));
|
ASSERT(MUTEX_HELD(&zv->zv_state_lock));
|
||||||
ASSERT(zv->zv_open_count != 0 || RW_READ_HELD(&zv->zv_suspend_lock));
|
|
||||||
|
|
||||||
if (zv->zv_open_count == 0) {
|
if (zv->zv_open_count == 0) {
|
||||||
|
ASSERT(RW_READ_HELD(&zv->zv_suspend_lock));
|
||||||
error = -zvol_first_open(zv, !(flag & FMODE_WRITE));
|
error = -zvol_first_open(zv, !(flag & FMODE_WRITE));
|
||||||
if (error)
|
if (error)
|
||||||
goto out_mutex;
|
goto out_mutex;
|
||||||
@ -530,7 +533,7 @@ zvol_release(struct gendisk *disk, fmode_t mode)
|
|||||||
zv = disk->private_data;
|
zv = disk->private_data;
|
||||||
|
|
||||||
mutex_enter(&zv->zv_state_lock);
|
mutex_enter(&zv->zv_state_lock);
|
||||||
ASSERT(zv->zv_open_count > 0);
|
ASSERT3U(zv->zv_open_count, >, 0);
|
||||||
/*
|
/*
|
||||||
* make sure zvol is not suspended during last close
|
* make sure zvol is not suspended during last close
|
||||||
* (hold zv_suspend_lock) and respect proper lock acquisition
|
* (hold zv_suspend_lock) and respect proper lock acquisition
|
||||||
@ -553,11 +556,12 @@ zvol_release(struct gendisk *disk, fmode_t mode)
|
|||||||
rw_exit(&zvol_state_lock);
|
rw_exit(&zvol_state_lock);
|
||||||
|
|
||||||
ASSERT(MUTEX_HELD(&zv->zv_state_lock));
|
ASSERT(MUTEX_HELD(&zv->zv_state_lock));
|
||||||
ASSERT(zv->zv_open_count != 1 || RW_READ_HELD(&zv->zv_suspend_lock));
|
|
||||||
|
|
||||||
zv->zv_open_count--;
|
zv->zv_open_count--;
|
||||||
if (zv->zv_open_count == 0)
|
if (zv->zv_open_count == 0) {
|
||||||
|
ASSERT(RW_READ_HELD(&zv->zv_suspend_lock));
|
||||||
zvol_last_close(zv);
|
zvol_last_close(zv);
|
||||||
|
}
|
||||||
|
|
||||||
mutex_exit(&zv->zv_state_lock);
|
mutex_exit(&zv->zv_state_lock);
|
||||||
|
|
||||||
@ -859,8 +863,8 @@ zvol_free(zvol_state_t *zv)
|
|||||||
|
|
||||||
ASSERT(!RW_LOCK_HELD(&zv->zv_suspend_lock));
|
ASSERT(!RW_LOCK_HELD(&zv->zv_suspend_lock));
|
||||||
ASSERT(!MUTEX_HELD(&zv->zv_state_lock));
|
ASSERT(!MUTEX_HELD(&zv->zv_state_lock));
|
||||||
ASSERT(zv->zv_open_count == 0);
|
ASSERT0(zv->zv_open_count);
|
||||||
ASSERT(zv->zv_zso->zvo_disk->private_data == NULL);
|
ASSERT3P(zv->zv_zso->zvo_disk->private_data, ==, NULL);
|
||||||
|
|
||||||
rw_destroy(&zv->zv_suspend_lock);
|
rw_destroy(&zv->zv_suspend_lock);
|
||||||
zfs_rangelock_fini(&zv->zv_rangelock);
|
zfs_rangelock_fini(&zv->zv_rangelock);
|
||||||
|
Loading…
Reference in New Issue
Block a user