Commit 8d910125 authored by Jan Kara's avatar Jan Kara Committed by David Sterba

btrfs: Make flush bios explicitely sync

Commit b685d3d6 "block: treat REQ_FUA and REQ_PREFLUSH as
synchronous" removed REQ_SYNC flag from WRITE_{FUA|PREFLUSH|...}
definitions.  generic_make_request_checks() however strips REQ_FUA and
REQ_PREFLUSH flags from a bio when the storage doesn't report volatile
write cache and thus write effectively becomes asynchronous which can
lead to performance regressions

Fix the problem by making sure all bios which are synchronous are
properly marked with REQ_SYNC.

CC: David Sterba <dsterba@suse.com>
CC: linux-btrfs@vger.kernel.org
Fixes: b685d3d6Signed-off-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 4751832d
...@@ -3488,10 +3488,12 @@ static int write_dev_supers(struct btrfs_device *device, ...@@ -3488,10 +3488,12 @@ static int write_dev_supers(struct btrfs_device *device,
* we fua the first super. The others we allow * we fua the first super. The others we allow
* to go down lazy. * to go down lazy.
*/ */
if (i == 0) if (i == 0) {
ret = btrfsic_submit_bh(REQ_OP_WRITE, REQ_FUA, bh); ret = btrfsic_submit_bh(REQ_OP_WRITE,
else REQ_SYNC | REQ_FUA, bh);
} else {
ret = btrfsic_submit_bh(REQ_OP_WRITE, REQ_SYNC, bh); ret = btrfsic_submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
}
if (ret) if (ret)
errors++; errors++;
} }
...@@ -3556,7 +3558,7 @@ static int write_dev_flush(struct btrfs_device *device, int wait) ...@@ -3556,7 +3558,7 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
bio->bi_end_io = btrfs_end_empty_barrier; bio->bi_end_io = btrfs_end_empty_barrier;
bio->bi_bdev = device->bdev; bio->bi_bdev = device->bdev;
bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH;
init_completion(&device->flush_wait); init_completion(&device->flush_wait);
bio->bi_private = &device->flush_wait; bio->bi_private = &device->flush_wait;
device->flush_bio = bio; device->flush_bio = bio;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment