aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-07-03 17:01:19 -0400
committerAlex Elder <elder@inktank.com>2012-10-01 15:30:52 -0400
commit3fcf2581c2c3c910aa46f6d205e502a97243ca2c (patch)
tree2b3c402f6a6e3485608c809076340076bc6a339f /drivers/block
parente86924a8092fda66b859f12a4d7d37a4a458d74a (diff)
rbd: assign header name later
Move the assignment of the header name for an rbd image a bit later, outside rbd_add_parse_args() and into its caller. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 1ecdeb15b618..48901b51f648 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2474,15 +2474,6 @@ static char *rbd_add_parse_args(struct rbd_device *rbd_dev,
2474 if (!rbd_dev->image_name) 2474 if (!rbd_dev->image_name)
2475 goto out_err; 2475 goto out_err;
2476 2476
2477 /* Create the name of the header object */
2478
2479 rbd_dev->header_name = kmalloc(rbd_dev->image_name_len
2480 + sizeof (RBD_SUFFIX),
2481 GFP_KERNEL);
2482 if (!rbd_dev->header_name)
2483 goto out_err;
2484 sprintf(rbd_dev->header_name, "%s%s", rbd_dev->image_name, RBD_SUFFIX);
2485
2486 /* Snapshot name is optional */ 2477 /* Snapshot name is optional */
2487 len = next_token(&buf); 2478 len = next_token(&buf);
2488 if (!len) { 2479 if (!len) {
@@ -2500,8 +2491,6 @@ dout(" SNAP_NAME is <%s>, len is %zd\n", snap_name, len);
2500 return snap_name; 2491 return snap_name;
2501 2492
2502out_err: 2493out_err:
2503 kfree(rbd_dev->header_name);
2504 rbd_dev->header_name = NULL;
2505 kfree(rbd_dev->image_name); 2494 kfree(rbd_dev->image_name);
2506 rbd_dev->image_name = NULL; 2495 rbd_dev->image_name = NULL;
2507 rbd_dev->image_name_len = 0; 2496 rbd_dev->image_name_len = 0;
@@ -2566,6 +2555,15 @@ static ssize_t rbd_add(struct bus_type *bus,
2566 goto err_out_client; 2555 goto err_out_client;
2567 rbd_dev->pool_id = rc; 2556 rbd_dev->pool_id = rc;
2568 2557
2558 /* Create the name of the header object */
2559
2560 rbd_dev->header_name = kmalloc(rbd_dev->image_name_len
2561 + sizeof (RBD_SUFFIX),
2562 GFP_KERNEL);
2563 if (!rbd_dev->header_name)
2564 goto err_out_client;
2565 sprintf(rbd_dev->header_name, "%s%s", rbd_dev->image_name, RBD_SUFFIX);
2566
2569 /* register our block device */ 2567 /* register our block device */
2570 rc = register_blkdev(0, rbd_dev->name); 2568 rc = register_blkdev(0, rbd_dev->name);
2571 if (rc < 0) 2569 if (rc < 0)
@@ -2626,11 +2624,11 @@ err_out_bus:
2626err_out_blkdev: 2624err_out_blkdev:
2627 unregister_blkdev(rbd_dev->major, rbd_dev->name); 2625 unregister_blkdev(rbd_dev->major, rbd_dev->name);
2628err_out_client: 2626err_out_client:
2627 kfree(rbd_dev->header_name);
2629 rbd_put_client(rbd_dev); 2628 rbd_put_client(rbd_dev);
2630err_put_id: 2629err_put_id:
2631 if (rbd_dev->pool_name) { 2630 if (rbd_dev->pool_name) {
2632 kfree(rbd_dev->mapping.snap_name); 2631 kfree(rbd_dev->mapping.snap_name);
2633 kfree(rbd_dev->header_name);
2634 kfree(rbd_dev->image_name); 2632 kfree(rbd_dev->image_name);
2635 kfree(rbd_dev->pool_name); 2633 kfree(rbd_dev->pool_name);
2636 } 2634 }