summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorYang Erkun <yangerkun@huawei.com>2024-12-09 19:04:35 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-03-13 12:49:51 +0100
commit2d43a6fcea0ee8f3472cabb1dc7831a2911bb5d3 (patch)
treee326391b5aef62c6599b389b0a4301755b3e3cc7 /block
parent6327dacfe6d6320f17c2f19dab0bbbd98f4ae05f (diff)
downloadlinux-2d43a6fcea0ee8f3472cabb1dc7831a2911bb5d3.tar.gz
linux-2d43a6fcea0ee8f3472cabb1dc7831a2911bb5d3.tar.bz2
linux-2d43a6fcea0ee8f3472cabb1dc7831a2911bb5d3.zip
block: retry call probe after request_module in blk_request_module
[ Upstream commit 457ef47c08d2979f3e59ce66267485c3faed70c8 ] Set kernel config: CONFIG_BLK_DEV_LOOP=m CONFIG_BLK_DEV_LOOP_MIN_COUNT=0 Do latter: mknod loop0 b 7 0 exec 4<> loop0 Before commit e418de3abcda ("block: switch gendisk lookup to a simple xarray"), lookup_gendisk will first use base_probe to load module loop, and then the retry will call loop_probe to prepare the loop disk. Finally open for this disk will success. However, after this commit, we lose the retry logic, and open will fail with ENXIO. Block device autoloading is deprecated and will be removed soon, but maybe we should keep open success until we really remove it. So, give a retry to fix it. Fixes: e418de3abcda ("block: switch gendisk lookup to a simple xarray") Suggested-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Yang Erkun <yangerkun@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20241209110435.3670985-1-yangerkun@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 2f66745de5d5..421e02794614 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -674,7 +674,7 @@ static ssize_t disk_badblocks_store(struct device *dev,
}
#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
-void blk_request_module(dev_t devt)
+static bool blk_probe_dev(dev_t devt)
{
unsigned int major = MAJOR(devt);
struct blk_major_name **n;
@@ -684,14 +684,26 @@ void blk_request_module(dev_t devt)
if ((*n)->major == major && (*n)->probe) {
(*n)->probe(devt);
mutex_unlock(&major_names_lock);
- return;
+ return true;
}
}
mutex_unlock(&major_names_lock);
+ return false;
+}
+
+void blk_request_module(dev_t devt)
+{
+ int error;
+
+ if (blk_probe_dev(devt))
+ return;
- if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
- /* Make old-style 2.4 aliases work */
- request_module("block-major-%d", MAJOR(devt));
+ error = request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt));
+ /* Make old-style 2.4 aliases work */
+ if (error > 0)
+ error = request_module("block-major-%d", MAJOR(devt));
+ if (!error)
+ blk_probe_dev(devt);
}
#endif /* CONFIG_BLOCK_LEGACY_AUTOLOAD */