From patchwork Wed Sep 27 09:34:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13400475 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73524E810B1 for ; Wed, 27 Sep 2023 09:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695807356; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JYy9MxZp2JA9nH+cSvhQ5c7wZhtuI/kx5A+7zdsmd8k=; b=F8mgLAahdySycXHYv6lDFXd4EQZD4iSQgap9Ri7+Ues9ZRsTIFNi/lQHJkD+31ZiHLuoCU KdI/+ttvoHO61SxjOvYI6+DMdjrbLiaz8LYCw3si84TtDLIo73RfCflqHG+VfOYx4yckHT KTWBO1ozQGr5hyDUu4gClrtREkpXvio= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-422-pHmdbtWWN6SRY9Zoob9nnQ-1; Wed, 27 Sep 2023 05:35:53 -0400 X-MC-Unique: pHmdbtWWN6SRY9Zoob9nnQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B900858F19; Wed, 27 Sep 2023 09:35:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29A7540C2070; Wed, 27 Sep 2023 09:35:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D58C21946589; Wed, 27 Sep 2023 09:35:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0BF0A1946588 for ; Wed, 27 Sep 2023 09:34:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F01792156A27; Wed, 27 Sep 2023 09:34:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E855F2156702 for ; Wed, 27 Sep 2023 09:34:48 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7BA7185A790 for ; Wed, 27 Sep 2023 09:34:48 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-JQk_fDvlOxyjnhQWW7mMNQ-1; Wed, 27 Sep 2023 05:34:45 -0400 X-MC-Unique: JQk_fDvlOxyjnhQWW7mMNQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3FDE31FD63; Wed, 27 Sep 2023 09:34:44 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2541413AD9; Wed, 27 Sep 2023 09:34:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id TP8SCTT3E2UYEwAAMHmgww (envelope-from ); Wed, 27 Sep 2023 09:34:44 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 2D803A07DB; Wed, 27 Sep 2023 11:34:43 +0200 (CEST) From: Jan Kara To: Christian Brauner Date: Wed, 27 Sep 2023 11:34:16 +0200 Message-Id: <20230927093442.25915-10-jack@suse.cz> In-Reply-To: <20230818123232.2269-1-jack@suse.cz> References: <20230818123232.2269-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2873; i=jack@suse.cz; h=from:subject; bh=cxZ5Kz93gXUz17a6Tn4ORP3Ydlcs2dUD7Zaids+xfpE=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBlE/cZKA/AFRVswIlrro2MBzY3+t30V0mtFvJ7N5SN EC8DU3eJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZRP3GQAKCRCcnaoHP2RA2b9qB/ 902wlOl4jfQWxLbWROf4tMukcBxO2x1dk8Vr15hj9Canj33g84WS19NhlC/lUPeVTw9S7BIDYm0OO3 Bh/o//hUjYF7ZdMn3M314D0dP0CXU0L4tblL88jkp1434GnMNpFaMKTWXlurTkTqpOPhsZm4QNqWrc mYetdpKQL6q8OdahRz7345W8M50dGKVmcyvZaZzel82JZaXpSBzC9tZSoVi+8UwyL59ARtQRVnnHuY eM53/JbNZH55bdmg5skAZMEzGVsCyO2/xTrfZPJeKVN7vPXY5onUTZuCGgl9ZIpok3GGQcdnSEof56 2EDTOBS+jNRcEeGsY2SPDX5Fvbco8P X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Subject: [dm-devel] [PATCH 10/29] dm: Convert to bdev_open_by_dev() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoph Hellwig , Jan Kara , Mike Snitzer , linux-block@vger.kernel.org, dm-devel@redhat.com, linux-fsdevel@vger.kernel.org, Christoph Hellwig , Alasdair Kergon Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: suse.cz Convert device mapper to use bdev_open_by_dev() and pass the handle around. CC: Alasdair Kergon CC: Mike Snitzer CC: dm-devel@redhat.com Acked-by: Christoph Hellwig Acked-by: Christian Brauner Signed-off-by: Jan Kara --- drivers/md/dm.c | 20 +++++++++++--------- include/linux/device-mapper.h | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 64a1f306c96c..f7212e8fc27f 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -724,7 +724,7 @@ static struct table_device *open_table_device(struct mapped_device *md, dev_t dev, blk_mode_t mode) { struct table_device *td; - struct block_device *bdev; + struct bdev_handle *bdev_handle; u64 part_off; int r; @@ -733,9 +733,9 @@ static struct table_device *open_table_device(struct mapped_device *md, return ERR_PTR(-ENOMEM); refcount_set(&td->count, 1); - bdev = blkdev_get_by_dev(dev, mode, _dm_claim_ptr, NULL); - if (IS_ERR(bdev)) { - r = PTR_ERR(bdev); + bdev_handle = bdev_open_by_dev(dev, mode, _dm_claim_ptr, NULL); + if (IS_ERR(bdev_handle)) { + r = PTR_ERR(bdev_handle); goto out_free_td; } @@ -745,20 +745,22 @@ static struct table_device *open_table_device(struct mapped_device *md, * called. */ if (md->disk->slave_dir) { - r = bd_link_disk_holder(bdev, md->disk); + r = bd_link_disk_holder(bdev_handle->bdev, md->disk); if (r) goto out_blkdev_put; } td->dm_dev.mode = mode; - td->dm_dev.bdev = bdev; - td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev, &part_off, NULL, NULL); + td->dm_dev.bdev = bdev_handle->bdev; + td->dm_dev.bdev_handle = bdev_handle; + td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev_handle->bdev, &part_off, + NULL, NULL); format_dev_t(td->dm_dev.name, dev); list_add(&td->list, &md->table_devices); return td; out_blkdev_put: - blkdev_put(bdev, _dm_claim_ptr); + bdev_release(bdev_handle); out_free_td: kfree(td); return ERR_PTR(r); @@ -771,7 +773,7 @@ static void close_table_device(struct table_device *td, struct mapped_device *md { if (md->disk->slave_dir) bd_unlink_disk_holder(td->dm_dev.bdev, md->disk); - blkdev_put(td->dm_dev.bdev, _dm_claim_ptr); + bdev_release(td->dm_dev.bdev_handle); put_dax(td->dm_dev.dax_dev); list_del(&td->list); kfree(td); diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 69d0435c7ebb..772ab4d74d94 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -165,6 +165,7 @@ void dm_error(const char *message); struct dm_dev { struct block_device *bdev; + struct bdev_handle *bdev_handle; struct dax_device *dax_dev; blk_mode_t mode; char name[16];