From patchwork Fri Mar 4 18:00:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12769714 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 30167C433EF for ; Fri, 4 Mar 2022 18:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241432AbiCDSCF (ORCPT ); Fri, 4 Mar 2022 13:02:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241430AbiCDSCB (ORCPT ); Fri, 4 Mar 2022 13:02:01 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC5DF1BD9BA; Fri, 4 Mar 2022 10:01:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=vjzfcuVeqJ5gslcqLmqRcao85OHrZZrw3DMsoQUqsYs=; b=BiKgnhAmpHPz87EcWAzhrmMGp6 JaGZlUMx1zQyrrO53wL2F8YQFToLKhXQl4HjSz2jIgTActUlh7rpAh3BdWhSXI/+4vtYujk7Jn0f4 pzQ4BPjJxSPVLHJVWEzPcl4eu1PlbGAgAgwl/cCFF1TxLVoAKXFkjyUjSU5J1oUyIG9M2g+AfStNA r0ZK3Z/5osrm7jlU9061/F5XSpxy0G39YAXq+7yrRuJ0lZxSeIjfTQedaRT/liapUdpbjZW6JERr1 DatQvFGwUVbQQH9EWGTI5vrTMCVHXEW8lAaao0PKa20ksSwa/e751hFgsK3pWqIr8wMJLQh0xXppG NlXju7tg==; Received: from [2001:4bb8:180:5296:cded:8d4b:ace6:f3c] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQCEn-00BUhb-V7; Fri, 04 Mar 2022 18:01:10 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Song Liu , "Theodore Ts'o" , linux-block@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-ext4@vger.kernel.org Subject: [PATCH 01/10] block: fix and cleanup bio_check_ro Date: Fri, 4 Mar 2022 19:00:56 +0100 Message-Id: <20220304180105.409765-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220304180105.409765-1-hch@lst.de> References: <20220304180105.409765-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org 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 --- 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 94bf37f8e61d2..34e1b7fdb7c89 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -580,14 +580,10 @@ late_initcall(fail_make_request_debugfs); 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; }