FreeBSD: zvol_os: Use SET_ERROR more judiciously

SET_ERROR is useful to trace errors, so use it where the errors occur
rather than factored out to the end of a function.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #11146
This commit is contained in:
Ryan Moeller 2020-11-03 12:21:09 -05:00 committed by GitHub
parent 2d7843401a
commit 181b2adc2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 13 deletions

View File

@ -289,17 +289,17 @@ retry:
*/ */
if ((flag & FWRITE) && ((zv->zv_flags & ZVOL_RDONLY) || if ((flag & FWRITE) && ((zv->zv_flags & ZVOL_RDONLY) ||
dmu_objset_incompatible_encryption_version(zv->zv_objset))) { dmu_objset_incompatible_encryption_version(zv->zv_objset))) {
err = EROFS; err = SET_ERROR(EROFS);
goto out_open_count; goto out_open_count;
} }
if (zv->zv_flags & ZVOL_EXCL) { if (zv->zv_flags & ZVOL_EXCL) {
err = EBUSY; err = SET_ERROR(EBUSY);
goto out_open_count; goto out_open_count;
} }
#ifdef FEXCL #ifdef FEXCL
if (flag & FEXCL) { if (flag & FEXCL) {
if (zv->zv_open_count != 0) { if (zv->zv_open_count != 0) {
err = EBUSY; err = SET_ERROR(EBUSY);
goto out_open_count; goto out_open_count;
} }
zv->zv_flags |= ZVOL_EXCL; zv->zv_flags |= ZVOL_EXCL;
@ -323,7 +323,7 @@ out_mutex:
mutex_exit(&zv->zv_state_lock); mutex_exit(&zv->zv_state_lock);
if (drop_suspend) if (drop_suspend)
rw_exit(&zv->zv_suspend_lock); rw_exit(&zv->zv_suspend_lock);
return (SET_ERROR(err)); return (err);
} }
/*ARGSUSED*/ /*ARGSUSED*/
@ -614,7 +614,7 @@ zvol_geom_bio_strategy(struct bio *bp)
goto sync; goto sync;
break; break;
default: default:
error = EOPNOTSUPP; error = SET_ERROR(EOPNOTSUPP);
goto resume; goto resume;
} }
@ -689,7 +689,7 @@ unlock:
bp->bio_completed = bp->bio_length - resid; bp->bio_completed = bp->bio_length - resid;
if (bp->bio_completed < bp->bio_length && off > volsize) if (bp->bio_completed < bp->bio_length && off > volsize)
error = EINVAL; error = SET_ERROR(EINVAL);
switch (bp->bio_cmd) { switch (bp->bio_cmd) {
case BIO_FLUSH: case BIO_FLUSH:
@ -870,17 +870,17 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
} }
if ((flags & FWRITE) && (zv->zv_flags & ZVOL_RDONLY)) { if ((flags & FWRITE) && (zv->zv_flags & ZVOL_RDONLY)) {
err = EROFS; err = SET_ERROR(EROFS);
goto out_opened; goto out_opened;
} }
if (zv->zv_flags & ZVOL_EXCL) { if (zv->zv_flags & ZVOL_EXCL) {
err = EBUSY; err = SET_ERROR(EBUSY);
goto out_opened; goto out_opened;
} }
#ifdef FEXCL #ifdef FEXCL
if (flags & FEXCL) { if (flags & FEXCL) {
if (zv->zv_open_count != 0) { if (zv->zv_open_count != 0) {
err = EBUSY; err = SET_ERROR(EBUSY);
goto out_opened; goto out_opened;
} }
zv->zv_flags |= ZVOL_EXCL; zv->zv_flags |= ZVOL_EXCL;
@ -907,7 +907,7 @@ out_locked:
mutex_exit(&zv->zv_state_lock); mutex_exit(&zv->zv_state_lock);
if (drop_suspend) if (drop_suspend)
rw_exit(&zv->zv_suspend_lock); rw_exit(&zv->zv_suspend_lock);
return (SET_ERROR(err)); return (err);
} }
static int static int
@ -1022,7 +1022,7 @@ zvol_cdev_ioctl(struct cdev *dev, ulong_t cmd, caddr_t data,
length <= 0) { length <= 0) {
printf("%s: offset=%jd length=%jd\n", __func__, offset, printf("%s: offset=%jd length=%jd\n", __func__, offset,
length); length);
error = EINVAL; error = SET_ERROR(EINVAL);
break; break;
} }
rw_enter(&zv->zv_suspend_lock, ZVOL_RW_READER); rw_enter(&zv->zv_suspend_lock, ZVOL_RW_READER);
@ -1076,7 +1076,7 @@ zvol_cdev_ioctl(struct cdev *dev, ulong_t cmd, caddr_t data,
refd = metaslab_class_get_alloc(spa_normal_class(spa)); refd = metaslab_class_get_alloc(spa_normal_class(spa));
arg->value.off = refd / DEV_BSIZE; arg->value.off = refd / DEV_BSIZE;
} else } else
error = ENOIOCTL; error = SET_ERROR(ENOIOCTL);
break; break;
} }
case FIOSEEKHOLE: case FIOSEEKHOLE:
@ -1092,7 +1092,7 @@ zvol_cdev_ioctl(struct cdev *dev, ulong_t cmd, caddr_t data,
break; break;
} }
default: default:
error = ENOIOCTL; error = SET_ERROR(ENOIOCTL);
} }
return (error); return (error);