diff options
Diffstat (limited to 'fs/9p/mux.c')
-rw-r--r-- | fs/9p/mux.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/fs/9p/mux.c b/fs/9p/mux.c index ea1134eb47c8..3e5b124a7212 100644 --- a/fs/9p/mux.c +++ b/fs/9p/mux.c | |||
@@ -7,9 +7,8 @@ | |||
7 | * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net> | 7 | * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net> |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License version 2 |
11 | * the Free Software Foundation; either version 2 of the License, or | 11 | * as published by the Free Software Foundation. |
12 | * (at your option) any later version. | ||
13 | * | 12 | * |
14 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
@@ -31,6 +30,7 @@ | |||
31 | #include <linux/poll.h> | 30 | #include <linux/poll.h> |
32 | #include <linux/kthread.h> | 31 | #include <linux/kthread.h> |
33 | #include <linux/idr.h> | 32 | #include <linux/idr.h> |
33 | #include <linux/mutex.h> | ||
34 | 34 | ||
35 | #include "debug.h" | 35 | #include "debug.h" |
36 | #include "v9fs.h" | 36 | #include "v9fs.h" |
@@ -69,7 +69,7 @@ struct v9fs_mux_data { | |||
69 | int msize; | 69 | int msize; |
70 | unsigned char *extended; | 70 | unsigned char *extended; |
71 | struct v9fs_transport *trans; | 71 | struct v9fs_transport *trans; |
72 | struct v9fs_idpool tidpool; | 72 | struct v9fs_idpool tagpool; |
73 | int err; | 73 | int err; |
74 | wait_queue_head_t equeue; | 74 | wait_queue_head_t equeue; |
75 | struct list_head req_list; | 75 | struct list_head req_list; |
@@ -110,7 +110,7 @@ static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address, | |||
110 | static u16 v9fs_mux_get_tag(struct v9fs_mux_data *); | 110 | static u16 v9fs_mux_get_tag(struct v9fs_mux_data *); |
111 | static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16); | 111 | static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16); |
112 | 112 | ||
113 | static DECLARE_MUTEX(v9fs_mux_task_lock); | 113 | static DEFINE_MUTEX(v9fs_mux_task_lock); |
114 | static struct workqueue_struct *v9fs_mux_wq; | 114 | static struct workqueue_struct *v9fs_mux_wq; |
115 | 115 | ||
116 | static int v9fs_mux_num; | 116 | static int v9fs_mux_num; |
@@ -142,7 +142,7 @@ void v9fs_mux_global_exit(void) | |||
142 | * | 142 | * |
143 | * The current implementation returns sqrt of the number of mounts. | 143 | * The current implementation returns sqrt of the number of mounts. |
144 | */ | 144 | */ |
145 | inline int v9fs_mux_calc_poll_procs(int muxnum) | 145 | static int v9fs_mux_calc_poll_procs(int muxnum) |
146 | { | 146 | { |
147 | int n; | 147 | int n; |
148 | 148 | ||
@@ -166,7 +166,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m) | |||
166 | 166 | ||
167 | dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num, | 167 | dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num, |
168 | v9fs_mux_poll_task_num); | 168 | v9fs_mux_poll_task_num); |
169 | up(&v9fs_mux_task_lock); | 169 | mutex_lock(&v9fs_mux_task_lock); |
170 | 170 | ||
171 | n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1); | 171 | n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1); |
172 | if (n > v9fs_mux_poll_task_num) { | 172 | if (n > v9fs_mux_poll_task_num) { |
@@ -225,7 +225,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m) | |||
225 | } | 225 | } |
226 | 226 | ||
227 | v9fs_mux_num++; | 227 | v9fs_mux_num++; |
228 | down(&v9fs_mux_task_lock); | 228 | mutex_unlock(&v9fs_mux_task_lock); |
229 | 229 | ||
230 | return 0; | 230 | return 0; |
231 | } | 231 | } |
@@ -235,7 +235,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m) | |||
235 | int i; | 235 | int i; |
236 | struct v9fs_mux_poll_task *vpt; | 236 | struct v9fs_mux_poll_task *vpt; |
237 | 237 | ||
238 | up(&v9fs_mux_task_lock); | 238 | mutex_lock(&v9fs_mux_task_lock); |
239 | vpt = m->poll_task; | 239 | vpt = m->poll_task; |
240 | list_del(&m->mux_list); | 240 | list_del(&m->mux_list); |
241 | for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { | 241 | for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { |
@@ -252,7 +252,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m) | |||
252 | v9fs_mux_poll_task_num--; | 252 | v9fs_mux_poll_task_num--; |
253 | } | 253 | } |
254 | v9fs_mux_num--; | 254 | v9fs_mux_num--; |
255 | down(&v9fs_mux_task_lock); | 255 | mutex_unlock(&v9fs_mux_task_lock); |
256 | } | 256 | } |
257 | 257 | ||
258 | /** | 258 | /** |
@@ -279,8 +279,8 @@ struct v9fs_mux_data *v9fs_mux_init(struct v9fs_transport *trans, int msize, | |||
279 | m->msize = msize; | 279 | m->msize = msize; |
280 | m->extended = extended; | 280 | m->extended = extended; |
281 | m->trans = trans; | 281 | m->trans = trans; |
282 | idr_init(&m->tidpool.pool); | 282 | idr_init(&m->tagpool.pool); |
283 | init_MUTEX(&m->tidpool.lock); | 283 | init_MUTEX(&m->tagpool.lock); |
284 | m->err = 0; | 284 | m->err = 0; |
285 | init_waitqueue_head(&m->equeue); | 285 | init_waitqueue_head(&m->equeue); |
286 | INIT_LIST_HEAD(&m->req_list); | 286 | INIT_LIST_HEAD(&m->req_list); |
@@ -383,7 +383,7 @@ v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address, | |||
383 | /** | 383 | /** |
384 | * v9fs_poll_mux - polls a mux and schedules read or write works if necessary | 384 | * v9fs_poll_mux - polls a mux and schedules read or write works if necessary |
385 | */ | 385 | */ |
386 | static inline void v9fs_poll_mux(struct v9fs_mux_data *m) | 386 | static void v9fs_poll_mux(struct v9fs_mux_data *m) |
387 | { | 387 | { |
388 | int n; | 388 | int n; |
389 | 389 | ||
@@ -634,6 +634,14 @@ static void v9fs_read_work(void *a) | |||
634 | goto error; | 634 | goto error; |
635 | } | 635 | } |
636 | 636 | ||
637 | if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) { | ||
638 | char buf[150]; | ||
639 | |||
640 | v9fs_printfcall(buf, sizeof(buf), m->rcall, | ||
641 | *m->extended); | ||
642 | printk(KERN_NOTICE ">>> %p %s\n", m, buf); | ||
643 | } | ||
644 | |||
637 | rcall = m->rcall; | 645 | rcall = m->rcall; |
638 | rbuf = m->rbuf; | 646 | rbuf = m->rbuf; |
639 | if (m->rpos > n) { | 647 | if (m->rpos > n) { |
@@ -739,6 +747,13 @@ static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m, | |||
739 | 747 | ||
740 | v9fs_set_tag(tc, n); | 748 | v9fs_set_tag(tc, n); |
741 | 749 | ||
750 | if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) { | ||
751 | char buf[150]; | ||
752 | |||
753 | v9fs_printfcall(buf, sizeof(buf), tc, *m->extended); | ||
754 | printk(KERN_NOTICE "<<< %p %s\n", m, buf); | ||
755 | } | ||
756 | |||
742 | req->tag = n; | 757 | req->tag = n; |
743 | req->tcall = tc; | 758 | req->tcall = tc; |
744 | req->rcall = NULL; | 759 | req->rcall = NULL; |
@@ -761,9 +776,8 @@ static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m, | |||
761 | return req; | 776 | return req; |
762 | } | 777 | } |
763 | 778 | ||
764 | static inline void | 779 | static void v9fs_mux_flush_cb(void *a, struct v9fs_fcall *tc, |
765 | v9fs_mux_flush_cb(void *a, struct v9fs_fcall *tc, struct v9fs_fcall *rc, | 780 | struct v9fs_fcall *rc, int err) |
766 | int err) | ||
767 | { | 781 | { |
768 | v9fs_mux_req_callback cb; | 782 | v9fs_mux_req_callback cb; |
769 | int tag; | 783 | int tag; |
@@ -901,6 +915,7 @@ v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc, | |||
901 | return err; | 915 | return err; |
902 | } | 916 | } |
903 | 917 | ||
918 | #if 0 | ||
904 | /** | 919 | /** |
905 | * v9fs_mux_rpcnb - sends 9P request without waiting for response. | 920 | * v9fs_mux_rpcnb - sends 9P request without waiting for response. |
906 | * @m: mux data | 921 | * @m: mux data |
@@ -924,6 +939,7 @@ int v9fs_mux_rpcnb(struct v9fs_mux_data *m, struct v9fs_fcall *tc, | |||
924 | dprintk(DEBUG_MUX, "mux %p tc %p tag %d\n", m, tc, req->tag); | 939 | dprintk(DEBUG_MUX, "mux %p tc %p tag %d\n", m, tc, req->tag); |
925 | return 0; | 940 | return 0; |
926 | } | 941 | } |
942 | #endif /* 0 */ | ||
927 | 943 | ||
928 | /** | 944 | /** |
929 | * v9fs_mux_cancel - cancel all pending requests with error | 945 | * v9fs_mux_cancel - cancel all pending requests with error |
@@ -963,7 +979,7 @@ static u16 v9fs_mux_get_tag(struct v9fs_mux_data *m) | |||
963 | { | 979 | { |
964 | int tag; | 980 | int tag; |
965 | 981 | ||
966 | tag = v9fs_get_idpool(&m->tidpool); | 982 | tag = v9fs_get_idpool(&m->tagpool); |
967 | if (tag < 0) | 983 | if (tag < 0) |
968 | return V9FS_NOTAG; | 984 | return V9FS_NOTAG; |
969 | else | 985 | else |
@@ -972,6 +988,6 @@ static u16 v9fs_mux_get_tag(struct v9fs_mux_data *m) | |||
972 | 988 | ||
973 | static void v9fs_mux_put_tag(struct v9fs_mux_data *m, u16 tag) | 989 | static void v9fs_mux_put_tag(struct v9fs_mux_data *m, u16 tag) |
974 | { | 990 | { |
975 | if (tag != V9FS_NOTAG && v9fs_check_idpool(tag, &m->tidpool)) | 991 | if (tag != V9FS_NOTAG && v9fs_check_idpool(tag, &m->tagpool)) |
976 | v9fs_put_idpool(tag, &m->tidpool); | 992 | v9fs_put_idpool(tag, &m->tagpool); |
977 | } | 993 | } |