io_uring: cleanup error-handling around io_req_complete
A message that is not in the archive (sent off-list or not yet received): CGME20220422101608epcas5p22e9c82eb1b3beef6bf6e1c2e83b4b19b@epcas5p2.samsung.com
PATCH 1/1 io_uring: cleanup error-handling around io_req_complete
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.
--- fs/io_uring.c | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-)
fs/io_uring.c +5 -29
@@ -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 ; }
Signature · 1 line
2.25.1
Quoted 6 lines · Kanchan Joshi
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_completeinstead.Suggested-by Christoph Hellwig <[email protected]>Signed-off-by Kanchan Joshi <[email protected]>
Looks good:
Jens Axboe
maintainerQuoted 3 lines · Kanchan Joshi
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_completeinstead.
This seems incomplete, missing msgring and openat2 at least? I do like the change though. Care to respin a v2?
Signature · 1 line
Jens Axboe
Quoted 7 lines · Jens Axboe
Quoted 3 lines · Kanchan Joshi
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_completeinstead.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?
Jens Axboe
maintainerQuoted 11 lines · Kanchan Joshi
Quoted 7 lines · Jens Axboe
Quoted 3 lines · Kanchan Joshi
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_completeinstead.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, andio_openat2) are already using__io_req_complete(and notio_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.
Signature · 1 line
Jens Axboe
Quoted 5 lines · Kanchan Joshi
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_completeinstead.
Applied, thanks!
[1/1] io_uring: cleanup error-handling around io_req_complete
commit: 4ffaa94b9c047fe0e82b1f271554f31f0e2e2867
Best regards,
Signature · 1 line
Jens Axboe