Commit d7fb2c38 authored by Paolo 'Blaisorblade' Giarrusso's avatar Paolo 'Blaisorblade' Giarrusso Committed by Linus Torvalds

[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: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5f75a4f8
...@@ -107,7 +107,8 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data) ...@@ -107,7 +107,8 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
#define DRIVER_NAME "uml-blkdev" #define DRIVER_NAME "uml-blkdev"
static DEFINE_SPINLOCK(ubd_io_lock); static DEFINE_SPINLOCK(ubd_io_lock);
static DEFINE_SPINLOCK(ubd_lock);
static DEFINE_MUTEX(ubd_lock);
static void (*do_ubd)(void); static void (*do_ubd)(void);
...@@ -314,7 +315,7 @@ static int ubd_setup_common(char *str, int *index_out) ...@@ -314,7 +315,7 @@ static int ubd_setup_common(char *str, int *index_out)
} }
err = 1; err = 1;
spin_lock(&ubd_lock); mutex_lock(&ubd_lock);
if(fake_major != MAJOR_NR){ if(fake_major != MAJOR_NR){
printk(KERN_ERR "Can't assign a fake major twice\n"); printk(KERN_ERR "Can't assign a fake major twice\n");
goto out1; goto out1;
...@@ -326,7 +327,7 @@ static int ubd_setup_common(char *str, int *index_out) ...@@ -326,7 +327,7 @@ static int ubd_setup_common(char *str, int *index_out)
major); major);
err = 0; err = 0;
out1: out1:
spin_unlock(&ubd_lock); mutex_unlock(&ubd_lock);
return(err); return(err);
} }
...@@ -343,7 +344,7 @@ static int ubd_setup_common(char *str, int *index_out) ...@@ -343,7 +344,7 @@ static int ubd_setup_common(char *str, int *index_out)
} }
err = 1; err = 1;
spin_lock(&ubd_lock); mutex_lock(&ubd_lock);
ubd_dev = &ubd_devs[n]; ubd_dev = &ubd_devs[n];
if(ubd_dev->file != NULL){ if(ubd_dev->file != NULL){
...@@ -405,7 +406,7 @@ break_loop: ...@@ -405,7 +406,7 @@ break_loop:
ubd_dev->cow.file = backing_file; ubd_dev->cow.file = backing_file;
ubd_dev->boot_openflags = flags; ubd_dev->boot_openflags = flags;
out: out:
spin_unlock(&ubd_lock); mutex_unlock(&ubd_lock);
return(err); return(err);
} }
...@@ -710,11 +711,11 @@ static int ubd_config(char *str) ...@@ -710,11 +711,11 @@ static int ubd_config(char *str)
} }
if(n == -1) return(0); if(n == -1) return(0);
spin_lock(&ubd_lock); mutex_lock(&ubd_lock);
err = ubd_add(n); err = ubd_add(n);
if(err) if(err)
ubd_devs[n].file = NULL; ubd_devs[n].file = NULL;
spin_unlock(&ubd_lock); mutex_unlock(&ubd_lock);
return(err); return(err);
} }
...@@ -731,7 +732,7 @@ static int ubd_get_config(char *name, char *str, int size, char **error_out) ...@@ -731,7 +732,7 @@ static int ubd_get_config(char *name, char *str, int size, char **error_out)
} }
ubd_dev = &ubd_devs[n]; ubd_dev = &ubd_devs[n];
spin_lock(&ubd_lock); mutex_lock(&ubd_lock);
if(ubd_dev->file == NULL){ if(ubd_dev->file == NULL){
CONFIG_CHUNK(str, size, len, "", 1); 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,7 +748,7 @@ static int ubd_get_config(char *name, char *str, int size, char **error_out)
else CONFIG_CHUNK(str, size, len, "", 1); else CONFIG_CHUNK(str, size, len, "", 1);
out: out:
spin_unlock(&ubd_lock); mutex_unlock(&ubd_lock);
return(len); return(len);
} }
...@@ -766,7 +767,7 @@ static int ubd_remove(int n) ...@@ -766,7 +767,7 @@ static int ubd_remove(int n)
struct ubd *ubd_dev; struct ubd *ubd_dev;
int err = -ENODEV; int err = -ENODEV;
spin_lock(&ubd_lock); mutex_lock(&ubd_lock);
if(ubd_gendisk[n] == NULL) if(ubd_gendisk[n] == NULL)
goto out; goto out;
...@@ -795,7 +796,7 @@ static int ubd_remove(int n) ...@@ -795,7 +796,7 @@ static int ubd_remove(int n)
*ubd_dev = ((struct ubd) DEFAULT_UBD); *ubd_dev = ((struct ubd) DEFAULT_UBD);
err = 0; err = 0;
out: out:
spin_unlock(&ubd_lock); mutex_unlock(&ubd_lock);
return err; return err;
} }
......
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