• J. Bruce Fields's avatar
    svcrpc: avoid double reply caused by deferral race · d76d1815
    J. Bruce Fields authored
    Commit d29068c4 "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: default avatarJ. Bruce Fields <bfields@redhat.com>
    Acked-by: default avatarNeilBrown <neilb@suse.de>
    d76d1815
cache.c 42.4 KB