From patchwork Wed May 1 21:36:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2508951 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E34F83FD85 for ; Wed, 1 May 2013 21:36:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932650Ab3EAVgI (ORCPT ); Wed, 1 May 2013 17:36:08 -0400 Received: from mail-ia0-f173.google.com ([209.85.210.173]:59404 "EHLO mail-ia0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932105Ab3EAVgH (ORCPT ); Wed, 1 May 2013 17:36:07 -0400 Received: by mail-ia0-f173.google.com with SMTP id 21so51162iay.18 for ; Wed, 01 May 2013 14:36:06 -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=5UuLxzAdLfzt4Wa8OnTOEdwGaBAIGYc1KWNUKLj2VXA=; b=pfArbna8xC/laOPXhTi7pBZ5rE//KlaFchF17FT6ctgV7VMRkukKVSkmG0VjEYRJUU /wWXkfSzQ+OyH6x8ne/aNwy3r17cJukENO6KMR7GADyD6MJB74gbBR9po/yKFt9/4JxT pxq1eXnmNG7z/J7B82XOOqgefrSSk/RktJ1TlbcDkpt8y4xgSVIkkjNjSNqHV5+671Dp p/uJBtYpM2TemohloMcIHSVpilIxHet48WFNSL8J2NxpsR7XrhOhcx2pwSv5jECH3+mF 0pvOZpoYURxSOrlJVHjOcYYxkKKIu+QCqDHA0rAFXqoWVVv6k8o0M7T0uSNCbvFXeP54 pksA== X-Received: by 10.50.115.36 with SMTP id jl4mr7208125igb.8.1367444166775; Wed, 01 May 2013 14:36:06 -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 ha2sm22613279igb.1.2013.05.01.14.36.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 May 2013 14:36:06 -0700 (PDT) Message-ID: <51818AC4.3070702@inktank.com> Date: Wed, 01 May 2013 16:36:04 -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/4] rbd: allocate object requests with a slab allocator References: <51818A5C.1080903@inktank.com> In-Reply-To: <51818A5C.1080903@inktank.com> X-Gm-Message-State: ALoCoQk/s3EdKqvbgGuwsvBvqxbKKiQhD9XUGlGuyPEAYrozZGUPNz5vfmm7J7d3RLoyu8vn/Gjv 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 rbd_obj_request allocation. We aren't using a constructor, and we'll zero-fill object request structures when they're allocated. This is part of: http://tracker.ceph.com/issues/3926 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) return NULL; @@ -1814,7 +1815,8 @@ static void rbd_obj_request_destroy(struct kref *kref) } kfree(obj_request->object_name); - kfree(obj_request); + obj_request->object_name = NULL; + kmem_cache_free(rbd_obj_request_cache, obj_request); } /* @@ -5008,14 +5010,29 @@ static int rbd_slab_init(void) sizeof (struct rbd_img_request), __alignof__(struct rbd_img_request), 0, NULL); - if (rbd_img_request_cache) + if (!rbd_img_request_cache) + return -ENOMEM; + + rbd_assert(!rbd_obj_request_cache); + rbd_obj_request_cache = kmem_cache_create("rbd_obj_request", + sizeof (struct rbd_obj_request), + __alignof__(struct rbd_obj_request), + 0, NULL); + if (rbd_obj_request_cache) return 0; + kmem_cache_destroy(rbd_img_request_cache); + rbd_img_request_cache = NULL; + return -ENOMEM; } static void rbd_slab_exit(void) { + rbd_assert(rbd_obj_request_cache); + kmem_cache_destroy(rbd_obj_request_cache); + rbd_obj_request_cache = NULL; + rbd_assert(rbd_img_request_cache); kmem_cache_destroy(rbd_img_request_cache); rbd_img_request_cache = NULL; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index da9f41d..28a5ea3 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -346,6 +346,7 @@ static LIST_HEAD(rbd_client_list); /* clients */ static DEFINE_SPINLOCK(rbd_client_list_lock); static struct kmem_cache *rbd_img_request_cache; +static struct kmem_cache *rbd_obj_request_cache; static int rbd_img_request_submit(struct rbd_img_request *img_request); @@ -1762,7 +1763,7 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, if (!name) return NULL; - obj_request = kzalloc(sizeof (*obj_request), GFP_KERNEL); + obj_request = kmem_cache_zalloc(rbd_obj_request_cache, GFP_KERNEL); if (!obj_request) { kfree(name);