Skip to content

Commit 3e44f32

Browse files
Christoph HellwigKent Overstreet
authored andcommitted
bcachefs: fix incorrect usage of REQ_OP_FLUSH
REQ_OP_FLUSH is only for internal use in the blk-mq and request based drivers. File systems and other block layer consumers must use REQ_OP_WRITE | REQ_PREFLUSH as documented in Documentation/block/writeback_cache_control.rst. While REQ_OP_FLUSH appears to work for blk-mq drivers it does not get the proper flush state machine handling, and completely fails for any bio based drivers, including all the stacking drivers. The block layer will also get a check in 6.8 to reject this use case entirely. [Note: completely untested, but as this never got fixed since the original bug report in November: https://bugzilla.kernel.org/show_bug.cgi?id=218184 and the the discussion in December: https://lore.kernel.org/all/20231221053016.72cqcfg46vxwohcj@moria.home.lan/T/ this seems to be best way to force it] Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 612e111 commit 3e44f32

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

fs/bcachefs/fs-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void bch2_inode_flush_nocow_writes_async(struct bch_fs *c,
7979
continue;
8080

8181
bio = container_of(bio_alloc_bioset(ca->disk_sb.bdev, 0,
82-
REQ_OP_FLUSH,
82+
REQ_OP_WRITE|REQ_PREFLUSH,
8383
GFP_KERNEL,
8484
&c->nocow_flush_bioset),
8585
struct nocow_flush, bio);

fs/bcachefs/journal_io.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,8 @@ CLOSURE_CALLBACK(bch2_journal_write)
19881988
percpu_ref_get(&ca->io_ref);
19891989

19901990
bio = ca->journal.bio;
1991-
bio_reset(bio, ca->disk_sb.bdev, REQ_OP_FLUSH);
1991+
bio_reset(bio, ca->disk_sb.bdev,
1992+
REQ_OP_WRITE|REQ_PREFLUSH);
19921993
bio->bi_end_io = journal_write_endio;
19931994
bio->bi_private = ca;
19941995
closure_bio_submit(bio, cl);

0 commit comments

Comments
 (0)