aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/drbd/drbd_main.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 8c13eeb83c53..e98da675f0c1 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2660,25 +2660,24 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,
2660 mdev->read_requests = RB_ROOT; 2660 mdev->read_requests = RB_ROOT;
2661 mdev->write_requests = RB_ROOT; 2661 mdev->write_requests = RB_ROOT;
2662 2662
2663 if (!idr_pre_get(&minors, GFP_KERNEL)) 2663 minor_got = idr_alloc(&minors, mdev, minor, minor + 1, GFP_KERNEL);
2664 goto out_no_minor_idr; 2664 if (minor_got < 0) {
2665 if (idr_get_new_above(&minors, mdev, minor, &minor_got)) 2665 if (minor_got == -ENOSPC) {
2666 err = ERR_MINOR_EXISTS;
2667 drbd_msg_put_info("requested minor exists already");
2668 }
2666 goto out_no_minor_idr; 2669 goto out_no_minor_idr;
2667 if (minor_got != minor) {
2668 err = ERR_MINOR_EXISTS;
2669 drbd_msg_put_info("requested minor exists already");
2670 goto out_idr_remove_minor;
2671 } 2670 }
2672 2671
2673 if (!idr_pre_get(&tconn->volumes, GFP_KERNEL)) 2672 vnr_got = idr_alloc(&tconn->volumes, mdev, vnr, vnr + 1, GFP_KERNEL);
2674 goto out_idr_remove_minor; 2673 if (vnr_got < 0) {
2675 if (idr_get_new_above(&tconn->volumes, mdev, vnr, &vnr_got)) 2674 if (vnr_got == -ENOSPC) {
2675 err = ERR_INVALID_REQUEST;
2676 drbd_msg_put_info("requested volume exists already");
2677 }
2676 goto out_idr_remove_minor; 2678 goto out_idr_remove_minor;
2677 if (vnr_got != vnr) {
2678 err = ERR_INVALID_REQUEST;
2679 drbd_msg_put_info("requested volume exists already");
2680 goto out_idr_remove_vol;
2681 } 2679 }
2680
2682 add_disk(disk); 2681 add_disk(disk);
2683 kref_init(&mdev->kref); /* one ref for both idrs and the the add_disk */ 2682 kref_init(&mdev->kref); /* one ref for both idrs and the the add_disk */
2684 2683
@@ -2689,8 +2688,6 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,
2689 2688
2690 return NO_ERROR; 2689 return NO_ERROR;
2691 2690
2692out_idr_remove_vol:
2693 idr_remove(&tconn->volumes, vnr_got);
2694out_idr_remove_minor: 2691out_idr_remove_minor:
2695 idr_remove(&minors, minor_got); 2692 idr_remove(&minors, minor_got);
2696 synchronize_rcu(); 2693 synchronize_rcu();