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

dm: make flush bios explicitly sync

Commit b685d3d65ac7 ("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.

Fixes: b685d3d65ac7 ("block: treat REQ_FUA and REQ_PREFLUSH as synchronous")
Cc: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

Jan Kara and committed by
Mike Snitzer
ff0361b3 8c1e2162

+7 -5
+1 -1
drivers/md/dm-bufio.c
··· 1334 1334 { 1335 1335 struct dm_io_request io_req = { 1336 1336 .bi_op = REQ_OP_WRITE, 1337 - .bi_op_flags = REQ_PREFLUSH, 1337 + .bi_op_flags = REQ_PREFLUSH | REQ_SYNC, 1338 1338 .mem.type = DM_IO_KMEM, 1339 1339 .mem.ptr.addr = NULL, 1340 1340 .client = c->dm_io,
+2 -1
drivers/md/dm-integrity.c
··· 783 783 for (i = 0; i < commit_sections; i++) 784 784 rw_section_mac(ic, commit_start + i, true); 785 785 } 786 - rw_journal(ic, REQ_OP_WRITE, REQ_FUA, commit_start, commit_sections, &io_comp); 786 + rw_journal(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, commit_start, 787 + commit_sections, &io_comp); 787 788 } else { 788 789 unsigned to_end; 789 790 io_comp.in_flight = (atomic_t)ATOMIC_INIT(2);
+1 -1
drivers/md/dm-raid1.c
··· 260 260 struct mirror *m; 261 261 struct dm_io_request io_req = { 262 262 .bi_op = REQ_OP_WRITE, 263 - .bi_op_flags = REQ_PREFLUSH, 263 + .bi_op_flags = REQ_PREFLUSH | REQ_SYNC, 264 264 .mem.type = DM_IO_KMEM, 265 265 .mem.ptr.addr = NULL, 266 266 .client = ms->io_client,
+2 -1
drivers/md/dm-snap-persistent.c
··· 741 741 /* 742 742 * Commit exceptions to disk. 743 743 */ 744 - if (ps->valid && area_io(ps, REQ_OP_WRITE, REQ_PREFLUSH | REQ_FUA)) 744 + if (ps->valid && area_io(ps, REQ_OP_WRITE, 745 + REQ_PREFLUSH | REQ_FUA | REQ_SYNC)) 745 746 ps->valid = 0; 746 747 747 748 /*
+1 -1
drivers/md/dm.c
··· 1657 1657 1658 1658 bio_init(&md->flush_bio, NULL, 0); 1659 1659 md->flush_bio.bi_bdev = md->bdev; 1660 - md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; 1660 + md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC; 1661 1661 1662 1662 dm_stats_init(&md->stats); 1663 1663