public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Pavel Begunkov <[email protected]>, [email protected]
Subject: Re: [PATCH 2/5] io_uring: refactor io_assign_file error path
Date: Mon, 18 Apr 2022 14:50:51 -0600	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <eff77fb1eac2b6a90cca5223813e6a396ffedec0.1650311386.git.asml.silence@gmail.com>

On 4/18/22 1:51 PM, Pavel Begunkov wrote:
> All io_assign_file() callers do error handling themselves,
> req_set_fail() in the io_assign_file()'s fail path needlessly bloats the
> kernel and is not the best abstraction to have. Simplify the error path.
> 
> Signed-off-by: Pavel Begunkov <[email protected]>
> ---
>  fs/io_uring.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 423427e2203f..9626bc1cb0a0 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -7117,12 +7117,8 @@ static bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags)
>  		req->file = io_file_get_fixed(req, req->cqe.fd, issue_flags);
>  	else
>  		req->file = io_file_get_normal(req, req->cqe.fd);
> -	if (req->file)
> -		return true;
>  
> -	req_set_fail(req);
> -	req->cqe.res = -EBADF;
> -	return false;
> +	return !!req->file;

Wouldn't it be cleaner to just do:


diff --git a/fs/io_uring.c b/fs/io_uring.c
index 7625b29153b9..b91bcd52cc95 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7098,15 +7098,8 @@ static bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags)
 		return true;
 
 	if (req->flags & REQ_F_FIXED_FILE)
-		req->file = io_file_get_fixed(req, req->fd, issue_flags);
-	else
-		req->file = io_file_get_normal(req, req->fd);
-	if (req->file)
-		return true;
-
-	req_set_fail(req);
-	req->result = -EBADF;
-	return false;
+		return io_file_get_fixed(req, req->fd, issue_flags);
+	return io_file_get_normal(req, req->fd);
 }
 
 static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)

-- 
Jens Axboe


  reply	other threads:[~2022-04-18 20:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-18 19:51 [PATCH 0/5] random 5.19 patches Pavel Begunkov
2022-04-18 19:51 ` [PATCH 1/5] io_uring: use right helpers for file assign locking Pavel Begunkov
2022-04-18 19:51 ` [PATCH 2/5] io_uring: refactor io_assign_file error path Pavel Begunkov
2022-04-18 20:50   ` Jens Axboe [this message]
2022-04-18 20:51     ` Jens Axboe
2022-04-18 19:51 ` [PATCH 3/5] io_uring: store rsrc node in req instead of refs Pavel Begunkov
2022-04-18 19:51 ` [PATCH 4/5] io_uring: add a helper for putting rsrc nodes Pavel Begunkov
2022-04-18 19:51 ` [PATCH 5/5] io_uring: kill ctx arg from io_req_put_rsrc Pavel Begunkov
2022-04-18 20:52 ` [PATCH 0/5] random 5.19 patches 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 \
    [email protected] \
    [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