• NeilBrown's avatar
    nfsd: avoid race after unhash_delegation_locked() · 83e73316
    NeilBrown authored
    NFS4_CLOSED_DELEG_STID and NFS4_REVOKED_DELEG_STID are similar in
    purpose.
    REVOKED is used for NFSv4.1 states which have been revoked because the
    lease has expired.  CLOSED is used in other cases.
    The difference has two practical effects.
    1/ REVOKED states are on the ->cl_revoked list
    2/ REVOKED states result in nfserr_deleg_revoked from
       nfsd4_verify_open_stid() and nfsd4_validate_stateid while
       CLOSED states result in nfserr_bad_stid.
    
    Currently a state that is being revoked is first set to "CLOSED" in
    unhash_delegation_locked(), then possibly to "REVOKED" in
    revoke_delegation(), at which point it is added to the cl_revoked list.
    
    It is possible that a stateid test could see the CLOSED state
    which really should be REVOKED, and so return the wrong error code.  So
    it is safest to remove this window of inconsistency.
    
    With this patch, unhash_delegation_locked() always sets the state
    correctly, and revoke_delegation() no longer changes the state.
    
    Also remove a redundant test on minorversion when
    NFS4_REVOKED_DELEG_STID is seen - it can only be seen when minorversion
    is non-zero.
    Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
    Signed-off-by: default avatarNeilBrown <neilb@suse.de>
    Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
    83e73316
nfs4state.c 220 KB