• Chris Mason's avatar
    Btrfs: Avoid writeback stalls · d2c3f4f6
    Chris Mason authored
    While building large bios in writepages, btrfs may end up waiting
    for other page writeback to finish if WB_SYNC_ALL is used.
    
    While it is waiting, the bio it is building has a number of pages with the
    writeback bit set and they aren't getting to the disk any time soon.  This
    lowers the latencies of writeback in general by sending down the bio being
    built before waiting for other pages.
    
    The bio submission code tries to limit the total number of async bios in
    flight by waiting when we're over a certain number of async bios.  But,
    the waits are happening while writepages is building bios, and this can easily
    lead to stalls and other problems for people calling wait_on_page_writeback.
    
    The current fix is to let the congestion tests take care of waiting.
    
    sync() and others make sure to drain the current async requests to make
    sure that everything that was pending when the sync was started really get
    to disk.  The code would drain pending requests both before and after
    submitting a new request.
    
    But, if one of the requests is waiting for page writeback to finish,
    the draining waits might block that page writeback.  This changes the
    draining code to only wait after submitting the bio being processed.
    Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
    d2c3f4f6
extent_io.c 93.2 KB