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 A64BEC636D3 for ; Tue, 31 Jan 2023 13:34:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbjAaNea (ORCPT ); Tue, 31 Jan 2023 08:34:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232317AbjAaNeS (ORCPT ); Tue, 31 Jan 2023 08:34:18 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F87851423; Tue, 31 Jan 2023 05:34:11 -0800 (PST) Received: from fpc.intra.ispras.ru (unknown [10.10.165.11]) by mail.ispras.ru (Postfix) with ESMTPSA id 45C2C40D403D; Tue, 31 Jan 2023 13:34:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 45C2C40D403D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1675172049; bh=GO7rQ3YnyPbvVQ6S5q0dnpEgom7k1sfTIO7vuJhqQNg=; h=From:To:Cc:Subject:Date:From; b=JLYGt7Brmw3nzlsjfYBKYhS55VRekLCSrgfI90Ug80FZhn3BTVAsh/hdv3yaPnhR9 dk99zL7faN+ySXaiGvCs4I3Y8GKGEubAcDtiePR/tMc7wSAP7qilHf8kokKwdWhaW2 40BTAiisobOgu9FDafFrLiw6sFWjkID4E0IsUpBo= 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 4.19] block: fix and cleanup bio_check_ro Date: Tue, 31 Jan 2023 16:34:01 +0300 Message-Id: <20230131133401.877826-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 80f3e729fdd4..4fbf915d9cb0 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2179,10 +2179,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