Commit fa0ca2ae authored by Al Viro's avatar Al Viro

deal with get_reqs_available() in aio_get_req() itself

simplifies the caller
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 74259703
...@@ -1033,6 +1033,11 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) ...@@ -1033,6 +1033,11 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx)
if (unlikely(!req)) if (unlikely(!req))
return NULL; return NULL;
if (unlikely(!get_reqs_available(ctx))) {
kfree(req);
return NULL;
}
percpu_ref_get(&ctx->reqs); percpu_ref_get(&ctx->reqs);
req->ki_ctx = ctx; req->ki_ctx = ctx;
INIT_LIST_HEAD(&req->ki_list); INIT_LIST_HEAD(&req->ki_list);
...@@ -1793,13 +1798,9 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, ...@@ -1793,13 +1798,9 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
return -EINVAL; return -EINVAL;
} }
if (!get_reqs_available(ctx))
return -EAGAIN;
ret = -EAGAIN;
req = aio_get_req(ctx); req = aio_get_req(ctx);
if (unlikely(!req)) if (unlikely(!req))
goto out_put_reqs_available; return -EAGAIN;
req->ki_filp = fget(iocb->aio_fildes); req->ki_filp = fget(iocb->aio_fildes);
ret = -EBADF; ret = -EBADF;
...@@ -1874,7 +1875,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, ...@@ -1874,7 +1875,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
out_put_req: out_put_req:
iocb_destroy(req); iocb_destroy(req);
out_put_reqs_available:
put_reqs_available(ctx, 1); put_reqs_available(ctx, 1);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment