From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-eopbgr710138.outbound.protection.outlook.com ([40.107.71.138]:50096 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727592AbeH3WGk (ORCPT ); Thu, 30 Aug 2018 18:06:40 -0400 From: Sasha Levin To: "stable@vger.kernel.org" CC: Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.18 050/113] block: don't warn for flush on read-only device Date: Thu, 30 Aug 2018 18:03:16 +0000 Message-ID: <20180830180050.35735-50-alexander.levin@microsoft.com> References: <20180830180050.35735-1-alexander.levin@microsoft.com> In-Reply-To: <20180830180050.35735-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jens Axboe [ 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 parti= tions") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index ee33590f54eb..3bb7237a2384 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2152,7 +2152,9 @@ static inline bool should_fail_request(struct hd_stru= ct *part, =20 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 =3D bio_op(bio); + + if (part->policy && (op_is_write(op) && !op_is_flush(op))) { char b[BDEVNAME_SIZE]; =20 WARN_ONCE(1, --=20 2.17.1