Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD: zvol_os: Use SET_ERROR more judiciously #11146

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions module/os/freebsd/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,17 @@ zvol_geom_open(struct g_provider *pp, int flag, int count)
*/
if ((flag & FWRITE) && ((zv->zv_flags & ZVOL_RDONLY) ||
dmu_objset_incompatible_encryption_version(zv->zv_objset))) {
err = EROFS;
err = SET_ERROR(EROFS);
goto out_open_count;
}
if (zv->zv_flags & ZVOL_EXCL) {
err = EBUSY;
err = SET_ERROR(EBUSY);
goto out_open_count;
}
#ifdef FEXCL
if (flag & FEXCL) {
if (zv->zv_open_count != 0) {
err = EBUSY;
err = SET_ERROR(EBUSY);
goto out_open_count;
}
zv->zv_flags |= ZVOL_EXCL;
Expand All @@ -323,7 +323,7 @@ zvol_geom_open(struct g_provider *pp, int flag, int count)
mutex_exit(&zv->zv_state_lock);
if (drop_suspend)
rw_exit(&zv->zv_suspend_lock);
return (SET_ERROR(err));
return (err);
}

/*ARGSUSED*/
Expand Down Expand Up @@ -614,7 +614,7 @@ zvol_geom_bio_strategy(struct bio *bp)
goto sync;
break;
default:
error = EOPNOTSUPP;
error = SET_ERROR(EOPNOTSUPP);
goto resume;
}

Expand Down Expand Up @@ -689,7 +689,7 @@ zvol_geom_bio_strategy(struct bio *bp)

bp->bio_completed = bp->bio_length - resid;
if (bp->bio_completed < bp->bio_length && off > volsize)
error = EINVAL;
error = SET_ERROR(EINVAL);

switch (bp->bio_cmd) {
case BIO_FLUSH:
Expand Down Expand Up @@ -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)) {
err = EROFS;
err = SET_ERROR(EROFS);
goto out_opened;
}
if (zv->zv_flags & ZVOL_EXCL) {
err = EBUSY;
err = SET_ERROR(EBUSY);
goto out_opened;
}
#ifdef FEXCL
if (flags & FEXCL) {
if (zv->zv_open_count != 0) {
err = EBUSY;
err = SET_ERROR(EBUSY);
goto out_opened;
}
zv->zv_flags |= ZVOL_EXCL;
Expand All @@ -907,7 +907,7 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
mutex_exit(&zv->zv_state_lock);
if (drop_suspend)
rw_exit(&zv->zv_suspend_lock);
return (SET_ERROR(err));
return (err);
}

static int
Expand Down Expand Up @@ -1022,7 +1022,7 @@ zvol_cdev_ioctl(struct cdev *dev, ulong_t cmd, caddr_t data,
length <= 0) {
printf("%s: offset=%jd length=%jd\n", __func__, offset,
length);
error = EINVAL;
error = SET_ERROR(EINVAL);
break;
}
rw_enter(&zv->zv_suspend_lock, ZVOL_RW_READER);
Expand Down Expand Up @@ -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));
arg->value.off = refd / DEV_BSIZE;
} else
error = ENOIOCTL;
error = SET_ERROR(ENOIOCTL);
break;
}
case FIOSEEKHOLE:
Expand All @@ -1092,7 +1092,7 @@ zvol_cdev_ioctl(struct cdev *dev, ulong_t cmd, caddr_t data,
break;
}
default:
error = ENOIOCTL;
error = SET_ERROR(ENOIOCTL);
}

return (error);
Expand Down