aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2006-06-26 03:27:21 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-26 12:58:34 -0400
commit62f75c2f3244553b1290447abd1f1e6b1144d3e9 (patch)
tree14bfc0757b6662e37f8544dd52a7c304230f8695
parentba61fdd17d73ddb5c892a9f12383c6c560a20d56 (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>
-rw-r--r--drivers/md/dm.c23
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)
766 if (minor >= (1 << MINORBITS)) 766 if (minor >= (1 << MINORBITS))
767 return -EINVAL; 767 return -EINVAL;
768 768
769 r = idr_pre_get(&_minor_idr, GFP_KERNEL);
770 if (!r)
771 return -ENOMEM;
772
769 mutex_lock(&_minor_lock); 773 mutex_lock(&_minor_lock);
770 774
771 if (idr_find(&_minor_idr, minor)) { 775 if (idr_find(&_minor_idr, minor)) {
@@ -773,16 +777,9 @@ static int specific_minor(struct mapped_device *md, unsigned int minor)
773 goto out; 777 goto out;
774 } 778 }
775 779
776 r = idr_pre_get(&_minor_idr, GFP_KERNEL);
777 if (!r) {
778 r = -ENOMEM;
779 goto out;
780 }
781
782 r = idr_get_new_above(&_minor_idr, MINOR_ALLOCED, minor, &m); 780 r = idr_get_new_above(&_minor_idr, MINOR_ALLOCED, minor, &m);
783 if (r) { 781 if (r)
784 goto out; 782 goto out;
785 }
786 783
787 if (m != minor) { 784 if (m != minor) {
788 idr_remove(&_minor_idr, m); 785 idr_remove(&_minor_idr, m);
@@ -800,13 +797,11 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor)
800 int r; 797 int r;
801 unsigned int m; 798 unsigned int m;
802 799
803 mutex_lock(&_minor_lock);
804
805 r = idr_pre_get(&_minor_idr, GFP_KERNEL); 800 r = idr_pre_get(&_minor_idr, GFP_KERNEL);
806 if (!r) { 801 if (!r)
807 r = -ENOMEM; 802 return -ENOMEM;
808 goto out; 803
809 } 804 mutex_lock(&_minor_lock);
810 805
811 r = idr_get_new(&_minor_idr, MINOR_ALLOCED, &m); 806 r = idr_get_new(&_minor_idr, MINOR_ALLOCED, &m);
812 if (r) { 807 if (r) {