public inbox for fio@vger.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, Vincent Fu <vincent.fu@samsung.com>
Cc: fio@vger.kernel.org, Damien Le Moal <dlemoal@kernel.org>,
	Jorgen S Hansen <jorgen.hansen@wdc.com>,
	Niklas Cassel <cassel@kernel.org>
Subject: [PATCH 1/3] fio: Fix error string not matching errno
Date: Fri,  6 Feb 2026 17:40:56 +0100	[thread overview]
Message-ID: <20260206164058.3105327-2-cassel@kernel.org> (raw)
In-Reply-To: <20260206164058.3105327-1-cassel@kernel.org>

When using --error_dump=1 together with --continue_on_error=io and
--ignore_error=62, we can get an inconsistent error in the summary line
 produced by __show_run_stats():

Before patch:
test: (groupid=0, jobs=1): err= 5 (file:io_u.c:2012, func=io_u error, error=Timer expired): pid=30925: Thu Feb  5 09:15:15 2026
...
  IO depths    : 1=0.8%, 2=1.6%, 4=3.3%, 8=6.6%, 16=13.1%, 32=74.6%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=98.9%, 8=0.0%, 16=0.0%, 32=1.1%, 64=0.0%, >=64=0.0%
     issued rwts: total=0,122,0,0 short=0,0,0,0 dropped=0,0,0,0
     errors    : total=4, first_error=62/<Timer expired>
     latency   : target=0, window=0, percentile=100.00%, depth=32

The string for errno "err= 5" is incorrectly printed as "Timer expired".
(The correct string for "err= 5" is "Input/output error".)

There is thus a mismatch between the errno and the verbose string for the
errno.

This problem is this code in __td_verror():

td->error = ____e;
if (!td->first_error)
	nowarn_snprintf(td->verror, ..);

I.e. td->error (errno) is updated unconditionally, while td->verror (the
verbose error string), is updated only if td->first_error is not set.

Thus, if you get a non-fatal error, it will set td->error and td->error.
Later, for a non-fatal error, io_completed() will call update_error_count()
which sets td->first_error, followed by td_clear_error() which will clear
td->error.

Thus a second error (fatal or non-fatal) will set td->error, but since
td->first_error is now set, it will not update td->verror.

Since td->verror contains the string representation of the errno stored in
td->error, these two struct members should obviously always be updated at
the same time.

If you look at the example print above, you can see that there is another
print: first_error=62/<Timer expired>

Which prints td->first_error, and does not even use td->verror. Instead
show_thread_status_normal() calls strerror(td->first_error) to get the
error string for td->first_error.

There is thus absolutely no reason to not set td->verror every time
td->error is set.

Remove the useless guard such that the error string will always correspond
to errno.

Fixes: f2bba1820a56 ("Add a 'continue_on_error' option to fio")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
 fio.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fio.h b/fio.h
index e0b7c13c..65c68d4b 100644
--- a/fio.h
+++ b/fio.h
@@ -542,10 +542,9 @@ enum {
 		if ((td)->error)					\
 			break;						\
 		(td)->error = ____e;					\
-		if (!(td)->first_error)					\
-			nowarn_snprintf(td->verror, sizeof(td->verror),	\
-					"file:%s:%d, func=%s, error=%s", \
-					__FILE__, __LINE__, (func), (msg)); \
+		nowarn_snprintf(td->verror, sizeof(td->verror),		\
+				"file:%s:%d, func=%s, error=%s",	\
+				__FILE__, __LINE__, (func), (msg));	\
 	} while (0)
 
 
-- 
2.53.0


  reply	other threads:[~2026-02-06 16:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06 16:40 [PATCH 0/3] fio: Avoid errno and errno string mismatch Niklas Cassel
2026-02-06 16:40 ` Niklas Cassel [this message]
2026-02-13  3:12   ` [PATCH 1/3] fio: Fix error string not matching errno Damien Le Moal
2026-02-06 16:40 ` [PATCH 2/3] io_u: Fix inconsistent handling of non-fatal errors with option error_dump Niklas Cassel
2026-02-13  3:17   ` Damien Le Moal
2026-02-06 16:40 ` [PATCH 3/3] stat: Remove duplicate space in __show_run_stats() Niklas Cassel
2026-02-13  3:17   ` Damien Le Moal
2026-02-06 17:57 ` [PATCH 0/3] fio: Avoid errno and errno string mismatch fiotestbot
2026-02-14  2:39 ` Vincent Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260206164058.3105327-2-cassel@kernel.org \
    --to=cassel@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=fio@vger.kernel.org \
    --cc=jorgen.hansen@wdc.com \
    --cc=vincent.fu@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox