Commit 4f7a07b8 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] convert fs/9p/ to mutexes, fix locking bugs

Convert fs/9p/mux.c from semaphore to mutex.

NOTE: fixed locking bugs in the process - the code was using semaphores
the other way around.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: Eric Van Hensbergen <ericvh@ericvh.myip.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9331b315
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/mutex.h>
#include "debug.h" #include "debug.h"
#include "v9fs.h" #include "v9fs.h"
...@@ -110,7 +111,7 @@ static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address, ...@@ -110,7 +111,7 @@ static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
static u16 v9fs_mux_get_tag(struct v9fs_mux_data *); static u16 v9fs_mux_get_tag(struct v9fs_mux_data *);
static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16); static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16);
static DECLARE_MUTEX(v9fs_mux_task_lock); static DEFINE_MUTEX(v9fs_mux_task_lock);
static struct workqueue_struct *v9fs_mux_wq; static struct workqueue_struct *v9fs_mux_wq;
static int v9fs_mux_num; static int v9fs_mux_num;
...@@ -166,7 +167,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m) ...@@ -166,7 +167,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num, dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num,
v9fs_mux_poll_task_num); v9fs_mux_poll_task_num);
up(&v9fs_mux_task_lock); mutex_lock(&v9fs_mux_task_lock);
n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1); n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1);
if (n > v9fs_mux_poll_task_num) { if (n > v9fs_mux_poll_task_num) {
...@@ -225,7 +226,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m) ...@@ -225,7 +226,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
} }
v9fs_mux_num++; v9fs_mux_num++;
down(&v9fs_mux_task_lock); mutex_unlock(&v9fs_mux_task_lock);
return 0; return 0;
} }
...@@ -235,7 +236,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m) ...@@ -235,7 +236,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
int i; int i;
struct v9fs_mux_poll_task *vpt; struct v9fs_mux_poll_task *vpt;
up(&v9fs_mux_task_lock); mutex_lock(&v9fs_mux_task_lock);
vpt = m->poll_task; vpt = m->poll_task;
list_del(&m->mux_list); list_del(&m->mux_list);
for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) {
...@@ -252,7 +253,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m) ...@@ -252,7 +253,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
v9fs_mux_poll_task_num--; v9fs_mux_poll_task_num--;
} }
v9fs_mux_num--; v9fs_mux_num--;
down(&v9fs_mux_task_lock); mutex_unlock(&v9fs_mux_task_lock);
} }
/** /**
......
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