6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
7 * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to:
20 * Free Software Foundation
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02111-1301 USA
26 #include <linux/module.h>
27 #include <linux/errno.h>
29 #include <linux/poll.h>
30 #include <linux/kthread.h>
31 #include <linux/idr.h>
32 #include <linux/mutex.h>
38 #include "transport.h"
42 #define SCHED_TIMEOUT 10
43 #define MAXPOLLWADDR 2
46 Rworksched = 1, /* read work scheduled or running */
47 Rpending = 2, /* can read */
48 Wworksched = 4, /* write work scheduled or running */
49 Wpending = 8, /* can write */
58 struct v9fs_mux_poll_task;
63 struct v9fs_fcall *tcall;
64 struct v9fs_fcall *rcall;
66 v9fs_mux_req_callback cb;
69 struct list_head req_list;
72 struct v9fs_mux_data {
74 struct list_head mux_list;
75 struct v9fs_mux_poll_task *poll_task;
77 unsigned char *extended;
78 struct v9fs_transport *trans;
79 struct v9fs_idpool tagpool;
81 wait_queue_head_t equeue;
82 struct list_head req_list;
83 struct list_head unsent_req_list;
84 struct v9fs_fcall *rcall;
90 wait_queue_t poll_wait[MAXPOLLWADDR];
91 wait_queue_head_t *poll_waddr[MAXPOLLWADDR];
93 struct work_struct rq;
94 struct work_struct wq;
98 struct v9fs_mux_poll_task {
99 struct task_struct *task;
100 struct list_head mux_list;
104 struct v9fs_mux_rpc {
105 struct v9fs_mux_data *m;
107 struct v9fs_fcall *tcall;
108 struct v9fs_fcall *rcall;
109 wait_queue_head_t wqueue;
112 static int v9fs_poll_proc(void *);
113 static void v9fs_read_work(struct work_struct *work);
114 static void v9fs_write_work(struct work_struct *work);
115 static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
117 static u16 v9fs_mux_get_tag(struct v9fs_mux_data *);
118 static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16);
120 static DEFINE_MUTEX(v9fs_mux_task_lock);
121 static struct workqueue_struct *v9fs_mux_wq;
123 static int v9fs_mux_num;
124 static int v9fs_mux_poll_task_num;
125 static struct v9fs_mux_poll_task v9fs_mux_poll_tasks[100];
127 int v9fs_mux_global_init(void)
131 for (i = 0; i < ARRAY_SIZE(v9fs_mux_poll_tasks); i++)
132 v9fs_mux_poll_tasks[i].task = NULL;
134 v9fs_mux_wq = create_workqueue("v9fs");
136 printk(KERN_WARNING "v9fs: mux: creating workqueue failed\n");
143 void v9fs_mux_global_exit(void)
145 destroy_workqueue(v9fs_mux_wq);
149 * v9fs_mux_calc_poll_procs - calculates the number of polling procs
150 * based on the number of mounted v9fs filesystems.
152 * The current implementation returns sqrt of the number of mounts.
154 static int v9fs_mux_calc_poll_procs(int muxnum)
158 if (v9fs_mux_poll_task_num)
159 n = muxnum / v9fs_mux_poll_task_num +
160 (muxnum % v9fs_mux_poll_task_num ? 1 : 0);
164 if (n > ARRAY_SIZE(v9fs_mux_poll_tasks))
165 n = ARRAY_SIZE(v9fs_mux_poll_tasks);
170 static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
173 struct v9fs_mux_poll_task *vpt, *vptlast;
174 struct task_struct *pproc;
176 dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num,
177 v9fs_mux_poll_task_num);
178 mutex_lock(&v9fs_mux_task_lock);
180 n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1);
181 if (n > v9fs_mux_poll_task_num) {
182 for (i = 0; i < ARRAY_SIZE(v9fs_mux_poll_tasks); i++) {
183 if (v9fs_mux_poll_tasks[i].task == NULL) {
184 vpt = &v9fs_mux_poll_tasks[i];
185 dprintk(DEBUG_MUX, "create proc %p\n", vpt);
186 pproc = kthread_create(v9fs_poll_proc, vpt,
189 if (!IS_ERR(pproc)) {
191 INIT_LIST_HEAD(&vpt->mux_list);
193 v9fs_mux_poll_task_num++;
194 wake_up_process(vpt->task);
200 if (i >= ARRAY_SIZE(v9fs_mux_poll_tasks))
201 dprintk(DEBUG_ERROR, "warning: no free poll slots\n");
204 n = (v9fs_mux_num + 1) / v9fs_mux_poll_task_num +
205 ((v9fs_mux_num + 1) % v9fs_mux_poll_task_num ? 1 : 0);
208 for (i = 0; i < ARRAY_SIZE(v9fs_mux_poll_tasks); i++) {
209 vpt = &v9fs_mux_poll_tasks[i];
210 if (vpt->task != NULL) {
212 if (vpt->muxnum < n) {
213 dprintk(DEBUG_MUX, "put in proc %d\n", i);
214 list_add(&m->mux_list, &vpt->mux_list);
217 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
218 init_poll_funcptr(&m->pt, v9fs_pollwait);
224 if (i >= ARRAY_SIZE(v9fs_mux_poll_tasks)) {
228 dprintk(DEBUG_MUX, "put in proc %d\n", i);
229 list_add(&m->mux_list, &vptlast->mux_list);
231 m->poll_task = vptlast;
232 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
233 init_poll_funcptr(&m->pt, v9fs_pollwait);
237 mutex_unlock(&v9fs_mux_task_lock);
242 static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
245 struct v9fs_mux_poll_task *vpt;
247 mutex_lock(&v9fs_mux_task_lock);
249 list_del(&m->mux_list);
250 for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) {
251 if (m->poll_waddr[i] != NULL) {
252 remove_wait_queue(m->poll_waddr[i], &m->poll_wait[i]);
253 m->poll_waddr[i] = NULL;
258 dprintk(DEBUG_MUX, "destroy proc %p\n", vpt);
259 kthread_stop(vpt->task);
261 v9fs_mux_poll_task_num--;
264 mutex_unlock(&v9fs_mux_task_lock);
268 * v9fs_mux_init - allocate and initialize the per-session mux data
269 * Creates the polling task if this is the first session.
271 * @trans - transport structure
272 * @msize - maximum message size
273 * @extended - pointer to the extended flag
275 struct v9fs_mux_data *v9fs_mux_init(struct v9fs_transport *trans, int msize,
276 unsigned char *extended)
279 struct v9fs_mux_data *m, *mtmp;
281 dprintk(DEBUG_MUX, "transport %p msize %d\n", trans, msize);
282 m = kmalloc(sizeof(struct v9fs_mux_data), GFP_KERNEL);
284 return ERR_PTR(-ENOMEM);
286 spin_lock_init(&m->lock);
287 INIT_LIST_HEAD(&m->mux_list);
289 m->extended = extended;
291 idr_init(&m->tagpool.pool);
292 init_MUTEX(&m->tagpool.lock);
294 init_waitqueue_head(&m->equeue);
295 INIT_LIST_HEAD(&m->req_list);
296 INIT_LIST_HEAD(&m->unsent_req_list);
300 m->wpos = m->wsize = 0;
302 INIT_WORK(&m->rq, v9fs_read_work);
303 INIT_WORK(&m->wq, v9fs_write_work);
305 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
307 n = v9fs_mux_poll_start(m);
311 n = trans->poll(trans, &m->pt);
313 dprintk(DEBUG_MUX, "mux %p can read\n", m);
314 set_bit(Rpending, &m->wsched);
318 dprintk(DEBUG_MUX, "mux %p can write\n", m);
319 set_bit(Wpending, &m->wsched);
322 for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) {
323 if (IS_ERR(m->poll_waddr[i])) {
324 v9fs_mux_poll_stop(m);
325 mtmp = (void *)m->poll_waddr; /* the error code */
336 * v9fs_mux_destroy - cancels all pending requests and frees mux resources
338 void v9fs_mux_destroy(struct v9fs_mux_data *m)
340 dprintk(DEBUG_MUX, "mux %p prev %p next %p\n", m,
341 m->mux_list.prev, m->mux_list.next);
342 v9fs_mux_cancel(m, -ECONNRESET);
344 if (!list_empty(&m->req_list)) {
345 /* wait until all processes waiting on this session exit */
346 dprintk(DEBUG_MUX, "mux %p waiting for empty request queue\n",
348 wait_event_timeout(m->equeue, (list_empty(&m->req_list)), 5000);
349 dprintk(DEBUG_MUX, "mux %p request queue empty: %d\n", m,
350 list_empty(&m->req_list));
353 v9fs_mux_poll_stop(m);
360 * v9fs_pollwait - called by files poll operation to add v9fs-poll task
361 * to files wait queue
364 v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
368 struct v9fs_mux_data *m;
370 m = container_of(p, struct v9fs_mux_data, pt);
371 for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++)
372 if (m->poll_waddr[i] == NULL)
375 if (i >= ARRAY_SIZE(m->poll_waddr)) {
376 dprintk(DEBUG_ERROR, "not enough wait_address slots\n");
380 m->poll_waddr[i] = wait_address;
383 dprintk(DEBUG_ERROR, "no wait_address\n");
384 m->poll_waddr[i] = ERR_PTR(-EIO);
388 init_waitqueue_entry(&m->poll_wait[i], m->poll_task->task);
389 add_wait_queue(wait_address, &m->poll_wait[i]);
393 * v9fs_poll_mux - polls a mux and schedules read or write works if necessary
395 static void v9fs_poll_mux(struct v9fs_mux_data *m)
402 n = m->trans->poll(m->trans, NULL);
403 if (n < 0 || n & (POLLERR | POLLHUP | POLLNVAL)) {
404 dprintk(DEBUG_MUX, "error mux %p err %d\n", m, n);
407 v9fs_mux_cancel(m, n);
411 set_bit(Rpending, &m->wsched);
412 dprintk(DEBUG_MUX, "mux %p can read\n", m);
413 if (!test_and_set_bit(Rworksched, &m->wsched)) {
414 dprintk(DEBUG_MUX, "schedule read work mux %p\n", m);
415 queue_work(v9fs_mux_wq, &m->rq);
420 set_bit(Wpending, &m->wsched);
421 dprintk(DEBUG_MUX, "mux %p can write\n", m);
422 if ((m->wsize || !list_empty(&m->unsent_req_list))
423 && !test_and_set_bit(Wworksched, &m->wsched)) {
424 dprintk(DEBUG_MUX, "schedule write work mux %p\n", m);
425 queue_work(v9fs_mux_wq, &m->wq);
431 * v9fs_poll_proc - polls all v9fs transports for new events and queues
432 * the appropriate work to the work queue
434 static int v9fs_poll_proc(void *a)
436 struct v9fs_mux_data *m, *mtmp;
437 struct v9fs_mux_poll_task *vpt;
440 dprintk(DEBUG_MUX, "start %p %p\n", current, vpt);
441 while (!kthread_should_stop()) {
442 set_current_state(TASK_INTERRUPTIBLE);
444 list_for_each_entry_safe(m, mtmp, &vpt->mux_list, mux_list) {
448 dprintk(DEBUG_MUX, "sleeping...\n");
449 schedule_timeout(SCHED_TIMEOUT * HZ);
452 __set_current_state(TASK_RUNNING);
453 dprintk(DEBUG_MUX, "finish\n");
458 * v9fs_write_work - called when a transport can send some data
460 static void v9fs_write_work(struct work_struct *work)
463 struct v9fs_mux_data *m;
464 struct v9fs_req *req;
466 m = container_of(work, struct v9fs_mux_data, wq);
469 clear_bit(Wworksched, &m->wsched);
474 if (list_empty(&m->unsent_req_list)) {
475 clear_bit(Wworksched, &m->wsched);
481 req = list_entry(m->unsent_req_list.next, struct v9fs_req,
483 list_move_tail(&req->req_list, &m->req_list);
484 if (req->err == ERREQFLUSH)
487 m->wbuf = req->tcall->sdata;
488 m->wsize = req->tcall->size;
490 dump_data(m->wbuf, m->wsize);
491 spin_unlock(&m->lock);
494 dprintk(DEBUG_MUX, "mux %p pos %d size %d\n", m, m->wpos, m->wsize);
495 clear_bit(Wpending, &m->wsched);
496 err = m->trans->write(m->trans, m->wbuf + m->wpos, m->wsize - m->wpos);
497 dprintk(DEBUG_MUX, "mux %p sent %d bytes\n", m, err);
498 if (err == -EAGAIN) {
499 clear_bit(Wworksched, &m->wsched);
507 if (m->wpos == m->wsize)
508 m->wpos = m->wsize = 0;
510 if (m->wsize == 0 && !list_empty(&m->unsent_req_list)) {
511 if (test_and_clear_bit(Wpending, &m->wsched))
514 n = m->trans->poll(m->trans, NULL);
517 dprintk(DEBUG_MUX, "schedule write work mux %p\n", m);
518 queue_work(v9fs_mux_wq, &m->wq);
520 clear_bit(Wworksched, &m->wsched);
522 clear_bit(Wworksched, &m->wsched);
527 v9fs_mux_cancel(m, err);
528 clear_bit(Wworksched, &m->wsched);
531 static void process_request(struct v9fs_mux_data *m, struct v9fs_req *req)
534 struct v9fs_str *ename;
536 if (!req->err && req->rcall->id == RERROR) {
537 ecode = req->rcall->params.rerror.errno;
538 ename = &req->rcall->params.rerror.error;
540 dprintk(DEBUG_MUX, "Rerror %.*s\n", ename->len, ename->str);
546 req->err = v9fs_errstr2errno(ename->str, ename->len);
548 if (!req->err) { /* string match failed */
549 PRINT_FCALL_ERROR("unknown error", req->rcall);
553 req->err = -ESERVERFAULT;
555 } else if (req->tcall && req->rcall->id != req->tcall->id + 1) {
556 dprintk(DEBUG_ERROR, "fcall mismatch: expected %d, got %d\n",
557 req->tcall->id + 1, req->rcall->id);
564 * v9fs_read_work - called when there is some data to be read from a transport
566 static void v9fs_read_work(struct work_struct *work)
569 struct v9fs_mux_data *m;
570 struct v9fs_req *req, *rptr, *rreq;
571 struct v9fs_fcall *rcall;
574 m = container_of(work, struct v9fs_mux_data, rq);
580 dprintk(DEBUG_MUX, "start mux %p pos %d\n", m, m->rpos);
584 kmalloc(sizeof(struct v9fs_fcall) + m->msize, GFP_KERNEL);
590 m->rbuf = (char *)m->rcall + sizeof(struct v9fs_fcall);
594 clear_bit(Rpending, &m->wsched);
595 err = m->trans->read(m->trans, m->rbuf + m->rpos, m->msize - m->rpos);
596 dprintk(DEBUG_MUX, "mux %p got %d bytes\n", m, err);
597 if (err == -EAGAIN) {
598 clear_bit(Rworksched, &m->wsched);
606 while (m->rpos > 4) {
607 n = le32_to_cpu(*(__le32 *) m->rbuf);
610 "requested packet size too big: %d\n", n);
618 dump_data(m->rbuf, n);
620 v9fs_deserialize_fcall(m->rbuf, n, m->rcall, *m->extended);
625 if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) {
628 v9fs_printfcall(buf, sizeof(buf), m->rcall,
630 printk(KERN_NOTICE ">>> %p %s\n", m, buf);
636 m->rcall = kmalloc(sizeof(struct v9fs_fcall) + m->msize,
643 m->rbuf = (char *)m->rcall + sizeof(struct v9fs_fcall);
644 memmove(m->rbuf, rbuf + n, m->rpos - n);
652 dprintk(DEBUG_MUX, "mux %p fcall id %d tag %d\n", m, rcall->id,
657 list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) {
658 if (rreq->tag == rcall->tag) {
660 if (req->flush != Flushing)
661 list_del(&req->req_list);
665 spin_unlock(&m->lock);
669 process_request(m, req);
671 if (req->flush != Flushing) {
673 (*req->cb) (req, req->cba);
680 if (err >= 0 && rcall->id != RFLUSH)
682 "unexpected response mux %p id %d tag %d\n",
683 m, rcall->id, rcall->tag);
688 if (!list_empty(&m->req_list)) {
689 if (test_and_clear_bit(Rpending, &m->wsched))
692 n = m->trans->poll(m->trans, NULL);
695 dprintk(DEBUG_MUX, "schedule read work mux %p\n", m);
696 queue_work(v9fs_mux_wq, &m->rq);
698 clear_bit(Rworksched, &m->wsched);
700 clear_bit(Rworksched, &m->wsched);
705 v9fs_mux_cancel(m, err);
706 clear_bit(Rworksched, &m->wsched);
710 * v9fs_send_request - send 9P request
711 * The function can sleep until the request is scheduled for sending.
712 * The function can be interrupted. Return from the function is not
713 * a guarantee that the request is sent successfully. Can return errors
714 * that can be retrieved by PTR_ERR macros.
717 * @tc: request to be sent
718 * @cb: callback function to call when response is received
719 * @cba: parameter to pass to the callback function
721 static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m,
722 struct v9fs_fcall *tc,
723 v9fs_mux_req_callback cb, void *cba)
726 struct v9fs_req *req;
728 dprintk(DEBUG_MUX, "mux %p task %p tcall %p id %d\n", m, current,
731 return ERR_PTR(m->err);
733 req = kmalloc(sizeof(struct v9fs_req), GFP_KERNEL);
735 return ERR_PTR(-ENOMEM);
737 if (tc->id == TVERSION)
740 n = v9fs_mux_get_tag(m);
743 return ERR_PTR(-ENOMEM);
746 if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) {
749 v9fs_printfcall(buf, sizeof(buf), tc, *m->extended);
750 printk(KERN_NOTICE "<<< %p %s\n", m, buf);
753 spin_lock_init(&req->lock);
763 list_add_tail(&req->req_list, &m->unsent_req_list);
764 spin_unlock(&m->lock);
766 if (test_and_clear_bit(Wpending, &m->wsched))
769 n = m->trans->poll(m->trans, NULL);
771 if (n & POLLOUT && !test_and_set_bit(Wworksched, &m->wsched))
772 queue_work(v9fs_mux_wq, &m->wq);
777 static void v9fs_mux_free_request(struct v9fs_mux_data *m, struct v9fs_req *req)
779 v9fs_mux_put_tag(m, req->tag);
783 static void v9fs_mux_flush_cb(struct v9fs_req *freq, void *a)
785 v9fs_mux_req_callback cb;
787 struct v9fs_mux_data *m;
788 struct v9fs_req *req, *rreq, *rptr;
791 dprintk(DEBUG_MUX, "mux %p tc %p rc %p err %d oldtag %d\n", m,
792 freq->tcall, freq->rcall, freq->err,
793 freq->tcall->params.tflush.oldtag);
797 tag = freq->tcall->params.tflush.oldtag;
799 list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) {
800 if (rreq->tag == tag) {
802 list_del(&req->req_list);
806 spin_unlock(&m->lock);
809 spin_lock(&req->lock);
810 req->flush = Flushed;
811 spin_unlock(&req->lock);
814 (*req->cb) (req, req->cba);
823 v9fs_mux_free_request(m, freq);
827 v9fs_mux_flush_request(struct v9fs_mux_data *m, struct v9fs_req *req)
829 struct v9fs_fcall *fc;
830 struct v9fs_req *rreq, *rptr;
832 dprintk(DEBUG_MUX, "mux %p req %p tag %d\n", m, req, req->tag);
834 /* if a response was received for a request, do nothing */
835 spin_lock(&req->lock);
836 if (req->rcall || req->err) {
837 spin_unlock(&req->lock);
838 dprintk(DEBUG_MUX, "mux %p req %p response already received\n", m, req);
842 req->flush = Flushing;
843 spin_unlock(&req->lock);
846 /* if the request is not sent yet, just remove it from the list */
847 list_for_each_entry_safe(rreq, rptr, &m->unsent_req_list, req_list) {
848 if (rreq->tag == req->tag) {
849 dprintk(DEBUG_MUX, "mux %p req %p request is not sent yet\n", m, req);
850 list_del(&rreq->req_list);
851 req->flush = Flushed;
852 spin_unlock(&m->lock);
854 (*req->cb) (req, req->cba);
858 spin_unlock(&m->lock);
860 clear_thread_flag(TIF_SIGPENDING);
861 fc = v9fs_create_tflush(req->tag);
862 v9fs_send_request(m, fc, v9fs_mux_flush_cb, m);
867 v9fs_mux_rpc_cb(struct v9fs_req *req, void *a)
869 struct v9fs_mux_rpc *r;
871 dprintk(DEBUG_MUX, "req %p r %p\n", req, a);
873 r->rcall = req->rcall;
876 if (req->flush!=None && !req->err)
877 r->err = -ERESTARTSYS;
883 * v9fs_mux_rpc - sends 9P request and waits until a response is available.
884 * The function can be interrupted.
886 * @tc: request to be sent
887 * @rc: pointer where a pointer to the response is stored
890 v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
891 struct v9fs_fcall **rc)
895 struct v9fs_req *req;
896 struct v9fs_mux_rpc r;
902 init_waitqueue_head(&r.wqueue);
908 if (signal_pending(current)) {
910 clear_thread_flag(TIF_SIGPENDING);
913 req = v9fs_send_request(m, tc, v9fs_mux_rpc_cb, &r);
916 dprintk(DEBUG_MUX, "error %d\n", err);
920 err = wait_event_interruptible(r.wqueue, r.rcall != NULL || r.err < 0);
924 if (err == -ERESTARTSYS && m->trans->status == Connected && m->err == 0) {
925 if (v9fs_mux_flush_request(m, req)) {
926 /* wait until we get response of the flush message */
928 clear_thread_flag(TIF_SIGPENDING);
929 err = wait_event_interruptible(r.wqueue,
931 } while (!r.rcall && !r.err && err==-ERESTARTSYS &&
932 m->trans->status==Connected && !m->err);
940 spin_lock_irqsave(¤t->sighand->siglock, flags);
942 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
950 v9fs_mux_free_request(m, req);
959 * v9fs_mux_rpcnb - sends 9P request without waiting for response.
961 * @tc: request to be sent
962 * @cb: callback function to be called when response arrives
963 * @cba: value to pass to the callback function
965 int v9fs_mux_rpcnb(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
966 v9fs_mux_req_callback cb, void *a)
969 struct v9fs_req *req;
971 req = v9fs_send_request(m, tc, cb, a);
974 dprintk(DEBUG_MUX, "error %d\n", err);
978 dprintk(DEBUG_MUX, "mux %p tc %p tag %d\n", m, tc, req->tag);
984 * v9fs_mux_cancel - cancel all pending requests with error
988 void v9fs_mux_cancel(struct v9fs_mux_data *m, int err)
990 struct v9fs_req *req, *rtmp;
991 LIST_HEAD(cancel_list);
993 dprintk(DEBUG_ERROR, "mux %p err %d\n", m, err);
996 list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) {
997 list_move(&req->req_list, &cancel_list);
999 list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) {
1000 list_move(&req->req_list, &cancel_list);
1002 spin_unlock(&m->lock);
1004 list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) {
1005 list_del(&req->req_list);
1010 (*req->cb) (req, req->cba);
1015 wake_up(&m->equeue);
1018 static u16 v9fs_mux_get_tag(struct v9fs_mux_data *m)
1022 tag = v9fs_get_idpool(&m->tagpool);
1029 static void v9fs_mux_put_tag(struct v9fs_mux_data *m, u16 tag)
1031 if (tag != V9FS_NOTAG && v9fs_check_idpool(tag, &m->tagpool))
1032 v9fs_put_idpool(tag, &m->tagpool);