All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: <linux-fsdevel@vger.kernel.org>
Cc: <linux-block@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 19/29] fs: Convert to bdev_open_by_dev()
Date: Fri, 11 Aug 2023 13:04:50 +0200	[thread overview]
Message-ID: <20230811110504.27514-19-jack@suse.cz> (raw)
In-Reply-To: <20230810171429.31759-1-jack@suse.cz>

Convert mount code to use bdev_open_by_dev() and propagate the handle
around to bdev_release().

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/super.c         | 15 +++++++++------
 include/linux/fs.h |  1 +
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 71fe297a7e90..030e897c2c68 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1270,14 +1270,16 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
 		struct fs_context *fc)
 {
 	blk_mode_t mode = sb_open_mode(sb_flags);
+	struct bdev_handle *bdev_handle;
 	struct block_device *bdev;
 
-	bdev = blkdev_get_by_dev(sb->s_dev, mode, sb, &fs_holder_ops);
-	if (IS_ERR(bdev)) {
+	bdev_handle = bdev_open_by_dev(sb->s_dev, mode, sb, &fs_holder_ops);
+	if (IS_ERR(bdev_handle)) {
 		if (fc)
 			errorf(fc, "%s: Can't open blockdev", fc->source);
-		return PTR_ERR(bdev);
+		return PTR_ERR(bdev_handle);
 	}
+	bdev = bdev_handle->bdev;
 
 	/*
 	 * This really should be in blkdev_get_by_dev, but right now can't due
@@ -1285,7 +1287,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
 	 * writable from userspace even for a read-only block device.
 	 */
 	if ((mode & BLK_OPEN_WRITE) && bdev_read_only(bdev)) {
-		blkdev_put(bdev, sb);
+		bdev_release(bdev_handle);
 		return -EACCES;
 	}
 
@@ -1301,10 +1303,11 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
 		mutex_unlock(&bdev->bd_fsfreeze_mutex);
 		if (fc)
 			warnf(fc, "%pg: Can't mount, blockdev is frozen", bdev);
-		blkdev_put(bdev, sb);
+		bdev_release(bdev_handle);
 		return -EBUSY;
 	}
 	spin_lock(&sb_lock);
+	sb->s_bdev_handle = bdev_handle;
 	sb->s_bdev = bdev;
 	sb->s_bdi = bdi_get(bdev->bd_disk->bdi);
 	if (bdev_stable_writes(bdev))
@@ -1438,7 +1441,7 @@ void kill_block_super(struct super_block *sb)
 	generic_shutdown_super(sb);
 	if (bdev) {
 		sync_blockdev(bdev);
-		blkdev_put(bdev, sb);
+		bdev_release(sb->s_bdev_handle);
 	}
 }
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 234ad85a28b5..a77a20955d91 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1187,6 +1187,7 @@ struct super_block {
 	struct hlist_bl_head	s_roots;	/* alternate root dentries for NFS */
 	struct list_head	s_mounts;	/* list of mounts; _not_ for fs use */
 	struct block_device	*s_bdev;
+	struct bdev_handle	*s_bdev_handle;
 	struct backing_dev_info *s_bdi;
 	struct mtd_info		*s_mtd;
 	struct hlist_node	s_instances;
-- 
2.35.3


  parent reply	other threads:[~2023-08-11 11:05 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11 11:04 [PATCH v2 0/29] block: Make blkdev_get_by_*() return handle Jan Kara
2023-08-11 11:04 ` Jan Kara
2023-08-11 11:04 ` [dm-devel] " Jan Kara
2023-08-11 11:04 ` Jan Kara
2023-08-11 11:04 ` Jan Kara
2023-08-11 11:04 ` [f2fs-dev] " Jan Kara
2023-08-11 11:04 ` [PATCH 01/29] block: Provide bdev_open_* functions Jan Kara
2023-08-11 11:04 ` [PATCH 02/29] block: Use bdev_open_by_dev() in blkdev_open() Jan Kara
2023-08-11 12:25   ` Christoph Hellwig
2023-08-14 13:51     ` Jan Kara
2023-08-25  1:14   ` Al Viro
2023-08-11 11:04 ` [PATCH 03/29] block: Use bdev_open_by_dev() in disk_scan_partitions() and blkdev_bszset() Jan Kara
2023-08-11 11:04 ` [PATCH 04/29] drdb: Convert to use bdev_open_by_path() Jan Kara
2023-08-11 11:04 ` [PATCH 05/29] pktcdvd: Convert to bdev_open_by_dev() Jan Kara
2023-08-11 11:04 ` [PATCH 06/29] rnbd-srv: Convert to use bdev_open_by_path() Jan Kara
2023-08-11 11:04 ` [PATCH 07/29] xen/blkback: Convert to bdev_open_by_dev() Jan Kara
2023-08-11 11:04 ` [PATCH 08/29] zram: Convert to use bdev_open_by_dev() Jan Kara
2023-08-11 11:04 ` [PATCH 09/29] bcache: Convert to bdev_open_by_path() Jan Kara
2023-08-21  1:06   ` Eric Wheeler
2023-08-21 17:50     ` Jan Kara
2023-08-21 18:54       ` Eric Wheeler
2023-08-23 10:10         ` Coly Li
2023-08-11 11:04 ` [PATCH 10/29] dm: Convert to bdev_open_by_dev() Jan Kara
2023-08-11 11:04   ` [dm-devel] " Jan Kara
2023-08-11 11:04 ` [PATCH 11/29] md: " Jan Kara
2023-08-13 15:54   ` Song Liu
2023-08-14 13:37     ` Jan Kara
2023-08-11 11:04 ` [PATCH 12/29] mtd: block2mtd: Convert to bdev_open_by_dev/path() Jan Kara
2023-08-11 11:04   ` Jan Kara
2023-08-11 11:04 ` [PATCH 13/29] nvmet: Convert to bdev_open_by_path() Jan Kara
2023-08-11 11:04 ` [PATCH 14/29] s390/dasd: " Jan Kara
2023-08-11 11:04 ` [PATCH 15/29] scsi: target: " Jan Kara
2023-08-11 11:04 ` [PATCH 16/29] PM: hibernate: Convert to bdev_open_by_dev() Jan Kara
2023-08-11 16:57   ` Rafael J. Wysocki
2023-08-11 11:04 ` [PATCH 17/29] PM: hibernate: Drop unused snapshot_test argument Jan Kara
2023-08-11 16:58   ` Rafael J. Wysocki
2023-08-11 11:04 ` [PATCH 18/29] mm/swap: Convert to use bdev_open_by_dev() Jan Kara
2023-08-11 11:04 ` Jan Kara [this message]
2023-08-11 11:04 ` [PATCH 20/29] btrfs: Convert to bdev_open_by_path() Jan Kara
2023-08-11 11:04 ` [PATCH 21/29] erofs: Convert to use bdev_open_by_path() Jan Kara
2023-08-11 11:04   ` Jan Kara
2023-08-11 11:04 ` [PATCH 22/29] ext4: Convert to bdev_open_by_dev() Jan Kara
2023-08-11 11:04 ` [PATCH 23/29] f2fs: Convert to bdev_open_by_dev/path() Jan Kara
2023-08-11 11:04   ` [f2fs-dev] " Jan Kara
2023-08-11 11:04 ` [PATCH 24/29] jfs: Convert to bdev_open_by_dev() Jan Kara
2023-08-11 11:04 ` [PATCH 25/29] nfs/blocklayout: Convert to use bdev_open_by_dev/path() Jan Kara
2023-08-11 11:04 ` [PATCH 26/29] ocfs2: Convert to use bdev_open_by_dev() Jan Kara
2023-08-11 11:04 ` [PATCH 27/29] reiserfs: Convert to bdev_open_by_dev/path() Jan Kara
2023-08-11 11:04   ` Jan Kara
2023-08-11 11:04 ` [PATCH 28/29] xfs: Convert to bdev_open_by_path() Jan Kara
     [not found]   ` <CGME20230814102748eucas1p269b8a53ed09fae1eb57dce3d2a7de752@eucas1p2.samsung.com>
2023-08-14 10:27     ` Daniel Gomez
2023-08-14 13:43       ` Jan Kara
2023-08-11 11:05 ` [PATCH 29/29] block: Remove blkdev_get_by_*() functions Jan Kara
2023-08-11 12:27 ` [PATCH v2 0/29] block: Make blkdev_get_by_*() return handle Christoph Hellwig
2023-08-11 12:27   ` Christoph Hellwig
2023-08-11 12:27   ` Christoph Hellwig
2023-08-11 12:27   ` [dm-devel] " Christoph Hellwig
2023-08-11 12:27   ` Christoph Hellwig
2023-08-11 12:27   ` [f2fs-dev] " Christoph Hellwig
2023-08-25  1:58 ` Al Viro
2023-08-25  1:58   ` Al Viro
2023-08-25  1:58   ` Al Viro
2023-08-25  1:58   ` [dm-devel] " Al Viro
2023-08-25  1:58   ` [f2fs-dev] " Al Viro
2023-08-25  1:58   ` Al Viro
2023-08-25 13:47   ` Jan Kara
2023-08-25 13:47     ` Jan Kara
2023-08-25 13:47     ` [dm-devel] " Jan Kara
2023-08-25 13:47     ` Jan Kara
2023-08-25 13:47     ` Jan Kara
2023-08-25 13:47     ` [f2fs-dev] " Jan Kara
2023-08-26  2:28     ` Al Viro
2023-08-26  2:28       ` Al Viro
2023-08-26  2:28       ` [dm-devel] " Al Viro
2023-08-26  2:28       ` Al Viro
2023-08-26  2:28       ` Al Viro
2023-08-26  2:28       ` [f2fs-dev] " Al Viro
2023-08-28 14:27       ` Christoph Hellwig
2023-08-28 14:27         ` Christoph Hellwig
2023-08-28 14:27         ` [dm-devel] " Christoph Hellwig
2023-08-28 14:27         ` Christoph Hellwig
2023-08-28 14:27         ` Christoph Hellwig
2023-08-28 14:27         ` [f2fs-dev] " Christoph Hellwig
2023-08-28 13:20     ` Christian Brauner
2023-08-28 13:20       ` Christian Brauner
2023-08-28 13:20       ` [dm-devel] " Christian Brauner
2023-08-28 13:20       ` Christian Brauner
2023-08-28 13:20       ` Christian Brauner
2023-08-28 13:20       ` [f2fs-dev] " Christian Brauner
2023-08-28 14:22     ` Christoph Hellwig
2023-08-28 14:22       ` Christoph Hellwig
2023-08-28 14:22       ` [dm-devel] " Christoph Hellwig
2023-08-28 14:22       ` Christoph Hellwig
2023-08-28 14:22       ` Christoph Hellwig
2023-08-28 14:22       ` [f2fs-dev] " Christoph Hellwig
2023-08-23 10:48 [PATCH v3 " Jan Kara
2023-08-23 10:48 ` [PATCH 19/29] fs: Convert to bdev_open_by_dev() Jan Kara
2023-08-25 12:20   ` Christian Brauner
2023-09-27  9:34 ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230811110504.27514-19-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.