diff options
author | Latchesar Ionkov <lucho@ionkov.net> | 2009-04-05 17:28:59 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@vTrogdor.(none)> | 2009-04-05 17:54:53 -0400 |
commit | 1bab88b2310998de18b32529a27ea835d164254a (patch) | |
tree | fed704a8b3b4ce93d8cd25462ccc9186dec84b7a /net/9p/trans_fd.c | |
parent | 742b11a7ec60faa25d76c95c268041ab215c25ad (diff) |
net/9p: handle correctly interrupted 9P requests
Currently the 9p code crashes when a operation is interrupted, i.e. for
example when the user presses ^C while reading from a file.
This patch fixes the code that is responsible for interruption and flushing
of 9P operations.
Signed-off-by: Latchesar Ionkov <lucho@ionkov.net>
Diffstat (limited to 'net/9p/trans_fd.c')
-rw-r--r-- | net/9p/trans_fd.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index c613ed08a5e..a2a1814c7a8 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -213,8 +213,8 @@ static void p9_conn_cancel(struct p9_conn *m, int err) | |||
213 | spin_unlock_irqrestore(&m->client->lock, flags); | 213 | spin_unlock_irqrestore(&m->client->lock, flags); |
214 | 214 | ||
215 | list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) { | 215 | list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) { |
216 | list_del(&req->req_list); | ||
217 | P9_DPRINTK(P9_DEBUG_ERROR, "call back req %p\n", req); | 216 | P9_DPRINTK(P9_DEBUG_ERROR, "call back req %p\n", req); |
217 | list_del(&req->req_list); | ||
218 | p9_client_cb(m->client, req); | 218 | p9_client_cb(m->client, req); |
219 | } | 219 | } |
220 | } | 220 | } |
@@ -336,7 +336,8 @@ static void p9_read_work(struct work_struct *work) | |||
336 | "mux %p pkt: size: %d bytes tag: %d\n", m, n, tag); | 336 | "mux %p pkt: size: %d bytes tag: %d\n", m, n, tag); |
337 | 337 | ||
338 | m->req = p9_tag_lookup(m->client, tag); | 338 | m->req = p9_tag_lookup(m->client, tag); |
339 | if (!m->req) { | 339 | if (!m->req || (m->req->status != REQ_STATUS_SENT && |
340 | m->req->status != REQ_STATUS_FLSH)) { | ||
340 | P9_DPRINTK(P9_DEBUG_ERROR, "Unexpected packet tag %d\n", | 341 | P9_DPRINTK(P9_DEBUG_ERROR, "Unexpected packet tag %d\n", |
341 | tag); | 342 | tag); |
342 | err = -EIO; | 343 | err = -EIO; |
@@ -361,10 +362,11 @@ static void p9_read_work(struct work_struct *work) | |||
361 | if ((m->req) && (m->rpos == m->rsize)) { /* packet is read in */ | 362 | if ((m->req) && (m->rpos == m->rsize)) { /* packet is read in */ |
362 | P9_DPRINTK(P9_DEBUG_TRANS, "got new packet\n"); | 363 | P9_DPRINTK(P9_DEBUG_TRANS, "got new packet\n"); |
363 | spin_lock(&m->client->lock); | 364 | spin_lock(&m->client->lock); |
365 | if (m->req->status != REQ_STATUS_ERROR) | ||
366 | m->req->status = REQ_STATUS_RCVD; | ||
364 | list_del(&m->req->req_list); | 367 | list_del(&m->req->req_list); |
365 | spin_unlock(&m->client->lock); | 368 | spin_unlock(&m->client->lock); |
366 | p9_client_cb(m->client, m->req); | 369 | p9_client_cb(m->client, m->req); |
367 | |||
368 | m->rbuf = NULL; | 370 | m->rbuf = NULL; |
369 | m->rpos = 0; | 371 | m->rpos = 0; |
370 | m->rsize = 0; | 372 | m->rsize = 0; |
@@ -454,6 +456,7 @@ static void p9_write_work(struct work_struct *work) | |||
454 | req = list_entry(m->unsent_req_list.next, struct p9_req_t, | 456 | req = list_entry(m->unsent_req_list.next, struct p9_req_t, |
455 | req_list); | 457 | req_list); |
456 | req->status = REQ_STATUS_SENT; | 458 | req->status = REQ_STATUS_SENT; |
459 | P9_DPRINTK(P9_DEBUG_TRANS, "move req %p\n", req); | ||
457 | list_move_tail(&req->req_list, &m->req_list); | 460 | list_move_tail(&req->req_list, &m->req_list); |
458 | 461 | ||
459 | m->wbuf = req->tc->sdata; | 462 | m->wbuf = req->tc->sdata; |
@@ -683,12 +686,13 @@ static int p9_fd_cancel(struct p9_client *client, struct p9_req_t *req) | |||
683 | P9_DPRINTK(P9_DEBUG_TRANS, "client %p req %p\n", client, req); | 686 | P9_DPRINTK(P9_DEBUG_TRANS, "client %p req %p\n", client, req); |
684 | 687 | ||
685 | spin_lock(&client->lock); | 688 | spin_lock(&client->lock); |
686 | list_del(&req->req_list); | ||
687 | 689 | ||
688 | if (req->status == REQ_STATUS_UNSENT) { | 690 | if (req->status == REQ_STATUS_UNSENT) { |
691 | list_del(&req->req_list); | ||
689 | req->status = REQ_STATUS_FLSHD; | 692 | req->status = REQ_STATUS_FLSHD; |
690 | ret = 0; | 693 | ret = 0; |
691 | } | 694 | } else if (req->status == REQ_STATUS_SENT) |
695 | req->status = REQ_STATUS_FLSH; | ||
692 | 696 | ||
693 | spin_unlock(&client->lock); | 697 | spin_unlock(&client->lock); |
694 | 698 | ||