Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> --- fs/aio.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 291bbc62b2a8..341eb1b19319 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1088,6 +1088,16 @@ static bool get_reqs_available(struct kioctx *ctx) return __get_reqs_available(ctx); } +static void aio_iocb_init(struct kioctx *ctx, struct aio_kiocb *req) +{ + percpu_ref_get(&ctx->reqs); + req->ki_ctx = ctx; + INIT_LIST_HEAD(&req->ki_list); + req->ki_flags = 0; + refcount_set(&req->ki_refcnt, 0); + req->ki_eventfd = NULL; +} + /* aio_get_req * Allocate a slot for an aio request. * Returns NULL if no requests are free. @@ -1097,14 +1107,8 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) struct aio_kiocb *req; req = kmem_cache_alloc(kiocb_cachep, GFP_KERNEL); - if (req) { - percpu_ref_get(&ctx->reqs); - req->ki_ctx = ctx; - INIT_LIST_HEAD(&req->ki_list); - req->ki_flags = 0; - refcount_set(&req->ki_refcnt, 0); - req->ki_eventfd = NULL; - } + if (req) + aio_iocb_init(ctx, req); return req; } -- 2.17.1