Skip to content

Commit

Permalink
linux/zvol_os: fix SET_ERROR with negative return codes
Browse files Browse the repository at this point in the history
SET_ERROR is our facility for tracking errors internally. The negation
is to match the what the kernel expects from us. Thus, the negation
should happen outside of the SET_ERROR.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <[email protected]>
  • Loading branch information
robn committed Jul 22, 2024
1 parent 76bb0e5 commit da568ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ zvol_open(struct block_device *bdev, fmode_t flag)
#endif
if (zv == NULL) {
rw_exit(&zvol_state_lock);
return (SET_ERROR(-ENXIO));
return (-SET_ERROR(ENXIO));
}

mutex_enter(&zv->zv_state_lock);
Expand Down Expand Up @@ -795,10 +795,10 @@ zvol_open(struct block_device *bdev, fmode_t flag)

#ifdef HAVE_BLKDEV_GET_ERESTARTSYS
schedule();
return (SET_ERROR(-ERESTARTSYS));
return (-SET_ERROR(ERESTARTSYS));
#else
if ((gethrtime() - start) > timeout)
return (SET_ERROR(-ERESTARTSYS));
return (-SET_ERROR(ERESTARTSYS));

schedule_timeout_interruptible(
MSEC_TO_TICK(10));
Expand All @@ -821,7 +821,7 @@ zvol_open(struct block_device *bdev, fmode_t flag)
if (zv->zv_open_count == 0)
zvol_last_close(zv);

error = SET_ERROR(-EROFS);
error = -SET_ERROR(EROFS);
} else {
zv->zv_open_count++;
}
Expand Down

0 comments on commit da568ec

Please sign in to comment.