aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Van Hensbergen <ericvh@gmail.com>2008-10-13 19:45:22 -0400
committerEric Van Hensbergen <ericvh@gmail.com>2008-10-17 12:04:42 -0400
commitff683452f7bc52d7fd653cf5e67b1134555734c7 (patch)
treeb8265741ed4cb8a0e48b6ce8e696c5c8f99a85d7
parentfea511a644fb0fb938309c6ab286725ac31b87e2 (diff)
9p: apply common tagpool handling to trans_fd
Simplify trans_fd by using new common client tagpool structure. Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
-rw-r--r--net/9p/trans_fd.c44
1 files changed, 10 insertions, 34 deletions
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 180163b3e8f9..6243093934b2 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -142,7 +142,6 @@ struct p9_poll_wait {
142 * @lock: protects mux_list (?) 142 * @lock: protects mux_list (?)
143 * @mux_list: list link for mux to manage multiple connections (?) 143 * @mux_list: list link for mux to manage multiple connections (?)
144 * @client: reference to client instance for this connection 144 * @client: reference to client instance for this connection
145 * @tagpool: id accounting for transactions
146 * @err: error state 145 * @err: error state
147 * @req_list: accounting for requests which have been sent 146 * @req_list: accounting for requests which have been sent
148 * @unsent_req_list: accounting for requests that haven't been sent 147 * @unsent_req_list: accounting for requests that haven't been sent
@@ -165,7 +164,6 @@ struct p9_conn {
165 spinlock_t lock; /* protect lock structure */ 164 spinlock_t lock; /* protect lock structure */
166 struct list_head mux_list; 165 struct list_head mux_list;
167 struct p9_client *client; 166 struct p9_client *client;
168 struct p9_idpool *tagpool;
169 int err; 167 int err;
170 struct list_head req_list; 168 struct list_head req_list;
171 struct list_head unsent_req_list; 169 struct list_head unsent_req_list;
@@ -188,23 +186,6 @@ static LIST_HEAD(p9_poll_pending_list);
188static struct workqueue_struct *p9_mux_wq; 186static struct workqueue_struct *p9_mux_wq;
189static struct task_struct *p9_poll_task; 187static struct task_struct *p9_poll_task;
190 188
191static u16 p9_mux_get_tag(struct p9_conn *m)
192{
193 int tag;
194
195 tag = p9_idpool_get(m->tagpool);
196 if (tag < 0)
197 return P9_NOTAG;
198 else
199 return (u16) tag;
200}
201
202static void p9_mux_put_tag(struct p9_conn *m, u16 tag)
203{
204 if (tag != P9_NOTAG && p9_idpool_check(tag, m->tagpool))
205 p9_idpool_put(tag, m->tagpool);
206}
207
208static void p9_mux_poll_stop(struct p9_conn *m) 189static void p9_mux_poll_stop(struct p9_conn *m)
209{ 190{
210 unsigned long flags; 191 unsigned long flags;
@@ -226,7 +207,9 @@ static void p9_mux_poll_stop(struct p9_conn *m)
226 207
227static void p9_mux_free_request(struct p9_conn *m, struct p9_req *req) 208static void p9_mux_free_request(struct p9_conn *m, struct p9_req *req)
228{ 209{
229 p9_mux_put_tag(m, req->tag); 210 if (req->tag != P9_NOTAG &&
211 p9_idpool_check(req->tag, m->client->tagpool))
212 p9_idpool_put(req->tag, m->client->tagpool);
230 kfree(req); 213 kfree(req);
231} 214}
232 215
@@ -745,11 +728,6 @@ static struct p9_conn *p9_conn_create(struct p9_client *client)
745 spin_lock_init(&m->lock); 728 spin_lock_init(&m->lock);
746 INIT_LIST_HEAD(&m->mux_list); 729 INIT_LIST_HEAD(&m->mux_list);
747 m->client = client; 730 m->client = client;
748 m->tagpool = p9_idpool_create();
749 if (IS_ERR(m->tagpool)) {
750 kfree(m);
751 return ERR_PTR(-ENOMEM);
752 }
753 731
754 INIT_LIST_HEAD(&m->req_list); 732 INIT_LIST_HEAD(&m->req_list);
755 INIT_LIST_HEAD(&m->unsent_req_list); 733 INIT_LIST_HEAD(&m->unsent_req_list);
@@ -848,14 +826,13 @@ static struct p9_req *p9_send_request(struct p9_conn *m, struct p9_fcall *tc)
848 if (!req) 826 if (!req)
849 return ERR_PTR(-ENOMEM); 827 return ERR_PTR(-ENOMEM);
850 828
851 if (tc->id == P9_TVERSION) 829 n = P9_NOTAG;
852 n = P9_NOTAG; 830 if (tc->id != P9_TVERSION) {
853 else 831 n = p9_idpool_get(m->client->tagpool);
854 n = p9_mux_get_tag(m); 832 if (n < 0) {
855 833 kfree(req);
856 if (n < 0) { 834 return ERR_PTR(-ENOMEM);
857 kfree(req); 835 }
858 return ERR_PTR(-ENOMEM);
859 } 836 }
860 837
861 p9_set_tag(tc, n); 838 p9_set_tag(tc, n);
@@ -1134,7 +1111,6 @@ static void p9_conn_destroy(struct p9_conn *m)
1134 p9_conn_cancel(m, -ECONNRESET); 1111 p9_conn_cancel(m, -ECONNRESET);
1135 1112
1136 m->client = NULL; 1113 m->client = NULL;
1137 p9_idpool_destroy(m->tagpool);
1138 kfree(m); 1114 kfree(m);
1139} 1115}
1140 1116