Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 345854
b: refs/heads/master
c: 569083c
h: refs/heads/master
v: v3
  • Loading branch information
Lars Ellenberg authored and Philipp Reisner committed Oct 14, 2011
1 parent a886a81 commit eb0965e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: da4a75d2ef064501f6756986af6ea330ba0585d7
refs/heads/master: 569083c08dc16c043b4bdd473d41ff85a2b2df9e
42 changes: 24 additions & 18 deletions trunk/drivers/block/drbd/drbd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,9 @@ void drbd_delete_device(unsigned int minor)
if (!mdev)
return;

idr_remove(&mdev->tconn->volumes, minor);
idr_remove(&mdev->tconn->volumes, mdev->vnr);
idr_remove(&minors, minor);
synchronize_rcu();

/* paranoia asserts */
D_ASSERT(mdev->open_cnt == 0);
Expand Down Expand Up @@ -2153,7 +2155,6 @@ void drbd_delete_device(unsigned int minor)
* allocated from drbd_new_device
* and actually free the mdev itself */
drbd_free_mdev(mdev);
idr_remove(&minors, minor);
}

static void drbd_cleanup(void)
Expand Down Expand Up @@ -2331,15 +2332,6 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,
return ERR_NOMEM;

mdev->tconn = tconn;
if (!idr_pre_get(&tconn->volumes, GFP_KERNEL))
goto out_no_idr;
if (idr_get_new(&tconn->volumes, mdev, &vnr_got))
goto out_no_idr;
if (vnr_got != vnr) {
dev_err(DEV, "vnr_got (%d) != vnr (%d)\n", vnr_got, vnr);
goto out_no_q;
}

mdev->minor = minor;

drbd_init_set_defaults(mdev);
Expand Down Expand Up @@ -2395,19 +2387,35 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,
INIT_LIST_HEAD(&mdev->current_epoch->list);
mdev->epochs = 1;

if (!idr_pre_get(&tconn->volumes, GFP_KERNEL))
goto out_no_vol_idr;
if (idr_get_new(&tconn->volumes, mdev, &vnr_got))
goto out_no_vol_idr;
if (vnr_got != vnr) {
dev_err(DEV, "vnr_got (%d) != vnr (%d)\n", vnr_got, vnr);
goto out_idr_remove_vol;
}

if (!idr_pre_get(&minors, GFP_KERNEL))
goto out_no_minor_idr;
goto out_idr_remove_vol;
if (idr_get_new(&minors, mdev, &minor_got))
goto out_no_minor_idr;
goto out_idr_remove_vol;
if (minor_got != minor) {
idr_remove(&minors, minor_got);
goto out_no_minor_idr;
/* minor exists, or other idr strangeness? */
dev_err(DEV, "available minor (%d) != requested minor (%d)\n",
minor_got, minor);
goto out_idr_remove_minor;
}
add_disk(disk);

return NO_ERROR;

out_no_minor_idr:
out_idr_remove_minor:
idr_remove(&minors, minor_got);
out_idr_remove_vol:
idr_remove(&tconn->volumes, vnr_got);
synchronize_rcu();
out_no_vol_idr:
kfree(mdev->current_epoch);
out_no_epoch:
drbd_bm_cleanup(mdev);
Expand All @@ -2418,8 +2426,6 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,
out_no_disk:
blk_cleanup_queue(q);
out_no_q:
idr_remove(&tconn->volumes, vnr_got);
out_no_idr:
kfree(mdev);
return ERR_NOMEM;
}
Expand Down

0 comments on commit eb0965e

Please sign in to comment.