]> git.karo-electronics.de Git - linux-beck.git/commit
svcrpc: avoid double reply caused by deferral race
authorJ. Bruce Fields <bfields@redhat.com>
Mon, 3 Jan 2011 02:28:34 +0000 (21:28 -0500)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 4 Jan 2011 21:49:21 +0000 (16:49 -0500)
commitd76d1815f3e72fb627ad7f95ef63120b0a557c9c
treee639629aabf50fe9b5441286ff12cfc4ec77de98
parent3beb6cd1d448e7ded938bbd676493e6a08e9a6cd
svcrpc: avoid double reply caused by deferral race

Commit d29068c431599fa "sunrpc: Simplify cache_defer_req and related
functions." asserted that cache_check() could determine success or
failure of cache_defer_req() by checking the CACHE_PENDING bit.

This isn't quite right.

We need to know whether cache_defer_req() created a deferred request,
in which case sending an rpc reply has become the responsibility of the
deferred request, and it is important that we not send our own reply,
resulting in two different replies to the same request.

And the CACHE_PENDING bit doesn't tell us that; we could have
succesfully created a deferred request at the same time as another
thread cleared the CACHE_PENDING bit.

So, partially revert that commit, to ensure that cache_check() returns
-EAGAIN if and only if a deferred request has been created.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Acked-by: NeilBrown <neilb@suse.de>
net/sunrpc/cache.c