diff mbox series

[1/3] aio-dio-write-verify: check for the IO errors

Message ID 2c9519c024e39b6eb4a3bb93f448752cedd83894.1692688971.git.naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series generic/551: improve error reporting and handling | expand

Commit Message

Naohiro Aota Aug. 22, 2023, 7:28 a.m. UTC
The async write IOs can return some errors, which may lead to a short read or
corruption in io_verify() stage. Catch an error early to identify the root
cause easily.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 src/aio-dio-regress/aio-dio-write-verify.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Zorro Lang Aug. 29, 2023, 3:47 a.m. UTC | #1
On Tue, Aug 22, 2023 at 04:28:50PM +0900, Naohiro Aota wrote:
> The async write IOs can return some errors, which may lead to a short read or
> corruption in io_verify() stage. Catch an error early to identify the root
> cause easily.
> 
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> ---

Looks good to me,
Reviewed-by: Zorro Lang <zlang@redhat.com>

>  src/aio-dio-regress/aio-dio-write-verify.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/aio-dio-regress/aio-dio-write-verify.c b/src/aio-dio-regress/aio-dio-write-verify.c
> index 302b8fe4a096..90e41b391289 100644
> --- a/src/aio-dio-regress/aio-dio-write-verify.c
> +++ b/src/aio-dio-regress/aio-dio-write-verify.c
> @@ -238,6 +238,16 @@ static int io_write(int fd, int num_events)
>  		return 1;
>  	}
>  
> +	for (i = 0; i < num_events; i++) {
> +		int err = (int)evs[i].res;
> +
> +		if (err < 0) {
> +			fprintf(stderr, "error %s with event %d\n",
> +				strerror(err), i);
> +			return 1;
> +		}
> +	}
> +
>  	/* Try to destroy at here, not necessary, so don't check result */
>  	io_destroy(ctx);
>  
> -- 
> 2.41.0
>
diff mbox series

Patch

diff --git a/src/aio-dio-regress/aio-dio-write-verify.c b/src/aio-dio-regress/aio-dio-write-verify.c
index 302b8fe4a096..90e41b391289 100644
--- a/src/aio-dio-regress/aio-dio-write-verify.c
+++ b/src/aio-dio-regress/aio-dio-write-verify.c
@@ -238,6 +238,16 @@  static int io_write(int fd, int num_events)
 		return 1;
 	}
 
+	for (i = 0; i < num_events; i++) {
+		int err = (int)evs[i].res;
+
+		if (err < 0) {
+			fprintf(stderr, "error %s with event %d\n",
+				strerror(err), i);
+			return 1;
+		}
+	}
+
 	/* Try to destroy at here, not necessary, so don't check result */
 	io_destroy(ctx);