• Chris Mason's avatar
    Btrfs: don't allow WRITE_SYNC bios to starve out regular writes · d84275c9
    Chris Mason authored
    
    
    Btrfs uses dedicated threads to submit bios when checksumming is on,
    which allows us to make sure the threads dedicated to checksumming don't get
    stuck waiting for requests.  For each btrfs device, there are
    two lists of bios.  One list is for WRITE_SYNC bios and the other
    is for regular priority bios.
    
    The IO submission threads used to process all of the WRITE_SYNC bios first and
    then switch to the regular bios.  This commit makes sure we don't completely
    starve the regular bios by rotating between the two lists.
    
    WRITE_SYNC bios are still favored 2:1 over the regular bios, and this tries
    to run in batches to avoid seeking.  Benchmarking shows this eliminates
    stalls during streaming buffered writes on both multi-device and
    single device filesystems.
    
    If the regular bios starve, the system can end up with a large amount of ram
    pinned down in writeback pages.  If we are a little more fair between the two
    classes, we're able to keep throughput up and make progress on the bulk of
    our dirty ram.
    Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
    d84275c9