aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-03-23 06:00:19 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 10:38:10 -0500
commit4f7a07b88726781e37c4c5f63db3a6ee3f8500d3 (patch)
tree024e0e5cf9232f35bed0cf8cb9aa40fe434b2064
parent9331b3157c835353dd28efcd80d23563ad226aee (diff)
[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: Ingo Molnar <mingo@elte.hu> Cc: Eric Van Hensbergen <ericvh@ericvh.myip.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/9p/mux.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/9p/mux.c b/fs/9p/mux.c
index ea1134eb47c8..8e8356c1c229 100644
--- a/fs/9p/mux.c
+++ b/fs/9p/mux.c
@@ -31,6 +31,7 @@
31#include <linux/poll.h> 31#include <linux/poll.h>
32#include <linux/kthread.h> 32#include <linux/kthread.h>
33#include <linux/idr.h> 33#include <linux/idr.h>
34#include <linux/mutex.h>
34 35
35#include "debug.h" 36#include "debug.h"
36#include "v9fs.h" 37#include "v9fs.h"
@@ -110,7 +111,7 @@ static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
110static u16 v9fs_mux_get_tag(struct v9fs_mux_data *); 111static u16 v9fs_mux_get_tag(struct v9fs_mux_data *);
111static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16); 112static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16);
112 113
113static DECLARE_MUTEX(v9fs_mux_task_lock); 114static DEFINE_MUTEX(v9fs_mux_task_lock);
114static struct workqueue_struct *v9fs_mux_wq; 115static struct workqueue_struct *v9fs_mux_wq;
115 116
116static int v9fs_mux_num; 117static int v9fs_mux_num;
@@ -166,7 +167,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
166 167
167 dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num, 168 dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num,
168 v9fs_mux_poll_task_num); 169 v9fs_mux_poll_task_num);
169 up(&v9fs_mux_task_lock); 170 mutex_lock(&v9fs_mux_task_lock);
170 171
171 n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1); 172 n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1);
172 if (n > v9fs_mux_poll_task_num) { 173 if (n > v9fs_mux_poll_task_num) {
@@ -225,7 +226,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
225 } 226 }
226 227
227 v9fs_mux_num++; 228 v9fs_mux_num++;
228 down(&v9fs_mux_task_lock); 229 mutex_unlock(&v9fs_mux_task_lock);
229 230
230 return 0; 231 return 0;
231} 232}
@@ -235,7 +236,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
235 int i; 236 int i;
236 struct v9fs_mux_poll_task *vpt; 237 struct v9fs_mux_poll_task *vpt;
237 238
238 up(&v9fs_mux_task_lock); 239 mutex_lock(&v9fs_mux_task_lock);
239 vpt = m->poll_task; 240 vpt = m->poll_task;
240 list_del(&m->mux_list); 241 list_del(&m->mux_list);
241 for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { 242 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 v9fs_mux_poll_task_num--; 253 v9fs_mux_poll_task_num--;
253 } 254 }
254 v9fs_mux_num--; 255 v9fs_mux_num--;
255 down(&v9fs_mux_task_lock); 256 mutex_unlock(&v9fs_mux_task_lock);
256} 257}
257 258
258/** 259/**