* [PATCH] io_uring: cleanup error-handling around io_req_complete
[not found] <CGME20220422101608epcas5p22e9c82eb1b3beef6bf6e1c2e83b4b19b@epcas5p2.samsung.com>
@ 2022-04-22 10:10 ` Kanchan Joshi
2022-04-23 17:49 ` Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Kanchan Joshi @ 2022-04-22 10:10 UTC (permalink / raw)
To: axboe, io-uring; +Cc: hch
Move common error-handling to io_req_complete, so that various callers
avoid repeating that. Few callers (io_tee, io_splice) require slightly
different handling. These are changed to use __io_req_complete instead.
Suggested-by: Christoph Hellwig <[email protected]>
Signed-off-by: Kanchan Joshi <[email protected]>
---
fs/io_uring.c | 34 +++++-----------------------------
1 file changed, 5 insertions(+), 29 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 2052a796436c..fcbe885a3175 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2287,6 +2287,8 @@ static inline void __io_req_complete(struct io_kiocb *req, unsigned issue_flags,
static inline void io_req_complete(struct io_kiocb *req, s32 res)
{
+ if (res < 0)
+ req_set_fail(req);
__io_req_complete(req, 0, res, 0);
}
@@ -4214,8 +4216,6 @@ static int io_renameat(struct io_kiocb *req, unsigned int issue_flags)
ren->newpath, ren->flags);
req->flags &= ~REQ_F_NEED_CLEANUP;
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
@@ -4236,9 +4236,6 @@ static void io_xattr_finish(struct io_kiocb *req, int ret)
req->flags &= ~REQ_F_NEED_CLEANUP;
__io_xattr_finish(req);
- if (ret < 0)
- req_set_fail(req);
-
io_req_complete(req, ret);
}
@@ -4514,8 +4511,6 @@ static int io_unlinkat(struct io_kiocb *req, unsigned int issue_flags)
ret = do_unlinkat(un->dfd, un->filename);
req->flags &= ~REQ_F_NEED_CLEANUP;
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
@@ -4557,8 +4552,6 @@ static int io_mkdirat(struct io_kiocb *req, unsigned int issue_flags)
ret = do_mkdirat(mkd->dfd, mkd->filename, mkd->mode);
req->flags &= ~REQ_F_NEED_CLEANUP;
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
@@ -4606,8 +4599,6 @@ static int io_symlinkat(struct io_kiocb *req, unsigned int issue_flags)
ret = do_symlinkat(sl->oldpath, sl->new_dfd, sl->newpath);
req->flags &= ~REQ_F_NEED_CLEANUP;
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
@@ -4657,8 +4648,6 @@ static int io_linkat(struct io_kiocb *req, unsigned int issue_flags)
lnk->newpath, lnk->flags);
req->flags &= ~REQ_F_NEED_CLEANUP;
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
@@ -4694,8 +4683,6 @@ static int io_shutdown(struct io_kiocb *req, unsigned int issue_flags)
return -ENOTSOCK;
ret = __sys_shutdown_sock(sock, req->shutdown.how);
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
#else
@@ -4756,7 +4743,7 @@ static int io_tee(struct io_kiocb *req, unsigned int issue_flags)
done:
if (ret != sp->len)
req_set_fail(req);
- io_req_complete(req, ret);
+ __io_req_complete(req, 0, ret, 0);
return 0;
}
@@ -4801,7 +4788,7 @@ static int io_splice(struct io_kiocb *req, unsigned int issue_flags)
done:
if (ret != sp->len)
req_set_fail(req);
- io_req_complete(req, ret);
+ __io_req_complete(req, 0, ret, 0);
return 0;
}
@@ -4888,8 +4875,6 @@ static int io_fsync(struct io_kiocb *req, unsigned int issue_flags)
ret = vfs_fsync_range(req->file, req->sync.off,
end > 0 ? end : LLONG_MAX,
req->sync.flags & IORING_FSYNC_DATASYNC);
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
@@ -4918,9 +4903,7 @@ static int io_fallocate(struct io_kiocb *req, unsigned int issue_flags)
return -EAGAIN;
ret = vfs_fallocate(req->file, req->sync.mode, req->sync.off,
req->sync.len);
- if (ret < 0)
- req_set_fail(req);
- else
+ if (ret >= 0)
fsnotify_modify(req->file);
io_req_complete(req, ret);
return 0;
@@ -5332,8 +5315,6 @@ static int io_madvise(struct io_kiocb *req, unsigned int issue_flags)
return -EAGAIN;
ret = do_madvise(current->mm, ma->addr, ma->len, ma->advice);
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
#else
@@ -5419,9 +5400,6 @@ static int io_statx(struct io_kiocb *req, unsigned int issue_flags)
ret = do_statx(ctx->dfd, ctx->filename, ctx->flags, ctx->mask,
ctx->buffer);
-
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
@@ -5521,8 +5499,6 @@ static int io_sync_file_range(struct io_kiocb *req, unsigned int issue_flags)
ret = sync_file_range(req->file, req->sync.off, req->sync.len,
req->sync.flags);
- if (ret < 0)
- req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] io_uring: cleanup error-handling around io_req_complete
2022-04-22 10:10 ` [PATCH] io_uring: cleanup error-handling around io_req_complete Kanchan Joshi
@ 2022-04-23 17:49 ` Christoph Hellwig
2022-04-23 18:06 ` Jens Axboe
2022-04-25 0:33 ` Jens Axboe
2 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2022-04-23 17:49 UTC (permalink / raw)
To: Kanchan Joshi; +Cc: axboe, io-uring, hch
On Fri, Apr 22, 2022 at 03:40:48PM +0530, Kanchan Joshi wrote:
> Move common error-handling to io_req_complete, so that various callers
> avoid repeating that. Few callers (io_tee, io_splice) require slightly
> different handling. These are changed to use __io_req_complete instead.
>
> Suggested-by: Christoph Hellwig <[email protected]>
> Signed-off-by: Kanchan Joshi <[email protected]>
Looks good:
Reviewed-by: Christoph Hellwig <[email protected]>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] io_uring: cleanup error-handling around io_req_complete
2022-04-22 10:10 ` [PATCH] io_uring: cleanup error-handling around io_req_complete Kanchan Joshi
2022-04-23 17:49 ` Christoph Hellwig
@ 2022-04-23 18:06 ` Jens Axboe
2022-04-24 6:22 ` Kanchan Joshi
2022-04-25 0:33 ` Jens Axboe
2 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2022-04-23 18:06 UTC (permalink / raw)
To: Kanchan Joshi, io-uring; +Cc: hch
On 4/22/22 4:10 AM, Kanchan Joshi wrote:
> Move common error-handling to io_req_complete, so that various callers
> avoid repeating that. Few callers (io_tee, io_splice) require slightly
> different handling. These are changed to use __io_req_complete instead.
This seems incomplete, missing msgring and openat2 at least? I do like
the change though. Care to respin a v2?
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] io_uring: cleanup error-handling around io_req_complete
2022-04-23 18:06 ` Jens Axboe
@ 2022-04-24 6:22 ` Kanchan Joshi
2022-04-25 0:32 ` Jens Axboe
0 siblings, 1 reply; 6+ messages in thread
From: Kanchan Joshi @ 2022-04-24 6:22 UTC (permalink / raw)
To: Jens Axboe; +Cc: io-uring, hch
[-- Attachment #1: Type: text/plain, Size: 564 bytes --]
On Sat, Apr 23, 2022 at 12:06:05PM -0600, Jens Axboe wrote:
>On 4/22/22 4:10 AM, Kanchan Joshi wrote:
>> Move common error-handling to io_req_complete, so that various callers
>> avoid repeating that. Few callers (io_tee, io_splice) require slightly
>> different handling. These are changed to use __io_req_complete instead.
>
>This seems incomplete, missing msgring and openat2 at least? I do like
>the change though. Care to respin a v2?
But both (io_msg_ring, and io_openat2) are already using
__io_req_complete (and not io_req_complete). So nothing is amiss?
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] io_uring: cleanup error-handling around io_req_complete
2022-04-24 6:22 ` Kanchan Joshi
@ 2022-04-25 0:32 ` Jens Axboe
0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2022-04-25 0:32 UTC (permalink / raw)
To: Kanchan Joshi; +Cc: io-uring, hch
On 4/24/22 12:22 AM, Kanchan Joshi wrote:
> On Sat, Apr 23, 2022 at 12:06:05PM -0600, Jens Axboe wrote:
>> On 4/22/22 4:10 AM, Kanchan Joshi wrote:
>>> Move common error-handling to io_req_complete, so that various callers
>>> avoid repeating that. Few callers (io_tee, io_splice) require slightly
>>> different handling. These are changed to use __io_req_complete instead.
>>
>> This seems incomplete, missing msgring and openat2 at least? I do like
>> the change though. Care to respin a v2?
>
> But both (io_msg_ring, and io_openat2) are already using
> __io_req_complete (and not io_req_complete). So nothing is amiss?
Yeah, I guess it's actually fine like that, and would in any case
require more changes to unify the rest. So let's just go with this for
now.
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] io_uring: cleanup error-handling around io_req_complete
2022-04-22 10:10 ` [PATCH] io_uring: cleanup error-handling around io_req_complete Kanchan Joshi
2022-04-23 17:49 ` Christoph Hellwig
2022-04-23 18:06 ` Jens Axboe
@ 2022-04-25 0:33 ` Jens Axboe
2 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2022-04-25 0:33 UTC (permalink / raw)
To: io-uring, joshi.k; +Cc: Christoph Hellwig
On Fri, 22 Apr 2022 15:40:48 +0530, Kanchan Joshi wrote:
> Move common error-handling to io_req_complete, so that various callers
> avoid repeating that. Few callers (io_tee, io_splice) require slightly
> different handling. These are changed to use __io_req_complete instead.
>
>
Applied, thanks!
[1/1] io_uring: cleanup error-handling around io_req_complete
commit: 4ffaa94b9c047fe0e82b1f271554f31f0e2e2867
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-25 0:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20220422101608epcas5p22e9c82eb1b3beef6bf6e1c2e83b4b19b@epcas5p2.samsung.com>
2022-04-22 10:10 ` [PATCH] io_uring: cleanup error-handling around io_req_complete Kanchan Joshi
2022-04-23 17:49 ` Christoph Hellwig
2022-04-23 18:06 ` Jens Axboe
2022-04-24 6:22 ` Kanchan Joshi
2022-04-25 0:32 ` Jens Axboe
2022-04-25 0:33 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox