• Jeff Layton's avatar
    nfsd: reduce cl_lock thrashing in release_openowner · 2c41beb0
    Jeff Layton authored
    Releasing an openowner is a bit inefficient as it can potentially thrash
    the cl_lock if you have a lot of stateids attached to it. Once we remove
    the client_mutex, it'll also potentially be dangerous to do this.
    
    Add some functions to make it easier to defer the part of putting a
    generic stateid reference that needs to be done outside the cl_lock while
    doing the parts that must be done while holding it under a single lock.
    
    First we unhash each open stateid. Then we call
    put_generic_stateid_locked which will put the reference to an
    nfs4_ol_stateid. If it turns out to be the last reference, it'll go
    ahead and remove the stid from the IDR tree and put it onto the reaplist
    using the st_locks list_head.
    
    Then, after dropping the lock we'll call free_ol_stateid_reaplist to
    walk the list of stateids that are fully unhashed and ready to be freed,
    and free each of them. This function can sleep, so it must be done
    outside any spinlocks.
    Signed-off-by: default avatarJeff Layton <jlayton@primarydata.com>
    Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
    2c41beb0
nfs4state.c 156 KB