Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 30335
b: refs/heads/master
c: ba61fdd
h: refs/heads/master
i:
  30333: a6be5cc
  30331: f1520bc
  30327: 354289f
  30319: a60a77b
  30303: 63605b5
  30271: 9144775
  30207: 589ad07
v: v3
  • Loading branch information
Jeff Mahoney authored and Linus Torvalds committed Jun 26, 2006
1 parent 352bfad commit cf471bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 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: 5806f07cd2c32920d5105e0f9ff3117338f34eec
refs/heads/master: ba61fdd17d73ddb5c892a9f12383c6c560a20d56
19 changes: 16 additions & 3 deletions trunk/drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ union map_info *dm_get_mapinfo(struct bio *bio)
return NULL;
}

#define MINOR_ALLOCED ((void *)-1)

/*
* Bits for the md->flags field.
*/
Expand Down Expand Up @@ -777,7 +779,7 @@ static int specific_minor(struct mapped_device *md, unsigned int minor)
goto out;
}

r = idr_get_new_above(&_minor_idr, md, minor, &m);
r = idr_get_new_above(&_minor_idr, MINOR_ALLOCED, minor, &m);
if (r) {
goto out;
}
Expand Down Expand Up @@ -806,7 +808,7 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor)
goto out;
}

r = idr_get_new(&_minor_idr, md, &m);
r = idr_get_new(&_minor_idr, MINOR_ALLOCED, &m);
if (r) {
goto out;
}
Expand All @@ -833,6 +835,7 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent)
{
int r;
struct mapped_device *md = kmalloc(sizeof(*md), GFP_KERNEL);
void *old_md;

if (!md) {
DMWARN("unable to allocate device, out of memory.");
Expand Down Expand Up @@ -888,6 +891,13 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent)
init_waitqueue_head(&md->wait);
init_waitqueue_head(&md->eventq);

/* Populate the mapping, nobody knows we exist yet */
mutex_lock(&_minor_lock);
old_md = idr_replace(&_minor_idr, md, minor);
mutex_unlock(&_minor_lock);

BUG_ON(old_md != MINOR_ALLOCED);

return md;

bad4:
Expand Down Expand Up @@ -1018,7 +1028,7 @@ static struct mapped_device *dm_find_md(dev_t dev)
mutex_lock(&_minor_lock);

md = idr_find(&_minor_idr, minor);
if (!md || (dm_disk(md)->first_minor != minor))
if (md && (md == MINOR_ALLOCED || (dm_disk(md)->first_minor != minor)))
md = NULL;

mutex_unlock(&_minor_lock);
Expand Down Expand Up @@ -1057,6 +1067,9 @@ void dm_put(struct mapped_device *md)

if (atomic_dec_and_test(&md->holders)) {
map = dm_get_table(md);
mutex_lock(&_minor_lock);
idr_replace(&_minor_idr, MINOR_ALLOCED, dm_disk(md)->first_minor);
mutex_unlock(&_minor_lock);
if (!dm_suspended(md)) {
dm_table_presuspend_targets(map);
dm_table_postsuspend_targets(map);
Expand Down

0 comments on commit cf471bb

Please sign in to comment.