• David Howells's avatar
    afs: Optimise callback breaking by not repeating volume lookup · 47ea0f2e
    David Howells authored
    At the moment, afs_break_callbacks calls afs_break_one_callback() for each
    separate FID it was given, and the latter looks up the volume individually
    for each one.
    
    However, this is inefficient if two or more FIDs have the same vid as we
    could reuse the volume.  This is complicated by cell aliasing whereby we
    may have multiple cells sharing a volume and can therefore have multiple
    callback interests for any particular volume ID.
    
    At the moment afs_break_one_callback() scans the entire list of volumes
    we're getting from a server and breaks the appropriate callback in every
    matching volume, regardless of cell.  This scan is done for every FID.
    
    Optimise callback breaking by the following means:
    
     (1) Sort the FID list by vid so that all FIDs belonging to the same volume
         are clumped together.
    
         This is done through the use of an indirection table as we cannot do
         an insertion sort on the afs_callback_break array as we decode FIDs
         into it as we subsequently also have to decode callback info into it
         that corresponds by array index only.
    
         We also don't really want to bubblesort afterwards if we can avoid it.
    
     (2) Sort the server->cb_interests array by vid so that all the matching
         volumes are grouped together.  This permits the scan to stop after
         finding a record that has a higher vid.
    
     (3) When breaking FIDs, we try to keep server->cb_break_lock as long as
         possible, caching the start point in the array for that volume group
         as long as possible.
    
         It might make sense to add another layer in that list and have a
         refcounted volume ID anchor that has the matching interests attached
         to it rather than being in the list.  This would allow the lock to be
         dropped without losing the cursor.
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    47ea0f2e
server.c 16.6 KB