Skip to content

Commit 8b2ded1

Browse files
Mikulas Patockaaxboe
authored andcommitted
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 b089cfd ("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: 721c7fc ("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>
1 parent bc811f0 commit 8b2ded1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

block/blk-core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2163,9 +2163,12 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
21632163
{
21642164
const int op = bio_op(bio);
21652165

2166-
if (part->policy && (op_is_write(op) && !op_is_flush(op))) {
2166+
if (part->policy && op_is_write(op)) {
21672167
char b[BDEVNAME_SIZE];
21682168

2169+
if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
2170+
return false;
2171+
21692172
WARN_ONCE(1,
21702173
"generic_make_request: Trying to write "
21712174
"to read-only block-device %s (partno %d)\n",

0 commit comments

Comments
 (0)