diff options
author | Jeff Mahoney <jeffm@suse.com> | 2006-06-26 00:27:21 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-26 09:58:34 -0700 |
commit | 62f75c2f3244553b1290447abd1f1e6b1144d3e9 (patch) | |
tree | 14bfc0757b6662e37f8544dd52a7c304230f8695 /drivers/md/dm.c | |
parent | ba61fdd17d73ddb5c892a9f12383c6c560a20d56 (diff) |
[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: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r-- | drivers/md/dm.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 87d8ca1121e2..6e577e749329 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -766,6 +766,10 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) if (minor >= (1 << MINORBITS)) return -EINVAL; + r = idr_pre_get(&_minor_idr, GFP_KERNEL); + if (!r) + return -ENOMEM; + mutex_lock(&_minor_lock); if (idr_find(&_minor_idr, minor)) { @@ -773,16 +777,9 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) 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); - if (r) { + if (r) goto out; - } if (m != minor) { idr_remove(&_minor_idr, m); @@ -800,13 +797,11 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor) int r; unsigned int m; - mutex_lock(&_minor_lock); - r = idr_pre_get(&_minor_idr, GFP_KERNEL); - if (!r) { - r = -ENOMEM; - goto out; - } + if (!r) + return -ENOMEM; + + mutex_lock(&_minor_lock); r = idr_get_new(&_minor_idr, MINOR_ALLOCED, &m); if (r) { |