From patchwork Wed May 1 21:35:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2508941 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 D64C23FD85 for ; Wed, 1 May 2013 21:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932608Ab3EAVfw (ORCPT ); Wed, 1 May 2013 17:35:52 -0400 Received: from mail-ie0-f180.google.com ([209.85.223.180]:41384 "EHLO mail-ie0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758252Ab3EAVft (ORCPT ); Wed, 1 May 2013 17:35:49 -0400 Received: by mail-ie0-f180.google.com with SMTP id to1so2399359ieb.39 for ; Wed, 01 May 2013 14:35:48 -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=dgAQjcQiBFkgOR3cE6AiJwFTz2fd5MOULOHQ2v1p4Lo=; b=jJkSFFutnGnxQbxX5ydao3xzTe+ijEvRVbvaoda2juwHYd8y4dH8nAcSyeFfUid1Pp 1vHWlX/Z3pzgi/AnCq92DQOuLxUGl8tKbgsXgHW2gg9UtZ+tWy6IwAO1nIZ0GiwHKCKr CDjlbgoY/FoOE/IkMkJgGFRUSKK9AuUn7XfZUk2aTRljTVen6LVKR84pvht3cgZV8j4x ctImSKpnbCcXrkCFeDdglqMiD3uhTgH1zECtPdGssdsuTGsuPvzZTAmltXzYCIiT22R9 5L2Bva6ikWwLrXZBbJtlJabyHE1pySfXtvFQ+Vu5kQthgTGv5GLrbmvW6gxkPslHsrz1 33Dw== X-Received: by 10.50.153.76 with SMTP id ve12mr2602327igb.61.1367444148764; Wed, 01 May 2013 14:35:48 -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 fl5sm5708988igb.9.2013.05.01.14.35.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 May 2013 14:35:48 -0700 (PDT) Message-ID: <51818AB2.1060909@inktank.com> Date: Wed, 01 May 2013 16:35:46 -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 2/4] rbd: allocate name separate from obj_request References: <51818A5C.1080903@inktank.com> In-Reply-To: <51818A5C.1080903@inktank.com> X-Gm-Message-State: ALoCoQmPBs+cMzOEwkDB7ZUHlVDws7UdL95c/vzDdZgbIm63jr1YfexmgQgCNdT7/wH/TeNGp7Ak Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org The next patch will define a slab allocator for a object requests. To use that we'll need to allocate the name of an object separate from the request structure itself. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) obj_request->length = length; @@ -1808,6 +1813,7 @@ static void rbd_obj_request_destroy(struct kref *kref) break; } + kfree(obj_request->object_name); kfree(obj_request); } diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 005c397..da9f41d 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1758,11 +1758,16 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, rbd_assert(obj_request_type_valid(type)); size = strlen(object_name) + 1; - obj_request = kzalloc(sizeof (*obj_request) + size, GFP_KERNEL); - if (!obj_request) + name = kmalloc(size, GFP_KERNEL); + if (!name) + return NULL; + + obj_request = kzalloc(sizeof (*obj_request), GFP_KERNEL); + if (!obj_request) { + kfree(name); return NULL; + } - name = (char *)(obj_request + 1); obj_request->object_name = memcpy(name, object_name, size); obj_request->offset = offset;