Skip to content

Commit b4a6bb3

Browse files
Christoph HellwigDamien Le Moal
Christoph Hellwig
authored and
Damien Le Moal
committed
block: add a sanity check for non-write flush/fua bios
Check that the PREFUSH and FUA flags are only set on write bios, given that the flush state machine expects that. [Damien] The check is also extended to REQ_OP_ZONE_APPEND operations as these are data write operations used by btrfs and zonefs and may also have the REQ_FUA bit set. Reported-by: Damien Le Moal <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Jens Axboe <[email protected]> Reviewed-by: Niklas Cassel <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]>
1 parent 002c487 commit b4a6bb3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

block/blk-core.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,16 @@ void submit_bio_noacct(struct bio *bio)
744744
* Filter flush bio's early so that bio based drivers without flush
745745
* support don't have to worry about them.
746746
*/
747-
if (op_is_flush(bio->bi_opf) &&
748-
!test_bit(QUEUE_FLAG_WC, &q->queue_flags)) {
749-
bio->bi_opf &= ~(REQ_PREFLUSH | REQ_FUA);
750-
if (!bio_sectors(bio)) {
751-
status = BLK_STS_OK;
747+
if (op_is_flush(bio->bi_opf)) {
748+
if (WARN_ON_ONCE(bio_op(bio) != REQ_OP_WRITE &&
749+
bio_op(bio) != REQ_OP_ZONE_APPEND))
752750
goto end_io;
751+
if (!test_bit(QUEUE_FLAG_WC, &q->queue_flags)) {
752+
bio->bi_opf &= ~(REQ_PREFLUSH | REQ_FUA);
753+
if (!bio_sectors(bio)) {
754+
status = BLK_STS_OK;
755+
goto end_io;
756+
}
753757
}
754758
}
755759

0 commit comments

Comments
 (0)