Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drbd: convert to idr_alloc()

Convert to the much saner new idr interface.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Tejun Heo and committed by
Linus Torvalds
56de2102 b051f6ed

+14 -17
+14 -17
drivers/block/drbd/drbd_main.c
··· 2660 2660 mdev->read_requests = RB_ROOT; 2661 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 + if (minor_got < 0) { 2665 + if (minor_got == -ENOSPC) { 2666 + err = ERR_MINOR_EXISTS; 2667 + drbd_msg_put_info("requested minor exists already"); 2668 + } 2664 2669 goto out_no_minor_idr; 2665 - if (idr_get_new_above(&minors, mdev, minor, &minor_got)) 2666 - 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 + } 2671 + 2672 + vnr_got = idr_alloc(&tconn->volumes, mdev, vnr, vnr + 1, GFP_KERNEL); 2673 + if (vnr_got < 0) { 2674 + if (vnr_got == -ENOSPC) { 2675 + err = ERR_INVALID_REQUEST; 2676 + drbd_msg_put_info("requested volume exists already"); 2677 + } 2670 2678 goto out_idr_remove_minor; 2671 2679 } 2672 2680 2673 - if (!idr_pre_get(&tconn->volumes, GFP_KERNEL)) 2674 - goto out_idr_remove_minor; 2675 - if (idr_get_new_above(&tconn->volumes, mdev, vnr, &vnr_got)) 2676 - 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 - } 2682 2681 add_disk(disk); 2683 2682 kref_init(&mdev->kref); /* one ref for both idrs and the the add_disk */ 2684 2683 ··· 2688 2689 2689 2690 return NO_ERROR; 2690 2691 2691 - out_idr_remove_vol: 2692 - idr_remove(&tconn->volumes, vnr_got); 2693 2692 out_idr_remove_minor: 2694 2693 idr_remove(&minors, minor_got); 2695 2694 synchronize_rcu();