Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2969841rdb; Mon, 4 Dec 2023 12:36:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGe/Cr349QpKAGWOTtzNJHfeDYvqBwN57Ug4m72XB21zd9taU1FsecieUQzwskVSXoZVDfl X-Received: by 2002:a05:6a00:450d:b0:6cb:cd3e:93c3 with SMTP id cw13-20020a056a00450d00b006cbcd3e93c3mr187822pfb.16.1701722167236; Mon, 04 Dec 2023 12:36:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701722167; cv=none; d=google.com; s=arc-20160816; b=kYXsQf3kQGjh/G3f8N+zxDPFYd3qxWqbKYJSo4eCy76+XwtpydWM6ObWZvAkmcL0kg dIynWyTuYRafIFXePY3lGZMkVE6phyuXqMZXE2tm7zKxVjspgzLN+v2+Mz9Bb9yDkr7C RXXZUlQ2ZxvljncgbEnZD8n6NSSteQra3y3RyY+sW+8p5pBHQ/T2GNb/qG3twGhEAF4e bkrdcvNEdY3lrEHCeWqXK3aTNl9bg0pbdR/4cs4jLHVbO5PjSW7qDcFe+YtBSQ5WFV0X xsj7yUau9QDfWuqlr7ArAdwRc7Qbc7jxfSsKcNSEyDNzoFVuIZzBDz+wB5AteiO0atDN dRhg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X4gwm54xStCl4WDx+Kzn9zZ099AAiAQGfMCj+xlzZrg=; fh=rJ2LV0/a9Crx+O0D0YQzuC8R22QbHMQk9mKjiuRGYpA=; b=w6h6q0IWXyvEfaEb0Bo7sbhO4ULj96s9yHT1+2ErNGWIJ8zxhu4P6PF0txppt/e0Ug vV5MVo2xHki7a2QNH1uOJMJx8LpR72FY2UXDnn04NnRmXEbpDjfNnH6M9aI0eFDHQv45 KeqJ2J107QgtR60EMlTjunZqblXv74H2/To31IyKjO5UwG0fwKAu0KGLp5Zo4Rwzrrl3 CpT4FT1TbySa9YiqCP/Il7gW3Cfawc2h3Pz1zVWEP9T1M6r815S9C+TO61nw3lmqDvSa LRZ53FGllawHPaYgdiaZQ9RJ/hn/qEz3I8aMTAZ88DZhJv0fHD4r18R8eFEBxE7SPpjI QZWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XQfHhGBa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id cb10-20020a056a02070a00b005c69365abbbsi1829928pgb.318.2023.12.04.12.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 12:36:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XQfHhGBa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 0EE8280473F8; Mon, 4 Dec 2023 12:35:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346222AbjLDUfX (ORCPT + 99 others); Mon, 4 Dec 2023 15:35:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346219AbjLDUex (ORCPT ); Mon, 4 Dec 2023 15:34:53 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FE011A6 for ; Mon, 4 Dec 2023 12:34:12 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E55A9C433CC; Mon, 4 Dec 2023 20:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701722052; bh=PGvdhsaMBMYO+a/7wVrzlPR3gLeQ5lkgOcpsQ7exj7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQfHhGBatVYZl/v4UUhTuuVQvPlpOvQbG7YyiahZTa1JrLQKpvZ6YX/6tMO0yhi1l su5RwV5DxpOhXEv3C/r8Untse3WtPMkak7ETFvaE/rdPDfeTtaMfd7E4fDJK6EKhHx RnHdeqXoBAPdu99vAyvrBi4FAoFVrw/lmEZj2NrZ7W6VrALbmVtWM2OlkrKd91ieAt HW4ZlwaqrcxE0fNWIJOOnhqzy7PTKncMEfPSDXzF1GIHUt7hNtMnkOhbFjnc8PzwjM yjfNGimMAd89GD7e1GBOBAZUp86jaSRHKcJFSPfYwGR94huK1aOboGlwNPIQZ+E2wn 01Dt0u3yVUVEg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yu Kuai , Christoph Hellwig , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 22/32] block: warn once for each partition in bio_check_ro() Date: Mon, 4 Dec 2023 15:32:42 -0500 Message-ID: <20231204203317.2092321-22-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204203317.2092321-1-sashal@kernel.org> References: <20231204203317.2092321-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.4 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 12:35:46 -0800 (PST) From: Yu Kuai [ Upstream commit 67d995e069535c32829f5d368d919063492cec6e ] Commit 1b0a151c10a6 ("blk-core: use pr_warn_ratelimited() in bio_check_ro()") fix message storm by limit the rate, however, there will still be lots of message in the long term. Fix it better by warn once for each partition. Signed-off-by: Yu Kuai Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20231128123027.971610-3-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-core.c | 14 +++++++++++--- include/linux/blk_types.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index fdf25b8d6e784..2eca76ccf4ee0 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -501,9 +501,17 @@ static inline void bio_check_ro(struct bio *bio) if (op_is_write(bio_op(bio)) && bdev_read_only(bio->bi_bdev)) { if (op_is_flush(bio->bi_opf) && !bio_sectors(bio)) return; - pr_warn_ratelimited("Trying to write to read-only block-device %pg\n", - bio->bi_bdev); - /* Older lvm-tools actually trigger this */ + + if (bio->bi_bdev->bd_ro_warned) + return; + + bio->bi_bdev->bd_ro_warned = true; + /* + * Use ioctl to set underlying disk of raid/dm to read-only + * will trigger this. + */ + pr_warn("Trying to write to read-only block-device %pg\n", + bio->bi_bdev); } } diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index d5c5e59ddbd25..92c8997b19381 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -69,6 +69,7 @@ struct block_device { #ifdef CONFIG_FAIL_MAKE_REQUEST bool bd_make_it_fail; #endif + bool bd_ro_warned; /* * keep this out-of-line as it's both big and not needed in the fast * path -- 2.42.0