9P: Fix race between p9_write_work() and p9_fd_request()

Race scenario:

thread A			thread B

p9_write_work()                p9_fd_request()

if (list_empty

                               req->status = REQ_STATUS_UNSENT;
                               list_add_tail(..., &m->unsent_req_list);
                               if (n & POLLOUT &&
                               !test_and_set_bit(Wworksched, &m->wsched)
                               --> not done because Wworksched is set

  clear_bit(Wworksched, &m->wsched);

--> nobody will take care of sending the new request.

This is not very likely to happen though, because p9_write_work()
being called with an empty unsent_req_list is not frequent.
But this also means that taking the lock earlier will not be costly.

Signed-off-by: Simon Derr <simon.derr@bull.net>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
1 file changed