summaryrefslogtreecommitdiff
path: root/block/fops.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-01-23 16:26:46 +0300
committerChristian Brauner <brauner@kernel.org>2024-02-25 14:05:27 +0300
commita56aefca8d386181415a1fb7cfec2f72b0404797 (patch)
tree94defbadef364f43e6265a641a3a50cae9ea8124 /block/fops.c
parentb1211a25c4fe3443cfef4ed7c39251502a663776 (diff)
downloadlinux-a56aefca8d386181415a1fb7cfec2f72b0404797.tar.xz
bdev: make struct bdev_handle private to the block layer
Link: https://lore.kernel.org/r/20240123-vfs-bdev-file-v2-29-adbd023e19cc@kernel.org Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'block/fops.c')
-rw-r--r--block/fops.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/block/fops.c b/block/fops.c
index 0cf8cf72cdfa..a1ba1a50ae77 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -599,36 +599,31 @@ blk_mode_t file_to_blk_mode(struct file *file)
static int blkdev_open(struct inode *inode, struct file *filp)
{
- struct bdev_handle *handle;
+ struct block_device *bdev;
blk_mode_t mode;
-
- /*
- * Preserve backwards compatibility and allow large file access
- * even if userspace doesn't ask for it explicitly. Some mkfs
- * binary needs it. We might want to drop this workaround
- * during an unstable branch.
- */
- filp->f_flags |= O_LARGEFILE;
- filp->f_mode |= FMODE_BUF_RASYNC | FMODE_CAN_ODIRECT;
+ void *holder;
+ int ret;
mode = file_to_blk_mode(filp);
- handle = bdev_open_by_dev(inode->i_rdev, mode,
- mode & BLK_OPEN_EXCL ? filp : NULL, NULL);
- if (IS_ERR(handle))
- return PTR_ERR(handle);
+ holder = mode & BLK_OPEN_EXCL ? filp : NULL;
+ ret = bdev_permission(inode->i_rdev, mode, holder);
+ if (ret)
+ return ret;
- if (bdev_nowait(handle->bdev))
- filp->f_mode |= FMODE_NOWAIT;
+ bdev = blkdev_get_no_open(inode->i_rdev);
+ if (!bdev)
+ return -ENXIO;
- filp->f_mapping = handle->bdev->bd_inode->i_mapping;
- filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping);
- filp->private_data = handle;
- return 0;
+ ret = bdev_open(bdev, mode, holder, NULL, filp);
+ if (ret)
+ blkdev_put_no_open(bdev);
+ return ret;
}
static int blkdev_release(struct inode *inode, struct file *filp)
{
- bdev_release(filp->private_data);
+ if (filp->private_data)
+ bdev_release(filp->private_data);
return 0;
}