Commit 62f75c2f authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Linus Torvalds

[PATCH] dm: move idr_pre_get

idr_pre_get() can sleep while allocating memory.

The next patch will change _minor_lock into a spinlock, so this patch moves
idr_pre_get() outside the lock in preparation.

[akpm: too late for 2.6.17 - suitable for 2.6.17.x after it has settled]
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ba61fdd1
...@@ -766,6 +766,10 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) ...@@ -766,6 +766,10 @@ static int specific_minor(struct mapped_device *md, unsigned int minor)
if (minor >= (1 << MINORBITS)) if (minor >= (1 << MINORBITS))
return -EINVAL; return -EINVAL;
r = idr_pre_get(&_minor_idr, GFP_KERNEL);
if (!r)
return -ENOMEM;
mutex_lock(&_minor_lock); mutex_lock(&_minor_lock);
if (idr_find(&_minor_idr, minor)) { if (idr_find(&_minor_idr, minor)) {
...@@ -773,16 +777,9 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) ...@@ -773,16 +777,9 @@ static int specific_minor(struct mapped_device *md, unsigned int minor)
goto out; goto out;
} }
r = idr_pre_get(&_minor_idr, GFP_KERNEL);
if (!r) {
r = -ENOMEM;
goto out;
}
r = idr_get_new_above(&_minor_idr, MINOR_ALLOCED, minor, &m); r = idr_get_new_above(&_minor_idr, MINOR_ALLOCED, minor, &m);
if (r) { if (r)
goto out; goto out;
}
if (m != minor) { if (m != minor) {
idr_remove(&_minor_idr, m); idr_remove(&_minor_idr, m);
...@@ -800,13 +797,11 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor) ...@@ -800,13 +797,11 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor)
int r; int r;
unsigned int m; unsigned int m;
mutex_lock(&_minor_lock);
r = idr_pre_get(&_minor_idr, GFP_KERNEL); r = idr_pre_get(&_minor_idr, GFP_KERNEL);
if (!r) { if (!r)
r = -ENOMEM; return -ENOMEM;
goto out;
} mutex_lock(&_minor_lock);
r = idr_get_new(&_minor_idr, MINOR_ALLOCED, &m); r = idr_get_new(&_minor_idr, MINOR_ALLOCED, &m);
if (r) { if (r) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment