block: don't warn for flush on read-only device
authorJens Axboe <axboe@kernel.dk>
Tue, 14 Aug 2018 16:52:40 +0000 (10:52 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 14 Aug 2018 16:52:40 +0000 (10:52 -0600)
Don't warn for a flush issued to a read-only device. It's not strictly
a writable command, as it doesn't change any on-media data by itself.

Reported-by: Stefan Agner <stefan@agner.ch>
Fixes: 721c7fc701c7 ("block: fail op_is_write() requests to read-only partitions")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c

index 49af34bf2119cd972962162a9cd6bf8dbccf1883..7aeef19704f2e220ceed5a6e03d737ba67f36da5 100644 (file)
@@ -2162,7 +2162,9 @@ static inline bool should_fail_request(struct hd_struct *part,
 
 static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
 {
-       if (part->policy && op_is_write(bio_op(bio))) {
+       const int op = bio_op(bio);
+
+       if (part->policy && (op_is_write(op) && !op_is_flush(op))) {
                char b[BDEVNAME_SIZE];
 
                printk(KERN_ERR