From patchwork Tue Jul 4 12:21:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13301090 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1A33EB64D9 for ; Tue, 4 Jul 2023 12:22:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28F7B900019; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23FC590000D; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BA80900019; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F131290000D for ; Tue, 4 Jul 2023 08:22:29 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9B37E140A37 for ; Tue, 4 Jul 2023 12:22:29 +0000 (UTC) X-FDA: 80973842418.18.10C831F Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf18.hostedemail.com (Postfix) with ESMTP id 40D061C0025 for ; Tue, 4 Jul 2023 12:22:26 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Yfx9ztWk; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=vF6CF3Ol; spf=pass (imf18.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688473347; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Y5Z0PpLwK7LWiMwHAJV3g58wt4Pu7/r/oCMflfsspxI=; b=fcJqNiGaPerXdzSleJqZ0avQFS64DnnEaP2Y7ji/OpzG/6YX2w7FfpU1hmLbAzlerxXbBS 3rkctGztFaT9IE0VswFZdJBhrKiDd2iZkcicmEsKimxOmlYzKB6KYhYdFg/dox5SMYQPKD 4eNmtdQPccJ7Q/So07zoTwIT2u0FT14= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688473347; a=rsa-sha256; cv=none; b=3cPfN7MviteLhoHra6ldK/cM+Qqia/aSo9M8Dn2aXKLl9SgKHmpIGEjo/BA2wIEa0GRUvy GvHQFSnnB0YhsRcdq0+ntzAH0QmVG8pSQ3vxmro5ujuD0vKzXS3ZeboBD6vvdD1O9eGTdS 6QhS5Bum6MpJqipazoILtjcfB4Tmfr4= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Yfx9ztWk; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=vF6CF3Ol; spf=pass (imf18.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none 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-out1.suse.de (Postfix) with ESMTPS id 5D9E422868; Tue, 4 Jul 2023 12:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1688473345; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y5Z0PpLwK7LWiMwHAJV3g58wt4Pu7/r/oCMflfsspxI=; b=Yfx9ztWkVatt0fVfNPxdamFDjV837Nu56ImHpS3yWvwdcdXXyeJ1ONnOd+6RA+xJckyxi2 Fr1h4BOlDMHKk2yJxxmlop9vtybjvkzPRI8sOxjaR75gWlVSNQjeXkVo/sHlsqPbUV+LJG uG3Fi84JhxR4KPvRm9XoLJxwd0lLAD0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1688473345; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y5Z0PpLwK7LWiMwHAJV3g58wt4Pu7/r/oCMflfsspxI=; b=vF6CF3OlMOzmEcsCihpnKLEsv6y6u4duYbSxFgbJ4TrA9OaJnML/9G2T1z6YHtiVQ3zwq6 zVCIM6qtTQOYAOBg== 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 433C713A97; Tue, 4 Jul 2023 12:22:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fiTSDwEPpGQQMAAAMHmgww (envelope-from ); Tue, 04 Jul 2023 12:22:25 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 97B9EA0763; Tue, 4 Jul 2023 14:22:24 +0200 (CEST) From: Jan Kara To: Cc: , Jens Axboe , Christoph Hellwig , Jan Kara , Alasdair Kergon , Andrew Morton , Anna Schumaker , Chao Yu , Christian Borntraeger , "Darrick J. Wong" , Dave Kleikamp , David Sterba , dm-devel@redhat.com, drbd-dev@lists.linbit.com, Gao Xiang , Jack Wang , Jaegeuk Kim , jfs-discussion@lists.sourceforge.net, Joern Engel , Joseph Qi , Kent Overstreet , linux-bcache@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mm@kvack.org, linux-mtd@lists.infradead.org, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-nvme@lists.infradead.org, linux-pm@vger.kernel.org, linux-raid@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-xfs@vger.kernel.org, "Md. Haris Iqbal" , Mike Snitzer , Minchan Kim , ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org, Sergey Senozhatsky , Song Liu , Sven Schnelle , target-devel@vger.kernel.org, Ted Tso , Trond Myklebust , xen-devel@lists.xenproject.org Subject: [PATCH 01/32] block: Provide blkdev_get_handle_* functions Date: Tue, 4 Jul 2023 14:21:28 +0200 Message-Id: <20230704122224.16257-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230629165206.383-1-jack@suse.cz> References: <20230629165206.383-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5599; i=jack@suse.cz; h=from:subject; bh=repJSb0/C5PfG8Cx5q/n/kNJZOabhc2tYWxiICNNTtg=; b=owGbwMvMwME4Z+4qdvsUh5uMp9WSGFKW8J3uuK2gorZt+knOzhX81snTGX/57phWXzfXM3w+50Xl rfb7OxmNWRgYORhkxRRZVkde1L42z6hra6iGDMwgViaQKQxcnAIwERsLDobphetsJoi99quKYIut26 wgv/K+lUS+secym02t85epsOp8rtu3acJMN1WFRiX1irKCnSu+LXh+rVyp65RAEGttl+XcP32mOR0n ZJYFm7orF8YFnhVftYzZjm2Rva3I0oqXdap/bUJr8qNjVVfHnBRiFEv0Ocgpck1jlTHfEWUu71NrKu 8EXrbnsfD7wm1qKHDqnnnD21y1n9OFHn8/7qJz4O19panPLvMxrOrNn970IcH6rnhQsq0ZS1v6JUfN RS5ah5XMXNI/c14+vVlVkPVI9n2HQNZlEfdsO13VFx17Z7f0vKnN9UZZ3Zii6WbsWS81/qefFs1Ljl +dK1sZIpSRdXfx+jksz9T4il4AAA== X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Queue-Id: 40D061C0025 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: p88c8jatxw65n61kxnp4oqb8brhhinsr X-HE-Tag: 1688473346-710850 X-HE-Meta: U2FsdGVkX1/lfFj8c7w5L4KPgGRBMCbmo28Mak53U1PiEQ08xe3Gsc/w//iSGdKiolKUDVBoIOqrmZGbx5Pk8f3Dr3Hk7cht/OAHs9pnzMB9I09DwUgFojx/rGyLr9401LBKDfvKCYZjut+25/zMPBxJKFd493zssK6qx230hF9GOYP43DgfVIITC+aQAv7nfvidWTRh0sM8GGoF1a6QFlYU9KQn4B9rmuguujn7NbHg/4auP04G467yAjj0Br2GtrjO0JyZIEMo4SN2CpxKpROpG5x88EXJB4EO73u3yoIFJAWJB/KDkaiHKcA+CjU5Oak4GBbl4H4O8BG/sVRrnMaZDSaxmwWwwlK6G2eZFQ2V4ddLYfnI4rleJjlddp1G2zH4F8qvSrnqhB+Csb1Q4xo0mZ7+YKI1jCQ1MDQKy1sm02Lt5qqvVAxn9sGhyUu7xPXOM3Zg5kHX6GC+yy5DHLgFWC//OXed0GB5A9LZfrF1HF5m83SxsqUvgKe+h+OSeHDnrqceDo0okv5ddglsnAaRv93VbLmG7eNYou2btumRrnxTyFL/R+1m016Ahf3eBQtN7WUc/3wDY6HdP5t+HQv6Sy5fY8EvviZEtKi4AtHkaifBCyjlUKQC1PLzAWvBhgF9JEZWAZNhIPLSVNPCvCuJ4k7BHhVk7o9KHI1+fr2ZcEEGMgGJ1HJQx/TdQPnEV7dNxXoIDlCXhTl7/PG7kWI/nU1u4u1UBiBBnaJfGb4Wgb/XPfOKfcVufebk6PPeKC95EqKC6iaaV0le4U4mhQ4AsyJ3QKIB5iCw5nMxPQZcDAybIKiaQVRmncGP5LmWFbNYoAXMo40FGx6EUGAxVaawLKwVUoNZpNPqzKaaHUm7WxrS1UekDpk1EdL7gVWn3UAZ9kOg5OD5Av7rNCYzbDEfXxjcYIc1/+3j5819c8Yp5hwDtimxYgszLZaL5nlu9AFDNAx+mtXpFdz2w7o t08nvMbO 6MR0lAhTr7SwoOBw8poJ2hO5nPP2gJgOZsBYPo+D/5hZ4CcFfn869DVY5Hc9XS6LupTFqEye3nQQAbQtYg5B3yQy0lvDs7dFrn7zfp6Xtc3NFoI02mbedHNWfACTUMB2bEmeG4u0mwuypjGOSIrIm8tTOvbc5l+F4FGzOilwWul/Kn36WMZ8D2JALlgV1IDbHN/mmpqZGJwOo7F+1RKFjzy5J4SFxLFOCZZF4XwBvASRGPsj9yqtD5T+MKr7HAMLDC3JrnW7KuYwFcg8D1AQ9fWPoUSwhKRh35Rlh3w4li7PRp9nPK68fFw7Wklv8ntRqjT0yB9L+dk78HH/RlPPabpHMJcnWpFcGGA6hg9A1u2y/w4t1OUndpuIJZiFYzBLcZ3UwvHswGxiuP8FVhx4nOz8SPpBBQLNJQBil9ixImREdI7HeeN9+gKsUoI1tRkTKlsXiIhONU/txTeoKL2gjE9xA994244fclkbegvwrlu1ILxHUXtIDC3Ucc8C9Evbs99uXm9TkLRIyt47Rrad/YC+HrgaTYe4t0+SMzFHlGDUz1MnV8Z0z+6Bo/D+YbUSdJetcPHrNRveRhWJBa/THlFQD2UUTDZal8wO7NCJLguSQsh+Jd0OhBsBC2//OKPWu7T5mOdS/zbl7GLN6joLpK4lgVzuEHPdpCVk5nqIEAAIXsDOP5IRjshmFCZbMPFTfxXtKjypGiOHlA8ZOQ1rAKR43pcFBWlkFoE/VtGQpqQei/zPWUIAuT4+FD1gEy3hqMn9yRYrgCTnl9E3ag/RJmdXudLMmzO1OwrDFFW+4cnfrhUV/Ko8QA3+ai2PLZ0aaprJOROOaUaExsU+4ZHM5a652FIbyZuWa6D0VxDDSF2JuPlmiAUvHnghQ2TnW3OWjFI0hjl3bzBeH6QKDppAFqRLnxtp1/Xbe/YzP+9USvusaFlqedw/ebzJ2wSq+u6fzfZJiSJ/jWFQsvnvIHz6LQMT0ediU 49i/w+24 6JjL4MF/DU2nN+6X9CBD9jvvH4fTESnCa2d2FE7G4YlI835naieZU1uDj5VGhKK/6LV1DyuJYq2OH81j8B/xHcUZLTINw8Q3xfg5zoEmyUtiy5WLAXu11oAhUoHov9lCyLpyZ6pCnx3aamojcDzulnWuvodxmd7/RNkjIUgeJsuh2AjqximB7g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Create struct bdev_handle that contains all parameters that need to be passed to blkdev_put() and provide blkdev_get_handle_* functions that return this structure instead of plain bdev pointer. This will eventually allow us to pass one more argument to blkdev_put() without too much hassle. CC: Alasdair Kergon CC: Andrew Morton CC: Anna Schumaker CC: Chao Yu CC: Christian Borntraeger CC: Coly Li CC: Dave Kleikamp CC: David Sterba CC: dm-devel@redhat.com CC: drbd-dev@lists.linbit.com CC: Gao Xiang CC: Jack Wang CC: Jaegeuk Kim CC: jfs-discussion@lists.sourceforge.net CC: Joern Engel CC: Joseph Qi CC: Kent Overstreet CC: linux-bcache@vger.kernel.org CC: linux-btrfs@vger.kernel.org CC: linux-erofs@lists.ozlabs.org CC: CC: linux-f2fs-devel@lists.sourceforge.net CC: linux-mm@kvack.org CC: linux-mtd@lists.infradead.org CC: linux-nfs@vger.kernel.org CC: linux-nilfs@vger.kernel.org CC: linux-nvme@lists.infradead.org CC: linux-pm@vger.kernel.org CC: linux-raid@vger.kernel.org CC: linux-s390@vger.kernel.org CC: linux-scsi@vger.kernel.org CC: linux-xfs@vger.kernel.org CC: "Md. Haris Iqbal" CC: Mike Snitzer CC: Minchan Kim CC: ocfs2-devel@oss.oracle.com CC: reiserfs-devel@vger.kernel.org CC: Sergey Senozhatsky CC: Song Liu CC: Sven Schnelle CC: target-devel@vger.kernel.org CC: Ted Tso CC: Trond Myklebust CC: xen-devel@lists.xenproject.org Signed-off-by: Jan Kara --- block/bdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++ include/linux/blkdev.h | 10 +++++++++ 2 files changed, 57 insertions(+) diff --git a/block/bdev.c b/block/bdev.c index 979e28a46b98..c75de5cac2bc 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -846,6 +846,24 @@ struct block_device *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder, } EXPORT_SYMBOL(blkdev_get_by_dev); +struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode, + void *holder, const struct blk_holder_ops *hops) +{ + struct bdev_handle *handle = kmalloc(sizeof(struct bdev_handle), + GFP_KERNEL); + struct block_device *bdev; + + if (!handle) + return ERR_PTR(-ENOMEM); + bdev = blkdev_get_by_dev(dev, mode, holder, hops); + if (IS_ERR(bdev)) + return ERR_CAST(bdev); + handle->bdev = bdev; + handle->holder = holder; + return handle; +} +EXPORT_SYMBOL(blkdev_get_handle_by_dev); + /** * blkdev_get_by_path - open a block device by name * @path: path to the block device to open @@ -884,6 +902,28 @@ struct block_device *blkdev_get_by_path(const char *path, blk_mode_t mode, } EXPORT_SYMBOL(blkdev_get_by_path); +struct bdev_handle *blkdev_get_handle_by_path(const char *path, blk_mode_t mode, + void *holder, const struct blk_holder_ops *hops) +{ + struct bdev_handle *handle; + dev_t dev; + int error; + + error = lookup_bdev(path, &dev); + if (error) + return ERR_PTR(error); + + handle = blkdev_get_handle_by_dev(dev, mode, holder, hops); + if (!IS_ERR(handle) && (mode & BLK_OPEN_WRITE) && + bdev_read_only(handle->bdev)) { + blkdev_handle_put(handle); + return ERR_PTR(-EACCES); + } + + return handle; +} +EXPORT_SYMBOL(blkdev_get_handle_by_path); + void blkdev_put(struct block_device *bdev, void *holder) { struct gendisk *disk = bdev->bd_disk; @@ -920,6 +960,13 @@ void blkdev_put(struct block_device *bdev, void *holder) } EXPORT_SYMBOL(blkdev_put); +void blkdev_handle_put(struct bdev_handle *handle) +{ + blkdev_put(handle->bdev, handle->holder); + kfree(handle); +} +EXPORT_SYMBOL(blkdev_handle_put); + /** * lookup_bdev() - Look up a struct block_device by name. * @pathname: Name of the block device in the filesystem. diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ed44a997f629..a910e9997ddd 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1471,14 +1471,24 @@ struct blk_holder_ops { #define sb_open_mode(flags) \ (BLK_OPEN_READ | (((flags) & SB_RDONLY) ? 0 : BLK_OPEN_WRITE)) +struct bdev_handle { + struct block_device *bdev; + void *holder; +}; + struct block_device *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder, const struct blk_holder_ops *hops); struct block_device *blkdev_get_by_path(const char *path, blk_mode_t mode, void *holder, const struct blk_holder_ops *hops); +struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode, + void *holder, const struct blk_holder_ops *hops); +struct bdev_handle *blkdev_get_handle_by_path(const char *path, blk_mode_t mode, + void *holder, const struct blk_holder_ops *hops); int bd_prepare_to_claim(struct block_device *bdev, void *holder, const struct blk_holder_ops *hops); void bd_abort_claiming(struct block_device *bdev, void *holder); void blkdev_put(struct block_device *bdev, void *holder); +void blkdev_handle_put(struct bdev_handle *handle); /* just for blk-cgroup, don't use elsewhere */ struct block_device *blkdev_get_no_open(dev_t dev); From patchwork Tue Jul 4 12:21:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13301089 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEF73EB64DD for ; Tue, 4 Jul 2023 12:22:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AE8D90000D; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65E9D90001A; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FEBA90000D; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 428D790001A for ; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E5521140A3D for ; Tue, 4 Jul 2023 12:22:29 +0000 (UTC) X-FDA: 80973842418.14.954B436 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf12.hostedemail.com (Postfix) with ESMTP id A6AF140011 for ; Tue, 4 Jul 2023 12:22:27 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=a81BmTCZ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Cm9YT4Ht; spf=pass (imf12.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688473347; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mdnEy6doZuj4T4K7nSzTIyIECtQFFVt3/RzDP88gsmY=; b=gcddiOg9lIwCUtmoPOZWxWZ+o34vYfloK0twr+tZd4k6+9JXztH4o7jQoI1BFVirjZ05oW VA016fqJSWM3numBkHzI7Bi5WplYKyVO4anXgfE3SunFo8iePr/a74iy71IOG5rJxa5HdS dsIT7O+qTNA823CvQZ4TjStaqGMsNeM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688473347; a=rsa-sha256; cv=none; b=hSmPHVDIf3MI8HkONk3+kZvXvW0+H/qdglTr5ViWblOacHJMvTiK84CYBYd/P7Uxw3GOjV 3DCfPiTUXcbNgfewuJeajOmPu40miSkmk5dMxPpRP8+SWZwFG6pUb8zYPg8DjE3+tOOmsu R3ylqLfwfqVsHR/TrKsjcH3lgeh0R34= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=a81BmTCZ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Cm9YT4Ht; spf=pass (imf12.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none 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-out1.suse.de (Postfix) with ESMTPS id 6A18822873; Tue, 4 Jul 2023 12:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1688473346; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mdnEy6doZuj4T4K7nSzTIyIECtQFFVt3/RzDP88gsmY=; b=a81BmTCZ90hLkXKtL+oiXj66o12wEJNqm/5N+YhSzQN//2u76/Sx/Ix2IzjSd2/ieb0Izd L1C0d9f7SEEFrpVNL1TLjbeBzGvcTpJYG4FMamPZHYghYBGMRk3zka0XU61wA63v6wqVX1 uWHCCk/yQiEzKPBOl5UqSaLQoClKgwg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1688473346; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mdnEy6doZuj4T4K7nSzTIyIECtQFFVt3/RzDP88gsmY=; b=Cm9YT4HtRVGdabVASUQcZymzmzyV9VOKtf4HzOMxaRIqr1Q9vWi5U4iD7mqh2LYosKOtIu 5TQo9zlahslRH/Dw== 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 59B9513A98; Tue, 4 Jul 2023 12:22:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id /63gFQIPpGREMAAAMHmgww (envelope-from ); Tue, 04 Jul 2023 12:22:26 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 0CA26A077D; Tue, 4 Jul 2023 14:22:25 +0200 (CEST) From: Jan Kara To: Cc: , Jens Axboe , Christoph Hellwig , Jan Kara , linux-mm@kvack.org, Andrew Morton Subject: [PATCH 19/32] mm/swap: Convert to use blkdev_get_handle_by_dev() Date: Tue, 4 Jul 2023 14:21:46 +0200 Message-Id: <20230704122224.16257-19-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230629165206.383-1-jack@suse.cz> References: <20230629165206.383-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2688; i=jack@suse.cz; h=from:subject; bh=wVpmIfN/eR5Ua8hSYo1mzxPGdVVPf7LYMVYIJFGGkHQ=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBkpA7bCKbxtHM46e9K00CmUmLKjtHbRBO9emBILVuZ hg9lmwOJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZKQO2wAKCRCcnaoHP2RA2ZCWB/ 9gpG67tIbc+Tvq85swoTN5lhCJ84EUHxZ+l5N6M6RpnR6hh+jUdzysCV/gfzdf1IbOkpwLhbsByeDB NQK6WTFg6tM7pUKTgqv/9CZqTqZO2ZB0/tgItgl6jf5ZirEuiXBAj45bkJ4h2HrruVsjBt4B4LX9L/ py35F0C37hdadhgcSfE9tc+xYWd3bolllxfISCrrBWE3c4Wi5DFCN9K749Vkfr4MxWifCJvhyxx/Bg aU9voIO+nVorMt8dwQgXwJlfWefUHOqn7RsZbwmNrvt4QHtSHaBMIfyXBLP29YS9QqPnq9s8ih2F+V KexxrhIyaScM7/+txmNwayQDHvcUcx X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Stat-Signature: t1naeinwz3gcejew6a6k5kwgym3nkcu5 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A6AF140011 X-Rspam-User: X-HE-Tag: 1688473347-362785 X-HE-Meta: U2FsdGVkX1/VPQN46O2Vpu0ft3joheDlfvzENaLZtmmKPH3uXYhayPNRHOwfPSiyV4Qlz+fU2abWktGlxCUlkZKQn6fXM2GqH/YtfZ16XLKPP7sICzr2liOgq/o0SUMZoVF8639oQOO/y81FZZycm8OJh2VXj4GE7rolNY0aF1vqyfOeQGF5QO0rtCTGh5IFcr+rGENgT2aonObKPm69Duw81VpeFyFNwC/PY6wTrpN8NufXLr++ni97g4X5zjiDi0z0saYhzmMhuMlZWl2oGl0PGYZCUEQFbwcNGPjy7FiZqWjz7HT7UOyZHrGOQSRsjcCMAyhhhoKrqU8oQ3Sdkl98uOK6jDNy20pk8RMuCfK5dGSuG4PYlfZvHO2M9fBf8m7t1pRocQAw8s2zDUnsZSJdEuKs1Rx6WAQnk7ItWfalcrLY0osAFfDdiPGJ+ambRY3RaiqDovH0p1LGxRDiQRRLU3/zBW9R94zTjjfELzpA5WVEE9fT+KvJ9XUwy3FapE7NzJ4F3jBzzObn2EWq4fCuNv6rLi6LyCMEhShna/Dz2djYTNHjZo/g7C9G9thrSDzbUwfkbQ/XkToDlehSlZE6tGgIeGYvfTJIdMgUdU/7diVkRe/D9tODOSwN5fol4RfiKjmDYuvR8AFw25iM+jXqcyjwEzcXAgDHYhrla8t7uw47xOLcbPeEr3tuKDjtAFLSUnc5+Va1TBXzI208BpkHP7KxN+JisdYWft2H2aZ2uv0Tl8/s76Y0VsgNjkml9bpN03D49VGuF1aTcyx7462p6ED5V0BrrGBJaDS/EQ0LD2OCsZX06zr7UNIuWVYyS+C648ACgXQE2K58Ea16VeE5ZqV72BCUhF62a8k3ghWVYyPewrfPKdStmY5LFtXq6RvmQPKbpUxfvRPEbCeZqU9KxrpgyHnS+OK7YFpEu9myjdl1tJKvqMraqZWiZB8/27SHKhHa8PHyFuGugSE IVmFjAOG 062VWOfOyfhiQXQjkgmHHSMLwV4hi8ezT+b+xHZPsZa9z66MYoSCwutMpoibMTAtwrgcihlp9/X84/EM8meU4mER418hrdeRm7yl6li9AR7C7S/G6gt4XlceSlow+iSfLbSKp1izSdliAX1OA/hsfpx2/P3C6/G6LX9pP4Llbp3Frz4VJFzrK5Zjob/nbQbni2xXGpgXrUeQ8tj/WNlN7q+fmF/kDLtbiIcV+fJSBAz7ezng6jjmBwxUCcHV7ZV4IINU4pTjVcP4n/QVh77U6Cqpu1YbyFzWL0bZ7k8lXRtSQMBDNv8l5bhnvIUgcbayr74Hr2I46zmV4CWoyHp+NgTJpxDOL35Cs8Om8 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert swapping code to use blkdev_get_handle_by_dev() and pass the handle around. CC: linux-mm@kvack.org CC: Andrew Morton Signed-off-by: Jan Kara --- include/linux/swap.h | 1 + mm/swapfile.c | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 456546443f1f..62334f8d4932 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -298,6 +298,7 @@ struct swap_info_struct { unsigned int __percpu *cluster_next_cpu; /*percpu index for next allocation */ struct percpu_cluster __percpu *percpu_cluster; /* per cpu's swap location */ struct rb_root swap_extent_root;/* root of the swap extent rbtree */ + struct bdev_handle *bdev_handle;/* open handle of the bdev */ struct block_device *bdev; /* swap device or bdev of swap file */ struct file *swap_file; /* seldom referenced */ unsigned int old_block_size; /* seldom referenced */ diff --git a/mm/swapfile.c b/mm/swapfile.c index 8e6dde68b389..dbd37aa4724d 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2526,11 +2526,9 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) exit_swap_address_space(p->type); inode = mapping->host; - if (S_ISBLK(inode->i_mode)) { - struct block_device *bdev = I_BDEV(inode); - - set_blocksize(bdev, old_block_size); - blkdev_put(bdev, p); + if (p->bdev_handle) { + set_blocksize(p->bdev, old_block_size); + blkdev_handle_put(p->bdev_handle); } inode_lock(inode); @@ -2760,13 +2758,14 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode) int error; if (S_ISBLK(inode->i_mode)) { - p->bdev = blkdev_get_by_dev(inode->i_rdev, + p->bdev_handle = blkdev_get_handle_by_dev(inode->i_rdev, BLK_OPEN_READ | BLK_OPEN_WRITE, p, NULL); - if (IS_ERR(p->bdev)) { - error = PTR_ERR(p->bdev); - p->bdev = NULL; + if (IS_ERR(p->bdev_handle)) { + error = PTR_ERR(p->bdev_handle); + p->bdev_handle = NULL; return error; } + p->bdev = p->bdev_handle->bdev; p->old_block_size = block_size(p->bdev); error = set_blocksize(p->bdev, PAGE_SIZE); if (error < 0) @@ -3210,9 +3209,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) p->percpu_cluster = NULL; free_percpu(p->cluster_next_cpu); p->cluster_next_cpu = NULL; - if (inode && S_ISBLK(inode->i_mode) && p->bdev) { + if (p->bdev_handle) { set_blocksize(p->bdev, p->old_block_size); - blkdev_put(p->bdev, p); + blkdev_handle_put(p->bdev_handle); } inode = NULL; destroy_swap_extents(p); From patchwork Tue Jul 4 12:21:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13301092 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C193C001B3 for ; Tue, 4 Jul 2023 12:22:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 06E4390001B; Tue, 4 Jul 2023 08:22:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECB1B90001A; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC61B280076; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B67A590001A for ; Tue, 4 Jul 2023 08:22:30 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 84DD11A0A08 for ; Tue, 4 Jul 2023 12:22:30 +0000 (UTC) X-FDA: 80973842460.07.81AA2A4 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf28.hostedemail.com (Postfix) with ESMTP id 4C447C0018 for ; Tue, 4 Jul 2023 12:22:28 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="IfhkJf/r"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=L7ND2oVd; spf=pass (imf28.hostedemail.com: domain of jack@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688473348; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mjuMHjhognYm/jp+4laDSDXEVfZVsA6D5XD84KVXIlM=; b=Ts4rO6EUebcSzoY1lqKGdLNo3ZPRjwVGyOLAsRuV5uTbWnOh7gdXUpz+lelMYO/TX/Mnaq rC6XBwN+BqnleanSnkEWN0caS/gLQfKfzeKJKVbspionM5938ZPbR4SCmFUQo1HJVH5U2U dlG5lv49o4k0hfgSUYzxOdvDI2fSkVQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688473348; a=rsa-sha256; cv=none; b=6Ckz4NhXkuDhpw2qqXrXevSlg1xuvtxU/gGBVBd+GXcdFJK0mw9JFjev0mYS8v4Bye50t7 NzpTc33r3vpPDjp2MvNOOAsqQWtk2BEvYMHqAPF6Da8rWMohkUYz3dzkQAL6PhdPi4p+n5 ThEvPX8be4mX1yTdZUvqZVLE8Yl5tWE= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="IfhkJf/r"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=L7ND2oVd; spf=pass (imf28.hostedemail.com: domain of jack@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none 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 0DABB20572; Tue, 4 Jul 2023 12:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1688473347; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mjuMHjhognYm/jp+4laDSDXEVfZVsA6D5XD84KVXIlM=; b=IfhkJf/r3YX79abK//kvxzsfxO8GBec3aFCgZUqKe4njAdibvh5nuXvRT9veRG5W0AjJWZ xkZTl1aaAGPgSVyAjWvo8s6nnqwhJ0ZaLpuEG69dT5keFHsUoEFpqPkzUx9qP0BhNBbooO p9QUcEDucrmYuqaoHoaI7BQaQFfMU7A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1688473347; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mjuMHjhognYm/jp+4laDSDXEVfZVsA6D5XD84KVXIlM=; b=L7ND2oVd/Fq2jDo7ljy5nF8o5bZWHZeR62gf2Xk9TE6mFJugTr7RIk/BG29uxhMgM00XlI Bt3Mp4tdxZ9r7HCg== 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 ABAF1139ED; Tue, 4 Jul 2023 12:22:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KsLiKQIPpGRjMAAAMHmgww (envelope-from ); Tue, 04 Jul 2023 12:22:26 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 59701A078D; Tue, 4 Jul 2023 14:22:25 +0200 (CEST) From: Jan Kara To: Cc: , Jens Axboe , Christoph Hellwig , Jan Kara , Alasdair Kergon , Andrew Morton , Anna Schumaker , Chao Yu , Christian Borntraeger , "Darrick J. Wong" , Dave Kleikamp , David Sterba , dm-devel@redhat.com, drbd-dev@lists.linbit.com, Gao Xiang , Jack Wang , Jaegeuk Kim , jfs-discussion@lists.sourceforge.net, Joern Engel , Joseph Qi , Kent Overstreet , linux-bcache@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mm@kvack.org, linux-mtd@lists.infradead.org, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-nvme@lists.infradead.org, linux-pm@vger.kernel.org, linux-raid@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-xfs@vger.kernel.org, "Md. Haris Iqbal" , Mike Snitzer , Minchan Kim , ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org, Sergey Senozhatsky , Song Liu , Sven Schnelle , target-devel@vger.kernel.org, Ted Tso , Trond Myklebust , xen-devel@lists.xenproject.org Subject: [PATCH 32/32] block: Rename blkdev_get_handle_by_*() and blkdev_handle_put() Date: Tue, 4 Jul 2023 14:21:59 +0200 Message-Id: <20230704122224.16257-32-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230629165206.383-1-jack@suse.cz> References: <20230629165206.383-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=52534; i=jack@suse.cz; h=from:subject; bh=V4VQzqtLPzebd9elTihpjhZGahpeEhAZnI7QsWZdPe4=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBkpA7mNc8ek6WBAiDfxElNQMWOHzv9hYYvjHN3eTqG Gc6z8KeJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZKQO5gAKCRCcnaoHP2RA2TWdB/ 4/tliM0M2A91liOZmHDiXajUGkW4GFvo5u3EtWLBTnoITi1cexbp98BuZsmF37Cwcua38PpwNGdNvC LjevVeWqas0lSaFPJpuEMGUAzkFn4nUF9yXneLyjoILCiV1OdKQNkZRO/tJaC8ntEgkrITOiw/+Z+s 7BqpGpN/dsEGe2ND8MR1y/Zxq99oQJfHMdrtpkdg6JooqUQ7d8jiMehC0ZRkkIrhmi/l6R533RJqXL o2pkFrxgsYDkpHv/Pc7FZA3/rq2WoCPTsRqLDPl1um222jRi2sYUcgPbtMy/oAC1WeVRFT1RFUEA3V nUZ6UiuuDjVfhIUnPyhZWutX8t6+Xs X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Queue-Id: 4C447C0018 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: wot14gwhpuosiwz9qnnx19zw91w3zujn X-HE-Tag: 1688473348-346852 X-HE-Meta: U2FsdGVkX18zoM5h23pjt5fPwJ0bqickDneufkSRUHATTCb9m6cpyMUQfjGR9pl4eqkfDPvl8Rzgzvzdx05uZIESOOa0HGukm+CndiYYwDVtq08IDvWwrN2z/h/7uEuhx8mheBwNsINZO1BXesxkWPUNhXr9M24SJZMT0Z+aJIaEDGRyvnayKcgIh2fyzAqweCBPs2sRf9fdtABtsOlMeTJdL9IMf6TsbNCIJRMR2qKlJeBViCGiT2EVi2H7eAOAoqTIqNnVRm4Mq94HtZTxrZxtACBB4OtV/5FKndPNihwaE8hfqu6VvWanqyX5vuHIcWrw1vk9OL/tHwpfb5J/pyBOSsZpjy3vcwQg6I7VcKqddUt1j60pXiaCPIsuNKwfOrxodqjz37IkH/7HhpFzuZHk113X4i7dyg6sjVzinpDemrpsacCYxiAX3Huf0FWZBLMLuuDuBdZ4E80Ht+tIsCKKRD7F665n9iQcqRLLCAkO0DfJsQJNURcfS6QYP1GIkfYenf8FkKJYlGS4n7QhUGtaWBp1pLOhU8fEWblGCA1eqHOhiefKuBOfoxBkOzI+2iaX/ymUil22/HSJPuGyKvtPWat3CVsfGrQcy3Vl1WjlMx2K3fwytkb2UKydC7gwbfKvqTEElG8rcotSXUqXSZayOlKm/BcOURrdStuGdhyT1L3bVnXU2dqUoXRhHtT2G0jpnCIuKKMAOkNkIKxqCREz//T06CN79N87RXftKNbo9jEdQwZzANn/f9uO8K4xy00UGt7i8OwVHOTttcbz5kbP/MGJns9viZY6OLqy/V6qP/F7uuqcI5sDNP/USLNc4+uzLtQ0sdRg4cjpYDBFlnvni0MmPpaG1quLQuTeDMRpbyGH/znQfAKYk4iTMkLBfb+f7jsOjmqzyqV6ShwsbWcvTM++8Ad2a6h+MxTVfnPjZdv94pWTa9Iicfro1rkuOEdoFtoyddr52D65mQO VvfDS2xl bf6Zijk1scli3A9w2kfznhKRUFrYAyQcIXq4JPpOWr5c5nKv098ay5JXIH9QvFugm66pwKj1OG1UdwgGz6EIctOCQDMEsQnT8qSMOwI+ExasuuG+Vzq1M3E8TZq9hngcb2HdgWoMWXkWEpz1ZDeKh4AgWXEkA+xcrCgXoQf91G0BFzNh1LTuBCrHFIItjXAFNqnY+k23p7rpQugC8DoHp9IkUUZGPjLjdjKNPT9Kq9XSsaOAnBW3zl+8Ic+CHRi2Owh3kUtjJcTfE/A2sjfO50Zh/lxU7n/z5fl0ntAZYeU8e6kpD1QJjxoAT1Fi7aAv7FlTnOp0IDoTwa/GTbUXG39sx5E3H3my8QgIU9qdEFXWeVNowAIcaHn7yDIx9vhFKkLNxUpFiQibBDIcFQ/gCUdCWGF9jVLvs3Kn6QR+9XGxwlfU1p5c+f/SKrUfwT1JKqIxDC/yNoi+QC8g3STDjN7aP2oSDE1irf0Iqi4lVOShsk0rGp2cjpxqDnaSg5d8Gz37kwkHpgQ/liwr1WeqRs1HQpM6D+CSCoa3aqJZtq6O5cNjDuwSd9opqn+Ca6FwAjgF3DT81hYDr0RzfXafkZOvUG5KT6ZB/mcgS1lMrCZpD0QoDOh2GR9cGG2RNZhV/nspPq+fvXbjoIGCbG8xRpcuDhc7MQKe+TjbI+FleWrVjpeTpMhTDOTzsCA30fMObx9mhm+mZR3LTdnNslPZPnz2zkr4Kp/d/DTtzdsS9Rv39LlJffPqw8rTvRQSYuODlpbc47aO2yNUqwqpwO1BYDOGrnk1oJz3TSp6snrvc0+vEAjIRn3r0oeof0oP5O5fWMfNy2GVpWDUeKde349u269xSlljCzfuWEkecoFGZLWmOmI0O6s234v0FFM/tUPhQ9XdwJxeYw5G7PBM+NzisPjed3JeJGcph8RJEQRNGViNZRp/YN6qQ49IYVSpoWhUJfakz6Pije4Whu1m/21UlICxaGISP Gc0ccD6z JHfDB4xgN6zeJ2D61Zw7fxVWb+IultqKBcF1BV2tnOH0BGfHGrJgEoJxYpPRQmrVoTtrOM/0dLt5ytjSrZ3QkX18ZP8onizessyfeJUFXxvdSv8hNwTG8VcwbVbkTqr3ejUWEb1ifrzC3e/9i+kGOuEb24m+uDwDTOQ7F3cYps23cIaRSLa/Qg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now that everybody is converted, we can rename blkdev_get_handle_by_*() and blkdev_handle_put() back to their original names. No functional change. Done by Coccinelle patch: @@ expression dev, mode, holder, hops; @@ - blkdev_get_handle_by_dev(dev, mode, holder, hops) + blkdev_get_by_dev(dev, mode, holder, hops) @@ expression path, mode, holder, hops; @@ - blkdev_get_handle_by_path(path, mode, holder, hops) + blkdev_get_by_path(path, mode, holder, hops) @@ expression handle; @@ - blkdev_handle_put(handle) + blkdev_put(handle) plus manual updates of comments, strings, and function declarations itself. CC: Alasdair Kergon CC: Andrew Morton CC: Anna Schumaker CC: Chao Yu CC: Christian Borntraeger CC: Coly Li CC: Dave Kleikamp CC: David Sterba CC: dm-devel@redhat.com CC: drbd-dev@lists.linbit.com CC: Gao Xiang CC: Jack Wang CC: Jaegeuk Kim CC: jfs-discussion@lists.sourceforge.net CC: Joern Engel CC: Joseph Qi CC: Kent Overstreet CC: linux-bcache@vger.kernel.org CC: linux-btrfs@vger.kernel.org CC: linux-erofs@lists.ozlabs.org CC: CC: linux-f2fs-devel@lists.sourceforge.net CC: linux-mm@kvack.org CC: linux-mtd@lists.infradead.org CC: linux-nfs@vger.kernel.org CC: linux-nilfs@vger.kernel.org CC: linux-nvme@lists.infradead.org CC: linux-pm@vger.kernel.org CC: linux-raid@vger.kernel.org CC: linux-s390@vger.kernel.org CC: linux-scsi@vger.kernel.org CC: linux-xfs@vger.kernel.org CC: "Md. Haris Iqbal" CC: Mike Snitzer CC: Minchan Kim CC: ocfs2-devel@oss.oracle.com CC: reiserfs-devel@vger.kernel.org CC: Sergey Senozhatsky CC: Song Liu CC: Sven Schnelle CC: target-devel@vger.kernel.org CC: Ted Tso CC: Trond Myklebust CC: xen-devel@lists.xenproject.org Signed-off-by: Jan Kara --- block/bdev.c | 24 +++++++++--------- block/fops.c | 6 ++--- block/genhd.c | 6 ++--- block/ioctl.c | 4 +-- drivers/block/drbd/drbd_nl.c | 10 ++++---- drivers/block/pktcdvd.c | 18 +++++++------- drivers/block/rnbd/rnbd-srv.c | 7 +++--- drivers/block/xen-blkback/xenbus.c | 7 +++--- drivers/block/zram/zram_drv.c | 9 ++++--- drivers/md/bcache/super.c | 23 ++++++++--------- drivers/md/dm.c | 6 ++--- drivers/md/md.c | 11 +++++---- drivers/mtd/devices/block2mtd.c | 7 +++--- drivers/nvme/target/io-cmd-bdev.c | 7 +++--- drivers/s390/block/dasd_genhd.c | 20 +++++++-------- drivers/target/target_core_iblock.c | 8 +++--- drivers/target/target_core_pscsi.c | 11 +++++---- fs/btrfs/dev-replace.c | 6 ++--- fs/btrfs/ioctl.c | 4 +-- fs/btrfs/volumes.c | 31 ++++++++++++----------- fs/erofs/super.c | 6 ++--- fs/ext4/super.c | 8 +++--- fs/f2fs/super.c | 15 +++++++----- fs/jfs/jfs_logmgr.c | 9 ++++--- fs/nfs/blocklayout/dev.c | 13 +++++----- fs/nilfs2/super.c | 8 +++--- fs/ocfs2/cluster/heartbeat.c | 10 ++++---- fs/reiserfs/journal.c | 10 ++++---- fs/super.c | 38 ++++++++++++++--------------- fs/xfs/xfs_super.c | 6 ++--- include/linux/blkdev.h | 8 +++--- kernel/power/swap.c | 15 ++++++------ mm/swapfile.c | 9 ++++--- 33 files changed, 194 insertions(+), 186 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 0423495fe5ac..523ea7289834 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -746,7 +746,7 @@ void blkdev_put_no_open(struct block_device *bdev) } /** - * blkdev_get_handle_by_dev - open a block device by device number + * blkdev_get_by_dev - open a block device by device number * @dev: device number of block device to open * @mode: open mode (BLK_OPEN_*) * @holder: exclusive holder identifier @@ -758,7 +758,7 @@ void blkdev_put_no_open(struct block_device *bdev) * * Use this interface ONLY if you really do not have anything better - i.e. when * you are behind a truly sucky interface and all you are given is a device - * number. Everything else should use blkdev_get_handle_by_path(). + * number. Everything else should use blkdev_get_by_path(). * * CONTEXT: * Might sleep. @@ -767,8 +767,8 @@ void blkdev_put_no_open(struct block_device *bdev) * Handle with a reference to the block_device on success, ERR_PTR(-errno) on * failure. */ -struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode, - void *holder, const struct blk_holder_ops *hops) +struct bdev_handle *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder, + const struct blk_holder_ops *hops) { struct bdev_handle *handle = kmalloc(sizeof(struct bdev_handle), GFP_KERNEL); @@ -856,10 +856,10 @@ struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode, kfree(handle); return ERR_PTR(ret); } -EXPORT_SYMBOL(blkdev_get_handle_by_dev); +EXPORT_SYMBOL(blkdev_get_by_dev); /** - * blkdev_get_handle_by_path - open a block device by name + * blkdev_get_by_path - open a block device by name * @path: path to the block device to open * @mode: open mode (BLK_OPEN_*) * @holder: exclusive holder identifier @@ -876,7 +876,7 @@ EXPORT_SYMBOL(blkdev_get_handle_by_dev); * Handle with a reference to the block_device on success, ERR_PTR(-errno) on * failure. */ -struct bdev_handle *blkdev_get_handle_by_path(const char *path, blk_mode_t mode, +struct bdev_handle *blkdev_get_by_path(const char *path, blk_mode_t mode, void *holder, const struct blk_holder_ops *hops) { struct bdev_handle *handle; @@ -887,18 +887,18 @@ struct bdev_handle *blkdev_get_handle_by_path(const char *path, blk_mode_t mode, if (error) return ERR_PTR(error); - handle = blkdev_get_handle_by_dev(dev, mode, holder, hops); + handle = blkdev_get_by_dev(dev, mode, holder, hops); if (!IS_ERR(handle) && (mode & BLK_OPEN_WRITE) && bdev_read_only(handle->bdev)) { - blkdev_handle_put(handle); + blkdev_put(handle); return ERR_PTR(-EACCES); } return handle; } -EXPORT_SYMBOL(blkdev_get_handle_by_path); +EXPORT_SYMBOL(blkdev_get_by_path); -void blkdev_handle_put(struct bdev_handle *handle) +void blkdev_put(struct bdev_handle *handle) { struct block_device *bdev = handle->bdev; struct gendisk *disk = bdev->bd_disk; @@ -934,7 +934,7 @@ void blkdev_handle_put(struct bdev_handle *handle) blkdev_put_no_open(bdev); kfree(handle); } -EXPORT_SYMBOL(blkdev_handle_put); +EXPORT_SYMBOL(blkdev_put); /** * lookup_bdev() - Look up a struct block_device by name. diff --git a/block/fops.c b/block/fops.c index d7f3b6e67a2f..ba928b0edeb0 100644 --- a/block/fops.c +++ b/block/fops.c @@ -509,8 +509,8 @@ static int blkdev_open(struct inode *inode, struct file *filp) filp->f_mode |= FMODE_BUF_RASYNC; mode = file_to_blk_mode(filp); - handle = blkdev_get_handle_by_dev(inode->i_rdev, mode, - mode & BLK_OPEN_EXCL ? filp : NULL, NULL); + handle = blkdev_get_by_dev(inode->i_rdev, mode, + mode & BLK_OPEN_EXCL ? filp : NULL, NULL); if (IS_ERR(handle)) return PTR_ERR(handle); @@ -527,7 +527,7 @@ static int blkdev_open(struct inode *inode, struct file *filp) static int blkdev_release(struct inode *inode, struct file *filp) { - blkdev_handle_put(filp->private_data); + blkdev_put(filp->private_data); return 0; } diff --git a/block/genhd.c b/block/genhd.c index d363ddb8d93a..a09fca0af308 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -366,12 +366,12 @@ int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode) } set_bit(GD_NEED_PART_SCAN, &disk->state); - handle = blkdev_get_handle_by_dev(disk_devt(disk), - mode & ~BLK_OPEN_EXCL, NULL, NULL); + handle = blkdev_get_by_dev(disk_devt(disk), mode & ~BLK_OPEN_EXCL, NULL, + NULL); if (IS_ERR(handle)) ret = PTR_ERR(handle); else - blkdev_handle_put(handle); + blkdev_put(handle); /* * If blkdev_get_by_dev() failed early, GD_NEED_PART_SCAN is still set, diff --git a/block/ioctl.c b/block/ioctl.c index 940a7b9284c4..96922830f908 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -470,11 +470,11 @@ static int blkdev_bszset(struct block_device *bdev, blk_mode_t mode, if (mode & BLK_OPEN_EXCL) return set_blocksize(bdev, n); - handle = blkdev_get_handle_by_dev(bdev->bd_dev, mode, &bdev, NULL); + handle = blkdev_get_by_dev(bdev->bd_dev, mode, &bdev, NULL); if (IS_ERR(handle)) return -EBUSY; ret = set_blocksize(bdev, n); - blkdev_handle_put(handle); + blkdev_put(handle); return ret; } diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 4a436a428e12..1f8b53468f0e 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -82,7 +82,7 @@ static atomic_t notify_genl_seq = ATOMIC_INIT(2); /* two. */ DEFINE_MUTEX(notification_mutex); -/* used blkdev_get_handle_by_path, to claim our meta data device(s) */ +/* used blkdev_get_by_path, to claim our meta data device(s) */ static char *drbd_m_holder = "Hands off! this is DRBD's meta data device."; static void drbd_adm_send_reply(struct sk_buff *skb, struct genl_info *info) @@ -1640,8 +1640,8 @@ static struct bdev_handle *open_backing_dev(struct drbd_device *device, struct bdev_handle *handle; int err = 0; - handle = blkdev_get_handle_by_path(bdev_path, - BLK_OPEN_READ | BLK_OPEN_WRITE, claim_ptr, NULL); + handle = blkdev_get_by_path(bdev_path, BLK_OPEN_READ | BLK_OPEN_WRITE, + claim_ptr, NULL); if (IS_ERR(handle)) { drbd_err(device, "open(\"%s\") failed with %ld\n", bdev_path, PTR_ERR(handle)); @@ -1653,7 +1653,7 @@ static struct bdev_handle *open_backing_dev(struct drbd_device *device, err = bd_link_disk_holder(handle->bdev, device->vdisk); if (err) { - blkdev_handle_put(handle); + blkdev_put(handle); drbd_err(device, "bd_link_disk_holder(\"%s\", ...) failed with %d\n", bdev_path, err); handle = ERR_PTR(err); @@ -1704,7 +1704,7 @@ static void close_backing_dev(struct drbd_device *device, return; if (do_bd_unlink) bd_unlink_disk_holder(handle->bdev, device->vdisk); - blkdev_handle_put(handle); + blkdev_put(handle); } void drbd_backing_dev_free(struct drbd_device *device, struct drbd_backing_dev *ldev) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index c50333ea9c75..924557408ed0 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2169,8 +2169,8 @@ static int pkt_open_dev(struct pktcdvd_device *pd, bool write) * to read/write from/to it. It is already opened in O_NONBLOCK mode * so open should not fail. */ - bdev_handle = blkdev_get_handle_by_dev(pd->bdev_handle->bdev->bd_dev, - BLK_OPEN_READ, pd, NULL); + bdev_handle = blkdev_get_by_dev(pd->bdev_handle->bdev->bd_dev, + BLK_OPEN_READ, pd, NULL); if (IS_ERR(bdev_handle)) { ret = PTR_ERR(bdev_handle); goto out; @@ -2218,7 +2218,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, bool write) return 0; out_putdev: - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); out: return ret; } @@ -2237,7 +2237,7 @@ static void pkt_release_dev(struct pktcdvd_device *pd, int flush) pkt_lock_door(pd, 0); pkt_set_speed(pd, MAX_SPEED, MAX_SPEED); - blkdev_handle_put(pd->open_bdev_handle); + blkdev_put(pd->open_bdev_handle); pd->open_bdev_handle = NULL; pkt_shrink_pktlist(pd); @@ -2519,13 +2519,13 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) } } - bdev_handle = blkdev_get_handle_by_dev(dev, - BLK_OPEN_READ | BLK_OPEN_NDELAY, NULL, NULL); + bdev_handle = blkdev_get_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_NDELAY, + NULL, NULL); if (IS_ERR(bdev_handle)) return PTR_ERR(bdev_handle); sdev = scsi_device_from_queue(bdev_handle->bdev->bd_disk->queue); if (!sdev) { - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return -EINVAL; } put_device(&sdev->sdev_gendev); @@ -2550,7 +2550,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) return 0; out_mem: - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); /* This is safe: open() is still holding a reference. */ module_put(THIS_MODULE); return -ENOMEM; @@ -2757,7 +2757,7 @@ static int pkt_remove_dev(dev_t pkt_dev) pkt_debugfs_dev_remove(pd); pkt_sysfs_dev_remove(pd); - blkdev_handle_put(pd->bdev_handle); + blkdev_put(pd->bdev_handle); remove_proc_entry(pd->disk->disk_name, pkt_proc); dev_notice(ddev, "writer unmapped\n"); diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index 606db77c1238..d462d6dac297 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -219,7 +219,7 @@ void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev *sess_dev, bool keep_id) rnbd_put_sess_dev(sess_dev); wait_for_completion(&dc); /* wait for inflights to drop to zero */ - blkdev_handle_put(sess_dev->bdev_handle); + blkdev_put(sess_dev->bdev_handle); mutex_lock(&sess_dev->dev->lock); list_del(&sess_dev->dev_list); if (!sess_dev->readonly) @@ -714,8 +714,7 @@ static int process_msg_open(struct rnbd_srv_session *srv_sess, goto reject; } - bdev_handle = blkdev_get_handle_by_path(full_path, open_flags, NULL, - NULL); + bdev_handle = blkdev_get_by_path(full_path, open_flags, NULL, NULL); if (IS_ERR(bdev_handle)) { ret = PTR_ERR(bdev_handle); pr_err("Opening device '%s' on session %s failed, failed to open the block device, err: %d\n", @@ -792,7 +791,7 @@ static int process_msg_open(struct rnbd_srv_session *srv_sess, } rnbd_put_srv_dev(srv_dev); blkdev_put: - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); free_path: kfree(full_path); reject: diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index b67d28584c72..c28b31872e5a 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -474,7 +474,7 @@ static void xenvbd_sysfs_delif(struct xenbus_device *dev) static void xen_vbd_free(struct xen_vbd *vbd) { if (vbd->bdev_handle) - blkdev_handle_put(vbd->bdev_handle); + blkdev_put(vbd->bdev_handle); vbd->bdev_handle = NULL; } @@ -492,8 +492,9 @@ static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle, vbd->pdevice = MKDEV(major, minor); - bdev_handle = blkdev_get_handle_by_dev(vbd->pdevice, vbd->readonly ? - BLK_OPEN_READ : BLK_OPEN_WRITE, NULL, NULL); + bdev_handle = blkdev_get_by_dev(vbd->pdevice, + vbd->readonly ? BLK_OPEN_READ : BLK_OPEN_WRITE, + NULL, NULL); if (IS_ERR(bdev_handle)) { pr_warn("xen_vbd_create: device %08x could not be opened\n", diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 987e4885956e..284f433bf5e9 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -417,7 +417,7 @@ static void reset_bdev(struct zram *zram) if (!zram->backing_dev) return; - blkdev_handle_put(zram->bdev_handle); + blkdev_put(zram->bdev_handle); /* hope filp_close flush all of IO */ filp_close(zram->backing_dev, NULL); zram->backing_dev = NULL; @@ -504,8 +504,9 @@ static ssize_t backing_dev_store(struct device *dev, goto out; } - bdev_handle = blkdev_get_handle_by_dev(inode->i_rdev, - BLK_OPEN_READ | BLK_OPEN_WRITE, zram, NULL); + bdev_handle = blkdev_get_by_dev(inode->i_rdev, + BLK_OPEN_READ | BLK_OPEN_WRITE, zram, + NULL); if (IS_ERR(bdev_handle)) { err = PTR_ERR(bdev_handle); bdev_handle = NULL; @@ -536,7 +537,7 @@ static ssize_t backing_dev_store(struct device *dev, kvfree(bitmap); if (bdev_handle) - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); if (backing_dev) filp_close(backing_dev, NULL); diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 2b3f35fd7477..c6b6b140f3e8 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1369,7 +1369,7 @@ static void cached_dev_free(struct closure *cl) put_page(virt_to_page(dc->sb_disk)); if (dc->bdev_handle) - blkdev_handle_put(dc->bdev_handle); + blkdev_put(dc->bdev_handle); wake_up(&unregister_wait); @@ -2218,7 +2218,7 @@ void bch_cache_release(struct kobject *kobj) put_page(virt_to_page(ca->sb_disk)); if (ca->bdev_handle) - blkdev_handle_put(ca->bdev_handle); + blkdev_put(ca->bdev_handle); kfree(ca); module_put(THIS_MODULE); @@ -2357,10 +2357,10 @@ static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk, /* * If we failed here, it means ca->kobj is not initialized yet, * kobject_put() won't be called and there is no chance to - * call blkdev_handle_put() to bdev in bch_cache_release(). So - * we explicitly call blkdev_handle_put() here. + * call blkdev_put() to bdev in bch_cache_release(). So we + * explicitly call blkdev_put() here. */ - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); if (ret == -ENOMEM) err = "cache_alloc(): -ENOMEM"; else if (ret == -EPERM) @@ -2551,8 +2551,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, ret = -EINVAL; err = "failed to open device"; - bdev_handle = blkdev_get_handle_by_path(strim(path), BLK_OPEN_READ, - NULL, NULL); + bdev_handle = blkdev_get_by_path(strim(path), BLK_OPEN_READ, NULL, + NULL); if (IS_ERR(bdev_handle)) goto out_free_sb; @@ -2572,9 +2572,10 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, } /* Now reopen in exclusive mode with proper holder */ - bdev_handle2 = blkdev_get_handle_by_dev(bdev_handle->bdev->bd_dev, - BLK_OPEN_READ | BLK_OPEN_WRITE, holder, NULL); - blkdev_handle_put(bdev_handle); + bdev_handle2 = blkdev_get_by_dev(bdev_handle->bdev->bd_dev, + BLK_OPEN_READ | BLK_OPEN_WRITE, + holder, NULL); + blkdev_put(bdev_handle); bdev_handle = bdev_handle2; if (IS_ERR(bdev_handle)) { ret = PTR_ERR(bdev_handle); @@ -2646,7 +2647,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, put_page(virt_to_page(sb_disk)); out_blkdev_put: if (bdev_handle) - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); out_free_sb: kfree(sb); out_free_path: diff --git a/drivers/md/dm.c b/drivers/md/dm.c index d73905149bef..018ae5802efb 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -751,7 +751,7 @@ static struct table_device *open_table_device(struct mapped_device *md, return ERR_PTR(-ENOMEM); refcount_set(&td->count, 1); - bdev_handle = blkdev_get_handle_by_dev(dev, mode, _dm_claim_ptr, NULL); + bdev_handle = blkdev_get_by_dev(dev, mode, _dm_claim_ptr, NULL); if (IS_ERR(bdev_handle)) { r = PTR_ERR(bdev_handle); goto out_free_td; @@ -778,7 +778,7 @@ static struct table_device *open_table_device(struct mapped_device *md, return td; out_blkdev_put: - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); out_free_td: kfree(td); return ERR_PTR(r); @@ -791,7 +791,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_handle_put(td->dm_dev.bdev_handle); + blkdev_put(td->dm_dev.bdev_handle); put_dax(td->dm_dev.dax_dev); list_del(&td->list); kfree(td); diff --git a/drivers/md/md.c b/drivers/md/md.c index bed142ee6f1f..595aeb6cc766 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2458,7 +2458,7 @@ static void export_rdev(struct md_rdev *rdev, struct mddev *mddev) if (test_bit(AutoDetected, &rdev->flags)) md_autodetect_dev(rdev->bdev->bd_dev); #endif - blkdev_handle_put(rdev->bdev_handle); + blkdev_put(rdev->bdev_handle); rdev->bdev = NULL; kobject_put(&rdev->kobj); } @@ -3654,9 +3654,10 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe if (err) goto out_clear_rdev; - rdev->bdev_handle = blkdev_get_handle_by_dev(newdev, - BLK_OPEN_READ | BLK_OPEN_WRITE, - super_format == -2 ? &claim_rdev : rdev, NULL); + rdev->bdev_handle = blkdev_get_by_dev(newdev, + BLK_OPEN_READ | BLK_OPEN_WRITE, + super_format == -2 ? &claim_rdev : rdev, + NULL); if (IS_ERR(rdev->bdev_handle)) { pr_warn("md: could not open device unknown-block(%u,%u).\n", MAJOR(newdev), MINOR(newdev)); @@ -3694,7 +3695,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe return rdev; out_blkdev_put: - blkdev_handle_put(rdev->bdev_handle); + blkdev_put(rdev->bdev_handle); out_clear_rdev: md_rdev_clear(rdev); out_free_rdev: diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 1614459297d2..385d34096031 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -213,7 +213,7 @@ static void block2mtd_free_device(struct block2mtd_dev *dev) if (dev->bdev_handle) { invalidate_mapping_pages( dev->bdev_handle->bdev->bd_inode->i_mapping, 0, -1); - blkdev_handle_put(dev->bdev_handle); + blkdev_put(dev->bdev_handle); } kfree(dev); @@ -253,8 +253,7 @@ static struct bdev_handle __ref *mdtblock_early_get_bdev(const char *devname, wait_for_device_probe(); if (!early_lookup_bdev(devname, &devt)) { - bdev_handle = blkdev_get_handle_by_dev(devt, mode, dev, - NULL); + bdev_handle = blkdev_get_by_dev(devt, mode, dev, NULL); if (!IS_ERR(bdev_handle)) break; } @@ -280,7 +279,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, return NULL; /* Get a handle on the device */ - bdev_handle = blkdev_get_handle_by_path(devname, mode, dev, NULL); + bdev_handle = blkdev_get_by_path(devname, mode, dev, NULL); if (IS_ERR(bdev_handle)) bdev_handle = mdtblock_early_get_bdev(devname, mode, timeout, dev); diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index 0f177a7e3b37..3f600dad7cbb 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -51,7 +51,7 @@ void nvmet_bdev_set_limits(struct block_device *bdev, struct nvme_id_ns *id) void nvmet_bdev_ns_disable(struct nvmet_ns *ns) { if (ns->bdev_handle) { - blkdev_handle_put(ns->bdev_handle); + blkdev_put(ns->bdev_handle); ns->bdev = NULL; ns->bdev_handle = NULL; } @@ -85,8 +85,9 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns) if (ns->buffered_io) return -ENOTBLK; - ns->bdev_handle = blkdev_get_handle_by_path(ns->device_path, - BLK_OPEN_READ | BLK_OPEN_WRITE, NULL, NULL); + ns->bdev_handle = blkdev_get_by_path(ns->device_path, + BLK_OPEN_READ | BLK_OPEN_WRITE, + NULL, NULL); if (IS_ERR(ns->bdev_handle)) { ret = PTR_ERR(ns->bdev_handle); if (ret != -ENOTBLK) { diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c index 1c22a5ee2ce7..13af36180372 100644 --- a/drivers/s390/block/dasd_genhd.c +++ b/drivers/s390/block/dasd_genhd.c @@ -130,8 +130,8 @@ int dasd_scan_partitions(struct dasd_block *block) struct bdev_handle *bdev_handle; int rc; - bdev_handle = blkdev_get_handle_by_dev(disk_devt(block->gdp), - BLK_OPEN_READ, NULL, NULL); + bdev_handle = blkdev_get_by_dev(disk_devt(block->gdp), BLK_OPEN_READ, + NULL, NULL); if (IS_ERR(bdev_handle)) { DBF_DEV_EVENT(DBF_ERR, block->base, "scan partitions error, blkdev_get returned %ld", @@ -147,13 +147,13 @@ int dasd_scan_partitions(struct dasd_block *block) "scan partitions error, rc %d", rc); /* - * Since the matching blkdev_handle_put() call to the - * blkdev_get_handle_by_path() in this function is not called before - * dasd_destroy_partitions the offline open_count limit needs to be - * increased from 0 to 1. This is done by setting device->bdev_handle - * (see dasd_generic_set_offline). As long as the partition detection - * is running no offline should be allowed. That is why the assignment - * to block->bdev_handle is done AFTER the BLKRRPART ioctl. + * Since the matching blkdev_put() call to the blkdev_get_by_path() in + * this function is not called before dasd_destroy_partitions the + * offline open_count limit needs to be increased from 0 to 1. This is + * done by setting device->bdev_handle (see dasd_generic_set_offline). + * As long as the partition detection is running no offline should be + * allowed. That is why the assignment to block->bdev_handle is done + * AFTER the BLKRRPART ioctl. */ block->bdev_handle = bdev_handle; return 0; @@ -179,7 +179,7 @@ void dasd_destroy_partitions(struct dasd_block *block) mutex_unlock(&bdev_handle->bdev->bd_disk->open_mutex); /* Matching blkdev_put to the blkdev_get in dasd_scan_partitions. */ - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); } int dasd_gendisk_init(void) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 979b0cfbea4a..d271a536d66f 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -117,8 +117,8 @@ static int iblock_configure_device(struct se_device *dev) else dev->dev_flags |= DF_READ_ONLY; - bdev_handle = blkdev_get_handle_by_path(ib_dev->ibd_udev_path, mode, - ib_dev, NULL); + bdev_handle = blkdev_get_by_path(ib_dev->ibd_udev_path, mode, ib_dev, + NULL); if (IS_ERR(bdev_handle)) { ret = PTR_ERR(bdev_handle); goto out_free_bioset; @@ -180,7 +180,7 @@ static int iblock_configure_device(struct se_device *dev) return 0; out_blkdev_put: - blkdev_handle_put(ib_dev->ibd_bdev_handle); + blkdev_put(ib_dev->ibd_bdev_handle); out_free_bioset: bioset_exit(&ib_dev->ibd_bio_set); out: @@ -206,7 +206,7 @@ static void iblock_destroy_device(struct se_device *dev) struct iblock_dev *ib_dev = IBLOCK_DEV(dev); if (ib_dev->ibd_bdev_handle) - blkdev_handle_put(ib_dev->ibd_bdev_handle); + blkdev_put(ib_dev->ibd_bdev_handle); bioset_exit(&ib_dev->ibd_bio_set); } diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 9ea2b29e95bf..38416426707f 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -366,10 +366,11 @@ static int pscsi_create_type_disk(struct se_device *dev, struct scsi_device *sd) * Claim exclusive struct block_device access to struct scsi_device * for TYPE_DISK and TYPE_ZBC using supplied udev_path */ - bdev_handle = blkdev_get_handle_by_path(dev->udev_path, - BLK_OPEN_WRITE | BLK_OPEN_READ, pdv, NULL); + bdev_handle = blkdev_get_by_path(dev->udev_path, + BLK_OPEN_WRITE | BLK_OPEN_READ, pdv, + NULL); if (IS_ERR(bdev_handle)) { - pr_err("pSCSI: blkdev_get_handle_by_path() failed\n"); + pr_err("pSCSI: blkdev_get_by_path() failed\n"); scsi_device_put(sd); return PTR_ERR(bdev_handle); } @@ -377,7 +378,7 @@ static int pscsi_create_type_disk(struct se_device *dev, struct scsi_device *sd) ret = pscsi_add_device_to_list(dev, sd); if (ret) { - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); scsi_device_put(sd); return ret; } @@ -565,7 +566,7 @@ static void pscsi_destroy_device(struct se_device *dev) */ if ((sd->type == TYPE_DISK || sd->type == TYPE_ZBC) && pdv->pdv_bdev_handle) { - blkdev_handle_put(pdv->pdv_bdev_handle); + blkdev_put(pdv->pdv_bdev_handle); pdv->pdv_bdev_handle = NULL; } /* diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 639eaecf1036..9842d777db76 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -258,8 +258,8 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, return -EINVAL; } - bdev_handle = blkdev_get_handle_by_path(device_path, BLK_OPEN_WRITE, - fs_info->bdev_holder, NULL); + bdev_handle = blkdev_get_by_path(device_path, BLK_OPEN_WRITE, + fs_info->bdev_holder, NULL); if (IS_ERR(bdev_handle)) { btrfs_err(fs_info, "target device %s is invalid!", device_path); return PTR_ERR(bdev_handle); @@ -336,7 +336,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, return 0; error: - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return ret; } diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 7d8f5625ad70..92aaba3e6948 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2722,7 +2722,7 @@ static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg) err_drop: mnt_drop_write_file(file); if (bdev_handle) - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); out: btrfs_put_dev_args_from_path(&args); kfree(vol_args); @@ -2770,7 +2770,7 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg) mnt_drop_write_file(file); if (bdev_handle) - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); out: btrfs_put_dev_args_from_path(&args); kfree(vol_args); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index db63b0be5405..fb7082426498 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -517,8 +517,7 @@ btrfs_get_bdev_and_sb(const char *device_path, blk_mode_t flags, void *holder, struct block_device *bdev; int ret; - *bdev_handle = blkdev_get_handle_by_path(device_path, flags, holder, - NULL); + *bdev_handle = blkdev_get_by_path(device_path, flags, holder, NULL); if (IS_ERR(*bdev_handle)) { ret = PTR_ERR(*bdev_handle); @@ -530,14 +529,14 @@ btrfs_get_bdev_and_sb(const char *device_path, blk_mode_t flags, void *holder, sync_blockdev(bdev); ret = set_blocksize(bdev, BTRFS_BDEV_BLOCKSIZE); if (ret) { - blkdev_handle_put(*bdev_handle); + blkdev_put(*bdev_handle); goto error; } invalidate_bdev(bdev); *disk_super = btrfs_read_dev_super(bdev); if (IS_ERR(*disk_super)) { ret = PTR_ERR(*disk_super); - blkdev_handle_put(*bdev_handle); + blkdev_put(*bdev_handle); goto error; } @@ -679,7 +678,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, error_free_page: btrfs_release_disk_super(disk_super); - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return -EINVAL; } @@ -1070,7 +1069,7 @@ static void __btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, continue; if (device->bdev_handle) { - blkdev_handle_put(device->bdev_handle); + blkdev_put(device->bdev_handle); device->bdev = NULL; device->bdev_handle = NULL; fs_devices->open_devices--; @@ -1117,7 +1116,7 @@ static void btrfs_close_bdev(struct btrfs_device *device) invalidate_bdev(device->bdev); } - blkdev_handle_put(device->bdev_handle); + blkdev_put(device->bdev_handle); } static void btrfs_close_one_device(struct btrfs_device *device) @@ -1388,7 +1387,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags) * values temporarily, as the device paths of the fsid are the only * required information for assembling the volume. */ - bdev_handle = blkdev_get_handle_by_path(path, flags, NULL, NULL); + bdev_handle = blkdev_get_by_path(path, flags, NULL, NULL); if (IS_ERR(bdev_handle)) return ERR_CAST(bdev_handle); @@ -1413,7 +1412,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags) btrfs_release_disk_super(disk_super); error_bdev_put: - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return device; } @@ -2225,9 +2224,9 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, * free the device. * * We cannot call btrfs_close_bdev() here because we're holding the sb - * write lock, and blkdev_handle_put() will pull in the ->open_mutex on - * the block device and it's dependencies. Instead just flush the - * device and let the caller do the final blkdev_handle_put. + * write lock, and blkdev_put() will pull in the ->open_mutex on the + * block device and it's dependencies. Instead just flush the device + * and let the caller do the final blkdev_put. */ if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) { btrfs_scratch_superblocks(fs_info, device->bdev, @@ -2406,7 +2405,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info, else memcpy(args->fsid, disk_super->fsid, BTRFS_FSID_SIZE); btrfs_release_disk_super(disk_super); - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return 0; } @@ -2639,8 +2638,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path if (sb_rdonly(sb) && !fs_devices->seeding) return -EROFS; - bdev_handle = blkdev_get_handle_by_path(device_path, BLK_OPEN_WRITE, - fs_info->bdev_holder, NULL); + bdev_handle = blkdev_get_by_path(device_path, BLK_OPEN_WRITE, + fs_info->bdev_holder, NULL); if (IS_ERR(bdev_handle)) return PTR_ERR(bdev_handle); @@ -2860,7 +2859,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path error_free_device: btrfs_free_device(device); error: - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); if (locked) { mutex_unlock(&uuid_mutex); up_write(&sb->s_umount); diff --git a/fs/erofs/super.c b/fs/erofs/super.c index a4742cc05f95..60d6b43ae5e3 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -254,8 +254,8 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb, return PTR_ERR(fscache); dif->fscache = fscache; } else if (!sbi->devs->flatdev) { - bdev_handle = blkdev_get_handle_by_path(dif->path, - BLK_OPEN_READ, sb->s_type, NULL); + bdev_handle = blkdev_get_by_path(dif->path, BLK_OPEN_READ, + sb->s_type, NULL); if (IS_ERR(bdev_handle)) return PTR_ERR(bdev_handle); dif->bdev_handle = bdev_handle; @@ -816,7 +816,7 @@ static int erofs_release_device_info(int id, void *ptr, void *data) fs_put_dax(dif->dax_dev, NULL); if (dif->bdev_handle) - blkdev_handle_put(dif->bdev_handle); + blkdev_put(dif->bdev_handle); erofs_fscache_unregister_cookie(dif->fscache); dif->fscache = NULL; kfree(dif->path); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index a3b982d6abf1..cbeb8a555fe3 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1112,8 +1112,8 @@ static struct bdev_handle *ext4_blkdev_get(dev_t dev, struct super_block *sb) { struct bdev_handle *handle; - handle = blkdev_get_handle_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_WRITE, - sb, &ext4_holder_ops); + handle = blkdev_get_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_WRITE, sb, + &ext4_holder_ops); if (IS_ERR(handle)) goto fail; return handle; @@ -1137,7 +1137,7 @@ static void ext4_blkdev_remove(struct ext4_sb_info *sbi) * hotswapped, and it breaks the `ro-after' testing code. */ invalidate_bdev(sbi->s_journal_bdev_handle->bdev); - blkdev_handle_put(sbi->s_journal_bdev_handle); + blkdev_put(sbi->s_journal_bdev_handle); sbi->s_journal_bdev_handle = NULL; } } @@ -5928,7 +5928,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, out_journal: jbd2_journal_destroy(journal); out_bdev: - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return NULL; } diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 570364954578..2823f3eb36c7 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1538,7 +1538,7 @@ static void destroy_device_list(struct f2fs_sb_info *sbi) int i; for (i = 0; i < sbi->s_ndevs; i++) { - blkdev_handle_put(FDEV(i).bdev_handle); + blkdev_put(FDEV(i).bdev_handle); #ifdef CONFIG_BLK_DEV_ZONED kvfree(FDEV(i).blkz_seq); #endif @@ -4024,9 +4024,10 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) if (max_devices == 1) { /* Single zoned block device mount */ - FDEV(0).bdev_handle = blkdev_get_handle_by_dev( - sbi->sb->s_bdev->bd_dev, - mode, sbi->sb->s_type, NULL); + FDEV(0).bdev_handle = blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev, + mode, + sbi->sb->s_type, + NULL); } else { /* Multi-device mount */ memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN); @@ -4044,8 +4045,10 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) (FDEV(i).total_segments << sbi->log_blocks_per_seg) - 1; } - FDEV(i).bdev_handle = blkdev_get_handle_by_path( - FDEV(i).path, mode, sbi->sb->s_type, NULL); + FDEV(i).bdev_handle = blkdev_get_by_path(FDEV(i).path, + mode, + sbi->sb->s_type, + NULL); } if (IS_ERR(FDEV(i).bdev_handle)) return PTR_ERR(FDEV(i).bdev_handle); diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index 9d06323261e6..4f5171f24191 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c @@ -1100,8 +1100,9 @@ int lmLogOpen(struct super_block *sb) * file systems to log may have n-to-1 relationship; */ - bdev_handle = blkdev_get_handle_by_dev(sbi->logdev, - BLK_OPEN_READ | BLK_OPEN_WRITE, log, NULL); + bdev_handle = blkdev_get_by_dev(sbi->logdev, + BLK_OPEN_READ | BLK_OPEN_WRITE, log, + NULL); if (IS_ERR(bdev_handle)) { rc = PTR_ERR(bdev_handle); goto free; @@ -1141,7 +1142,7 @@ int lmLogOpen(struct super_block *sb) lbmLogShutdown(log); close: /* close external log device */ - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); free: /* free log descriptor */ mutex_unlock(&jfs_log_mutex); @@ -1485,7 +1486,7 @@ int lmLogClose(struct super_block *sb) bdev_handle = log->bdev_handle; rc = lmLogShutdown(log); - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); kfree(log); diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c index 549de8600beb..26d22802a6f6 100644 --- a/fs/nfs/blocklayout/dev.c +++ b/fs/nfs/blocklayout/dev.c @@ -35,7 +35,7 @@ bl_free_device(struct pnfs_block_dev *dev) } if (dev->bdev_handle) - blkdev_handle_put(dev->bdev_handle); + blkdev_put(dev->bdev_handle); } } @@ -243,8 +243,8 @@ bl_parse_simple(struct nfs_server *server, struct pnfs_block_dev *d, if (!dev) return -EIO; - bdev_handle = blkdev_get_handle_by_dev(dev, - BLK_OPEN_READ | BLK_OPEN_WRITE, NULL, NULL); + bdev_handle = blkdev_get_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_WRITE, + NULL, NULL); if (IS_ERR(bdev_handle)) { printk(KERN_WARNING "pNFS: failed to open device %d:%d (%ld)\n", MAJOR(dev), MINOR(dev), PTR_ERR(bdev_handle)); @@ -311,8 +311,9 @@ bl_open_path(struct pnfs_block_volume *v, const char *prefix) if (!devname) return ERR_PTR(-ENOMEM); - bdev_handle = blkdev_get_handle_by_path(devname, - BLK_OPEN_READ | BLK_OPEN_WRITE, NULL, NULL); + bdev_handle = blkdev_get_by_path(devname, + BLK_OPEN_READ | BLK_OPEN_WRITE, NULL, + NULL); if (IS_ERR(bdev_handle)) { pr_warn("pNFS: failed to open device %s (%ld)\n", devname, PTR_ERR(bdev_handle)); @@ -373,7 +374,7 @@ bl_parse_scsi(struct nfs_server *server, struct pnfs_block_dev *d, return 0; out_blkdev_put: - blkdev_handle_put(d->bdev_handle); + blkdev_put(d->bdev_handle); return error; } diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 0aba0daa06d2..310ebbcc324d 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -1304,8 +1304,8 @@ nilfs_mount(struct file_system_type *fs_type, int flags, struct dentry *root_dentry; int err, s_new = false; - bdev_handle = blkdev_get_handle_by_path(dev_name, sb_open_mode(flags), - fs_type, NULL); + bdev_handle = blkdev_get_by_path(dev_name, sb_open_mode(flags), + fs_type, NULL); if (IS_ERR(bdev_handle)) return ERR_CAST(bdev_handle); @@ -1377,7 +1377,7 @@ nilfs_mount(struct file_system_type *fs_type, int flags, } if (!s_new) - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return root_dentry; @@ -1386,7 +1386,7 @@ nilfs_mount(struct file_system_type *fs_type, int flags, failed: if (!s_new) - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return ERR_PTR(err); } diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 5509e7fb98db..c9f76d6cd796 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -1510,7 +1510,7 @@ static void o2hb_region_release(struct config_item *item) } if (reg->hr_bdev_handle) - blkdev_handle_put(reg->hr_bdev_handle); + blkdev_put(reg->hr_bdev_handle); kfree(reg->hr_slots); @@ -1795,9 +1795,9 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, if (!S_ISBLK(f.file->f_mapping->host->i_mode)) goto out2; - reg->hr_bdev_handle = blkdev_get_handle_by_dev( - f.file->f_mapping->host->i_rdev, - BLK_OPEN_WRITE | BLK_OPEN_READ, NULL, NULL); + reg->hr_bdev_handle = blkdev_get_by_dev(f.file->f_mapping->host->i_rdev, + BLK_OPEN_WRITE | BLK_OPEN_READ, + NULL, NULL); if (IS_ERR(reg->hr_bdev_handle)) { ret = PTR_ERR(reg->hr_bdev_handle); reg->hr_bdev_handle = NULL; @@ -1904,7 +1904,7 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, out3: if (ret < 0) { - blkdev_handle_put(reg->hr_bdev_handle); + blkdev_put(reg->hr_bdev_handle); reg->hr_bdev_handle = NULL; } out2: diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index 9518ff7865f0..3eaff21947a0 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c @@ -2587,7 +2587,7 @@ static void journal_list_init(struct super_block *sb) static void release_journal_dev(struct reiserfs_journal *journal) { if (journal->j_bdev_handle) { - blkdev_handle_put(journal->j_bdev_handle); + blkdev_put(journal->j_bdev_handle); journal->j_bdev_handle = NULL; } } @@ -2614,8 +2614,8 @@ static int journal_init_dev(struct super_block *super, if ((!jdev_name || !jdev_name[0])) { if (jdev == super->s_dev) holder = NULL; - journal->j_bdev_handle = blkdev_get_handle_by_dev(jdev, - blkdev_mode, holder, NULL); + journal->j_bdev_handle = blkdev_get_by_dev(jdev, blkdev_mode, + holder, NULL); if (IS_ERR(journal->j_bdev_handle)) { result = PTR_ERR(journal->j_bdev_handle); journal->j_bdev_handle = NULL; @@ -2630,8 +2630,8 @@ static int journal_init_dev(struct super_block *super, return 0; } - journal->j_bdev_handle = blkdev_get_handle_by_path(jdev_name, - blkdev_mode, holder, NULL); + journal->j_bdev_handle = blkdev_get_by_path(jdev_name, blkdev_mode, + holder, NULL); if (IS_ERR(journal->j_bdev_handle)) { result = PTR_ERR(journal->j_bdev_handle); journal->j_bdev_handle = NULL; diff --git a/fs/super.c b/fs/super.c index d35545364c5d..ea135fece772 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1266,9 +1266,9 @@ int get_tree_bdev(struct fs_context *fc, if (!fc->source) return invalf(fc, "No source specified"); - bdev_handle = blkdev_get_handle_by_path(fc->source, - sb_open_mode(fc->sb_flags), fc->fs_type, - &fs_holder_ops); + bdev_handle = blkdev_get_by_path(fc->source, + sb_open_mode(fc->sb_flags), + fc->fs_type, &fs_holder_ops); if (IS_ERR(bdev_handle)) { errorf(fc, "%s: Can't open blockdev", fc->source); return PTR_ERR(bdev_handle); @@ -1283,7 +1283,7 @@ int get_tree_bdev(struct fs_context *fc, if (bdev->bd_fsfreeze_count > 0) { mutex_unlock(&bdev->bd_fsfreeze_mutex); warnf(fc, "%pg: Can't mount, blockdev is frozen", bdev); - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return -EBUSY; } @@ -1292,7 +1292,7 @@ int get_tree_bdev(struct fs_context *fc, s = sget_fc(fc, test_bdev_super_fc, set_bdev_super_fc); mutex_unlock(&bdev->bd_fsfreeze_mutex); if (IS_ERR(s)) { - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return PTR_ERR(s); } @@ -1301,19 +1301,18 @@ int get_tree_bdev(struct fs_context *fc, if ((fc->sb_flags ^ s->s_flags) & SB_RDONLY) { warnf(fc, "%pg: Can't mount, would change RO state", bdev); deactivate_locked_super(s); - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); return -EBUSY; } /* * s_umount nests inside open_mutex during - * __invalidate_device(). blkdev_handle_put() acquires - * open_mutex and can't be called under s_umount. Drop - * s_umount temporarily. This is safe as we're - * holding an active reference. + * __invalidate_device(). blkdev_put() acquires open_mutex and + * can't be called under s_umount. Drop s_umount temporarily. + * This is safe as we're holding an active reference. */ up_write(&s->s_umount); - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); down_write(&s->s_umount); } else { snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); @@ -1351,8 +1350,8 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, struct super_block *s; int error = 0; - bdev_handle = blkdev_get_handle_by_path(dev_name, sb_open_mode(flags), - fs_type, &fs_holder_ops); + bdev_handle = blkdev_get_by_path(dev_name, sb_open_mode(flags), + fs_type, &fs_holder_ops); if (IS_ERR(bdev_handle)) return ERR_CAST(bdev_handle); bdev = bdev_handle->bdev; @@ -1383,13 +1382,12 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, /* * s_umount nests inside open_mutex during - * __invalidate_device(). blkdev_handle_put() acquires - * open_mutex and can't be called under s_umount. Drop - * s_umount temporarily. This is safe as we're - * holding an active reference. + * __invalidate_device(). blkdev_put() acquires open_mutex and + * can't be called under s_umount. Drop s_umount temporarily. + * This is safe as we're holding an active reference. */ up_write(&s->s_umount); - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); down_write(&s->s_umount); } else { snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); @@ -1411,7 +1409,7 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, error_s: error = PTR_ERR(s); error_bdev: - blkdev_handle_put(bdev_handle); + blkdev_put(bdev_handle); error: return ERR_PTR(error); } @@ -1424,7 +1422,7 @@ void kill_block_super(struct super_block *sb) bdev->bd_super = NULL; generic_shutdown_super(sb); sync_blockdev(bdev); - blkdev_handle_put(sb->s_bdev_handle); + blkdev_put(sb->s_bdev_handle); } EXPORT_SYMBOL(kill_block_super); diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 5a958ae3a3ae..b0fbf8ea7846 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -396,8 +396,8 @@ xfs_blkdev_get( { int error = 0; - *handlep = blkdev_get_handle_by_path(name, - BLK_OPEN_READ | BLK_OPEN_WRITE, mp, &xfs_holder_ops); + *handlep = blkdev_get_by_path(name, BLK_OPEN_READ | BLK_OPEN_WRITE, + mp, &xfs_holder_ops); if (IS_ERR(*handlep)) { error = PTR_ERR(*handlep); xfs_warn(mp, "Invalid device [%s], error=%d", name, error); @@ -411,7 +411,7 @@ xfs_blkdev_put( struct bdev_handle *handle) { if (handle) - blkdev_handle_put(handle); + blkdev_put(handle); } STATIC void diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 134dfd1162e2..4ae3647a0322 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1476,14 +1476,14 @@ struct bdev_handle { void *holder; }; -struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode, - void *holder, const struct blk_holder_ops *hops); -struct bdev_handle *blkdev_get_handle_by_path(const char *path, blk_mode_t mode, +struct bdev_handle *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder, + const struct blk_holder_ops *hops); +struct bdev_handle *blkdev_get_by_path(const char *path, blk_mode_t mode, void *holder, const struct blk_holder_ops *hops); int bd_prepare_to_claim(struct block_device *bdev, void *holder, const struct blk_holder_ops *hops); void bd_abort_claiming(struct block_device *bdev, void *holder); -void blkdev_handle_put(struct bdev_handle *handle); +void blkdev_put(struct bdev_handle *handle); /* just for blk-cgroup, don't use elsewhere */ struct block_device *blkdev_get_no_open(dev_t dev); diff --git a/kernel/power/swap.c b/kernel/power/swap.c index 9ebac878497f..25f06d92944c 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c @@ -357,14 +357,14 @@ static int swsusp_swap_check(void) return res; root_swap = res; - hib_resume_bdev_handle = blkdev_get_handle_by_dev(swsusp_resume_device, - BLK_OPEN_WRITE, NULL, NULL); + hib_resume_bdev_handle = blkdev_get_by_dev(swsusp_resume_device, + BLK_OPEN_WRITE, NULL, NULL); if (IS_ERR(hib_resume_bdev_handle)) return PTR_ERR(hib_resume_bdev_handle); res = set_blocksize(hib_resume_bdev_handle->bdev, PAGE_SIZE); if (res < 0) - blkdev_handle_put(hib_resume_bdev_handle); + blkdev_put(hib_resume_bdev_handle); return res; } @@ -1522,8 +1522,9 @@ int swsusp_check(bool snapshot_test) void *holder = snapshot_test ? &swsusp_holder : NULL; int error; - hib_resume_bdev_handle = blkdev_get_handle_by_dev(swsusp_resume_device, - BLK_OPEN_READ, holder, NULL); + hib_resume_bdev_handle = blkdev_get_by_dev(swsusp_resume_device, + BLK_OPEN_READ, holder, + NULL); if (!IS_ERR(hib_resume_bdev_handle)) { set_blocksize(hib_resume_bdev_handle->bdev, PAGE_SIZE); clear_page(swsusp_header); @@ -1550,7 +1551,7 @@ int swsusp_check(bool snapshot_test) put: if (error) - blkdev_handle_put(hib_resume_bdev_handle); + blkdev_put(hib_resume_bdev_handle); else pr_debug("Image signature found, resuming\n"); } else { @@ -1574,7 +1575,7 @@ void swsusp_close(void) return; } - blkdev_handle_put(hib_resume_bdev_handle); + blkdev_put(hib_resume_bdev_handle); } /** diff --git a/mm/swapfile.c b/mm/swapfile.c index dbd37aa4724d..921fdb7e5e09 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2528,7 +2528,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) inode = mapping->host; if (p->bdev_handle) { set_blocksize(p->bdev, old_block_size); - blkdev_handle_put(p->bdev_handle); + blkdev_put(p->bdev_handle); } inode_lock(inode); @@ -2758,8 +2758,9 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode) int error; if (S_ISBLK(inode->i_mode)) { - p->bdev_handle = blkdev_get_handle_by_dev(inode->i_rdev, - BLK_OPEN_READ | BLK_OPEN_WRITE, p, NULL); + p->bdev_handle = blkdev_get_by_dev(inode->i_rdev, + BLK_OPEN_READ | BLK_OPEN_WRITE, + p, NULL); if (IS_ERR(p->bdev_handle)) { error = PTR_ERR(p->bdev_handle); p->bdev_handle = NULL; @@ -3211,7 +3212,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) p->cluster_next_cpu = NULL; if (p->bdev_handle) { set_blocksize(p->bdev, p->old_block_size); - blkdev_handle_put(p->bdev_handle); + blkdev_put(p->bdev_handle); } inode = NULL; destroy_swap_extents(p);