Skip to content

Commit 8d91012

Browse files
jankarakdave
authored andcommitted
btrfs: Make flush bios explicitely sync
Commit b685d3d "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 <[email protected]> CC: [email protected] Fixes: b685d3d Signed-off-by: Jan Kara <[email protected]> Reviewed-by: Liu Bo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 4751832 commit 8d91012

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/btrfs/disk-io.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3488,10 +3488,12 @@ static int write_dev_supers(struct btrfs_device *device,
34883488
* we fua the first super. The others we allow
34893489
* to go down lazy.
34903490
*/
3491-
if (i == 0)
3492-
ret = btrfsic_submit_bh(REQ_OP_WRITE, REQ_FUA, bh);
3493-
else
3491+
if (i == 0) {
3492+
ret = btrfsic_submit_bh(REQ_OP_WRITE,
3493+
REQ_SYNC | REQ_FUA, bh);
3494+
} else {
34943495
ret = btrfsic_submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
3496+
}
34953497
if (ret)
34963498
errors++;
34973499
}
@@ -3556,7 +3558,7 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
35563558

35573559
bio->bi_end_io = btrfs_end_empty_barrier;
35583560
bio->bi_bdev = device->bdev;
3559-
bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
3561+
bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH;
35603562
init_completion(&device->flush_wait);
35613563
bio->bi_private = &device->flush_wait;
35623564
device->flush_bio = bio;

0 commit comments

Comments
 (0)