• David Howells's avatar
    afs: Try to avoid taking RCU read lock when checking vnode validity · 4fe6a946
    David Howells authored
    Try to avoid taking the RCU read lock when checking the validity of a
    vnode's callback state.  The only thing it's needed for is to pin the
    parent volume's server list whilst we search it to find the record of the
    server we're currently using to see if it has been reinitialised (ie. it
    sent us a CB.InitCallBackState* RPC).
    
    Do this by the following means:
    
     (1) Keep an additional per-cell counter (fs_s_break) that's incremented
         each time any of the fileservers in the cell reinitialises.
    
         Since the new counter can be accessed without RCU from the vnode, we
         can check that first - and only if it differs, get the RCU read lock
         and check the volume's server list.
    
     (2) Replace afs_get_s_break_rcu() with afs_check_server_good() which now
         indicates whether the callback promise is still expected to be present
         on the server.  This does the checks as described in (1).
    
     (3) Restructure afs_check_validity() to take account of the change in (2).
    
         We can also get rid of the valid variable and just use the need_clear
         variable with the addition of the afs_cb_break_no_promise reason.
    
     (4) afs_check_validity() probably shouldn't be altering vnode->cb_v_break
         and vnode->cb_s_break when it doesn't have cb_lock exclusively locked.
    
         Move the change to vnode->cb_v_break to __afs_break_callback().
    
         Delegate the change to vnode->cb_s_break to afs_select_fileserver()
         and set vnode->cb_fs_s_break there also.
    
     (5) afs_validate() no longer needs to get the RCU read lock around its
         call to afs_check_validity() - and can skip the call entirely if we
         don't have a promise.
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    Tested-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
    cc: linux-afs@lists.infradead.org
    Link: https://lore.kernel.org/r/163111669583.283156.1397603105683094563.stgit@warthog.procyon.org.uk/
    4fe6a946
rotate.c 13 KB