diff options
Diffstat (limited to 'net/9p/trans_fd.c')
-rw-r--r-- | net/9p/trans_fd.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 15656b8573f3..02efb25c2957 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -316,8 +316,7 @@ static void p9_read_work(struct work_struct *work) | |||
316 | m->rsize - m->rpos); | 316 | m->rsize - m->rpos); |
317 | p9_debug(P9_DEBUG_TRANS, "mux %p got %d bytes\n", m, err); | 317 | p9_debug(P9_DEBUG_TRANS, "mux %p got %d bytes\n", m, err); |
318 | if (err == -EAGAIN) { | 318 | if (err == -EAGAIN) { |
319 | clear_bit(Rworksched, &m->wsched); | 319 | goto end_clear; |
320 | return; | ||
321 | } | 320 | } |
322 | 321 | ||
323 | if (err <= 0) | 322 | if (err <= 0) |
@@ -379,19 +378,20 @@ static void p9_read_work(struct work_struct *work) | |||
379 | m->req = NULL; | 378 | m->req = NULL; |
380 | } | 379 | } |
381 | 380 | ||
381 | end_clear: | ||
382 | clear_bit(Rworksched, &m->wsched); | ||
383 | |||
382 | if (!list_empty(&m->req_list)) { | 384 | if (!list_empty(&m->req_list)) { |
383 | if (test_and_clear_bit(Rpending, &m->wsched)) | 385 | if (test_and_clear_bit(Rpending, &m->wsched)) |
384 | n = POLLIN; | 386 | n = POLLIN; |
385 | else | 387 | else |
386 | n = p9_fd_poll(m->client, NULL); | 388 | n = p9_fd_poll(m->client, NULL); |
387 | 389 | ||
388 | if (n & POLLIN) { | 390 | if ((n & POLLIN) && !test_and_set_bit(Rworksched, &m->wsched)) { |
389 | p9_debug(P9_DEBUG_TRANS, "sched read work %p\n", m); | 391 | p9_debug(P9_DEBUG_TRANS, "sched read work %p\n", m); |
390 | schedule_work(&m->rq); | 392 | schedule_work(&m->rq); |
391 | } else | 393 | } |
392 | clear_bit(Rworksched, &m->wsched); | 394 | } |
393 | } else | ||
394 | clear_bit(Rworksched, &m->wsched); | ||
395 | 395 | ||
396 | return; | 396 | return; |
397 | error: | 397 | error: |
@@ -453,12 +453,13 @@ static void p9_write_work(struct work_struct *work) | |||
453 | } | 453 | } |
454 | 454 | ||
455 | if (!m->wsize) { | 455 | if (!m->wsize) { |
456 | spin_lock(&m->client->lock); | ||
456 | if (list_empty(&m->unsent_req_list)) { | 457 | if (list_empty(&m->unsent_req_list)) { |
457 | clear_bit(Wworksched, &m->wsched); | 458 | clear_bit(Wworksched, &m->wsched); |
459 | spin_unlock(&m->client->lock); | ||
458 | return; | 460 | return; |
459 | } | 461 | } |
460 | 462 | ||
461 | spin_lock(&m->client->lock); | ||
462 | req = list_entry(m->unsent_req_list.next, struct p9_req_t, | 463 | req = list_entry(m->unsent_req_list.next, struct p9_req_t, |
463 | req_list); | 464 | req_list); |
464 | req->status = REQ_STATUS_SENT; | 465 | req->status = REQ_STATUS_SENT; |
@@ -476,10 +477,9 @@ static void p9_write_work(struct work_struct *work) | |||
476 | clear_bit(Wpending, &m->wsched); | 477 | clear_bit(Wpending, &m->wsched); |
477 | err = p9_fd_write(m->client, m->wbuf + m->wpos, m->wsize - m->wpos); | 478 | err = p9_fd_write(m->client, m->wbuf + m->wpos, m->wsize - m->wpos); |
478 | p9_debug(P9_DEBUG_TRANS, "mux %p sent %d bytes\n", m, err); | 479 | p9_debug(P9_DEBUG_TRANS, "mux %p sent %d bytes\n", m, err); |
479 | if (err == -EAGAIN) { | 480 | if (err == -EAGAIN) |
480 | clear_bit(Wworksched, &m->wsched); | 481 | goto end_clear; |
481 | return; | 482 | |
482 | } | ||
483 | 483 | ||
484 | if (err < 0) | 484 | if (err < 0) |
485 | goto error; | 485 | goto error; |
@@ -492,19 +492,21 @@ static void p9_write_work(struct work_struct *work) | |||
492 | if (m->wpos == m->wsize) | 492 | if (m->wpos == m->wsize) |
493 | m->wpos = m->wsize = 0; | 493 | m->wpos = m->wsize = 0; |
494 | 494 | ||
495 | if (m->wsize == 0 && !list_empty(&m->unsent_req_list)) { | 495 | end_clear: |
496 | clear_bit(Wworksched, &m->wsched); | ||
497 | |||
498 | if (m->wsize || !list_empty(&m->unsent_req_list)) { | ||
496 | if (test_and_clear_bit(Wpending, &m->wsched)) | 499 | if (test_and_clear_bit(Wpending, &m->wsched)) |
497 | n = POLLOUT; | 500 | n = POLLOUT; |
498 | else | 501 | else |
499 | n = p9_fd_poll(m->client, NULL); | 502 | n = p9_fd_poll(m->client, NULL); |
500 | 503 | ||
501 | if (n & POLLOUT) { | 504 | if ((n & POLLOUT) && |
505 | !test_and_set_bit(Wworksched, &m->wsched)) { | ||
502 | p9_debug(P9_DEBUG_TRANS, "sched write work %p\n", m); | 506 | p9_debug(P9_DEBUG_TRANS, "sched write work %p\n", m); |
503 | schedule_work(&m->wq); | 507 | schedule_work(&m->wq); |
504 | } else | 508 | } |
505 | clear_bit(Wworksched, &m->wsched); | 509 | } |
506 | } else | ||
507 | clear_bit(Wworksched, &m->wsched); | ||
508 | 510 | ||
509 | return; | 511 | return; |
510 | 512 | ||