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/config.h>
27 #include <linux/module.h>
28 #include <linux/errno.h>
30 #include <linux/poll.h>
31 #include <linux/kthread.h>
32 #include <linux/idr.h>
33 #include <linux/mutex.h>
39 #include "transport.h"
43 #define SCHED_TIMEOUT 10
44 #define MAXPOLLWADDR 2
47 Rworksched = 1, /* read work scheduled or running */
48 Rpending = 2, /* can read */
49 Wworksched = 4, /* write work scheduled or running */
50 Wpending = 8, /* can write */
59 struct v9fs_mux_poll_task;
64 struct v9fs_fcall *tcall;
65 struct v9fs_fcall *rcall;
67 v9fs_mux_req_callback cb;
70 struct list_head req_list;
73 struct v9fs_mux_data {
75 struct list_head mux_list;
76 struct v9fs_mux_poll_task *poll_task;
78 unsigned char *extended;
79 struct v9fs_transport *trans;
80 struct v9fs_idpool tagpool;
82 wait_queue_head_t equeue;
83 struct list_head req_list;
84 struct list_head unsent_req_list;
85 struct v9fs_fcall *rcall;
91 wait_queue_t poll_wait[MAXPOLLWADDR];
92 wait_queue_head_t *poll_waddr[MAXPOLLWADDR];
94 struct work_struct rq;
95 struct work_struct wq;
99 struct v9fs_mux_poll_task {
100 struct task_struct *task;
101 struct list_head mux_list;
105 struct v9fs_mux_rpc {
106 struct v9fs_mux_data *m;
108 struct v9fs_fcall *tcall;
109 struct v9fs_fcall *rcall;
110 wait_queue_head_t wqueue;
113 static int v9fs_poll_proc(void *);
114 static void v9fs_read_work(void *);
115 static void v9fs_write_work(void *);
116 static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
118 static u16 v9fs_mux_get_tag(struct v9fs_mux_data *);
119 static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16);
121 static DEFINE_MUTEX(v9fs_mux_task_lock);
122 static struct workqueue_struct *v9fs_mux_wq;
124 static int v9fs_mux_num;
125 static int v9fs_mux_poll_task_num;
126 static struct v9fs_mux_poll_task v9fs_mux_poll_tasks[100];
128 int v9fs_mux_global_init(void)
132 for (i = 0; i < ARRAY_SIZE(v9fs_mux_poll_tasks); i++)
133 v9fs_mux_poll_tasks[i].task = NULL;
135 v9fs_mux_wq = create_workqueue("v9fs");
142 void v9fs_mux_global_exit(void)
144 destroy_workqueue(v9fs_mux_wq);
148 * v9fs_mux_calc_poll_procs - calculates the number of polling procs
149 * based on the number of mounted v9fs filesystems.
151 * The current implementation returns sqrt of the number of mounts.
153 static int v9fs_mux_calc_poll_procs(int muxnum)
157 if (v9fs_mux_poll_task_num)
158 n = muxnum / v9fs_mux_poll_task_num +
159 (muxnum % v9fs_mux_poll_task_num ? 1 : 0);
163 if (n > ARRAY_SIZE(v9fs_mux_poll_tasks))
164 n = ARRAY_SIZE(v9fs_mux_poll_tasks);
169 static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
172 struct v9fs_mux_poll_task *vpt, *vptlast;
173 struct task_struct *pproc;
175 dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num,
176 v9fs_mux_poll_task_num);
177 mutex_lock(&v9fs_mux_task_lock);
179 n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1);
180 if (n > v9fs_mux_poll_task_num) {
181 for (i = 0; i < ARRAY_SIZE(v9fs_mux_poll_tasks); i++) {
182 if (v9fs_mux_poll_tasks[i].task == NULL) {
183 vpt = &v9fs_mux_poll_tasks[i];
184 dprintk(DEBUG_MUX, "create proc %p\n", vpt);
185 pproc = kthread_create(v9fs_poll_proc, vpt,
188 if (!IS_ERR(pproc)) {
190 INIT_LIST_HEAD(&vpt->mux_list);
192 v9fs_mux_poll_task_num++;
193 wake_up_process(vpt->task);
199 if (i >= ARRAY_SIZE(v9fs_mux_poll_tasks))
200 dprintk(DEBUG_ERROR, "warning: no free poll slots\n");
203 n = (v9fs_mux_num + 1) / v9fs_mux_poll_task_num +
204 ((v9fs_mux_num + 1) % v9fs_mux_poll_task_num ? 1 : 0);
207 for (i = 0; i < ARRAY_SIZE(v9fs_mux_poll_tasks); i++) {
208 vpt = &v9fs_mux_poll_tasks[i];
209 if (vpt->task != NULL) {
211 if (vpt->muxnum < n) {
212 dprintk(DEBUG_MUX, "put in proc %d\n", i);
213 list_add(&m->mux_list, &vpt->mux_list);
216 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
217 init_poll_funcptr(&m->pt, v9fs_pollwait);
223 if (i >= ARRAY_SIZE(v9fs_mux_poll_tasks)) {
227 dprintk(DEBUG_MUX, "put in proc %d\n", i);
228 list_add(&m->mux_list, &vptlast->mux_list);
230 m->poll_task = vptlast;
231 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
232 init_poll_funcptr(&m->pt, v9fs_pollwait);
236 mutex_unlock(&v9fs_mux_task_lock);
241 static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
244 struct v9fs_mux_poll_task *vpt;
246 mutex_lock(&v9fs_mux_task_lock);
248 list_del(&m->mux_list);
249 for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) {
250 if (m->poll_waddr[i] != NULL) {
251 remove_wait_queue(m->poll_waddr[i], &m->poll_wait[i]);
252 m->poll_waddr[i] = NULL;
257 dprintk(DEBUG_MUX, "destroy proc %p\n", vpt);
258 send_sig(SIGKILL, vpt->task, 1);
260 v9fs_mux_poll_task_num--;
263 mutex_unlock(&v9fs_mux_task_lock);
267 * v9fs_mux_init - allocate and initialize the per-session mux data
268 * Creates the polling task if this is the first session.
270 * @trans - transport structure
271 * @msize - maximum message size
272 * @extended - pointer to the extended flag
274 struct v9fs_mux_data *v9fs_mux_init(struct v9fs_transport *trans, int msize,
275 unsigned char *extended)
278 struct v9fs_mux_data *m, *mtmp;
280 dprintk(DEBUG_MUX, "transport %p msize %d\n", trans, msize);
281 m = kmalloc(sizeof(struct v9fs_mux_data), GFP_KERNEL);
283 return ERR_PTR(-ENOMEM);
285 spin_lock_init(&m->lock);
286 INIT_LIST_HEAD(&m->mux_list);
288 m->extended = extended;
290 idr_init(&m->tagpool.pool);
291 init_MUTEX(&m->tagpool.lock);
293 init_waitqueue_head(&m->equeue);
294 INIT_LIST_HEAD(&m->req_list);
295 INIT_LIST_HEAD(&m->unsent_req_list);
299 m->wpos = m->wsize = 0;
301 INIT_WORK(&m->rq, v9fs_read_work, m);
302 INIT_WORK(&m->wq, v9fs_write_work, m);
304 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
306 n = v9fs_mux_poll_start(m);
310 n = trans->poll(trans, &m->pt);
312 dprintk(DEBUG_MUX, "mux %p can read\n", m);
313 set_bit(Rpending, &m->wsched);
317 dprintk(DEBUG_MUX, "mux %p can write\n", m);
318 set_bit(Wpending, &m->wsched);
321 for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) {
322 if (IS_ERR(m->poll_waddr[i])) {
323 v9fs_mux_poll_stop(m);
324 mtmp = (void *)m->poll_waddr; /* the error code */
335 * v9fs_mux_destroy - cancels all pending requests and frees mux resources
337 void v9fs_mux_destroy(struct v9fs_mux_data *m)
339 dprintk(DEBUG_MUX, "mux %p prev %p next %p\n", m,
340 m->mux_list.prev, m->mux_list.next);
341 v9fs_mux_cancel(m, -ECONNRESET);
343 if (!list_empty(&m->req_list)) {
344 /* wait until all processes waiting on this session exit */
345 dprintk(DEBUG_MUX, "mux %p waiting for empty request queue\n",
347 wait_event_timeout(m->equeue, (list_empty(&m->req_list)), 5000);
348 dprintk(DEBUG_MUX, "mux %p request queue empty: %d\n", m,
349 list_empty(&m->req_list));
352 v9fs_mux_poll_stop(m);
359 * v9fs_pollwait - called by files poll operation to add v9fs-poll task
360 * to files wait queue
363 v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
367 struct v9fs_mux_data *m;
369 m = container_of(p, struct v9fs_mux_data, pt);
370 for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++)
371 if (m->poll_waddr[i] == NULL)
374 if (i >= ARRAY_SIZE(m->poll_waddr)) {
375 dprintk(DEBUG_ERROR, "not enough wait_address slots\n");
379 m->poll_waddr[i] = wait_address;
382 dprintk(DEBUG_ERROR, "no wait_address\n");
383 m->poll_waddr[i] = ERR_PTR(-EIO);
387 init_waitqueue_entry(&m->poll_wait[i], m->poll_task->task);
388 add_wait_queue(wait_address, &m->poll_wait[i]);
392 * v9fs_poll_mux - polls a mux and schedules read or write works if necessary
394 static void v9fs_poll_mux(struct v9fs_mux_data *m)
401 n = m->trans->poll(m->trans, NULL);
402 if (n < 0 || n & (POLLERR | POLLHUP | POLLNVAL)) {
403 dprintk(DEBUG_MUX, "error mux %p err %d\n", m, n);
406 v9fs_mux_cancel(m, n);
410 set_bit(Rpending, &m->wsched);
411 dprintk(DEBUG_MUX, "mux %p can read\n", m);
412 if (!test_and_set_bit(Rworksched, &m->wsched)) {
413 dprintk(DEBUG_MUX, "schedule read work mux %p\n", m);
414 queue_work(v9fs_mux_wq, &m->rq);
419 set_bit(Wpending, &m->wsched);
420 dprintk(DEBUG_MUX, "mux %p can write\n", m);
421 if ((m->wsize || !list_empty(&m->unsent_req_list))
422 && !test_and_set_bit(Wworksched, &m->wsched)) {
423 dprintk(DEBUG_MUX, "schedule write work mux %p\n", m);
424 queue_work(v9fs_mux_wq, &m->wq);
430 * v9fs_poll_proc - polls all v9fs transports for new events and queues
431 * the appropriate work to the work queue
433 static int v9fs_poll_proc(void *a)
435 struct v9fs_mux_data *m, *mtmp;
436 struct v9fs_mux_poll_task *vpt;
439 dprintk(DEBUG_MUX, "start %p %p\n", current, vpt);
440 allow_signal(SIGKILL);
441 while (!kthread_should_stop()) {
442 set_current_state(TASK_INTERRUPTIBLE);
443 if (signal_pending(current))
446 list_for_each_entry_safe(m, mtmp, &vpt->mux_list, mux_list) {
450 dprintk(DEBUG_MUX, "sleeping...\n");
451 schedule_timeout(SCHED_TIMEOUT * HZ);
454 __set_current_state(TASK_RUNNING);
455 dprintk(DEBUG_MUX, "finish\n");
460 * v9fs_write_work - called when a transport can send some data
462 static void v9fs_write_work(void *a)
465 struct v9fs_mux_data *m;
466 struct v9fs_req *req;
471 clear_bit(Wworksched, &m->wsched);
476 if (list_empty(&m->unsent_req_list)) {
477 clear_bit(Wworksched, &m->wsched);
483 req = list_entry(m->unsent_req_list.next, struct v9fs_req,
485 list_move_tail(&req->req_list, &m->req_list);
486 if (req->err == ERREQFLUSH)
489 m->wbuf = req->tcall->sdata;
490 m->wsize = req->tcall->size;
492 dump_data(m->wbuf, m->wsize);
493 spin_unlock(&m->lock);
496 dprintk(DEBUG_MUX, "mux %p pos %d size %d\n", m, m->wpos, m->wsize);
497 clear_bit(Wpending, &m->wsched);
498 err = m->trans->write(m->trans, m->wbuf + m->wpos, m->wsize - m->wpos);
499 dprintk(DEBUG_MUX, "mux %p sent %d bytes\n", m, err);
500 if (err == -EAGAIN) {
501 clear_bit(Wworksched, &m->wsched);
509 if (m->wpos == m->wsize)
510 m->wpos = m->wsize = 0;
512 if (m->wsize == 0 && !list_empty(&m->unsent_req_list)) {
513 if (test_and_clear_bit(Wpending, &m->wsched))
516 n = m->trans->poll(m->trans, NULL);
519 dprintk(DEBUG_MUX, "schedule write work mux %p\n", m);
520 queue_work(v9fs_mux_wq, &m->wq);
522 clear_bit(Wworksched, &m->wsched);
524 clear_bit(Wworksched, &m->wsched);
529 v9fs_mux_cancel(m, err);
530 clear_bit(Wworksched, &m->wsched);
533 static void process_request(struct v9fs_mux_data *m, struct v9fs_req *req)
536 struct v9fs_str *ename;
538 if (!req->err && req->rcall->id == RERROR) {
539 ecode = req->rcall->params.rerror.errno;
540 ename = &req->rcall->params.rerror.error;
542 dprintk(DEBUG_MUX, "Rerror %.*s\n", ename->len, ename->str);
548 req->err = v9fs_errstr2errno(ename->str, ename->len);
550 if (!req->err) { /* string match failed */
551 PRINT_FCALL_ERROR("unknown error", req->rcall);
555 req->err = -ESERVERFAULT;
557 } else if (req->tcall && req->rcall->id != req->tcall->id + 1) {
558 dprintk(DEBUG_ERROR, "fcall mismatch: expected %d, got %d\n",
559 req->tcall->id + 1, req->rcall->id);
566 * v9fs_read_work - called when there is some data to be read from a transport
568 static void v9fs_read_work(void *a)
571 struct v9fs_mux_data *m;
572 struct v9fs_req *req, *rptr, *rreq;
573 struct v9fs_fcall *rcall;
582 dprintk(DEBUG_MUX, "start mux %p pos %d\n", m, m->rpos);
586 kmalloc(sizeof(struct v9fs_fcall) + m->msize, GFP_KERNEL);
592 m->rbuf = (char *)m->rcall + sizeof(struct v9fs_fcall);
596 clear_bit(Rpending, &m->wsched);
597 err = m->trans->read(m->trans, m->rbuf + m->rpos, m->msize - m->rpos);
598 dprintk(DEBUG_MUX, "mux %p got %d bytes\n", m, err);
599 if (err == -EAGAIN) {
600 clear_bit(Rworksched, &m->wsched);
608 while (m->rpos > 4) {
609 n = le32_to_cpu(*(__le32 *) m->rbuf);
612 "requested packet size too big: %d\n", n);
620 dump_data(m->rbuf, n);
622 v9fs_deserialize_fcall(m->rbuf, n, m->rcall, *m->extended);
627 if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) {
630 v9fs_printfcall(buf, sizeof(buf), m->rcall,
632 printk(KERN_NOTICE ">>> %p %s\n", m, buf);
638 m->rcall = kmalloc(sizeof(struct v9fs_fcall) + m->msize,
645 m->rbuf = (char *)m->rcall + sizeof(struct v9fs_fcall);
646 memmove(m->rbuf, rbuf + n, m->rpos - n);
654 dprintk(DEBUG_MUX, "mux %p fcall id %d tag %d\n", m, rcall->id,
659 list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) {
660 if (rreq->tag == rcall->tag) {
662 if (req->flush != Flushing)
663 list_del(&req->req_list);
667 spin_unlock(&m->lock);
671 process_request(m, req);
673 if (req->flush != Flushing) {
675 (*req->cb) (req, req->cba);
682 if (err >= 0 && rcall->id != RFLUSH)
684 "unexpected response mux %p id %d tag %d\n",
685 m, rcall->id, rcall->tag);
690 if (!list_empty(&m->req_list)) {
691 if (test_and_clear_bit(Rpending, &m->wsched))
694 n = m->trans->poll(m->trans, NULL);
697 dprintk(DEBUG_MUX, "schedule read work mux %p\n", m);
698 queue_work(v9fs_mux_wq, &m->rq);
700 clear_bit(Rworksched, &m->wsched);
702 clear_bit(Rworksched, &m->wsched);
707 v9fs_mux_cancel(m, err);
708 clear_bit(Rworksched, &m->wsched);
712 * v9fs_send_request - send 9P request
713 * The function can sleep until the request is scheduled for sending.
714 * The function can be interrupted. Return from the function is not
715 * a guarantee that the request is sent successfully. Can return errors
716 * that can be retrieved by PTR_ERR macros.
719 * @tc: request to be sent
720 * @cb: callback function to call when response is received
721 * @cba: parameter to pass to the callback function
723 static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m,
724 struct v9fs_fcall *tc,
725 v9fs_mux_req_callback cb, void *cba)
728 struct v9fs_req *req;
730 dprintk(DEBUG_MUX, "mux %p task %p tcall %p id %d\n", m, current,
733 return ERR_PTR(m->err);
735 req = kmalloc(sizeof(struct v9fs_req), GFP_KERNEL);
737 return ERR_PTR(-ENOMEM);
739 if (tc->id == TVERSION)
742 n = v9fs_mux_get_tag(m);
745 return ERR_PTR(-ENOMEM);
748 if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) {
751 v9fs_printfcall(buf, sizeof(buf), tc, *m->extended);
752 printk(KERN_NOTICE "<<< %p %s\n", m, buf);
755 spin_lock_init(&req->lock);
765 list_add_tail(&req->req_list, &m->unsent_req_list);
766 spin_unlock(&m->lock);
768 if (test_and_clear_bit(Wpending, &m->wsched))
771 n = m->trans->poll(m->trans, NULL);
773 if (n & POLLOUT && !test_and_set_bit(Wworksched, &m->wsched))
774 queue_work(v9fs_mux_wq, &m->wq);
779 static void v9fs_mux_free_request(struct v9fs_mux_data *m, struct v9fs_req *req)
781 v9fs_mux_put_tag(m, req->tag);
785 static void v9fs_mux_flush_cb(struct v9fs_req *freq, void *a)
787 v9fs_mux_req_callback cb;
789 struct v9fs_mux_data *m;
790 struct v9fs_req *req, *rreq, *rptr;
793 dprintk(DEBUG_MUX, "mux %p tc %p rc %p err %d oldtag %d\n", m,
794 freq->tcall, freq->rcall, freq->err,
795 freq->tcall->params.tflush.oldtag);
799 tag = freq->tcall->params.tflush.oldtag;
801 list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) {
802 if (rreq->tag == tag) {
804 list_del(&req->req_list);
808 spin_unlock(&m->lock);
811 spin_lock(&req->lock);
812 req->flush = Flushed;
813 spin_unlock(&req->lock);
816 (*req->cb) (req, req->cba);
825 v9fs_mux_free_request(m, freq);
829 v9fs_mux_flush_request(struct v9fs_mux_data *m, struct v9fs_req *req)
831 struct v9fs_fcall *fc;
832 struct v9fs_req *rreq, *rptr;
834 dprintk(DEBUG_MUX, "mux %p req %p tag %d\n", m, req, req->tag);
836 /* if a response was received for a request, do nothing */
837 spin_lock(&req->lock);
838 if (req->rcall || req->err) {
839 spin_unlock(&req->lock);
840 dprintk(DEBUG_MUX, "mux %p req %p response already received\n", m, req);
844 req->flush = Flushing;
845 spin_unlock(&req->lock);
848 /* if the request is not sent yet, just remove it from the list */
849 list_for_each_entry_safe(rreq, rptr, &m->unsent_req_list, req_list) {
850 if (rreq->tag == req->tag) {
851 dprintk(DEBUG_MUX, "mux %p req %p request is not sent yet\n", m, req);
852 list_del(&rreq->req_list);
853 req->flush = Flushed;
854 spin_unlock(&m->lock);
856 (*req->cb) (req, req->cba);
860 spin_unlock(&m->lock);
862 clear_thread_flag(TIF_SIGPENDING);
863 fc = v9fs_create_tflush(req->tag);
864 v9fs_send_request(m, fc, v9fs_mux_flush_cb, m);
869 v9fs_mux_rpc_cb(struct v9fs_req *req, void *a)
871 struct v9fs_mux_rpc *r;
873 dprintk(DEBUG_MUX, "req %p r %p\n", req, a);
875 r->rcall = req->rcall;
878 if (req->flush!=None && !req->err)
879 r->err = -ERESTARTSYS;
885 * v9fs_mux_rpc - sends 9P request and waits until a response is available.
886 * The function can be interrupted.
888 * @tc: request to be sent
889 * @rc: pointer where a pointer to the response is stored
892 v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
893 struct v9fs_fcall **rc)
897 struct v9fs_req *req;
898 struct v9fs_mux_rpc r;
904 init_waitqueue_head(&r.wqueue);
910 if (signal_pending(current)) {
912 clear_thread_flag(TIF_SIGPENDING);
915 req = v9fs_send_request(m, tc, v9fs_mux_rpc_cb, &r);
918 dprintk(DEBUG_MUX, "error %d\n", err);
922 err = wait_event_interruptible(r.wqueue, r.rcall != NULL || r.err < 0);
926 if (err == -ERESTARTSYS && m->trans->status == Connected && m->err == 0) {
927 if (v9fs_mux_flush_request(m, req)) {
928 /* wait until we get response of the flush message */
930 clear_thread_flag(TIF_SIGPENDING);
931 err = wait_event_interruptible(r.wqueue,
933 } while (!r.rcall && !r.err && err==-ERESTARTSYS &&
934 m->trans->status==Connected && !m->err);
942 spin_lock_irqsave(¤t->sighand->siglock, flags);
944 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
952 v9fs_mux_free_request(m, req);
961 * v9fs_mux_rpcnb - sends 9P request without waiting for response.
963 * @tc: request to be sent
964 * @cb: callback function to be called when response arrives
965 * @cba: value to pass to the callback function
967 int v9fs_mux_rpcnb(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
968 v9fs_mux_req_callback cb, void *a)
971 struct v9fs_req *req;
973 req = v9fs_send_request(m, tc, cb, a);
976 dprintk(DEBUG_MUX, "error %d\n", err);
980 dprintk(DEBUG_MUX, "mux %p tc %p tag %d\n", m, tc, req->tag);
986 * v9fs_mux_cancel - cancel all pending requests with error
990 void v9fs_mux_cancel(struct v9fs_mux_data *m, int err)
992 struct v9fs_req *req, *rtmp;
993 LIST_HEAD(cancel_list);
995 dprintk(DEBUG_ERROR, "mux %p err %d\n", m, err);
998 list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) {
999 list_move(&req->req_list, &cancel_list);
1001 list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) {
1002 list_move(&req->req_list, &cancel_list);
1004 spin_unlock(&m->lock);
1006 list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) {
1007 list_del(&req->req_list);
1012 (*req->cb) (req, req->cba);
1017 wake_up(&m->equeue);
1020 static u16 v9fs_mux_get_tag(struct v9fs_mux_data *m)
1024 tag = v9fs_get_idpool(&m->tagpool);
1031 static void v9fs_mux_put_tag(struct v9fs_mux_data *m, u16 tag)
1033 if (tag != V9FS_NOTAG && v9fs_check_idpool(tag, &m->tagpool))
1034 v9fs_put_idpool(tag, &m->tagpool);