Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1940347rdb; Sun, 19 Nov 2023 17:45:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHE7PkchOrTi5VdMTYzVWZSvdB1ybzO6JXfU5ioB0jxW4DT2tW1kFZQnHcdwrh+601vLPPu X-Received: by 2002:a05:6830:1e0d:b0:6c0:ae30:671e with SMTP id s13-20020a0568301e0d00b006c0ae30671emr7722942otr.20.1700444758942; Sun, 19 Nov 2023 17:45:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700444758; cv=none; d=google.com; s=arc-20160816; b=q++Jo2jS/pCmGbvSRNUOunKGRIHZlc0OWMExiXFPoCxEv7hTf1q9kr03hOSCw+1a6B NO5ccirFFsc0VFY8iuocLjoETh6UKrrHd4NSxEt9q1W4WcwRQSr7JkyAOnvEY637sniX CVp2UYYHnaimfBpBrrLyf6wyz265Z9ttwYWgVuz0ocUzl8LCbQ8H1m9d2D6TswnTWsIh j1ixFg+CTmckmzttTkQIFGPUnYnTtrnypZvobub2KB38P5NSxrKBUTL24vnMesGJfiDJ 7MiCzFArKxYHSrmc0wiAFGTsU4idyyWTova3S1/c/hzhGmmjO2jS3sF/GoFKcmuJkU7Q KNWA== 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; bh=lD6zEhCe0JJKcAHDkuTtn7Q1wIe/9K6fnKwgtCh2Rsw=; fh=Oq8AZtSdB9WVO0QeE9Ym+sXB+FvqBHwYg1xHLfVNApg=; b=BDmbp5ZIposReMaTKpB4SdqI1l0RvjxSOpebfEt3woO1qHLuxd+GU3+ThUaTkwPu58 vUfuuO9loihFHu3DzvEkh2gzSoGa6uBM8ZEyfv2XC1IkbMGgA7ncAzjVO/jD9SM7hAbr NWumJGFmbAd6JUTgBYi9spDKqFrF3wStdGGV1QdAis/BHPy+68FTejnItFOX76blUz1/ DtYDyS1x0kzCb3a/uBOuK2ugDyhVv5H1vLfDzsvFi9qlFsKDbuR91Y215ntk65OvUE0D 1Y0uVpqZL+jx48LNEvNM/ZMtBPbDA532J8JjXr1AFqeZ5Vh7GsDOVeMjYNEJs7lEhc6Z b6vA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b14-20020a631b4e000000b005859c255ce9si7179513pgm.861.2023.11.19.17.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 17:45:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5D1E88098FC5; Sun, 19 Nov 2023 17:45:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231782AbjKTBo4 (ORCPT + 99 others); Sun, 19 Nov 2023 20:44:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231633AbjKTBox (ORCPT ); Sun, 19 Nov 2023 20:44:53 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C9CC133; Sun, 19 Nov 2023 17:44:49 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SYVgG0z64z4f3lDV; Mon, 20 Nov 2023 09:44:42 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 4D7371A0173; Mon, 20 Nov 2023 09:44:46 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgA3iA4LulplbmCcBQ--.47132S6; Mon, 20 Nov 2023 09:44:46 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH 2/2] block: warn once for each partition in bio_check_ro() Date: Mon, 20 Nov 2023 17:38:47 +0800 Message-Id: <20231120093847.2228127-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120093847.2228127-1-yukuai1@huaweicloud.com> References: <20231120093847.2228127-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgA3iA4LulplbmCcBQ--.47132S6 X-Coremail-Antispam: 1UD129KBjvJXoW7CF1kXr15WF4xJF47ZrWDJwb_yoW8Ar1rpF 9IgFyrCryjgrW7uan7GF13Aa4rGa1kCry5JrWfZw4FyFy3Kwn2q3Wvgry5Jr48uF4SkrW3 Xr1jkrWkCryDWrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPab4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJr0_GcWl84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2 z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v2 6r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6I AqYI8I648v4I1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAq x4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r 1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF 7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxV WUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTR QNVDUUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-Spam-Status: No, score=-0.8 required=5.0 tests=DATE_IN_FUTURE_06_12, HEADER_FROM_DIFFERENT_DOMAINS,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 groat.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 (groat.vger.email [0.0.0.0]); Sun, 19 Nov 2023 17:45:55 -0800 (PST) From: Yu Kuai 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 --- 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 577a693165d8..ccfc80d0302d 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -502,9 +502,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 (test_bit(BD_FLAG_RO_WARNED, &bio->bi_bdev->flags) || + test_and_set_bit(BD_FLAG_RO_WARNED, &bio->bi_bdev->flags)) + return; + + /* + * 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 95bd26c62655..99d32c841c0d 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -41,6 +41,7 @@ struct bio_crypt_ctx; #define BD_FLAG_WRITE_HOLDER 1 #define BD_FLAG_HAS_SUBMIT_BIO 2 #define BD_FLAG_MAKE_IT_FAIL 3 +#define BD_FLAG_RO_WARNED 4 struct block_device { sector_t bd_start_sect; -- 2.39.2