aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-07-09 22:04:23 -0400
committerSage Weil <sage@inktank.com>2012-07-30 12:30:04 -0400
commitbf3e5ae1129ef18a702c14fbaac27aeb2fe25e62 (patch)
tree80475b9c9994f4c1316db2497d0428fe462a702d /drivers/block/rbd.c
parentcb8627c76db699e3a085596aa80503fb0973c041 (diff)
rbd: dynamically allocate image name
There is no need to impose a small limit the length of the rbd image name recorded in a struct rbd_dev. Remove the limitation by allocating space for the image name dynamically. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 9b676b3b9ba0..7d4735c9dba5 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -161,8 +161,8 @@ struct rbd_device {
161 spinlock_t lock; /* queue lock */ 161 spinlock_t lock; /* queue lock */
162 162
163 struct rbd_image_header header; 163 struct rbd_image_header header;
164 char obj[RBD_MAX_OBJ_NAME_LEN]; /* rbd image name */ 164 char *obj; /* rbd image name */
165 int obj_len; 165 size_t obj_len;
166 char *obj_md_name; /* hdr nm. */ 166 char *obj_md_name; /* hdr nm. */
167 char *pool_name; 167 char *pool_name;
168 int pool_id; 168 int pool_id;
@@ -2371,27 +2371,22 @@ static int rbd_add_parse_args(struct rbd_device *rbd_dev,
2371 if (!len || len >= options_size) 2371 if (!len || len >= options_size)
2372 return -EINVAL; 2372 return -EINVAL;
2373 2373
2374 ret = -ENOMEM;
2374 rbd_dev->pool_name = dup_token(&buf, NULL); 2375 rbd_dev->pool_name = dup_token(&buf, NULL);
2375 if (!rbd_dev->pool_name) 2376 if (!rbd_dev->pool_name)
2376 return -ENOMEM;
2377
2378 len = copy_token(&buf, rbd_dev->obj, sizeof (rbd_dev->obj));
2379 if (!len || len >= sizeof (rbd_dev->obj)) {
2380 ret = -EINVAL;
2381 goto out_err; 2377 goto out_err;
2382 }
2383 2378
2384 /* We have the object length in hand, save it. */ 2379 rbd_dev->obj = dup_token(&buf, &rbd_dev->obj_len);
2385 2380 if (!rbd_dev->obj)
2386 rbd_dev->obj_len = len; 2381 goto out_err;
2387 2382
2388 /* Create the name of the header object */ 2383 /* Create the name of the header object */
2389 2384
2390 rbd_dev->obj_md_name = kmalloc(len + sizeof (RBD_SUFFIX), GFP_KERNEL); 2385 rbd_dev->obj_md_name = kmalloc(rbd_dev->obj_len
2391 if (!rbd_dev->obj_md_name) { 2386 + sizeof (RBD_SUFFIX),
2392 ret = -ENOMEM; 2387 GFP_KERNEL);
2388 if (!rbd_dev->obj_md_name)
2393 goto out_err; 2389 goto out_err;
2394 }
2395 sprintf(rbd_dev->obj_md_name, "%s%s", rbd_dev->obj, RBD_SUFFIX); 2390 sprintf(rbd_dev->obj_md_name, "%s%s", rbd_dev->obj, RBD_SUFFIX);
2396 2391
2397 /* 2392 /*
@@ -2411,6 +2406,7 @@ static int rbd_add_parse_args(struct rbd_device *rbd_dev,
2411 2406
2412out_err: 2407out_err:
2413 kfree(rbd_dev->obj_md_name); 2408 kfree(rbd_dev->obj_md_name);
2409 kfree(rbd_dev->obj);
2414 kfree(rbd_dev->pool_name); 2410 kfree(rbd_dev->pool_name);
2415 rbd_dev->pool_name = NULL; 2411 rbd_dev->pool_name = NULL;
2416 2412
@@ -2514,6 +2510,7 @@ err_out_client:
2514err_put_id: 2510err_put_id:
2515 if (rbd_dev->pool_name) { 2511 if (rbd_dev->pool_name) {
2516 kfree(rbd_dev->obj_md_name); 2512 kfree(rbd_dev->obj_md_name);
2513 kfree(rbd_dev->obj);
2517 kfree(rbd_dev->pool_name); 2514 kfree(rbd_dev->pool_name);
2518 } 2515 }
2519 rbd_id_put(rbd_dev); 2516 rbd_id_put(rbd_dev);
@@ -2566,6 +2563,7 @@ static void rbd_dev_release(struct device *dev)
2566 /* done with the id, and with the rbd_dev */ 2563 /* done with the id, and with the rbd_dev */
2567 kfree(rbd_dev->obj_md_name); 2564 kfree(rbd_dev->obj_md_name);
2568 kfree(rbd_dev->pool_name); 2565 kfree(rbd_dev->pool_name);
2566 kfree(rbd_dev->obj);
2569 rbd_id_put(rbd_dev); 2567 rbd_id_put(rbd_dev);
2570 kfree(rbd_dev); 2568 kfree(rbd_dev);
2571 2569