Skip to content

Commit 5a8948f

Browse files
jankarashligit
authored andcommitted
md: 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: [email protected] CC: Shaohua Li <[email protected]> Fixes: b685d3d CC: [email protected] Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Shaohua Li <[email protected]>
1 parent e153903 commit 5a8948f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

drivers/md/md.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev,
765765
test_bit(FailFast, &rdev->flags) &&
766766
!test_bit(LastDev, &rdev->flags))
767767
ff = MD_FAILFAST;
768-
bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_FUA | ff;
768+
bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH | REQ_FUA | ff;
769769

770770
atomic_inc(&mddev->pending_writes);
771771
submit_bio(bio);

drivers/md/raid5-cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ static int r5l_log_write_empty_meta_block(struct r5l_log *log, sector_t pos,
17821782
mb->checksum = cpu_to_le32(crc32c_le(log->uuid_checksum,
17831783
mb, PAGE_SIZE));
17841784
if (!sync_page_io(log->rdev, pos, PAGE_SIZE, page, REQ_OP_WRITE,
1785-
REQ_FUA, false)) {
1785+
REQ_SYNC | REQ_FUA, false)) {
17861786
__free_page(page);
17871787
return -EIO;
17881788
}
@@ -2388,7 +2388,7 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
23882388
mb->checksum = cpu_to_le32(crc32c_le(log->uuid_checksum,
23892389
mb, PAGE_SIZE));
23902390
sync_page_io(log->rdev, ctx->pos, PAGE_SIZE, page,
2391-
REQ_OP_WRITE, REQ_FUA, false);
2391+
REQ_OP_WRITE, REQ_SYNC | REQ_FUA, false);
23922392
sh->log_start = ctx->pos;
23932393
list_add_tail(&sh->r5c, &log->stripe_in_journal_list);
23942394
atomic_inc(&log->stripe_in_journal_count);

drivers/md/raid5-ppl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,8 @@ static int ppl_write_empty_header(struct ppl_log *log)
907907
pplhdr->checksum = cpu_to_le32(~crc32c_le(~0, pplhdr, PAGE_SIZE));
908908

909909
if (!sync_page_io(rdev, rdev->ppl.sector - rdev->data_offset,
910-
PPL_HEADER_SIZE, page, REQ_OP_WRITE | REQ_FUA, 0,
911-
false)) {
910+
PPL_HEADER_SIZE, page, REQ_OP_WRITE | REQ_SYNC |
911+
REQ_FUA, 0, false)) {
912912
md_error(rdev->mddev, rdev);
913913
ret = -EIO;
914914
}

0 commit comments

Comments
 (0)