diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2018-09-05 18:14:36 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-09-05 18:14:36 -0400 |
commit | 8b2ded1c94c06f841f8c1612bcfa33c85012a36b (patch) | |
tree | a53368fb013c47854de1fc6d18a97e59a1390232 | |
parent | bc811f05d77f47059c197a98b6ad242eb03999cb (diff) |
block: don't warn when doing fsync on read-only devices
It is possible to call fsync on a read-only handle (for example, fsck.ext2
does it when doing read-only check), and this call results in kernel
warning.
The patch b089cfd95d32 ("block: don't warn for flush on read-only device")
attempted to disable the warning, but it is buggy and it doesn't
(op_is_flush tests flags, but bio_op strips off the flags).
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: 721c7fc701c7 ("block: fail op_is_write() requests to read-only partitions")
Cc: stable@vger.kernel.org # 4.18
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/blk-core.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index dee56c282efb..4dbc93f43b38 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -2163,9 +2163,12 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part) | |||
2163 | { | 2163 | { |
2164 | const int op = bio_op(bio); | 2164 | const int op = bio_op(bio); |
2165 | 2165 | ||
2166 | if (part->policy && (op_is_write(op) && !op_is_flush(op))) { | 2166 | if (part->policy && op_is_write(op)) { |
2167 | char b[BDEVNAME_SIZE]; | 2167 | char b[BDEVNAME_SIZE]; |
2168 | 2168 | ||
2169 | if (op_is_flush(bio->bi_opf) && !bio_sectors(bio)) | ||
2170 | return false; | ||
2171 | |||
2169 | WARN_ONCE(1, | 2172 | WARN_ONCE(1, |
2170 | "generic_make_request: Trying to write " | 2173 | "generic_make_request: Trying to write " |
2171 | "to read-only block-device %s (partno %d)\n", | 2174 | "to read-only block-device %s (partno %d)\n", |