• Chris Mason's avatar
    Btrfs: keep processing bios for a given bdev if our proc is batching · b765ead5
    Chris Mason authored
    Btrfs uses async helper threads to submit write bios so the checksumming
    helper threads don't block on the disk.
    The submit bio threads may process bios for more than one block device,
    so when they find one device congested they try to move on to other
    devices instead of blocking in get_request_wait for one device.
    This does a pretty good job of keeping multiple devices busy, but the
    congested flag has a number of problems.  A congested device may still
    give you a request, and other procs that aren't backing off the congested
    device may starve you out.
    This commit uses the io_context stored in current to decide if our process
    has been made a batching process by the block layer.  If so, it keeps
    sending IO down for at least one batch.  This helps make sure we do
    a good amount of work each time we visit a bdev, and avoids large IO
    stalls in multi-device workloads.
    It's also very ugly.  A better solution is in the works with Jens Axboe.
    Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>