summaryrefslogtreecommitdiffstats
path: root/block/bdev.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2023-09-27 11:34:08 +0200
committerChristian Brauner <brauner@kernel.org>2023-10-28 13:29:16 +0200
commit841dd789b8625eb9288aaa2be9f10872e6622033 (patch)
tree68ccf22ca8afac4616f8135532e6ad52d12118c9 /block/bdev.c
parentblock: Provide bdev_open_* functions (diff)
downloadlinux-841dd789b8625eb9288aaa2be9f10872e6622033.tar.xz
linux-841dd789b8625eb9288aaa2be9f10872e6622033.zip
block: Use bdev_open_by_dev() in blkdev_open()
Convert blkdev_open() to use bdev_open_by_dev(). To be able to propagate handle from blkdev_open() to blkdev_release() we need to stop using existence of file->private_data to determine exclusive block device opens. Use bdev_handle->mode for this purpose since file->f_flags isn't usable for this (O_EXCL is cleared from the flags during open). Acked-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20230927093442.25915-2-jack@suse.cz Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'block/bdev.c')
-rw-r--r--block/bdev.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/bdev.c b/block/bdev.c
index bdc7d739882b..4628dcb1da8a 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -844,6 +844,9 @@ struct bdev_handle *bdev_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
}
handle->bdev = bdev;
handle->holder = holder;
+ if (holder)
+ mode |= BLK_OPEN_EXCL;
+ handle->mode = mode;
return handle;
}
EXPORT_SYMBOL(bdev_open_by_dev);