diff options
author | Simon Derr <simon.derr@bull.net> | 2012-09-17 15:16:30 +0200 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2012-09-17 14:54:11 -0500 |
commit | 584a8c13d58423462680907d4cc40d9929c9030a (patch) | |
tree | 17191b8555e06f8f62aaea1c5a76fde040980e00 /net/9p | |
parent | 1957b3a86f8eb5ceab32e3aae99e2822258aa530 (diff) | |
download | blackbird-op-linux-584a8c13d58423462680907d4cc40d9929c9030a.tar.gz blackbird-op-linux-584a8c13d58423462680907d4cc40d9929c9030a.zip |
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: Simon Derr <simon.derr@bull.net>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p')
-rw-r--r-- | net/9p/trans_fd.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 7088a94b2601..b2c308fffb8a 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c @@ -476,10 +476,9 @@ static void p9_write_work(struct work_struct *work) clear_bit(Wpending, &m->wsched); 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); - if (err == -EAGAIN) { - clear_bit(Wworksched, &m->wsched); - return; - } + if (err == -EAGAIN) + goto end_clear; + if (err < 0) goto error; @@ -492,19 +491,21 @@ static void p9_write_work(struct work_struct *work) if (m->wpos == m->wsize) m->wpos = m->wsize = 0; +end_clear: + clear_bit(Wworksched, &m->wsched); + if (m->wsize || !list_empty(&m->unsent_req_list)) { if (test_and_clear_bit(Wpending, &m->wsched)) n = POLLOUT; else 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); schedule_work(&m->wq); - } else - clear_bit(Wworksched, &m->wsched); - } else - clear_bit(Wworksched, &m->wsched); + } + } return; |