diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2019-03-06 18:21:08 -0500 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2019-03-17 20:52:31 -0400 |
| commit | fa0ca2aee3bec899f9b9e753baf3808d1b0628f6 (patch) | |
| tree | 8eaa91b00758d1a99d78e162e9dc9327dbd795a8 | |
| parent | 7425970347a21204632a27ed28978cf875f205b2 (diff) | |
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>
| -rw-r--r-- | fs/aio.c | 12 |
1 files changed, 6 insertions, 6 deletions
| @@ -1033,6 +1033,11 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) | |||
| 1033 | if (unlikely(!req)) | 1033 | if (unlikely(!req)) |
| 1034 | return NULL; | 1034 | return NULL; |
| 1035 | 1035 | ||
| 1036 | if (unlikely(!get_reqs_available(ctx))) { | ||
| 1037 | kfree(req); | ||
| 1038 | return NULL; | ||
| 1039 | } | ||
| 1040 | |||
| 1036 | percpu_ref_get(&ctx->reqs); | 1041 | percpu_ref_get(&ctx->reqs); |
| 1037 | req->ki_ctx = ctx; | 1042 | req->ki_ctx = ctx; |
| 1038 | INIT_LIST_HEAD(&req->ki_list); | 1043 | INIT_LIST_HEAD(&req->ki_list); |
| @@ -1793,13 +1798,9 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, | |||
| 1793 | return -EINVAL; | 1798 | return -EINVAL; |
| 1794 | } | 1799 | } |
| 1795 | 1800 | ||
| 1796 | if (!get_reqs_available(ctx)) | ||
| 1797 | return -EAGAIN; | ||
| 1798 | |||
| 1799 | ret = -EAGAIN; | ||
| 1800 | req = aio_get_req(ctx); | 1801 | req = aio_get_req(ctx); |
| 1801 | if (unlikely(!req)) | 1802 | if (unlikely(!req)) |
| 1802 | goto out_put_reqs_available; | 1803 | return -EAGAIN; |
| 1803 | 1804 | ||
| 1804 | req->ki_filp = fget(iocb->aio_fildes); | 1805 | req->ki_filp = fget(iocb->aio_fildes); |
| 1805 | ret = -EBADF; | 1806 | ret = -EBADF; |
| @@ -1874,7 +1875,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, | |||
| 1874 | 1875 | ||
| 1875 | out_put_req: | 1876 | out_put_req: |
| 1876 | iocb_destroy(req); | 1877 | iocb_destroy(req); |
| 1877 | out_put_reqs_available: | ||
| 1878 | put_reqs_available(ctx, 1); | 1878 | put_reqs_available(ctx, 1); |
| 1879 | return ret; | 1879 | return ret; |
| 1880 | } | 1880 | } |
