From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-nvme@lists.infradead.org,
Phillip Potter <phil@philpotter.co.uk>, Chris Mason <clm@fb.com>,
dm-devel@redhat.com, "Md. Haris Iqbal" <haris.iqbal@ionos.com>,
Pavel Machek <pavel@ucw.cz>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Jack Wang <jinpu.wang@ionos.com>,
linux-nilfs@vger.kernel.org, linux-scsi@vger.kernel.org,
Richard Weinberger <richard@nod.at>,
linux-pm@vger.kernel.org, linux-um@lists.infradead.org,
Josef Bacik <josef@toxicpanda.com>, Coly Li <colyli@suse.de>,
linux-block@vger.kernel.org, linux-bcache@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
David Sterba <dsterba@suse.com>,
Christian Brauner <brauner@kernel.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.
Subject: [PATCH 15/31] btrfs: don't pass a holder for non-exclusive blkdev_get_by_path
Date: Tue, 6 Jun 2023 09:39:34 +0200 [thread overview]
Message-ID: <20230606073950.225178-16-hch@lst.de> (raw)
In-Reply-To: <20230606073950.225178-1-hch@lst.de>
Passing a holder to blkdev_get_by_path when FMODE_EXCL isn't set doesn't
make sense, so pass NULL instead and remove the holder argument from the
call chains the only end up in non-FMODE_EXCL blkdev_get_by_path calls.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/super.c | 16 ++++++----------
fs/btrfs/volumes.c | 17 ++++++++---------
fs/btrfs/volumes.h | 3 +--
3 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index ec18e22106023b..1a2ee9407f5414 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -849,8 +849,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
* All other options will be parsed on much later in the mount process and
* only when we need to allocate a new super block.
*/
-static int btrfs_parse_device_options(const char *options, fmode_t flags,
- void *holder)
+static int btrfs_parse_device_options(const char *options, fmode_t flags)
{
substring_t args[MAX_OPT_ARGS];
char *device_name, *opts, *orig, *p;
@@ -884,8 +883,7 @@ static int btrfs_parse_device_options(const char *options, fmode_t flags,
error = -ENOMEM;
goto out;
}
- device = btrfs_scan_one_device(device_name, flags,
- holder);
+ device = btrfs_scan_one_device(device_name, flags);
kfree(device_name);
if (IS_ERR(device)) {
error = PTR_ERR(device);
@@ -1477,13 +1475,13 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
}
mutex_lock(&uuid_mutex);
- error = btrfs_parse_device_options(data, mode, fs_type);
+ error = btrfs_parse_device_options(data, mode);
if (error) {
mutex_unlock(&uuid_mutex);
goto error_fs_info;
}
- device = btrfs_scan_one_device(device_name, mode, fs_type);
+ device = btrfs_scan_one_device(device_name, mode);
if (IS_ERR(device)) {
mutex_unlock(&uuid_mutex);
error = PTR_ERR(device);
@@ -2190,8 +2188,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
switch (cmd) {
case BTRFS_IOC_SCAN_DEV:
mutex_lock(&uuid_mutex);
- device = btrfs_scan_one_device(vol->name, FMODE_READ,
- &btrfs_root_fs_type);
+ device = btrfs_scan_one_device(vol->name, FMODE_READ);
ret = PTR_ERR_OR_ZERO(device);
mutex_unlock(&uuid_mutex);
break;
@@ -2205,8 +2202,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
break;
case BTRFS_IOC_DEVICES_READY:
mutex_lock(&uuid_mutex);
- device = btrfs_scan_one_device(vol->name, FMODE_READ,
- &btrfs_root_fs_type);
+ device = btrfs_scan_one_device(vol->name, FMODE_READ);
if (IS_ERR(device)) {
mutex_unlock(&uuid_mutex);
ret = PTR_ERR(device);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 784ccc8f6c69c1..035868cee3ddc3 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1348,8 +1348,7 @@ int btrfs_forget_devices(dev_t devt)
* and we are not allowed to call set_blocksize during the scan. The superblock
* is read via pagecache
*/
-struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags,
- void *holder)
+struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags)
{
struct btrfs_super_block *disk_super;
bool new_device_added = false;
@@ -1368,16 +1367,16 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags,
*/
/*
- * Avoid using flag |= FMODE_EXCL here, as the systemd-udev may
- * initiate the device scan which may race with the user's mount
- * or mkfs command, resulting in failure.
- * Since the device scan is solely for reading purposes, there is
- * no need for FMODE_EXCL. Additionally, the devices are read again
+ * Avoid an exclusive open here, as the systemd-udev may initiate the
+ * device scan which may race with the user's mount or mkfs command,
+ * resulting in failure.
+ * Since the device scan is solely for reading purposes, there is no
+ * need for an exclusive open. Additionally, the devices are read again
* during the mount process. It is ok to get some inconsistent
* values temporarily, as the device paths of the fsid are the only
* required information for assembling the volume.
*/
- bdev = blkdev_get_by_path(path, flags, holder, NULL);
+ bdev = blkdev_get_by_path(path, flags, NULL, NULL);
if (IS_ERR(bdev))
return ERR_CAST(bdev);
@@ -2381,7 +2380,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info,
return -ENOMEM;
}
- ret = btrfs_get_bdev_and_sb(path, FMODE_READ, fs_info->bdev_holder, 0,
+ ret = btrfs_get_bdev_and_sb(path, FMODE_READ, NULL, 0,
&bdev, &disk_super);
if (ret) {
btrfs_put_dev_args_from_path(args);
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index bf47a1a70813ba..eb97a397b3c3fb 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -600,8 +600,7 @@ struct btrfs_block_group *btrfs_create_chunk(struct btrfs_trans_handle *trans,
void btrfs_mapping_tree_free(struct extent_map_tree *tree);
int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
fmode_t flags, void *holder);
-struct btrfs_device *btrfs_scan_one_device(const char *path,
- fmode_t flags, void *holder);
+struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags);
int btrfs_forget_devices(dev_t devt);
void btrfs_close_devices(struct btrfs_fs_devices *fs_devices);
void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices);
--
2.39.2
next prev parent reply other threads:[~2023-06-06 7:39 UTC|newest]
Thread overview: 125+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-06 7:39 decouple block open flags from fmode_t Christoph Hellwig
2023-06-06 7:39 ` [PATCH 01/31] block: also call ->open for incremental partition opens Christoph Hellwig
2023-06-07 8:14 ` Christian Brauner
2023-06-07 8:32 ` Christoph Hellwig
2023-06-07 12:10 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 02/31] cdrom: remove the unused bdev argument to cdrom_open Christoph Hellwig
2023-06-06 22:50 ` Phillip Potter
2023-06-07 8:16 ` Christian Brauner
2023-06-07 12:10 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 03/31] cdrom: remove the unused mode argument to cdrom_ioctl Christoph Hellwig
[not found] ` <20230606073950.225178-4-hch-jcswGhMUV9g@public.gmane.org>
2023-06-06 22:54 ` Phillip Potter
2023-06-07 8:17 ` Christian Brauner
2023-06-07 12:11 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 04/31] cdrom: remove the unused cdrom_close_write release code Christoph Hellwig
[not found] ` <20230606073950.225178-5-hch-jcswGhMUV9g@public.gmane.org>
2023-06-06 22:56 ` Phillip Potter
2023-06-07 8:17 ` Christian Brauner
2023-06-07 12:12 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 05/31] cdrom: track if a cdrom_device_info was opened for data Christoph Hellwig
2023-06-06 22:59 ` Phillip Potter
2023-06-07 8:19 ` Christian Brauner
[not found] ` <20230606073950.225178-6-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 12:13 ` Hannes Reinecke
2023-06-07 12:20 ` Christoph Hellwig
2023-06-06 7:39 ` [PATCH 06/31] cdrom: remove the unused mode argument to cdrom_release Christoph Hellwig
2023-06-07 8:20 ` Christian Brauner
2023-06-07 12:14 ` Hannes Reinecke
[not found] ` <20230606073950.225178-7-hch-jcswGhMUV9g@public.gmane.org>
2023-06-06 23:00 ` Phillip Potter
2023-06-08 8:41 ` Christoph Hellwig
[not found] ` <20230608084129.GA14689-jcswGhMUV9g@public.gmane.org>
2023-06-08 8:47 ` Phillip Potter
2023-06-08 9:04 ` Christoph Hellwig
2023-06-08 9:44 ` Phillip Potter
2023-06-27 5:41 ` Guenter Roeck
2023-06-06 7:39 ` [PATCH 07/31] block: pass a gendisk on bdev_check_media_change Christoph Hellwig
[not found] ` <20230606073950.225178-8-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 8:25 ` Christian Brauner
2023-06-07 12:15 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 08/31] block: share code between disk_check_media_change and disk_force_media_change Christoph Hellwig
2023-06-07 8:26 ` Christian Brauner
2023-06-07 12:19 ` Hannes Reinecke
2023-06-07 12:21 ` Christoph Hellwig
[not found] ` <20230607122131.GB14579-jcswGhMUV9g@public.gmane.org>
2023-06-07 13:18 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 09/31] block: pass a gendisk to ->open Christoph Hellwig
2023-06-07 8:34 ` Christian Brauner
2023-06-07 9:42 ` Jinpu Wang
2023-06-07 12:19 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 10/31] block: remove the unused mode argument to ->release Christoph Hellwig
2023-06-07 8:34 ` Christian Brauner
2023-06-07 9:41 ` Jinpu Wang
2023-06-07 12:20 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 11/31] block: rename blkdev_close to blkdev_release Christoph Hellwig
2023-06-07 8:35 ` Christian Brauner
2023-06-07 12:21 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 12/31] swsusp: don't pass a stack address to blkdev_get_by_path Christoph Hellwig
2023-06-07 12:22 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 13/31] bcache: " Christoph Hellwig
2023-06-07 12:23 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 14/31] rnbd-srv: don't pass a holder for non-exclusive blkdev_get_by_path Christoph Hellwig
[not found] ` <20230606073950.225178-15-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 8:39 ` Christian Brauner
2023-06-07 9:38 ` Jinpu Wang
2023-06-07 12:24 ` Hannes Reinecke
2023-06-06 7:39 ` Christoph Hellwig [this message]
2023-06-07 8:40 ` [PATCH 15/31] btrfs: " Christian Brauner
2023-06-07 12:24 ` Hannes Reinecke
2023-06-07 13:32 ` David Sterba
2023-06-06 7:39 ` [PATCH 16/31] block: use the holder as indication for exclusive opens Christoph Hellwig
2023-06-07 8:49 ` Christian Brauner
2023-06-07 9:40 ` Jinpu Wang
2023-06-07 12:29 ` Hannes Reinecke
2023-06-07 13:53 ` David Sterba
2023-06-06 7:39 ` [PATCH 17/31] block: add a sb_open_mode helper Christoph Hellwig
2023-06-07 8:55 ` Christian Brauner
2023-06-07 12:30 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 18/31] fs: remove sb->s_mode Christoph Hellwig
2023-06-07 8:56 ` Christian Brauner
2023-06-07 13:01 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 19/31] scsi: replace the fmode_t argument to scsi_cmd_allowed with a simple bool Christoph Hellwig
2023-06-07 8:57 ` Christian Brauner
[not found] ` <20230606073950.225178-20-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 13:02 ` Hannes Reinecke
2023-06-08 1:18 ` Martin K. Petersen
2023-06-06 7:39 ` [PATCH 20/31] scsi: replace the fmode_t argument to scsi_ioctl " Christoph Hellwig
2023-06-07 8:58 ` Christian Brauner
2023-06-07 13:04 ` Hannes Reinecke
2023-06-08 1:17 ` Martin K. Petersen
2023-06-06 7:39 ` [PATCH 21/31] scsi: replace the fmode_t argument to ->sg_io_fn " Christoph Hellwig
2023-06-07 8:58 ` Christian Brauner
2023-06-07 13:05 ` Hannes Reinecke
2023-06-08 1:18 ` Martin K. Petersen
2023-06-06 7:39 ` [PATCH 22/31] nvme: replace the fmode_t argument to the nvme ioctl handlers " Christoph Hellwig
2023-06-07 8:59 ` Christian Brauner
[not found] ` <20230606073950.225178-23-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 13:06 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 23/31] mtd: block: use a simple bool to track open for write Christoph Hellwig
2023-06-06 8:24 ` Richard Weinberger
2023-06-07 9:00 ` Christian Brauner
2023-06-07 13:07 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 24/31] rnbd-srv: replace sess->open_flags with a "bool readonly" Christoph Hellwig
2023-06-07 9:01 ` Christian Brauner
[not found] ` <20230606073950.225178-25-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 9:43 ` Jinpu Wang
2023-06-07 13:07 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 25/31] ubd: remove commented out code in ubd_open Christoph Hellwig
2023-06-06 8:20 ` Richard Weinberger
2023-06-07 9:02 ` Christian Brauner
2023-06-07 13:08 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 26/31] block: move a few internal definitions out of blkdev.h Christoph Hellwig
2023-06-07 9:03 ` Christian Brauner
2023-06-07 13:09 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 27/31] block: remove unused fmode_t arguments from ioctl handlers Christoph Hellwig
2023-06-07 9:03 ` Christian Brauner
2023-06-07 13:10 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 28/31] block: replace fmode_t with a block-specific type for block open flags Christoph Hellwig
[not found] ` <20230606073950.225178-29-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 9:21 ` Christian Brauner
2023-06-07 9:32 ` Christian Brauner
2023-06-07 12:16 ` Christoph Hellwig
2023-06-07 12:47 ` Christian Brauner
2023-06-07 9:45 ` Jinpu Wang
2023-06-06 7:39 ` [PATCH 29/31] block: always use I_BDEV on file->f_mapping->host to find the bdev Christoph Hellwig
2023-06-07 9:23 ` Christian Brauner
[not found] ` <20230606073950.225178-30-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 13:11 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 30/31] block: store the holder in file->private_data Christoph Hellwig
2023-06-07 9:24 ` Christian Brauner
2023-06-07 12:18 ` Christoph Hellwig
[not found] ` <20230606073950.225178-31-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 13:14 ` Hannes Reinecke
2023-06-06 7:39 ` [PATCH 31/31] fs: remove the now unused FMODE_* flags Christoph Hellwig
2023-06-07 9:25 ` Christian Brauner
[not found] ` <20230606073950.225178-32-hch-jcswGhMUV9g@public.gmane.org>
2023-06-07 13:15 ` Hannes Reinecke
2023-06-06 8:27 ` decouple block open flags from fmode_t Christian Brauner
2023-06-06 8:40 ` Christoph Hellwig
2023-06-07 9:27 ` Christian Brauner
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=20230606073950.225178-16-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=clm@fb.com \
--cc=colyli@suse.de \
--cc=dm-devel@redhat.com \
--cc=dsterba@suse.com \
--cc=haris.iqbal@ionos.com \
--cc=jinpu.wang@ionos.com \
--cc=josef@toxicpanda.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mtd@lists.infradead. \
--cc=linux-nilfs@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=martin.petersen@oracle.com \
--cc=miquel.raynal@bootlin.com \
--cc=pavel@ucw.cz \
--cc=phil@philpotter.co.uk \
--cc=rafael@kernel.org \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).