Commit 584a8c13 authored by Simon Derr's avatar Simon Derr Committed by Eric Van Hensbergen

9P: Fix race in p9_write_work()

See previous commit about p9_read_work() for details.

This fixes a similar race between p9_write_work() and p9_poll_mux()
Signed-off-by: default avatarSimon Derr <simon.derr@bull.net>
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent 1957b3a8
...@@ -476,10 +476,9 @@ static void p9_write_work(struct work_struct *work) ...@@ -476,10 +476,9 @@ static void p9_write_work(struct work_struct *work)
clear_bit(Wpending, &m->wsched); clear_bit(Wpending, &m->wsched);
err = p9_fd_write(m->client, m->wbuf + m->wpos, m->wsize - m->wpos); err = p9_fd_write(m->client, m->wbuf + m->wpos, m->wsize - m->wpos);
p9_debug(P9_DEBUG_TRANS, "mux %p sent %d bytes\n", m, err); p9_debug(P9_DEBUG_TRANS, "mux %p sent %d bytes\n", m, err);
if (err == -EAGAIN) { if (err == -EAGAIN)
clear_bit(Wworksched, &m->wsched); goto end_clear;
return;
}
if (err < 0) if (err < 0)
goto error; goto error;
...@@ -492,19 +491,21 @@ static void p9_write_work(struct work_struct *work) ...@@ -492,19 +491,21 @@ static void p9_write_work(struct work_struct *work)
if (m->wpos == m->wsize) if (m->wpos == m->wsize)
m->wpos = m->wsize = 0; m->wpos = m->wsize = 0;
end_clear:
clear_bit(Wworksched, &m->wsched);
if (m->wsize || !list_empty(&m->unsent_req_list)) { if (m->wsize || !list_empty(&m->unsent_req_list)) {
if (test_and_clear_bit(Wpending, &m->wsched)) if (test_and_clear_bit(Wpending, &m->wsched))
n = POLLOUT; n = POLLOUT;
else else
n = p9_fd_poll(m->client, NULL); n = p9_fd_poll(m->client, NULL);
if (n & POLLOUT) { if ((n & POLLOUT) &&
!test_and_set_bit(Wworksched, &m->wsched)) {
p9_debug(P9_DEBUG_TRANS, "sched write work %p\n", m); p9_debug(P9_DEBUG_TRANS, "sched write work %p\n", m);
schedule_work(&m->wq); schedule_work(&m->wq);
} else }
clear_bit(Wworksched, &m->wsched); }
} else
clear_bit(Wworksched, &m->wsched);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment