aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers
diff options
context:
space:
mode:
authorPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>2006-10-31 01:07:07 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-31 11:06:59 -0500
commitd7fb2c3865ca0f95d92e2864c3dc9220789d83f5 (patch)
treeade46df79306ba0c5bea3449fe9a8ef66d25129b /arch/um/drivers
parent5f75a4f887a35b99878fc07ed749a90375194b63 (diff)
[PATCH] uml ubd driver: change ubd_lock to be a mutex
This lock protects ubd setup and teardown, so is only used in process context; beyond that, during such setup memory allocations must be performed and some generic functions which can sleep must be called (such as add_disk()). So the only correct solution is to make it a mutex instead of a spin_lock. No other change is done - this lock must be acquired in different places but it's done afterwards. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/drivers')
-rw-r--r--arch/um/drivers/ubd_kern.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index cdd82e896180..a3061ae39b3b 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -107,7 +107,8 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
107#define DRIVER_NAME "uml-blkdev" 107#define DRIVER_NAME "uml-blkdev"
108 108
109static DEFINE_SPINLOCK(ubd_io_lock); 109static DEFINE_SPINLOCK(ubd_io_lock);
110static DEFINE_SPINLOCK(ubd_lock); 110
111static DEFINE_MUTEX(ubd_lock);
111 112
112static void (*do_ubd)(void); 113static void (*do_ubd)(void);
113 114
@@ -314,7 +315,7 @@ static int ubd_setup_common(char *str, int *index_out)
314 } 315 }
315 316
316 err = 1; 317 err = 1;
317 spin_lock(&ubd_lock); 318 mutex_lock(&ubd_lock);
318 if(fake_major != MAJOR_NR){ 319 if(fake_major != MAJOR_NR){
319 printk(KERN_ERR "Can't assign a fake major twice\n"); 320 printk(KERN_ERR "Can't assign a fake major twice\n");
320 goto out1; 321 goto out1;
@@ -326,7 +327,7 @@ static int ubd_setup_common(char *str, int *index_out)
326 major); 327 major);
327 err = 0; 328 err = 0;
328 out1: 329 out1:
329 spin_unlock(&ubd_lock); 330 mutex_unlock(&ubd_lock);
330 return(err); 331 return(err);
331 } 332 }
332 333
@@ -343,7 +344,7 @@ static int ubd_setup_common(char *str, int *index_out)
343 } 344 }
344 345
345 err = 1; 346 err = 1;
346 spin_lock(&ubd_lock); 347 mutex_lock(&ubd_lock);
347 348
348 ubd_dev = &ubd_devs[n]; 349 ubd_dev = &ubd_devs[n];
349 if(ubd_dev->file != NULL){ 350 if(ubd_dev->file != NULL){
@@ -405,7 +406,7 @@ break_loop:
405 ubd_dev->cow.file = backing_file; 406 ubd_dev->cow.file = backing_file;
406 ubd_dev->boot_openflags = flags; 407 ubd_dev->boot_openflags = flags;
407out: 408out:
408 spin_unlock(&ubd_lock); 409 mutex_unlock(&ubd_lock);
409 return(err); 410 return(err);
410} 411}
411 412
@@ -710,11 +711,11 @@ static int ubd_config(char *str)
710 } 711 }
711 if(n == -1) return(0); 712 if(n == -1) return(0);
712 713
713 spin_lock(&ubd_lock); 714 mutex_lock(&ubd_lock);
714 err = ubd_add(n); 715 err = ubd_add(n);
715 if(err) 716 if(err)
716 ubd_devs[n].file = NULL; 717 ubd_devs[n].file = NULL;
717 spin_unlock(&ubd_lock); 718 mutex_unlock(&ubd_lock);
718 719
719 return(err); 720 return(err);
720} 721}
@@ -731,7 +732,7 @@ static int ubd_get_config(char *name, char *str, int size, char **error_out)
731 } 732 }
732 733
733 ubd_dev = &ubd_devs[n]; 734 ubd_dev = &ubd_devs[n];
734 spin_lock(&ubd_lock); 735 mutex_lock(&ubd_lock);
735 736
736 if(ubd_dev->file == NULL){ 737 if(ubd_dev->file == NULL){
737 CONFIG_CHUNK(str, size, len, "", 1); 738 CONFIG_CHUNK(str, size, len, "", 1);
@@ -747,7 +748,7 @@ static int ubd_get_config(char *name, char *str, int size, char **error_out)
747 else CONFIG_CHUNK(str, size, len, "", 1); 748 else CONFIG_CHUNK(str, size, len, "", 1);
748 749
749 out: 750 out:
750 spin_unlock(&ubd_lock); 751 mutex_unlock(&ubd_lock);
751 return(len); 752 return(len);
752} 753}
753 754
@@ -766,7 +767,7 @@ static int ubd_remove(int n)
766 struct ubd *ubd_dev; 767 struct ubd *ubd_dev;
767 int err = -ENODEV; 768 int err = -ENODEV;
768 769
769 spin_lock(&ubd_lock); 770 mutex_lock(&ubd_lock);
770 771
771 if(ubd_gendisk[n] == NULL) 772 if(ubd_gendisk[n] == NULL)
772 goto out; 773 goto out;
@@ -795,7 +796,7 @@ static int ubd_remove(int n)
795 *ubd_dev = ((struct ubd) DEFAULT_UBD); 796 *ubd_dev = ((struct ubd) DEFAULT_UBD);
796 err = 0; 797 err = 0;
797out: 798out:
798 spin_unlock(&ubd_lock); 799 mutex_unlock(&ubd_lock);
799 return err; 800 return err;
800} 801}
801 802