diff options
author | Eric Van Hensbergen <ericvh@gmail.com> | 2008-10-17 13:45:40 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2008-10-17 13:45:40 -0400 |
commit | 7eb923b80c8ce16697129fb2dcdfaeabf83f0dbc (patch) | |
tree | 0bd70a738587c58b7029e46c9508c21949601d6c /net/9p/trans_fd.c | |
parent | f0a0ac2ee50c62cf4ad9b06cf8a12435cc5ac44d (diff) |
9p: add more conservative locking
During the reorganization some of the multi-theaded locking assumptions were
accidently relaxed. This patch moves us back towards a more conservative
locking strategy.
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p/trans_fd.c')
-rw-r--r-- | net/9p/trans_fd.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index e8ebe2cb7e8b..be65d8242fd2 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -188,8 +188,16 @@ static void p9_conn_cancel(struct p9_conn *m, int err) | |||
188 | LIST_HEAD(cancel_list); | 188 | LIST_HEAD(cancel_list); |
189 | 189 | ||
190 | P9_DPRINTK(P9_DEBUG_ERROR, "mux %p err %d\n", m, err); | 190 | P9_DPRINTK(P9_DEBUG_ERROR, "mux %p err %d\n", m, err); |
191 | m->err = err; | 191 | |
192 | spin_lock_irqsave(&m->client->lock, flags); | 192 | spin_lock_irqsave(&m->client->lock, flags); |
193 | |||
194 | if (m->err) { | ||
195 | spin_unlock_irqrestore(&m->client->lock, flags); | ||
196 | return; | ||
197 | } | ||
198 | |||
199 | m->err = err; | ||
200 | |||
193 | list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) { | 201 | list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) { |
194 | req->status = REQ_STATUS_ERROR; | 202 | req->status = REQ_STATUS_ERROR; |
195 | if (!req->t_err) | 203 | if (!req->t_err) |
@@ -352,8 +360,9 @@ static void p9_read_work(struct work_struct *work) | |||
352 | /* not an else because some packets (like clunk) have no payload */ | 360 | /* not an else because some packets (like clunk) have no payload */ |
353 | if ((m->req) && (m->rpos == m->rsize)) { /* packet is read in */ | 361 | if ((m->req) && (m->rpos == m->rsize)) { /* packet is read in */ |
354 | P9_DPRINTK(P9_DEBUG_TRANS, "got new packet\n"); | 362 | P9_DPRINTK(P9_DEBUG_TRANS, "got new packet\n"); |
355 | 363 | spin_lock(&m->client->lock); | |
356 | list_del(&m->req->req_list); | 364 | list_del(&m->req->req_list); |
365 | spin_unlock(&m->client->lock); | ||
357 | p9_client_cb(m->client, m->req); | 366 | p9_client_cb(m->client, m->req); |
358 | 367 | ||
359 | m->rbuf = NULL; | 368 | m->rbuf = NULL; |
@@ -651,9 +660,8 @@ static int p9_fd_request(struct p9_client *client, struct p9_req_t *req) | |||
651 | if (m->err < 0) | 660 | if (m->err < 0) |
652 | return m->err; | 661 | return m->err; |
653 | 662 | ||
654 | req->status = REQ_STATUS_UNSENT; | ||
655 | |||
656 | spin_lock(&client->lock); | 663 | spin_lock(&client->lock); |
664 | req->status = REQ_STATUS_UNSENT; | ||
657 | list_add_tail(&req->req_list, &m->unsent_req_list); | 665 | list_add_tail(&req->req_list, &m->unsent_req_list); |
658 | spin_unlock(&client->lock); | 666 | spin_unlock(&client->lock); |
659 | 667 | ||
@@ -672,19 +680,21 @@ static int p9_fd_cancel(struct p9_client *client, struct p9_req_t *req) | |||
672 | { | 680 | { |
673 | struct p9_trans_fd *ts = client->trans; | 681 | struct p9_trans_fd *ts = client->trans; |
674 | struct p9_conn *m = ts->conn; | 682 | struct p9_conn *m = ts->conn; |
683 | int ret = 1; | ||
675 | 684 | ||
676 | P9_DPRINTK(P9_DEBUG_TRANS, "mux %p req %p\n", m, req); | 685 | P9_DPRINTK(P9_DEBUG_TRANS, "mux %p req %p\n", m, req); |
677 | 686 | ||
678 | spin_lock(&client->lock); | 687 | spin_lock(&client->lock); |
679 | list_del(&req->req_list); | 688 | list_del(&req->req_list); |
680 | spin_unlock(&client->lock); | ||
681 | 689 | ||
682 | if (req->status == REQ_STATUS_UNSENT) { | 690 | if (req->status == REQ_STATUS_UNSENT) { |
683 | req->status = REQ_STATUS_FLSHD; | 691 | req->status = REQ_STATUS_FLSHD; |
684 | return 0; | 692 | ret = 0; |
685 | } | 693 | } |
686 | 694 | ||
687 | return 1; | 695 | spin_unlock(&client->lock); |
696 | |||
697 | return ret; | ||
688 | } | 698 | } |
689 | 699 | ||
690 | /** | 700 | /** |