• NeilBrown's avatar
    nfsd: split sc_status out of sc_type · 3f29cc82
    NeilBrown authored
    sc_type identifies the type of a state - open, lock, deleg, layout - and
    also the status of a state - closed or revoked.
    
    This is a bit untidy and could get worse when "admin-revoked" states are
    added.  So clean it up.
    
    With this patch, the type is now all that is stored in sc_type.  This is
    zero when the state is first added to ->cl_stateids (causing it to be
    ignored), and is then set appropriately once it is fully initialised.
    It is set under ->cl_lock to ensure atomicity w.r.t lookup.  It is now
    never cleared.
    
    sc_type is still a bit-set even though at most one bit is set.  This allows
    lookup functions to be given a bitmap of acceptable types.
    
    sc_type is now an unsigned short rather than char.  There is no value in
    restricting to just 8 bits.
    
    All the constants now start SC_TYPE_ matching the field in which they
    are stored.  Keeping the existing names and ensuring clear separation
    from non-type flags would have required something like
    NFS4_STID_TYPE_CLOSED which is cumbersome.  The "NFS4" prefix is
    redundant was they only appear in NFS4 code, so remove that and change
    STID to SC to match the field.
    
    The status is stored in a separate unsigned short named "sc_status".  It
    has two flags: SC_STATUS_CLOSED and SC_STATUS_REVOKED.
    CLOSED combines NFS4_CLOSED_STID, NFS4_CLOSED_DELEG_STID, and is used
    for SC_TYPE_LOCK and SC_TYPE_LAYOUT instead of setting the sc_type to zero.
    These flags are only ever set, never cleared.
    For deleg stateids they are set under the global state_lock.
    For open and lock stateids they are set under ->cl_lock.
    For layout stateids they are set under ->ls_lock
    
    nfs4_unhash_stid() has been removed, and we never set sc_type = 0.  This
    was only used for LOCK and LAYOUT stids and they now use
    SC_STATUS_CLOSED.
    
    Also TRACE_DEFINE_NUM() calls for the various STID #define have been
    removed because these things are not enums, and so that call is
    incorrect.
    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>
    3f29cc82
nfs4state.c 220 KB