Re: [PATCH 2/5] io_uring: refactor io_assign_file error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <asml.silence@xxxxxxxxx>
> ---
>  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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux