Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3808310rwb; Mon, 16 Jan 2023 13:19:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXtOwfp9DjTdQPjrMdUKuZlNcQQZnzg6h0YN1KZqUHkyQvID5udtTqHLWMrgBY16aT9YuOxn X-Received: by 2002:a17:907:2489:b0:84d:430a:5e5c with SMTP id zg9-20020a170907248900b0084d430a5e5cmr521949ejb.32.1673903988054; Mon, 16 Jan 2023 13:19:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673903988; cv=none; d=google.com; s=arc-20160816; b=CkMyZmZRzXsEoDr8IEnHlYNevsp6d2OcVM0FcoRfRRQ+aOzmhcfrq+KTbiaX3NN2Tp nqlgkSQ55hftHtnDBYbz21rHkHz9t5cOlb5h/ZkJ8Djg+H8Eo8UR0Yskv1A4VXS+hX8z woRNAv6R6nrRHX3vSccub1w5Il5ir+2/7NMj6sCUNM6dtCtdhNgm/2cjXnVIJwbfvdy5 VlhbvHoePKcmnRc4ktMy07jJq1l/eqBAwERgDulTEbgFg4by8D4bekTV4+PKQekDxpS4 G/9CJVyvMcl6/2u21VxADVDWCd5Xk3HN9TzKVO+2+aIzaq3CkCgKS5Wi8UobUpTzXNJr mOCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=aPV6pXyHE8sCh3Ryx3ARXM6RJp4EZ+mnoTRRwaCNjdo=; b=jxngCJ9toqeIeisMWvhJdYrGgjtAChnuO47BW3q4X7lTAu2JOzt/dbZWbFztIF1r48 MQ09rpZ8iHY7hYa5k8b7mWHVuKGc7DuS1igtkScAew7Trm0sTBhFrjKClx47WSNwyDL1 D4Oo0GGd9jtM0D6RuX1Cbxg/j5qKcVF+b7LKVgklmNCWFOmg3Dd3L0qxiYctYsbWnqv0 9Zk3N37/BlywcsLWSOKpN1vwJR+eBvdH6lIawQc5YZdq+fuHGsb3JVPrms+11mfakcT9 c+6nrpPDEol8EzohKcRHWSXphqgrp7gGCCnbnd4jF8ub+vTlnUZMQTsAIg5zuKz3rRwj GN+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b="FXCbw/QY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs40-20020a1709073ea800b007413f3cdd18si7603779ejc.238.2023.01.16.13.19.35; Mon, 16 Jan 2023 13:19:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b="FXCbw/QY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233093AbjAPVBB (ORCPT + 50 others); Mon, 16 Jan 2023 16:01:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbjAPVA6 (ORCPT ); Mon, 16 Jan 2023 16:00:58 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6507035A7; Mon, 16 Jan 2023 13:00:56 -0800 (PST) Received: from fedcomp.intra.ispras.ru (unknown [46.242.14.200]) by mail.ispras.ru (Postfix) with ESMTPSA id 2890F40D403D; Mon, 16 Jan 2023 21:00:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 2890F40D403D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1673902852; bh=aPV6pXyHE8sCh3Ryx3ARXM6RJp4EZ+mnoTRRwaCNjdo=; h=From:To:Cc:Subject:Date:From; b=FXCbw/QYuC8QnIz1VNr3ed5sUSwXO+2jdNi2CUXmtNds4aa/CS3hT4oasox2nhI9z jElg7zq6MjptUH5BBY/pSMziVwEJFJWyttGtjKoqkIDocsvibya9FyGhuaIKitkC+k KDFGNPPA51SsCRpn0sViNH0BKo5iiste8F5iYMXw= 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, Alexey Khoroshilov Subject: [PATCH 5.15] block: fix and cleanup bio_check_ro Date: Tue, 17 Jan 2023 00:00:40 +0300 Message-Id: <20230116210040.804629-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 Signed-off-by: Fedor Pchelkin --- block/blk-core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 13e1fca1e923..ed6271dcc1b1 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -698,14 +698,10 @@ static inline bool should_fail_request(struct block_device *part, static inline bool bio_check_ro(struct bio *bio) { if (op_is_write(bio_op(bio)) && bdev_read_only(bio->bi_bdev)) { - char b[BDEVNAME_SIZE]; - if (op_is_flush(bio->bi_opf) && !bio_sectors(bio)) return false; - - WARN_ONCE(1, - "Trying to write to read-only block-device %s (partno %d)\n", - bio_devname(bio, b), bio->bi_bdev->bd_partno); + pr_warn("Trying to write to read-only block-device %pg\n", + bio->bi_bdev); /* Older lvm-tools actually trigger this */ return false; } -- 2.34.1