block: don't autoload drivers on stat
blkdev_get_no_open can trigger the legacy autoload of block drivers. A
simple stat of a block device has not historically done that, so disable
this behavior again.
Fixes: 9abcfbd235 ("block: Add atomic write support for statx")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20250423053810.1683309-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
d13b7090b2
commit
5f33b5226c
4 changed files with 7 additions and 7 deletions
|
|
@ -815,13 +815,13 @@ static void blkdev_put_part(struct block_device *part)
|
|||
blkdev_put_whole(whole);
|
||||
}
|
||||
|
||||
struct block_device *blkdev_get_no_open(dev_t dev)
|
||||
struct block_device *blkdev_get_no_open(dev_t dev, bool autoload)
|
||||
{
|
||||
struct block_device *bdev;
|
||||
struct inode *inode;
|
||||
|
||||
inode = ilookup(blockdev_superblock, dev);
|
||||
if (!inode && IS_ENABLED(CONFIG_BLOCK_LEGACY_AUTOLOAD)) {
|
||||
if (!inode && autoload && IS_ENABLED(CONFIG_BLOCK_LEGACY_AUTOLOAD)) {
|
||||
blk_request_module(dev);
|
||||
inode = ilookup(blockdev_superblock, dev);
|
||||
if (inode)
|
||||
|
|
@ -1043,7 +1043,7 @@ struct file *bdev_file_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
|
|||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
bdev = blkdev_get_no_open(dev);
|
||||
bdev = blkdev_get_no_open(dev, true);
|
||||
if (!bdev)
|
||||
return ERR_PTR(-ENXIO);
|
||||
|
||||
|
|
@ -1321,7 +1321,7 @@ void bdev_statx(struct path *path, struct kstat *stat,
|
|||
* use I_BDEV() here; the block device has to be looked up by i_rdev
|
||||
* instead.
|
||||
*/
|
||||
bdev = blkdev_get_no_open(d_backing_inode(path->dentry)->i_rdev);
|
||||
bdev = blkdev_get_no_open(d_backing_inode(path->dentry)->i_rdev, false);
|
||||
if (!bdev)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -797,7 +797,7 @@ int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
|
|||
return -EINVAL;
|
||||
input = skip_spaces(input);
|
||||
|
||||
bdev = blkdev_get_no_open(MKDEV(major, minor));
|
||||
bdev = blkdev_get_no_open(MKDEV(major, minor), true);
|
||||
if (!bdev)
|
||||
return -ENODEV;
|
||||
if (bdev_is_partition(bdev)) {
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ static inline void blk_wait_io(struct completion *done)
|
|||
wait_for_completion_io(done);
|
||||
}
|
||||
|
||||
struct block_device *blkdev_get_no_open(dev_t dev);
|
||||
struct block_device *blkdev_get_no_open(dev_t dev, bool autoload);
|
||||
void blkdev_put_no_open(struct block_device *bdev);
|
||||
|
||||
#define BIO_INLINE_VECS 4
|
||||
|
|
|
|||
|
|
@ -642,7 +642,7 @@ static int blkdev_open(struct inode *inode, struct file *filp)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
bdev = blkdev_get_no_open(inode->i_rdev);
|
||||
bdev = blkdev_get_no_open(inode->i_rdev, true);
|
||||
if (!bdev)
|
||||
return -ENXIO;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue