Skip to content

Commit

Permalink
block: don't warn when doing fsync on read-only devices
Browse files Browse the repository at this point in the history
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 <[email protected]>
Fixes: 721c7fc ("block: fail op_is_write() requests to read-only partitions")
Cc: [email protected]	# 4.18
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Mikulas Patocka authored and axboe committed Sep 5, 2018
1 parent bc811f0 commit 8b2ded1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2163,9 +2163,12 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
{
const int op = bio_op(bio);

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

if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
return false;

WARN_ONCE(1,
"generic_make_request: Trying to write "
"to read-only block-device %s (partno %d)\n",
Expand Down

0 comments on commit 8b2ded1

Please sign in to comment.