Skip to content

Commit

Permalink
Btrfs: force unplugs when switching from high to regular priority bios
Browse files Browse the repository at this point in the history
Btrfs does bio submissions from a worker thread, and each device
has a list of high priority bios and regular priority bios.

Synchronous writes go to the high priority thread while async writes
go to regular list.  This commit brings back an explicit unplug
any time we switch from high to regular priority, which makes it
easier for the block layer to give us low latencies.

Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
chrismason-xx committed Aug 5, 2011
1 parent 0d10ee2 commit 2ab1ba6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ static noinline int run_scheduled_bios(struct btrfs_device *device)
unsigned long limit;
unsigned long last_waited = 0;
int force_reg = 0;
int sync_pending;
struct blk_plug plug;

/*
Expand Down Expand Up @@ -229,6 +230,22 @@ static noinline int run_scheduled_bios(struct btrfs_device *device)

BUG_ON(atomic_read(&cur->bi_cnt) == 0);

/*
* if we're doing the sync list, record that our
* plug has some sync requests on it
*
* If we're doing the regular list and there are
* sync requests sitting around, unplug before
* we add more
*/
if (pending_bios == &device->pending_sync_bios) {
sync_pending = 1;
} else if (sync_pending) {
blk_finish_plug(&plug);
blk_start_plug(&plug);
sync_pending = 0;
}

submit_bio(cur->bi_rw, cur);
num_run++;
batch_run++;
Expand Down

0 comments on commit 2ab1ba6

Please sign in to comment.