Skip to content

Commit ee55b92

Browse files
Mikulas Patockasnitm
authored andcommitted
dm writecache: flush origin device when writing and cache is full
Commit d53f1fa ("dm writecache: do direct write if the cache is full") changed dm-writecache, so that it writes directly to the origin device if the cache is full. Unfortunately, it doesn't forward flush requests to the origin device, so that there is a bug where flushes are being ignored. Fix this by adding missing flush forwarding. For PMEM mode, we fix this bug by disabling direct writes to the origin device, because it performs better. Signed-off-by: Mikulas Patocka <[email protected]> Fixes: d53f1fa ("dm writecache: do direct write if the cache is full") Cc: [email protected] # v5.7+ Signed-off-by: Mike Snitzer <[email protected]>
1 parent 293128b commit ee55b92

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/md/dm-writecache.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,8 +1297,12 @@ static int writecache_map(struct dm_target *ti, struct bio *bio)
12971297
writecache_flush(wc);
12981298
if (writecache_has_error(wc))
12991299
goto unlock_error;
1300+
if (unlikely(wc->cleaner))
1301+
goto unlock_remap_origin;
13001302
goto unlock_submit;
13011303
} else {
1304+
if (dm_bio_get_target_bio_nr(bio))
1305+
goto unlock_remap_origin;
13021306
writecache_offload_bio(wc, bio);
13031307
goto unlock_return;
13041308
}
@@ -1377,7 +1381,7 @@ static int writecache_map(struct dm_target *ti, struct bio *bio)
13771381
}
13781382
e = writecache_pop_from_freelist(wc, (sector_t)-1);
13791383
if (unlikely(!e)) {
1380-
if (!found_entry) {
1384+
if (!WC_MODE_PMEM(wc) && !found_entry) {
13811385
direct_write:
13821386
e = writecache_find_entry(wc, bio->bi_iter.bi_sector, WFE_RETURN_FOLLOWING);
13831387
if (e) {
@@ -2484,7 +2488,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
24842488
goto bad;
24852489
}
24862490

2487-
ti->num_flush_bios = 1;
2491+
ti->num_flush_bios = WC_MODE_PMEM(wc) ? 1 : 2;
24882492
ti->flush_supported = true;
24892493
ti->num_discard_bios = 1;
24902494

0 commit comments

Comments
 (0)