From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it1-f196.google.com ([209.85.166.196]:39877 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbeLRPnD (ORCPT ); Tue, 18 Dec 2018 10:43:03 -0500 Received: by mail-it1-f196.google.com with SMTP id a6so4802949itl.4 for ; Tue, 18 Dec 2018 07:43:02 -0800 (PST) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org Cc: hch@lst.de, viro@zeniv.linux.org.uk, Jens Axboe Subject: [PATCH 11/22] aio: split iocb init from allocation Date: Tue, 18 Dec 2018 08:42:19 -0700 Message-Id: <20181218154230.3120-12-axboe@kernel.dk> In-Reply-To: <20181218154230.3120-1-axboe@kernel.dk> References: <20181218154230.3120-1-axboe@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: In preparation from having pre-allocated requests, that we then just need to initialize before use. Signed-off-by: Jens Axboe --- fs/aio.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 24630db36fd4..63f2688332a3 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1098,6 +1098,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. @@ -1110,12 +1120,7 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) if (unlikely(!req)) return NULL; - 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_iocb_init(ctx, req); return req; } -- 2.17.1