aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Van Hensbergen <ericvh@gmail.com>2008-10-13 19:45:24 -0400
committerEric Van Hensbergen <ericvh@gmail.com>2008-10-17 12:04:41 -0400
commit21c003687e2d1c589cf177a3ba17fd439af94850 (patch)
treede699ee9fe179710308b3dc20a060919b13796c6 /net
parent5503ac565998837350f3ee1cc344c36143ea2386 (diff)
9p: consolidate mux_rpc and request structure
Currently, trans_fd has two structures (p9_req and p9_mux-rpc) which contain mostly duplicate data. This patch consolidates these two structures and removes p9_mux_rpc. Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net')
-rw-r--r--net/9p/trans_fd.c68
1 files changed, 22 insertions, 46 deletions
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 334d39cc5ba3..dbb057d7fa5f 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -119,6 +119,8 @@ typedef void (*p9_conn_req_callback)(struct p9_req *req, void *a);
119 * @cba: argument to pass to callback 119 * @cba: argument to pass to callback
120 * @flush: flag to indicate RPC has been flushed 120 * @flush: flag to indicate RPC has been flushed
121 * @req_list: list link for higher level objects to chain requests 121 * @req_list: list link for higher level objects to chain requests
122 * @m: connection this request was issued on
123 * @wqueue: wait queue that client is blocked on for this rpc
122 * 124 *
123 */ 125 */
124 126
@@ -132,6 +134,8 @@ struct p9_req {
132 void *cba; 134 void *cba;
133 int flush; 135 int flush;
134 struct list_head req_list; 136 struct list_head req_list;
137 struct p9_conn *m;
138 wait_queue_head_t wqueue;
135}; 139};
136 140
137struct p9_poll_wait { 141struct p9_poll_wait {
@@ -186,25 +190,6 @@ struct p9_conn {
186 unsigned long wsched; 190 unsigned long wsched;
187}; 191};
188 192
189/**
190 * struct p9_mux_rpc - fd mux rpc accounting structure
191 * @m: connection this request was issued on
192 * @err: error state
193 * @tcall: request &p9_fcall
194 * @rcall: response &p9_fcall
195 * @wqueue: wait queue that client is blocked on for this rpc
196 *
197 * Bug: isn't this information duplicated elsewhere like &p9_req
198 */
199
200struct p9_mux_rpc {
201 struct p9_conn *m;
202 int err;
203 struct p9_fcall *tcall;
204 struct p9_fcall *rcall;
205 wait_queue_head_t wqueue;
206};
207
208static DEFINE_SPINLOCK(p9_poll_lock); 193static DEFINE_SPINLOCK(p9_poll_lock);
209static LIST_HEAD(p9_poll_pending_list); 194static LIST_HEAD(p9_poll_pending_list);
210static struct workqueue_struct *p9_mux_wq; 195static struct workqueue_struct *p9_mux_wq;
@@ -844,6 +829,8 @@ static struct p9_req *p9_send_request(struct p9_conn *m,
844#endif 829#endif
845 830
846 spin_lock_init(&req->lock); 831 spin_lock_init(&req->lock);
832 req->m = m;
833 init_waitqueue_head(&req->wqueue);
847 req->tag = n; 834 req->tag = n;
848 req->tcall = tc; 835 req->tcall = tc;
849 req->rcall = NULL; 836 req->rcall = NULL;
@@ -954,20 +941,14 @@ p9_mux_flush_request(struct p9_conn *m, struct p9_req *req)
954 return 1; 941 return 1;
955} 942}
956 943
957static void 944static void p9_conn_rpc_cb(struct p9_req *req, void *a)
958p9_conn_rpc_cb(struct p9_req *req, void *a)
959{ 945{
960 struct p9_mux_rpc *r; 946 P9_DPRINTK(P9_DEBUG_MUX, "req %p arg %p\n", req, a);
961
962 P9_DPRINTK(P9_DEBUG_MUX, "req %p r %p\n", req, a);
963 r = a;
964 r->rcall = req->rcall;
965 r->err = req->err;
966 947
967 if (req->flush != None && !req->err) 948 if (req->flush != None && !req->err)
968 r->err = -ERESTARTSYS; 949 req->err = -ERESTARTSYS;
969 950
970 wake_up(&r->wqueue); 951 wake_up(&req->wqueue);
971} 952}
972 953
973/** 954/**
@@ -987,13 +968,6 @@ p9_fd_rpc(struct p9_client *client, struct p9_fcall *tc, struct p9_fcall **rc)
987 int err, sigpending; 968 int err, sigpending;
988 unsigned long flags; 969 unsigned long flags;
989 struct p9_req *req; 970 struct p9_req *req;
990 struct p9_mux_rpc r;
991
992 r.err = 0;
993 r.tcall = tc;
994 r.rcall = NULL;
995 r.m = m;
996 init_waitqueue_head(&r.wqueue);
997 971
998 if (rc) 972 if (rc)
999 *rc = NULL; 973 *rc = NULL;
@@ -1004,16 +978,17 @@ p9_fd_rpc(struct p9_client *client, struct p9_fcall *tc, struct p9_fcall **rc)
1004 clear_thread_flag(TIF_SIGPENDING); 978 clear_thread_flag(TIF_SIGPENDING);
1005 } 979 }
1006 980
1007 req = p9_send_request(m, tc, p9_conn_rpc_cb, &r); 981 req = p9_send_request(m, tc, p9_conn_rpc_cb, NULL);
1008 if (IS_ERR(req)) { 982 if (IS_ERR(req)) {
1009 err = PTR_ERR(req); 983 err = PTR_ERR(req);
1010 P9_DPRINTK(P9_DEBUG_MUX, "error %d\n", err); 984 P9_DPRINTK(P9_DEBUG_MUX, "error %d\n", err);
1011 return err; 985 return err;
1012 } 986 }
1013 987
1014 err = wait_event_interruptible(r.wqueue, r.rcall != NULL || r.err < 0); 988 err = wait_event_interruptible(req->wqueue, req->rcall != NULL ||
1015 if (r.err < 0) 989 req->err < 0);
1016 err = r.err; 990 if (req->err < 0)
991 err = req->err;
1017 992
1018 if (err == -ERESTARTSYS && client->status == Connected 993 if (err == -ERESTARTSYS && client->status == Connected
1019 && m->err == 0) { 994 && m->err == 0) {
@@ -1021,10 +996,11 @@ p9_fd_rpc(struct p9_client *client, struct p9_fcall *tc, struct p9_fcall **rc)
1021 /* wait until we get response of the flush message */ 996 /* wait until we get response of the flush message */
1022 do { 997 do {
1023 clear_thread_flag(TIF_SIGPENDING); 998 clear_thread_flag(TIF_SIGPENDING);
1024 err = wait_event_interruptible(r.wqueue, 999 err = wait_event_interruptible(req->wqueue,
1025 r.rcall || r.err); 1000 req->rcall || req->err);
1026 } while (!r.rcall && !r.err && err == -ERESTARTSYS && 1001 } while (!req->rcall && !req->err &&
1027 client->status == Connected && !m->err); 1002 err == -ERESTARTSYS &&
1003 client->status == Connected && !m->err);
1028 1004
1029 err = -ERESTARTSYS; 1005 err = -ERESTARTSYS;
1030 } 1006 }
@@ -1038,9 +1014,9 @@ p9_fd_rpc(struct p9_client *client, struct p9_fcall *tc, struct p9_fcall **rc)
1038 } 1014 }
1039 1015
1040 if (rc) 1016 if (rc)
1041 *rc = r.rcall; 1017 *rc = req->rcall;
1042 else 1018 else
1043 kfree(r.rcall); 1019 kfree(req->rcall);
1044 1020
1045 p9_mux_free_request(m, req); 1021 p9_mux_free_request(m, req);
1046 if (err > 0) 1022 if (err > 0)