Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Btrfs: force unplugs when switching from high to regular priority bios

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 <chris.mason@oracle.com>

+17
+17
fs/btrfs/volumes.c
··· 142 142 unsigned long limit; 143 143 unsigned long last_waited = 0; 144 144 int force_reg = 0; 145 + int sync_pending; 145 146 struct blk_plug plug; 146 147 147 148 /* ··· 229 228 wake_up(&fs_info->async_submit_wait); 230 229 231 230 BUG_ON(atomic_read(&cur->bi_cnt) == 0); 231 + 232 + /* 233 + * if we're doing the sync list, record that our 234 + * plug has some sync requests on it 235 + * 236 + * If we're doing the regular list and there are 237 + * sync requests sitting around, unplug before 238 + * we add more 239 + */ 240 + if (pending_bios == &device->pending_sync_bios) { 241 + sync_pending = 1; 242 + } else if (sync_pending) { 243 + blk_finish_plug(&plug); 244 + blk_start_plug(&plug); 245 + sync_pending = 0; 246 + } 232 247 233 248 submit_bio(cur->bi_rw, cur); 234 249 num_run++;