Re: [PATCH 05/19] block: rework requesting modules for unclaimed devices

2020-09-04 Thread Hannes Reinecke

On 9/3/20 10:01 AM, Christoph Hellwig wrote:

Instead of reusing the ranges in bdev_map, add a new helper that is
called if no ranges was found.  This is a first step to unpeel and
eventually remove the complex ranges structure.

Signed-off-by: Christoph Hellwig 
---
  block/genhd.c | 25 +++--
  1 file changed, 15 insertions(+), 10 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
--
Dr. Hannes ReineckeKernel Storage Architect
h...@suse.de  +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer


[PATCH 05/19] block: rework requesting modules for unclaimed devices

2020-09-03 Thread Christoph Hellwig
Instead of reusing the ranges in bdev_map, add a new helper that is
called if no ranges was found.  This is a first step to unpeel and
eventually remove the complex ranges structure.

Signed-off-by: Christoph Hellwig 
---
 block/genhd.c | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 034e9089965a82..d9ecc751fc956c 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1033,6 +1033,13 @@ static ssize_t disk_badblocks_store(struct device *dev,
return badblocks_store(disk->bb, page, len, 0);
 }
 
+static void request_gendisk_module(dev_t devt)
+{
+   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));
+}
+
 static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
 {
struct kobject *kobj;
@@ -1057,6 +1064,14 @@ static struct gendisk *lookup_gendisk(dev_t dev, int 
*partno)
probe = p->probe;
best = p->range - 1;
*partno = dev - p->dev;
+
+   if (!probe) {
+   mutex_unlock(_map_lock);
+   module_put(owner);
+   request_gendisk_module(dev);
+   goto retry;
+   }
+
if (p->lock && p->lock(dev, data) < 0) {
module_put(owner);
continue;
@@ -1295,15 +1310,6 @@ static const struct seq_operations partitions_op = {
 };
 #endif
 
-
-static struct kobject *base_probe(dev_t devt, int *partno, void *data)
-{
-   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));
-   return NULL;
-}
-
 static void bdev_map_init(void)
 {
struct bdev_map *base;
@@ -1315,7 +1321,6 @@ static void bdev_map_init(void)
 
base->dev = 1;
base->range = ~0 ;
-   base->probe = base_probe;
for (i = 0; i < 255; i++)
bdev_map[i] = base;
 }
-- 
2.28.0



[PATCH 05/19] block: rework requesting modules for unclaimed devices

2020-08-30 Thread Christoph Hellwig
Instead of reusing the ranges in bdev_map, add a new helper that is
called if no ranges was found.  This is a first step to unpeel and
eventually remove the complex ranges structure.

Signed-off-by: Christoph Hellwig 
---
 block/genhd.c | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 0ae6210e141ee5..00164304317cfa 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1035,6 +1035,13 @@ static ssize_t disk_badblocks_store(struct device *dev,
return badblocks_store(disk->bb, page, len, 0);
 }
 
+static void request_gendisk_module(dev_t devt)
+{
+   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));
+}
+
 static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
 {
struct kobject *kobj;
@@ -1059,6 +1066,14 @@ static struct gendisk *lookup_gendisk(dev_t dev, int 
*partno)
probe = p->probe;
best = p->range - 1;
*partno = dev - p->dev;
+
+   if (!probe) {
+   mutex_unlock(_map_lock);
+   module_put(owner);
+   request_gendisk_module(dev);
+   goto retry;
+   }
+
if (p->lock && p->lock(dev, data) < 0) {
module_put(owner);
continue;
@@ -1297,15 +1312,6 @@ static const struct seq_operations partitions_op = {
 };
 #endif
 
-
-static struct kobject *base_probe(dev_t devt, int *partno, void *data)
-{
-   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));
-   return NULL;
-}
-
 static void bdev_map_init(void)
 {
struct bdev_map *base;
@@ -1317,7 +1323,6 @@ static void bdev_map_init(void)
 
base->dev = 1;
base->range = ~0 ;
-   base->probe = base_probe;
for (i = 0; i < 255; i++)
bdev_map[i] = base;
 }
-- 
2.28.0



[PATCH 05/19] block: rework requesting modules for unclaimed devices

2020-08-26 Thread Christoph Hellwig
Instead of reusing the ranges in bdev_map, add a new helper that is
called if no ranges was found.  This is a first step to unpeel and
eventually remove the complex ranges structure.

Signed-off-by: Christoph Hellwig 
---
 block/genhd.c | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 0ae6210e141ee5..00164304317cfa 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1035,6 +1035,13 @@ static ssize_t disk_badblocks_store(struct device *dev,
return badblocks_store(disk->bb, page, len, 0);
 }
 
+static void request_gendisk_module(dev_t devt)
+{
+   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));
+}
+
 static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
 {
struct kobject *kobj;
@@ -1059,6 +1066,14 @@ static struct gendisk *lookup_gendisk(dev_t dev, int 
*partno)
probe = p->probe;
best = p->range - 1;
*partno = dev - p->dev;
+
+   if (!probe) {
+   mutex_unlock(_map_lock);
+   module_put(owner);
+   request_gendisk_module(dev);
+   goto retry;
+   }
+
if (p->lock && p->lock(dev, data) < 0) {
module_put(owner);
continue;
@@ -1297,15 +1312,6 @@ static const struct seq_operations partitions_op = {
 };
 #endif
 
-
-static struct kobject *base_probe(dev_t devt, int *partno, void *data)
-{
-   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));
-   return NULL;
-}
-
 static void bdev_map_init(void)
 {
struct bdev_map *base;
@@ -1317,7 +1323,6 @@ static void bdev_map_init(void)
 
base->dev = 1;
base->range = ~0 ;
-   base->probe = base_probe;
for (i = 0; i < 255; i++)
bdev_map[i] = base;
 }
-- 
2.28.0