From patchwork Wed May 1 21:38:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2508991 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8E04FDF230 for ; Wed, 1 May 2013 21:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932998Ab3EAVie (ORCPT ); Wed, 1 May 2013 17:38:34 -0400 Received: from mail-ie0-f171.google.com ([209.85.223.171]:40768 "EHLO mail-ie0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932993Ab3EAVic (ORCPT ); Wed, 1 May 2013 17:38:32 -0400 Received: by mail-ie0-f171.google.com with SMTP id e11so2462250iej.30 for ; Wed, 01 May 2013 14:38:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=kNMk/WtXuFvkTTg6XmqI4FT3xEK9ewOIvfIxz1pVWRo=; b=fQfY0w1q7YgynS5nTrJMivhs4bfKAH7uOGTumpofShM8agQZ1O4LB9sV4qjEpY2Xhy WqOOaXbHWQMyzZQlvDHsAt3/FKJaCvlgxPjy2/QmttCWJXwhWgrALtqsuyK78OomnsRT sert9H1jcNrt5047rfjYFtZhDZrdZtpeDRIC0gwKLd8wSkAcLZMPmyYrgjLHXDK8wBll T4tTC9ab04g69x/gF1kg7VaeT7SJnVnaTEJCsXVdMSkUz0/4Irrj6ddorjBd+YSC+f1f tuzAIXRpNWRLIjBWETzzBQomxNVof3/MuUZp0SnQT1SI42ApW+l/YAtWRZVTjCURPcoY Swig== X-Received: by 10.50.61.162 with SMTP id q2mr2648713igr.87.1367444311965; Wed, 01 May 2013 14:38:31 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id ve9sm5789985igb.3.2013.05.01.14.38.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 May 2013 14:38:31 -0700 (PDT) Message-ID: <51818B55.2010403@inktank.com> Date: Wed, 01 May 2013 16:38:29 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 3/3] libceph: use slab cache for osd client requests References: <51818B12.4010307@inktank.com> In-Reply-To: <51818B12.4010307@inktank.com> X-Gm-Message-State: ALoCoQmgYPY5310z6yOlguqedsLA/XiyB4YcztcdSuLC882R0KG5l5F0vB8VNQ3oXDXvCNsDfDWQ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Create a slab cache to manage allocation of ceph_osdc_request structures. This resolves: http://tracker.ceph.com/issues/3926 Signed-off-by: Alex Elder --- include/linux/ceph/osd_client.h | 3 +++ net/ceph/ceph_common.c | 7 +++++++ net/ceph/osd_client.c | 27 +++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) return NULL; @@ -2365,6 +2368,26 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, } EXPORT_SYMBOL(ceph_osdc_writepages); +int ceph_osdc_setup(void) +{ + BUG_ON(ceph_osd_request_cache); + ceph_osd_request_cache = kmem_cache_create("ceph_osd_request", + sizeof (struct ceph_osd_request), + __alignof__(struct ceph_osd_request), + 0, NULL); + + return ceph_osd_request_cache ? 0 : -ENOMEM; +} +EXPORT_SYMBOL(ceph_osdc_setup); + +void ceph_osdc_cleanup(void) +{ + BUG_ON(!ceph_osd_request_cache); + kmem_cache_destroy(ceph_osd_request_cache); + ceph_osd_request_cache = NULL; +} +EXPORT_SYMBOL(ceph_osdc_cleanup); + /* * handle incoming message */ diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index 4191cd2..186db0b 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h @@ -224,6 +224,9 @@ struct ceph_osd_client { struct workqueue_struct *notify_wq; }; +extern int ceph_osdc_setup(void); +extern void ceph_osdc_cleanup(void); + extern int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client); extern void ceph_osdc_stop(struct ceph_osd_client *osdc); diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index c5605ae..b746cd7 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -601,11 +601,17 @@ static int __init init_ceph_lib(void) if (ret < 0) goto out_crypto; + ret = ceph_osdc_setup(); + if (ret < 0) + goto out_msgr; + pr_info("loaded (mon/osd proto %d/%d)\n", CEPH_MONC_PROTOCOL, CEPH_OSDC_PROTOCOL); return 0; +out_msgr: + ceph_msgr_exit(); out_crypto: ceph_crypto_shutdown(); out_debugfs: @@ -617,6 +623,7 @@ out: static void __exit exit_ceph_lib(void) { dout("exit_ceph_lib\n"); + ceph_osdc_cleanup(); ceph_msgr_exit(); ceph_crypto_shutdown(); ceph_debugfs_cleanup(); diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 57d8db5..a3395fd 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -22,6 +22,8 @@ #define OSD_OP_FRONT_LEN 4096 #define OSD_OPREPLY_FRONT_LEN 512 +static struct kmem_cache *ceph_osd_request_cache; + static const struct ceph_connection_operations osd_con_ops; static void __send_queued(struct ceph_osd_client *osdc); @@ -315,7 +317,8 @@ void ceph_osdc_release_request(struct kref *kref) if (req->r_mempool) mempool_free(req, req->r_osdc->req_mempool); else - kfree(req); + kmem_cache_free(ceph_osd_request_cache, req); + } EXPORT_SYMBOL(ceph_osdc_release_request); @@ -346,7 +349,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, req = mempool_alloc(osdc->req_mempool, gfp_flags); memset(req, 0, sizeof(*req)); } else { - req = kzalloc(sizeof(*req), gfp_flags); + req = kmem_cache_zalloc(ceph_osd_request_cache, gfp_flags); } if (req == NULL)