public inbox for [email protected]
 help / color / mirror / Atom feed
From: Keith Busch <[email protected]>
To: Jens Axboe <[email protected]>
Cc: io-uring <[email protected]>
Subject: Re: [PATCH] io_uring/rw: cleanup io_rw_done()
Date: Wed, 10 Jan 2024 11:32:29 -0700	[thread overview]
Message-ID: <ZZ7ivQcfP4rgtbS0@kbusch-mbp> (raw)
In-Reply-To: <[email protected]>

On Wed, Jan 10, 2024 at 10:09:19AM -0700, Jens Axboe wrote:
> +static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret)
> +{
> +	if (ret == -EIOCBQUEUED) {
> +		return;
> +	} else if (ret >= 0) {
> +end_io:
> +		INDIRECT_CALL_2(kiocb->ki_complete, io_complete_rw_iopoll,
> +				io_complete_rw, kiocb, ret);
> +	} else {
> +		switch (ret) {
> +		case -ERESTARTSYS:
> +		case -ERESTARTNOINTR:
> +		case -ERESTARTNOHAND:
> +		case -ERESTART_RESTARTBLOCK:
> +			/*
> +			 * We can't just restart the syscall, since previously
> +			 * submitted sqes may already be in progress. Just fail
> +			 * this IO with EINTR.
> +			 */
> +			ret = -EINTR;
> +			WARN_ON_ONCE(1);
> +			break;
> +		}
> +		goto end_io;
> +	}
> +}

Are you just trying to get the most common two conditions at the top? A
little rearringing and you can remove the 'goto'. Maybe just my opinion,
but I find using goto for flow control harder to read if there's a
structured alternative.

static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret)
{
	if (ret == -EIOCBQUEUED)
		return;

	if (unlikely(ret < 0)) {
		switch (ret) {
		case -ERESTARTSYS:
		case -ERESTARTNOINTR:
		case -ERESTARTNOHAND:
		case -ERESTART_RESTARTBLOCK:
			/*
			 * We can't just restart the syscall, since previously
			 * submitted sqes may already be in progress. Just fail
			 * this IO with EINTR.
			 */
			ret = -EINTR;
			WARN_ON_ONCE(1);
			break;
		}
	}

	INDIRECT_CALL_2(kiocb->ki_complete, io_complete_rw_iopoll,
			io_complete_rw, kiocb, ret);
}

  reply	other threads:[~2024-01-10 18:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10 17:09 [PATCH] io_uring/rw: cleanup io_rw_done() Jens Axboe
2024-01-10 18:32 ` Keith Busch [this message]
2024-01-10 18:35   ` Jens Axboe

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=ZZ7ivQcfP4rgtbS0@kbusch-mbp \
    [email protected] \
    [email protected] \
    [email protected] \
    /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