Skip to content

Commit fa0ca2a

Browse files
author
Al Viro
committed
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>
1 parent 7425970 commit fa0ca2a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fs/aio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,11 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx)
10331033
if (unlikely(!req))
10341034
return NULL;
10351035

1036+
if (unlikely(!get_reqs_available(ctx))) {
1037+
kfree(req);
1038+
return NULL;
1039+
}
1040+
10361041
percpu_ref_get(&ctx->reqs);
10371042
req->ki_ctx = ctx;
10381043
INIT_LIST_HEAD(&req->ki_list);
@@ -1793,13 +1798,9 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
17931798
return -EINVAL;
17941799
}
17951800

1796-
if (!get_reqs_available(ctx))
1797-
return -EAGAIN;
1798-
1799-
ret = -EAGAIN;
18001801
req = aio_get_req(ctx);
18011802
if (unlikely(!req))
1802-
goto out_put_reqs_available;
1803+
return -EAGAIN;
18031804

18041805
req->ki_filp = fget(iocb->aio_fildes);
18051806
ret = -EBADF;
@@ -1874,7 +1875,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
18741875

18751876
out_put_req:
18761877
iocb_destroy(req);
1877-
out_put_reqs_available:
18781878
put_reqs_available(ctx, 1);
18791879
return ret;
18801880
}

0 commit comments

Comments
 (0)