From: Jens Axboe Date: Tue, 14 Aug 2018 16:52:40 +0000 (-0600) Subject: block: don't warn for flush on read-only device X-Git-Tag: v4.18.8~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b02fd8a8dc25e237b2f8b78ff662c6b4d6995598;p=thirdparty%2Fkernel%2Fstable.git block: don't warn for flush on read-only device [ Upstream commit b089cfd95d32638335c551651a8e00fd2c4edb0b ] 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 Fixes: 721c7fc701c7 ("block: fail op_is_write() requests to read-only partitions") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/block/blk-core.c b/block/blk-core.c index 1646ea85dadeb..746a5eac45410 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2159,7 +2159,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]; WARN_ONCE(1,