All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: mwilck@suse.com
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>,
	dm-devel@lists.linux.dev
Subject: Re: [PATCH v2 07/14] libmultipath: io_err_stat: fix error handling
Date: Fri, 27 Oct 2023 15:09:13 -0400	[thread overview]
Message-ID: <ZTwK2e59eDaKxxvX@bmarzins-01.fast.rdu2.eng.redhat.com> (raw)
In-Reply-To: <20231026174153.1133-8-mwilck@suse.com>

On Thu, Oct 26, 2023 at 07:41:46PM +0200, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> libaio uses a different error return convention than glibc. The error code is
> not returned in errno, but as the negated return value of the function.
> Adapt the error handling code in io_err_stat.c. Don't print an error message
> for failure of io_cancel(), which always returns -EINPRPOGRESS.
> 
> Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>  libmultipath/io_err_stat.c | 36 ++++++++++++++++--------------------
>  1 file changed, 16 insertions(+), 20 deletions(-)
> 
> diff --git a/libmultipath/io_err_stat.c b/libmultipath/io_err_stat.c
> index 5749003..1c59445 100644
> --- a/libmultipath/io_err_stat.c
> +++ b/libmultipath/io_err_stat.c
> @@ -19,7 +19,6 @@
>  #include <sys/ioctl.h>
>  #include <linux/fs.h>
>  #include <libaio.h>
> -#include <errno.h>
>  #include <sys/mman.h>
>  #include <sys/select.h>
>  
> @@ -469,7 +468,7 @@ static void end_io_err_stat(struct io_err_stat_path *pp)
>  
>  static int send_each_async_io(struct dio_ctx *ct, int fd, char *dev)
>  {
> -	int rc = -1;
> +	int rc;
>  
>  	if (ct->io_starttime.tv_nsec == 0 &&
>  			ct->io_starttime.tv_sec == 0) {
> @@ -477,15 +476,15 @@ static int send_each_async_io(struct dio_ctx *ct, int fd, char *dev)
>  
>  		get_monotonic_time(&ct->io_starttime);
>  		io_prep_pread(&ct->io, fd, ct->buf, ct->blksize, 0);
> -		if (io_submit(ioctx, 1, ios) != 1) {
> -			io_err_stat_log(2, "%s: io_submit error %i",
> -					dev, errno);
> -			return rc;
> +		if ((rc = io_submit(ioctx, 1, ios)) != 1) {
> +			io_err_stat_log(2, "%s: io_submit error %s",
> +					dev, strerror(-rc));
> +			return -1;
>  		}
> -		rc = 0;
> +		return 0;
>  	}
>  
> -	return rc;
> +	return -1;
>  }
>  
>  static void send_batch_async_ios(struct io_err_stat_path *pp)
> @@ -530,8 +529,8 @@ static int try_to_cancel_timeout_io(struct dio_ctx *ct, struct timespec *t,
>  		io_err_stat_log(5, "%s: abort check on timeout", dev);
>  		r = io_cancel(ioctx, ios[0], &event);
>  		if (r)
> -			io_err_stat_log(5, "%s: io_cancel error %i",
> -					dev, errno);
> +			io_err_stat_log(5, "%s: io_cancel error %s",
> +					dev, strerror(-r));
>  		rc = PATH_TIMEOUT;
>  	} else {
>  		rc = PATH_PENDING;
> @@ -560,7 +559,7 @@ static void poll_async_io_timeout(void)
>  static void cancel_inflight_io(struct io_err_stat_path *pp)
>  {
>  	struct io_event event;
> -	int i, r;
> +	int i;
>  
>  	for (i = 0; i < CONCUR_NR_EVENT; i++) {
>  		struct dio_ctx *ct = pp->dio_ctx_array + i;
> @@ -571,10 +570,7 @@ static void cancel_inflight_io(struct io_err_stat_path *pp)
>  			continue;
>  		io_err_stat_log(5, "%s: abort infligh io",
>  				pp->devname);
> -		r = io_cancel(ioctx, ios[0], &event);
> -		if (r)
> -			io_err_stat_log(5, "%s: io_cancel error %d, %i",
> -					pp->devname, r, errno);
> +		io_cancel(ioctx, ios[0], &event);
>  	}
>  }
>  
> @@ -610,12 +606,11 @@ static void process_async_ios_event(int timeout_nsecs, char *dev)
>  	int		i, n;
>  	struct timespec	timeout = { .tv_nsec = timeout_nsecs };
>  
> -	errno = 0;
>  	pthread_testcancel();
>  	n = io_getevents(ioctx, 1L, CONCUR_NR_EVENT, events, &timeout);
>  	if (n < 0) {
> -		io_err_stat_log(3, "%s: async io events returned %d (errno=%s)",
> -				dev, n, strerror(errno));
> +		io_err_stat_log(3, "%s: io_getevents returned %s",
> +				dev, strerror(-n));
>  	} else {
>  		for (i = 0; i < n; i++)
>  			handle_async_io_done_event(&events[i]);
> @@ -704,8 +699,9 @@ int start_io_err_stat_thread(void *data)
>  	if (uatomic_read(&io_err_thread_running) == 1)
>  		return 0;
>  
> -	if (io_setup(CONCUR_NR_EVENT * NR_IOSTAT_PATHS, &ioctx) != 0) {
> -		io_err_stat_log(1, "io_setup failed - increase /proc/sys/fs/aio-nr ?");
> +	if ((ret = io_setup(NR_IOSTAT_PATHS * CONCUR_NR_EVENT, &ioctx)) != 0) {
> +		io_err_stat_log(1, "io_setup failed: %s, increase /proc/sys/fs/aio-nr ?",
> +				strerror(-ret));
>  		return 1;
>  	}
>  
> -- 
> 2.42.0


  reply	other threads:[~2023-10-27 19:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26 17:41 [PATCH v2 00/14] multipath: aio, systemd, and documentation improvements mwilck
2023-10-26 17:41 ` [PATCH v2 01/14] libmultipath: reduce log level of directio messages mwilck
2023-10-26 17:41 ` [PATCH v2 02/14] libmultipath: directio: don't reset ct->running after io_cancel() mwilck
2023-10-27 18:54   ` Benjamin Marzinski
2023-10-26 17:41 ` [PATCH v2 03/14] libmultipath: directio: fix error handling mwilck
2023-10-27 18:54   ` Benjamin Marzinski
2023-10-26 17:41 ` [PATCH v2 04/14] libmultipath: io_err_stat: don't free aio memory before completion mwilck
2023-10-27 18:55   ` Benjamin Marzinski
2023-10-26 17:41 ` [PATCH v2 05/14] libmultipath: io_err_stat: call io_destroy() inside free_io_err_pathvec() mwilck
2023-10-27 18:55   ` Benjamin Marzinski
2023-10-26 17:41 ` [PATCH v2 06/14] libmultipath: io_err_stat: use higher number of aio slots mwilck
2023-10-27 18:56   ` Benjamin Marzinski
2023-10-26 17:41 ` [PATCH v2 07/14] libmultipath: io_err_stat: fix error handling mwilck
2023-10-27 19:09   ` Benjamin Marzinski [this message]
2023-10-26 17:41 ` [PATCH v2 08/14] multipathd.service: require modprobe@dm_multipath.service if available mwilck
2023-10-27 19:09   ` Benjamin Marzinski
2023-10-27 20:05   ` Benjamin Marzinski
2023-10-30 11:45     ` Martin Wilck
2023-10-26 17:41 ` [PATCH v2 09/14] libmpathutil: remove systemd_service_enabled() mwilck
2023-10-26 17:41 ` [PATCH v2 10/14] multipath.conf.5: fix typo mwilck
2023-10-27 19:10   ` Benjamin Marzinski
2023-10-26 17:41 ` [PATCH v2 11/14] Makefile.inc, README.md: fix docs for prefix in split-usr case mwilck
2023-10-27 19:27   ` Benjamin Marzinski
2023-10-26 17:41 ` [PATCH v2 12/14] README.md: update mailing list and contributing information mwilck
2023-10-27 19:29   ` Benjamin Marzinski
2023-10-30 11:41     ` Martin Wilck
2023-10-26 17:41 ` [PATCH v2 13/14] README.md: Extend the section about NVMe mwilck
2023-10-27 19:34   ` Benjamin Marzinski
2023-10-26 17:41 ` [PATCH v2 14/14] README.md: fix formatting of Changelog section mwilck
2023-10-27 19:35   ` Benjamin Marzinski

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=ZTwK2e59eDaKxxvX@bmarzins-01.fast.rdu2.eng.redhat.com \
    --to=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=mwilck@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.