Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69C20C636D4 for ; Tue, 31 Jan 2023 13:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232341AbjAaNaf (ORCPT ); Tue, 31 Jan 2023 08:30:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232254AbjAaNaL (ORCPT ); Tue, 31 Jan 2023 08:30:11 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 369B04FCF2; Tue, 31 Jan 2023 05:30:03 -0800 (PST) Received: from fpc.intra.ispras.ru (unknown [10.10.165.11]) by mail.ispras.ru (Postfix) with ESMTPSA id 5E07844C101C; Tue, 31 Jan 2023 13:30:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 5E07844C101C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1675171801; bh=mI19dm7Fk00QlQvujoR9rtAuLR5XJESDyEf9vZSEIpU=; h=From:To:Cc:Subject:Date:From; b=Hf5gL8ZZYTkT5jwoo18OKYu6LCX0r5Wcn8jIK0Gd1jF9QFGZ/vtLBrMXPMaE12Zho NTHCfGEwP4fBAg6vhAJgfvKEJu7EB5QH8I+/ObFe566WqnKeGNW+0rkWI1VQL6cHR5 /yJlfQtFlzR7GMGlJFh8cRWSFUxumbFkrsFpNtr8= From: Fedor Pchelkin To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Fedor Pchelkin , Jens Axboe , Christoph Hellwig , Chaitanya Kulkarni , Johannes Thumshirn , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Alexey Khoroshilov Subject: [PATCH v2 5.4] block: fix and cleanup bio_check_ro Date: Tue, 31 Jan 2023 16:29:50 +0300 Message-Id: <20230131132950.873202-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig commit 57e95e4670d1126c103305bcf34a9442f49f6d6a upstream. Don't use a WARN_ON when printing a potentially user triggered condition. Also don't print the partno when the block device name already includes it, and use the %pg specifier to simplify printing the block device name. Signed-off-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn Link: https://lore.kernel.org/r/20220304180105.409765-2-hch@lst.de Signed-off-by: Jens Axboe [the formatted string layout is not changed because struct bio hasn't got bi_bdev field in stable branches older than 5.15; generic_make_request is removed as it is unnecessary] Signed-off-by: Fedor Pchelkin --- v1->v2: added backport comment block/blk-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 5808baa950c3..030de4fdf9b1 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -793,10 +793,7 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part) 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", + pr_warn("Trying to write to read-only block-device %s (partno %d)\n", bio_devname(bio, b), part->partno); /* Older lvm-tools actually trigger this */ return false; -- 2.34.1