diff mbox series

[v2,27/34] bdev: remove bdev_open_by_path()

Message ID 20240123-vfs-bdev-file-v2-27-adbd023e19cc@kernel.org (mailing list archive)
State New, archived
Headers show
Series Open block devices as files | expand

Commit Message

Christian Brauner Jan. 23, 2024, 1:26 p.m. UTC
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 block/bdev.c           | 40 ----------------------------------------
 include/linux/blkdev.h |  2 --
 2 files changed, 42 deletions(-)

Comments

Christoph Hellwig Jan. 29, 2024, 4:17 p.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Jan Kara Feb. 1, 2024, 10:24 a.m. UTC | #2
On Tue 23-01-24 14:26:44, Christian Brauner wrote:
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Sure. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  block/bdev.c           | 40 ----------------------------------------
>  include/linux/blkdev.h |  2 --
>  2 files changed, 42 deletions(-)
> 
> diff --git a/block/bdev.c b/block/bdev.c
> index 4246a57a7c5a..eb5607af6ec5 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -1007,46 +1007,6 @@ struct file *bdev_file_open_by_path(const char *path, blk_mode_t mode,
>  }
>  EXPORT_SYMBOL(bdev_file_open_by_path);
>  
> -/**
> - * bdev_open_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
> - * @hops: holder operations
> - *
> - * Open the block device described by the device file at @path.  If @holder is
> - * not %NULL, the block device is opened with exclusive access.  Exclusive opens
> - * may nest for the same @holder.
> - *
> - * CONTEXT:
> - * Might sleep.
> - *
> - * RETURNS:
> - * Handle with a reference to the block_device on success, ERR_PTR(-errno) on
> - * failure.
> - */
> -struct bdev_handle *bdev_open_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 = bdev_open_by_dev(dev, mode, holder, hops);
> -	if (!IS_ERR(handle) && (mode & BLK_OPEN_WRITE) &&
> -	    bdev_read_only(handle->bdev)) {
> -		bdev_release(handle);
> -		return ERR_PTR(-EACCES);
> -	}
> -
> -	return handle;
> -}
> -EXPORT_SYMBOL(bdev_open_by_path);
> -
>  void bdev_release(struct bdev_handle *handle)
>  {
>  	struct block_device *bdev = handle->bdev;
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 76706aa47316..5880d5abfebe 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1484,8 +1484,6 @@ struct bdev_handle {
>  
>  struct bdev_handle *bdev_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
>  		const struct blk_holder_ops *hops);
> -struct bdev_handle *bdev_open_by_path(const char *path, blk_mode_t mode,
> -		void *holder, const struct blk_holder_ops *hops);
>  struct file *bdev_file_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
>  		const struct blk_holder_ops *hops);
>  struct file *bdev_file_open_by_path(const char *path, blk_mode_t mode,
> 
> -- 
> 2.43.0
>
diff mbox series

Patch

diff --git a/block/bdev.c b/block/bdev.c
index 4246a57a7c5a..eb5607af6ec5 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -1007,46 +1007,6 @@  struct file *bdev_file_open_by_path(const char *path, blk_mode_t mode,
 }
 EXPORT_SYMBOL(bdev_file_open_by_path);
 
-/**
- * bdev_open_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
- * @hops: holder operations
- *
- * Open the block device described by the device file at @path.  If @holder is
- * not %NULL, the block device is opened with exclusive access.  Exclusive opens
- * may nest for the same @holder.
- *
- * CONTEXT:
- * Might sleep.
- *
- * RETURNS:
- * Handle with a reference to the block_device on success, ERR_PTR(-errno) on
- * failure.
- */
-struct bdev_handle *bdev_open_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 = bdev_open_by_dev(dev, mode, holder, hops);
-	if (!IS_ERR(handle) && (mode & BLK_OPEN_WRITE) &&
-	    bdev_read_only(handle->bdev)) {
-		bdev_release(handle);
-		return ERR_PTR(-EACCES);
-	}
-
-	return handle;
-}
-EXPORT_SYMBOL(bdev_open_by_path);
-
 void bdev_release(struct bdev_handle *handle)
 {
 	struct block_device *bdev = handle->bdev;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 76706aa47316..5880d5abfebe 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1484,8 +1484,6 @@  struct bdev_handle {
 
 struct bdev_handle *bdev_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
 		const struct blk_holder_ops *hops);
-struct bdev_handle *bdev_open_by_path(const char *path, blk_mode_t mode,
-		void *holder, const struct blk_holder_ops *hops);
 struct file *bdev_file_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
 		const struct blk_holder_ops *hops);
 struct file *bdev_file_open_by_path(const char *path, blk_mode_t mode,