Skip to content

Commit

Permalink
engines/io_uring: Fix negative errno in io_u->error
Browse files Browse the repository at this point in the history
io_u->error can have either negative errno value or device-specific
error status as a positive value.  fio always tries to parse the errno
with strerrno() and it expects the value to be a positive one.

Commit ebe67b6 ("io_uring: Add IO_U_F_DEVICE_ERRROR to identify
error types") tried to abs(io_u->error) to convert it first.  And it
caused the following build warning:

  engines/io_uring.c:553:16: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
          io_u->error = abs(io_u->error);
                        ^
  engines/io_uring.c:553:16: note: remove the call to 'abs' since unsigned values cannot be negative
          io_u->error = abs(io_u->error);
                        ^~~

Commit 9eaa8e7 ("engines/io_uring: don't use abs() on an unsigned
value") tried to remove the warning by removing abs() on io_u->error,
but if so, negative errno (e.g., -EINVAL) can't be parsed properly like:

  fio: io_u error on file /dev/ng0n1: Unknown error -22: write offset=429916160, buflen=1048576

This patch fixed this fixed to convert to positive value properly by
casting it first to int and then do abs() on it.

Fixes: 9eaa8e7 ("engines/io_uring: don't use abs() on an unsigned value")

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Link: https://lore.kernel.org/r/20240927030857.17001-1-minwoo.im.dev@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
minwooim authored and axboe committed Sep 27, 2024
1 parent aa66518 commit e4e8520
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion engines/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ static struct io_u *fio_ioring_cmd_event(struct thread_data *td, int event)
io_u_set(td, io_u, IO_U_F_DEVICE_ERROR);
else
io_u_clear(td, io_u, IO_U_F_DEVICE_ERROR);
io_u->error = io_u->error;
io_u->error = abs((int)io_u->error);
return io_u;
}

Expand Down

0 comments on commit e4e8520

Please sign in to comment.