All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Durgin <josh.durgin@inktank.com>
To: Alex Elder <elder@inktank.com>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH 2/4] rbd: allocate name separate from obj_request
Date: Thu, 02 May 2013 09:20:19 -0700	[thread overview]
Message-ID: <51829243.3050701@inktank.com> (raw)
In-Reply-To: <51818AB2.1060909@inktank.com>

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 05/01/2013 02:35 PM, Alex Elder wrote:
> 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 <elder@inktank.com>
> ---
>   drivers/block/rbd.c |   12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
>
> 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;
>   	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);
>   }
>


  reply	other threads:[~2013-05-02 16:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-01 21:34 [PATCH 0/4] rbd: use slab caches for frequently allocated structures Alex Elder
2013-05-01 21:35 ` [PATCH 1/4] rbd: allocate image requests with a slab allocator Alex Elder
2013-05-02 16:19   ` Josh Durgin
2013-05-02 16:28     ` Alex Elder
2013-05-01 21:35 ` [PATCH 2/4] rbd: allocate name separate from obj_request Alex Elder
2013-05-02 16:20   ` Josh Durgin [this message]
2013-05-01 21:36 ` [PATCH 3/4] rbd: allocate object requests with a slab allocator Alex Elder
2013-05-02 16:21   ` Josh Durgin
2013-05-01 21:36 ` [PATCH 4/4] rbd: allocate image object names " Alex Elder
2013-05-02 16:24   ` Josh Durgin
2013-05-02 16:30     ` Alex Elder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51829243.3050701@inktank.com \
    --to=josh.durgin@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=elder@inktank.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.