Skip to content

Commit

Permalink
deal with get_reqs_available() in aio_get_req() itself
Browse files Browse the repository at this point in the history
simplifies the caller

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Mar 18, 2019
1 parent 7425970 commit fa0ca2a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit fa0ca2a

Please sign in to comment.