提交 f907ad55 编写于 作者: A Alex Elder

rbd: allocate name separate from obj_request

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: NAlex Elder <elder@inktank.com>
Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
上级 1c2a9dfe
...@@ -1758,11 +1758,16 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, ...@@ -1758,11 +1758,16 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name,
rbd_assert(obj_request_type_valid(type)); rbd_assert(obj_request_type_valid(type));
size = strlen(object_name) + 1; size = strlen(object_name) + 1;
obj_request = kzalloc(sizeof (*obj_request) + size, GFP_KERNEL); name = kmalloc(size, GFP_KERNEL);
if (!obj_request) if (!name)
return NULL;
obj_request = kzalloc(sizeof (*obj_request), GFP_KERNEL);
if (!obj_request) {
kfree(name);
return NULL; return NULL;
}
name = (char *)(obj_request + 1);
obj_request->object_name = memcpy(name, object_name, size); obj_request->object_name = memcpy(name, object_name, size);
obj_request->offset = offset; obj_request->offset = offset;
obj_request->length = length; obj_request->length = length;
...@@ -1808,6 +1813,7 @@ static void rbd_obj_request_destroy(struct kref *kref) ...@@ -1808,6 +1813,7 @@ static void rbd_obj_request_destroy(struct kref *kref)
break; break;
} }
kfree(obj_request->object_name);
kfree(obj_request); kfree(obj_request);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册