Skip to content

Commit

Permalink
rbd: allocate name separate from obj_request
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
  • Loading branch information
Alex Elder committed May 2, 2013
1 parent 1c2a9df commit f907ad5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1808,6 +1813,7 @@ static void rbd_obj_request_destroy(struct kref *kref)
break;
}

kfree(obj_request->object_name);
kfree(obj_request);
}

Expand Down

0 comments on commit f907ad5

Please sign in to comment.