aboutsummaryrefslogtreecommitdiffstats
path: root/fs/coda/psdev.c
diff options
context:
space:
mode:
authorYoshihisa Abe <yoshiabe@cs.cmu.edu>2010-10-25 02:03:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-25 11:02:40 -0400
commitda47c19e5c746829042933c8f945a71e2b62d6fc (patch)
tree54110db260f57c01745e1ace343ec72b7eec6c69 /fs/coda/psdev.c
parentf7cc02b8715618e179242ba9cc10bdc5146ae565 (diff)
Coda: replace BKL with mutex
Replace the BKL with a mutex to protect the venus_comm structure which binds the mountpoint with the character device and holds the upcall queues. Signed-off-by: Yoshihisa Abe <yoshiabe@cs.cmu.edu> Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/coda/psdev.c')
-rw-r--r--fs/coda/psdev.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 9a9248e632c6..62647a8595e4 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -35,7 +35,7 @@
35#include <linux/poll.h> 35#include <linux/poll.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/list.h> 37#include <linux/list.h>
38#include <linux/smp_lock.h> 38#include <linux/mutex.h>
39#include <linux/device.h> 39#include <linux/device.h>
40#include <asm/io.h> 40#include <asm/io.h>
41#include <asm/system.h> 41#include <asm/system.h>
@@ -67,8 +67,10 @@ static unsigned int coda_psdev_poll(struct file *file, poll_table * wait)
67 unsigned int mask = POLLOUT | POLLWRNORM; 67 unsigned int mask = POLLOUT | POLLWRNORM;
68 68
69 poll_wait(file, &vcp->vc_waitq, wait); 69 poll_wait(file, &vcp->vc_waitq, wait);
70 mutex_lock(&vcp->vc_mutex);
70 if (!list_empty(&vcp->vc_pending)) 71 if (!list_empty(&vcp->vc_pending))
71 mask |= POLLIN | POLLRDNORM; 72 mask |= POLLIN | POLLRDNORM;
73 mutex_unlock(&vcp->vc_mutex);
72 74
73 return mask; 75 return mask;
74} 76}
@@ -143,7 +145,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
143 } 145 }
144 146
145 /* Look for the message on the processing queue. */ 147 /* Look for the message on the processing queue. */
146 lock_kernel(); 148 mutex_lock(&vcp->vc_mutex);
147 list_for_each(lh, &vcp->vc_processing) { 149 list_for_each(lh, &vcp->vc_processing) {
148 tmp = list_entry(lh, struct upc_req , uc_chain); 150 tmp = list_entry(lh, struct upc_req , uc_chain);
149 if (tmp->uc_unique == hdr.unique) { 151 if (tmp->uc_unique == hdr.unique) {
@@ -152,7 +154,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
152 break; 154 break;
153 } 155 }
154 } 156 }
155 unlock_kernel(); 157 mutex_unlock(&vcp->vc_mutex);
156 158
157 if (!req) { 159 if (!req) {
158 printk("psdev_write: msg (%d, %d) not found\n", 160 printk("psdev_write: msg (%d, %d) not found\n",
@@ -207,7 +209,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf,
207 if (nbytes == 0) 209 if (nbytes == 0)
208 return 0; 210 return 0;
209 211
210 lock_kernel(); 212 mutex_lock(&vcp->vc_mutex);
211 213
212 add_wait_queue(&vcp->vc_waitq, &wait); 214 add_wait_queue(&vcp->vc_waitq, &wait);
213 set_current_state(TASK_INTERRUPTIBLE); 215 set_current_state(TASK_INTERRUPTIBLE);
@@ -221,7 +223,9 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf,
221 retval = -ERESTARTSYS; 223 retval = -ERESTARTSYS;
222 break; 224 break;
223 } 225 }
226 mutex_unlock(&vcp->vc_mutex);
224 schedule(); 227 schedule();
228 mutex_lock(&vcp->vc_mutex);
225 } 229 }
226 230
227 set_current_state(TASK_RUNNING); 231 set_current_state(TASK_RUNNING);
@@ -254,7 +258,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf,
254 CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr)); 258 CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr));
255 kfree(req); 259 kfree(req);
256out: 260out:
257 unlock_kernel(); 261 mutex_unlock(&vcp->vc_mutex);
258 return (count ? count : retval); 262 return (count ? count : retval);
259} 263}
260 264
@@ -267,10 +271,10 @@ static int coda_psdev_open(struct inode * inode, struct file * file)
267 if (idx < 0 || idx >= MAX_CODADEVS) 271 if (idx < 0 || idx >= MAX_CODADEVS)
268 return -ENODEV; 272 return -ENODEV;
269 273
270 lock_kernel();
271
272 err = -EBUSY; 274 err = -EBUSY;
273 vcp = &coda_comms[idx]; 275 vcp = &coda_comms[idx];
276 mutex_lock(&vcp->vc_mutex);
277
274 if (!vcp->vc_inuse) { 278 if (!vcp->vc_inuse) {
275 vcp->vc_inuse++; 279 vcp->vc_inuse++;
276 280
@@ -284,7 +288,7 @@ static int coda_psdev_open(struct inode * inode, struct file * file)
284 err = 0; 288 err = 0;
285 } 289 }
286 290
287 unlock_kernel(); 291 mutex_unlock(&vcp->vc_mutex);
288 return err; 292 return err;
289} 293}
290 294
@@ -299,7 +303,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file)
299 return -1; 303 return -1;
300 } 304 }
301 305
302 lock_kernel(); 306 mutex_lock(&vcp->vc_mutex);
303 307
304 /* Wakeup clients so they can return. */ 308 /* Wakeup clients so they can return. */
305 list_for_each_entry_safe(req, tmp, &vcp->vc_pending, uc_chain) { 309 list_for_each_entry_safe(req, tmp, &vcp->vc_pending, uc_chain) {
@@ -324,7 +328,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file)
324 328
325 file->private_data = NULL; 329 file->private_data = NULL;
326 vcp->vc_inuse--; 330 vcp->vc_inuse--;
327 unlock_kernel(); 331 mutex_unlock(&vcp->vc_mutex);
328 return 0; 332 return 0;
329} 333}
330 334
@@ -353,9 +357,11 @@ static int init_coda_psdev(void)
353 err = PTR_ERR(coda_psdev_class); 357 err = PTR_ERR(coda_psdev_class);
354 goto out_chrdev; 358 goto out_chrdev;
355 } 359 }
356 for (i = 0; i < MAX_CODADEVS; i++) 360 for (i = 0; i < MAX_CODADEVS; i++) {
361 mutex_init(&(&coda_comms[i])->vc_mutex);
357 device_create(coda_psdev_class, NULL, 362 device_create(coda_psdev_class, NULL,
358 MKDEV(CODA_PSDEV_MAJOR, i), NULL, "cfs%d", i); 363 MKDEV(CODA_PSDEV_MAJOR, i), NULL, "cfs%d", i);
364 }
359 coda_sysctl_init(); 365 coda_sysctl_init();
360 goto out; 366 goto out;
361 367