public inbox for fio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] engines/io_uring: Fix negative errno in io_u->error
@ 2024-09-27  3:08 Minwoo Im
  2024-09-27 10:18 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Minwoo Im @ 2024-09-27  3:08 UTC (permalink / raw)
  To: fio; +Cc: Jens Axboe, Vincent Fu, Minwoo Im, Minwoo Im

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 ebe67b667f25 ("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 9eaa8e7c8e0b ("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: 9eaa8e7c8e0b ("engines/io_uring: don't use abs() on an unsigned value")

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
---
 engines/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/engines/io_uring.c b/engines/io_uring.c
index 6c07c1011c40..85cebf8371cf 100644
--- a/engines/io_uring.c
+++ b/engines/io_uring.c
@@ -589,7 +589,7 @@ ret:
 		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;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] engines/io_uring: Fix negative errno in io_u->error
  2024-09-27  3:08 [PATCH] engines/io_uring: Fix negative errno in io_u->error Minwoo Im
@ 2024-09-27 10:18 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2024-09-27 10:18 UTC (permalink / raw)
  To: fio, Minwoo Im; +Cc: Vincent Fu, Minwoo Im


On Fri, 27 Sep 2024 12:08:57 +0900, Minwoo Im wrote:
> 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 ebe67b667f25 ("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:
> 
> [...]

Applied, thanks!

[1/1] engines/io_uring: Fix negative errno in io_u->error
      commit: e4e8520b374e7e021d289d400ade70c41681d635

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-27 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-27  3:08 [PATCH] engines/io_uring: Fix negative errno in io_u->error Minwoo Im
2024-09-27 10:18 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox