From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it1-f196.google.com ([209.85.166.196]:38891 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727624AbeLAEHT (ORCPT ); Fri, 30 Nov 2018 23:07:19 -0500 Received: by mail-it1-f196.google.com with SMTP id h65so10227630ith.3 for ; Fri, 30 Nov 2018 08:57:23 -0800 (PST) From: Jens Axboe To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org Cc: hch@lst.de, Jens Axboe Subject: [PATCH 21/27] aio: split iocb init from allocation Date: Fri, 30 Nov 2018 09:56:40 -0700 Message-Id: <20181130165646.27341-22-axboe@kernel.dk> In-Reply-To: <20181130165646.27341-1-axboe@kernel.dk> References: <20181130165646.27341-1-axboe@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Signed-off-by: Jens Axboe --- 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