From 841dd789b8625eb9288aaa2be9f10872e6622033 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Wed, 27 Sep 2023 11:34:08 +0200 Subject: 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 Reviewed-by: Christian Brauner Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20230927093442.25915-2-jack@suse.cz Signed-off-by: Christian Brauner --- block/bdev.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'block/bdev.c') 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); -- cgit v1.2.3