summaryrefslogtreecommitdiff
path: root/block/fops.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-01-23 16:26:49 +0300
committerChristian Brauner <brauner@kernel.org>2024-02-25 14:05:28 +0300
commitab838b3fd9a442a62f36ea7eeb93e77259f787ce (patch)
tree961c6004ba64d9575d47201d83d33ff1bc97b39a /block/fops.c
parent321de651fa565dcf76c017b257bdf15ec7fff45d (diff)
downloadlinux-ab838b3fd9a442a62f36ea7eeb93e77259f787ce.tar.xz
block: remove bdev_handle completely
We just need to use the holder to indicate whether a block device open was exclusive or not. We did use to do that before but had to give that up once we switched to struct bdev_handle. Before struct bdev_handle we only stashed stuff in file->private_data if this was an exclusive open but after struct bdev_handle we always set file->private_data to a struct bdev_handle and so we had to use bdev_handle->mode or bdev_handle->holder. Now that we don't use struct bdev_handle anymore we can revert back to the old behavior. Link: https://lore.kernel.org/r/20240123-vfs-bdev-file-v2-32-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.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/block/fops.c b/block/fops.c
index aab9b89e4c77..029e787f0119 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -569,18 +569,17 @@ static int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
blk_mode_t file_to_blk_mode(struct file *file)
{
blk_mode_t mode = 0;
- struct bdev_handle *handle = file->private_data;
if (file->f_mode & FMODE_READ)
mode |= BLK_OPEN_READ;
if (file->f_mode & FMODE_WRITE)
mode |= BLK_OPEN_WRITE;
/*
- * do_dentry_open() clears O_EXCL from f_flags, use handle->mode to
- * determine whether the open was exclusive for already open files.
+ * do_dentry_open() clears O_EXCL from f_flags, use file->private_data
+ * to determine whether the open was exclusive for already open files.
*/
- if (handle)
- mode |= handle->mode & BLK_OPEN_EXCL;
+ if (file->private_data)
+ mode |= BLK_OPEN_EXCL;
else if (file->f_flags & O_EXCL)
mode |= BLK_OPEN_EXCL;
if (file->f_flags & O_NDELAY)
@@ -601,12 +600,13 @@ static int blkdev_open(struct inode *inode, struct file *filp)
{
struct block_device *bdev;
blk_mode_t mode;
- void *holder;
int ret;
mode = file_to_blk_mode(filp);
- holder = mode & BLK_OPEN_EXCL ? filp : NULL;
- ret = bdev_permission(inode->i_rdev, mode, holder);
+ /* Use the file as the holder. */
+ if (mode & BLK_OPEN_EXCL)
+ filp->private_data = filp;
+ ret = bdev_permission(inode->i_rdev, mode, filp->private_data);
if (ret)
return ret;
@@ -614,7 +614,7 @@ static int blkdev_open(struct inode *inode, struct file *filp)
if (!bdev)
return -ENXIO;
- ret = bdev_open(bdev, mode, holder, NULL, filp);
+ ret = bdev_open(bdev, mode, filp->private_data, NULL, filp);
if (ret)
blkdev_put_no_open(bdev);
return ret;
@@ -622,8 +622,7 @@ static int blkdev_open(struct inode *inode, struct file *filp)
static int blkdev_release(struct inode *inode, struct file *filp)
{
- if (filp->private_data)
- bdev_release(filp);
+ bdev_release(filp);
return 0;
}