• Dave Chinner's avatar
    xfs: reduce lock hold times in buffer writeback · 26f1fe85
    Dave Chinner authored
    When we have a lot of metadata to flush from the AIL, the buffer
    list can get very long. The current submission code tries to batch
    submission to optimise IO order of the metadata (i.e. ascending
    block order) to maximise block layer merging or IO to adjacent
    metadata blocks.
    
    Unfortunately, the method used can result in long lock times
    occurring as buffers locked early on in the buffer list might not be
    dispatched until the end of the IO licst processing. This is because
    sorting does not occur util after the buffer list has been processed
    and the buffers that are going to be submitted are locked. Hence
    when the buffer list is several thousand buffers long, the lock hold
    times before IO dispatch can be significant.
    
    To fix this, sort the buffer list before we start trying to lock and
    submit buffers. This means we can now submit buffers immediately
    after they are locked, allowing merging to occur immediately on the
    plug and dispatch to occur as quickly as possible. This means there
    is minimal delay between locking the buffer and IO submission
    occuring, hence reducing the worst case lock hold times seen during
    delayed write buffer IO submission signficantly.
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    26f1fe85
xfs_buf.c 44.7 KB