Skip to content

Commit c0f04d8

Browse files
Kent Overstreettorvalds
Kent Overstreet
authored andcommitted
bcache: Fix flushes in writeback mode
In writeback mode, when we get a cache flush we need to make sure we issue a flush to the backing device. The code for sending down an extra flush was wrong - by cloning the bio we were probably getting flags that didn't make sense for a bare flush, and also the old code was firing for FUA bios, for which we don't need to send a flush to the backing device. This was causing data corruption somehow - the mechanism was never determined, but this patch fixes it for the users that were seeing it. Signed-off-by: Kent Overstreet <[email protected]> Cc: linux-stable <[email protected]> # >= v3.10 Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8478643 commit c0f04d8

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/md/bcache/request.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -997,14 +997,17 @@ static void request_write(struct cached_dev *dc, struct search *s)
997997
} else {
998998
bch_writeback_add(dc);
999999

1000-
if (s->op.flush_journal) {
1000+
if (bio->bi_rw & REQ_FLUSH) {
10011001
/* Also need to send a flush to the backing device */
1002-
s->op.cache_bio = bio_clone_bioset(bio, GFP_NOIO,
1003-
dc->disk.bio_split);
1002+
struct bio *flush = bio_alloc_bioset(0, GFP_NOIO,
1003+
dc->disk.bio_split);
10041004

1005-
bio->bi_size = 0;
1006-
bio->bi_vcnt = 0;
1007-
closure_bio_submit(bio, cl, s->d);
1005+
flush->bi_rw = WRITE_FLUSH;
1006+
flush->bi_bdev = bio->bi_bdev;
1007+
flush->bi_end_io = request_endio;
1008+
flush->bi_private = cl;
1009+
1010+
closure_bio_submit(flush, cl, s->d);
10081011
} else {
10091012
s->op.cache_bio = bio;
10101013
}

0 commit comments

Comments
 (0)