* [PATCH] block: don't warn when calling fsync on read-only block devices
@ 2018-08-22 16:23 Mikulas Patocka
2018-08-22 16:26 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Mikulas Patocka @ 2018-08-22 16:23 UTC (permalink / raw)
To: Jens Axboe
Cc: Ilya Dryomov, Sagi Grimberg, Mike Snitzer, Zdenek Kabelac, WGH,
linux-block
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. This bug was introduced by the commit 721c7fc701c7 "block: fail
op_is_write() requests to read-only partitions".
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
---
block/blk-core.c | 3 +++
drivers/md/dm-verity-target.c | 33 +++++++++++++++++----------------
2 files changed, 20 insertions(+), 16 deletions(-)
Index: linux-2.6/block/blk-core.c
===================================================================
--- linux-2.6.orig/block/blk-core.c 2018-08-15 16:47:18.930000000 +0200
+++ linux-2.6/block/blk-core.c 2018-08-22 16:37:19.680000000 +0200
@@ -2155,6 +2155,9 @@ static inline bool bio_check_ro(struct b
if (part->policy && op_is_write(bio_op(bio))) {
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",
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: don't warn when calling fsync on read-only block devices
2018-08-22 16:23 [PATCH] block: don't warn when calling fsync on read-only block devices Mikulas Patocka
@ 2018-08-22 16:26 ` Jens Axboe
2018-09-03 22:05 ` Mikulas Patocka
0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2018-08-22 16:26 UTC (permalink / raw)
To: Mikulas Patocka
Cc: Ilya Dryomov, Sagi Grimberg, Mike Snitzer, Zdenek Kabelac, WGH,
linux-block
On 8/22/18 10:23 AM, Mikulas Patocka wrote:
> 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. This bug was introduced by the commit 721c7fc701c7 "block: fail
> op_is_write() requests to read-only partitions".
Similar patch is already queued up, it'll go into Linus's tree before
-rc1.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: don't warn when calling fsync on read-only block devices
2018-08-22 16:26 ` Jens Axboe
@ 2018-09-03 22:05 ` Mikulas Patocka
2018-09-05 22:14 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Mikulas Patocka @ 2018-09-03 22:05 UTC (permalink / raw)
To: Jens Axboe
Cc: Ilya Dryomov, Sagi Grimberg, Mike Snitzer, Zdenek Kabelac, WGH,
linux-block, Stefan Agner
On Wed, 22 Aug 2018, Jens Axboe wrote:
> On 8/22/18 10:23 AM, Mikulas Patocka wrote:
> > 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. This bug was introduced by the commit 721c7fc701c7 "block: fail
> > op_is_write() requests to read-only partitions".
>
> Similar patch is already queued up, it'll go into Linus's tree before
> -rc1.
>
> --
> Jens Axboe
I think you mean the patch b089cfd95d32638335c551651a8e00fd2c4edb0b, but
it doesn't work.
The first problem is that bio_op returns the opcode, but op_is_flush
expects flags as its parameter. bio_op strips off the flags, and so the
condition op_is_flush is never true and the warning is not shut off.
Anoher problem is that the flags REQ_FUA and REQ_PREFLUSH may be
superimposed on regular write bio and in that case the warning should be
triggered. We want to shut the warning off only if bio_sectors is zero
(i.e. if the flush request is not superimposed on regular write).
Mikulas
From: Mikulas Patocka <mpatocka@redhat.com>
Subject: [PATCH] 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
---
block/blk-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: linux-2.6/block/blk-core.c
===================================================================
--- linux-2.6.orig/block/blk-core.c 2018-09-03 23:32:38.550000000 +0200
+++ linux-2.6/block/blk-core.c 2018-09-03 23:33:11.960000000 +0200
@@ -2163,9 +2163,12 @@ static inline bool bio_check_ro(struct b
{
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",
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: don't warn when calling fsync on read-only block devices
2018-09-03 22:05 ` Mikulas Patocka
@ 2018-09-05 22:14 ` Jens Axboe
0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2018-09-05 22:14 UTC (permalink / raw)
To: Mikulas Patocka
Cc: Ilya Dryomov, Sagi Grimberg, Mike Snitzer, Zdenek Kabelac, WGH,
linux-block, Stefan Agner
On 9/3/18 4:05 PM, Mikulas Patocka wrote:
>
>
> On Wed, 22 Aug 2018, Jens Axboe wrote:
>
>> On 8/22/18 10:23 AM, Mikulas Patocka wrote:
>>> 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. This bug was introduced by the commit 721c7fc701c7 "block: fail
>>> op_is_write() requests to read-only partitions".
>>
>> Similar patch is already queued up, it'll go into Linus's tree before
>> -rc1.
>>
>> --
>> Jens Axboe
>
> I think you mean the patch b089cfd95d32638335c551651a8e00fd2c4edb0b, but
> it doesn't work.
>
> The first problem is that bio_op returns the opcode, but op_is_flush
> expects flags as its parameter. bio_op strips off the flags, and so the
> condition op_is_flush is never true and the warning is not shut off.
>
> Anoher problem is that the flags REQ_FUA and REQ_PREFLUSH may be
> superimposed on regular write bio and in that case the warning should be
> triggered. We want to shut the warning off only if bio_sectors is zero
> (i.e. if the flush request is not superimposed on regular write).
Thanks for fixing that up, that was somewhat of a disaster. Applied.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-09-05 22:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-22 16:23 [PATCH] block: don't warn when calling fsync on read-only block devices Mikulas Patocka
2018-08-22 16:26 ` Jens Axboe
2018-09-03 22:05 ` Mikulas Patocka
2018-09-05 22:14 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.