• Trond Myklebust's avatar
    NFSv4: Fix CLOSE races with OPEN · 3e7dfb16
    Trond Myklebust authored
    If the reply to a successful CLOSE call races with an OPEN to the same
    file, we can end up scribbling over the stateid that represents the
    new open state.
    The race looks like:
    
      Client				Server
      ======				======
    
      CLOSE stateid A on file "foo"
    					CLOSE stateid A, return stateid C
      OPEN file "foo"
    					OPEN "foo", return stateid B
      Receive reply to OPEN
      Reset open state for "foo"
      Associate stateid B to "foo"
    
      Receive CLOSE for A
      Reset open state for "foo"
      Replace stateid B with C
    
    The fix is to examine the argument of the CLOSE, and check for a match
    with the current stateid "other" field. If the two do not match, then
    the above race occurred, and we should just ignore the CLOSE.
    Reported-by: default avatarBenjamin Coddington <bcodding@redhat.com>
    Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
    Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
    3e7dfb16
nfs4_fs.h 19 KB