Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56de2102 authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds
Browse files

drbd: convert to idr_alloc()



Convert to the much saner new idr interface.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b051f6ed
Loading
Loading
Loading
Loading
+13 −16
Original line number Original line Diff line number Diff line
@@ -2660,25 +2660,24 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,
	mdev->read_requests = RB_ROOT;
	mdev->read_requests = RB_ROOT;
	mdev->write_requests = RB_ROOT;
	mdev->write_requests = RB_ROOT;


	if (!idr_pre_get(&minors, GFP_KERNEL))
	minor_got = idr_alloc(&minors, mdev, minor, minor + 1, GFP_KERNEL);
		goto out_no_minor_idr;
	if (minor_got < 0) {
	if (idr_get_new_above(&minors, mdev, minor, &minor_got))
		if (minor_got == -ENOSPC) {
		goto out_no_minor_idr;
	if (minor_got != minor) {
			err = ERR_MINOR_EXISTS;
			err = ERR_MINOR_EXISTS;
			drbd_msg_put_info("requested minor exists already");
			drbd_msg_put_info("requested minor exists already");
		goto out_idr_remove_minor;
		}
		goto out_no_minor_idr;
	}
	}


	if (!idr_pre_get(&tconn->volumes, GFP_KERNEL))
	vnr_got = idr_alloc(&tconn->volumes, mdev, vnr, vnr + 1, GFP_KERNEL);
		goto out_idr_remove_minor;
	if (vnr_got < 0) {
	if (idr_get_new_above(&tconn->volumes, mdev, vnr, &vnr_got))
		if (vnr_got == -ENOSPC) {
		goto out_idr_remove_minor;
	if (vnr_got != vnr) {
			err = ERR_INVALID_REQUEST;
			err = ERR_INVALID_REQUEST;
			drbd_msg_put_info("requested volume exists already");
			drbd_msg_put_info("requested volume exists already");
		goto out_idr_remove_vol;
		}
		}
		goto out_idr_remove_minor;
	}

	add_disk(disk);
	add_disk(disk);
	kref_init(&mdev->kref); /* one ref for both idrs and the the add_disk */
	kref_init(&mdev->kref); /* one ref for both idrs and the the add_disk */


@@ -2689,8 +2688,6 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,


	return NO_ERROR;
	return NO_ERROR;


out_idr_remove_vol:
	idr_remove(&tconn->volumes, vnr_got);
out_idr_remove_minor:
out_idr_remove_minor:
	idr_remove(&minors, minor_got);
	idr_remove(&minors, minor_got);
	synchronize_rcu();
	synchronize_rcu();