diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/rbd.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index aa4752d9d9fa..7a600ca2dbcf 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -2554,10 +2554,10 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
2554 | 2554 | ||
2555 | options = kmalloc(count, GFP_KERNEL); | 2555 | options = kmalloc(count, GFP_KERNEL); |
2556 | if (!options) | 2556 | if (!options) |
2557 | goto err_nomem; | 2557 | goto err_out_mem; |
2558 | rbd_dev = kzalloc(sizeof(*rbd_dev), GFP_KERNEL); | 2558 | rbd_dev = kzalloc(sizeof(*rbd_dev), GFP_KERNEL); |
2559 | if (!rbd_dev) | 2559 | if (!rbd_dev) |
2560 | goto err_nomem; | 2560 | goto err_out_mem; |
2561 | 2561 | ||
2562 | /* static rbd_device initialization */ | 2562 | /* static rbd_device initialization */ |
2563 | spin_lock_init(&rbd_dev->lock); | 2563 | spin_lock_init(&rbd_dev->lock); |
@@ -2565,25 +2565,17 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
2565 | INIT_LIST_HEAD(&rbd_dev->snaps); | 2565 | INIT_LIST_HEAD(&rbd_dev->snaps); |
2566 | init_rwsem(&rbd_dev->header_rwsem); | 2566 | init_rwsem(&rbd_dev->header_rwsem); |
2567 | 2567 | ||
2568 | /* generate unique id: find highest unique id, add one */ | ||
2569 | rbd_dev_id_get(rbd_dev); | ||
2570 | |||
2571 | /* Fill in the device name, now that we have its id. */ | ||
2572 | BUILD_BUG_ON(DEV_NAME_LEN | ||
2573 | < sizeof (RBD_DRV_NAME) + MAX_INT_FORMAT_WIDTH); | ||
2574 | sprintf(rbd_dev->name, "%s%d", RBD_DRV_NAME, rbd_dev->dev_id); | ||
2575 | |||
2576 | /* parse add command */ | 2568 | /* parse add command */ |
2577 | snap_name = rbd_add_parse_args(rbd_dev, buf, | 2569 | snap_name = rbd_add_parse_args(rbd_dev, buf, |
2578 | &mon_addrs, &mon_addrs_size, options, count); | 2570 | &mon_addrs, &mon_addrs_size, options, count); |
2579 | if (IS_ERR(snap_name)) { | 2571 | if (IS_ERR(snap_name)) { |
2580 | rc = PTR_ERR(snap_name); | 2572 | rc = PTR_ERR(snap_name); |
2581 | goto err_put_id; | 2573 | goto err_out_mem; |
2582 | } | 2574 | } |
2583 | 2575 | ||
2584 | rc = rbd_get_client(rbd_dev, mon_addrs, mon_addrs_size - 1, options); | 2576 | rc = rbd_get_client(rbd_dev, mon_addrs, mon_addrs_size - 1, options); |
2585 | if (rc < 0) | 2577 | if (rc < 0) |
2586 | goto err_put_id; | 2578 | goto err_out_args; |
2587 | 2579 | ||
2588 | /* pick the pool */ | 2580 | /* pick the pool */ |
2589 | osdc = &rbd_dev->rbd_client->client->osdc; | 2581 | osdc = &rbd_dev->rbd_client->client->osdc; |
@@ -2616,10 +2608,19 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
2616 | if (rc) | 2608 | if (rc) |
2617 | goto err_out_header; | 2609 | goto err_out_header; |
2618 | 2610 | ||
2619 | /* register our block device */ | 2611 | /* generate unique id: find highest unique id, add one */ |
2612 | rbd_dev_id_get(rbd_dev); | ||
2613 | |||
2614 | /* Fill in the device name, now that we have its id. */ | ||
2615 | BUILD_BUG_ON(DEV_NAME_LEN | ||
2616 | < sizeof (RBD_DRV_NAME) + MAX_INT_FORMAT_WIDTH); | ||
2617 | sprintf(rbd_dev->name, "%s%d", RBD_DRV_NAME, rbd_dev->dev_id); | ||
2618 | |||
2619 | /* Get our block major device number. */ | ||
2620 | |||
2620 | rc = register_blkdev(0, rbd_dev->name); | 2621 | rc = register_blkdev(0, rbd_dev->name); |
2621 | if (rc < 0) | 2622 | if (rc < 0) |
2622 | goto err_out_header; | 2623 | goto err_out_id; |
2623 | rbd_dev->major = rc; | 2624 | rbd_dev->major = rc; |
2624 | 2625 | ||
2625 | rc = rbd_bus_add_dev(rbd_dev); | 2626 | rc = rbd_bus_add_dev(rbd_dev); |
@@ -2665,19 +2666,18 @@ err_out_bus: | |||
2665 | 2666 | ||
2666 | err_out_blkdev: | 2667 | err_out_blkdev: |
2667 | unregister_blkdev(rbd_dev->major, rbd_dev->name); | 2668 | unregister_blkdev(rbd_dev->major, rbd_dev->name); |
2669 | err_out_id: | ||
2670 | rbd_dev_id_put(rbd_dev); | ||
2668 | err_out_header: | 2671 | err_out_header: |
2669 | rbd_header_free(&rbd_dev->header); | 2672 | rbd_header_free(&rbd_dev->header); |
2670 | err_out_client: | 2673 | err_out_client: |
2671 | kfree(rbd_dev->header_name); | 2674 | kfree(rbd_dev->header_name); |
2672 | rbd_put_client(rbd_dev); | 2675 | rbd_put_client(rbd_dev); |
2673 | err_put_id: | 2676 | err_out_args: |
2674 | if (rbd_dev->pool_name) { | 2677 | kfree(rbd_dev->mapping.snap_name); |
2675 | kfree(rbd_dev->mapping.snap_name); | 2678 | kfree(rbd_dev->image_name); |
2676 | kfree(rbd_dev->image_name); | 2679 | kfree(rbd_dev->pool_name); |
2677 | kfree(rbd_dev->pool_name); | 2680 | err_out_mem: |
2678 | } | ||
2679 | rbd_dev_id_put(rbd_dev); | ||
2680 | err_nomem: | ||
2681 | kfree(rbd_dev); | 2681 | kfree(rbd_dev); |
2682 | kfree(options); | 2682 | kfree(options); |
2683 | 2683 | ||