Skip to content

Commit 62d549d

Browse files
Ryan Moellerbehlendorf
authored andcommitted
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 <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #11146
1 parent ab9011e commit 62d549d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

module/os/freebsd/zfs/zvol_os.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,17 @@ zvol_geom_open(struct g_provider *pp, int flag, int count)
289289
*/
290290
if ((flag & FWRITE) && ((zv->zv_flags & ZVOL_RDONLY) ||
291291
dmu_objset_incompatible_encryption_version(zv->zv_objset))) {
292-
err = EROFS;
292+
err = SET_ERROR(EROFS);
293293
goto out_open_count;
294294
}
295295
if (zv->zv_flags & ZVOL_EXCL) {
296-
err = EBUSY;
296+
err = SET_ERROR(EBUSY);
297297
goto out_open_count;
298298
}
299299
#ifdef FEXCL
300300
if (flag & FEXCL) {
301301
if (zv->zv_open_count != 0) {
302-
err = EBUSY;
302+
err = SET_ERROR(EBUSY);
303303
goto out_open_count;
304304
}
305305
zv->zv_flags |= ZVOL_EXCL;
@@ -323,7 +323,7 @@ zvol_geom_open(struct g_provider *pp, int flag, int count)
323323
mutex_exit(&zv->zv_state_lock);
324324
if (drop_suspend)
325325
rw_exit(&zv->zv_suspend_lock);
326-
return (SET_ERROR(err));
326+
return (err);
327327
}
328328

329329
/*ARGSUSED*/
@@ -614,7 +614,7 @@ zvol_geom_bio_strategy(struct bio *bp)
614614
goto sync;
615615
break;
616616
default:
617-
error = EOPNOTSUPP;
617+
error = SET_ERROR(EOPNOTSUPP);
618618
goto resume;
619619
}
620620

@@ -689,7 +689,7 @@ zvol_geom_bio_strategy(struct bio *bp)
689689

690690
bp->bio_completed = bp->bio_length - resid;
691691
if (bp->bio_completed < bp->bio_length && off > volsize)
692-
error = EINVAL;
692+
error = SET_ERROR(EINVAL);
693693

694694
switch (bp->bio_cmd) {
695695
case BIO_FLUSH:
@@ -870,17 +870,17 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
870870
}
871871

872872
if ((flags & FWRITE) && (zv->zv_flags & ZVOL_RDONLY)) {
873-
err = EROFS;
873+
err = SET_ERROR(EROFS);
874874
goto out_opened;
875875
}
876876
if (zv->zv_flags & ZVOL_EXCL) {
877-
err = EBUSY;
877+
err = SET_ERROR(EBUSY);
878878
goto out_opened;
879879
}
880880
#ifdef FEXCL
881881
if (flags & FEXCL) {
882882
if (zv->zv_open_count != 0) {
883-
err = EBUSY;
883+
err = SET_ERROR(EBUSY);
884884
goto out_opened;
885885
}
886886
zv->zv_flags |= ZVOL_EXCL;
@@ -907,7 +907,7 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
907907
mutex_exit(&zv->zv_state_lock);
908908
if (drop_suspend)
909909
rw_exit(&zv->zv_suspend_lock);
910-
return (SET_ERROR(err));
910+
return (err);
911911
}
912912

913913
static int
@@ -1022,7 +1022,7 @@ zvol_cdev_ioctl(struct cdev *dev, ulong_t cmd, caddr_t data,
10221022
length <= 0) {
10231023
printf("%s: offset=%jd length=%jd\n", __func__, offset,
10241024
length);
1025-
error = EINVAL;
1025+
error = SET_ERROR(EINVAL);
10261026
break;
10271027
}
10281028
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,
10761076
refd = metaslab_class_get_alloc(spa_normal_class(spa));
10771077
arg->value.off = refd / DEV_BSIZE;
10781078
} else
1079-
error = ENOIOCTL;
1079+
error = SET_ERROR(ENOIOCTL);
10801080
break;
10811081
}
10821082
case FIOSEEKHOLE:
@@ -1092,7 +1092,7 @@ zvol_cdev_ioctl(struct cdev *dev, ulong_t cmd, caddr_t data,
10921092
break;
10931093
}
10941094
default:
1095-
error = ENOIOCTL;
1095+
error = SET_ERROR(ENOIOCTL);
10961096
}
10971097

10981098
return (error);

0 commit comments

Comments
 (0)