summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2019-03-07 02:21:08 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2019-03-18 03:52:31 +0300
commitfa0ca2aee3bec899f9b9e753baf3808d1b0628f6 (patch)
tree8eaa91b00758d1a99d78e162e9dc9327dbd795a8 /fs
parent7425970347a21204632a27ed28978cf875f205b2 (diff)
downloadlinux-fa0ca2aee3bec899f9b9e753baf3808d1b0628f6.tar.xz
deal with get_reqs_available() in aio_get_req() itself
simplifies the caller Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/aio.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/aio.c b/fs/aio.c
index d3837f607d09..eee4b4cfb66f 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1033,6 +1033,11 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx)
if (unlikely(!req))
return NULL;
+ if (unlikely(!get_reqs_available(ctx))) {
+ kfree(req);
+ return NULL;
+ }
+
percpu_ref_get(&ctx->reqs);
req->ki_ctx = ctx;
INIT_LIST_HEAD(&req->ki_list);
@@ -1793,13 +1798,9 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
return -EINVAL;
}
- if (!get_reqs_available(ctx))
- return -EAGAIN;
-
- ret = -EAGAIN;
req = aio_get_req(ctx);
if (unlikely(!req))
- goto out_put_reqs_available;
+ return -EAGAIN;
req->ki_filp = fget(iocb->aio_fildes);
ret = -EBADF;
@@ -1874,7 +1875,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
out_put_req:
iocb_destroy(req);
-out_put_reqs_available:
put_reqs_available(ctx, 1);
return ret;
}