Re: [PATCH 09/19] sd: use __register_blkdev to avoid a modprobe for an unregistered dev_t

2020-09-04 Thread Hannes Reinecke

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

Switch from using blk_register_region to the probe callback passed to
__register_blkdev to disable the request_module call for an unclaimed
dev_t in the SD majors.

Signed-off-by: Christoph Hellwig 
---
  drivers/scsi/sd.c | 19 +--
  1 file changed, 5 insertions(+), 14 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 09/19] sd: use __register_blkdev to avoid a modprobe for an unregistered dev_t

2020-09-03 Thread Christoph Hellwig
Switch from using blk_register_region to the probe callback passed to
__register_blkdev to disable the request_module call for an unclaimed
dev_t in the SD majors.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/sd.c | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 2bec8cd526164d..97bf84b1871571 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -596,13 +596,11 @@ static struct scsi_driver sd_template = {
 };
 
 /*
- * Dummy kobj_map->probe function.
- * The default ->probe function will call modprobe, which is
- * pointless as this module is already loaded.
+ * Don't request a new module, as that could deadlock in multipath
+ * environment.
  */
-static struct kobject *sd_default_probe(dev_t devt, int *partno, void *data)
+static void sd_default_probe(dev_t devt)
 {
-   return NULL;
 }
 
 /*
@@ -3481,9 +3479,6 @@ static int sd_remove(struct device *dev)
 
free_opal_dev(sdkp->opal_dev);
 
-   blk_register_region(devt, SD_MINORS, NULL,
-   sd_default_probe, NULL, NULL);
-
mutex_lock(_ref_mutex);
dev_set_drvdata(dev, NULL);
put_device(>dev);
@@ -3673,11 +3668,9 @@ static int __init init_sd(void)
SCSI_LOG_HLQUEUE(3, printk("init_sd: sd driver entry point\n"));
 
for (i = 0; i < SD_MAJORS; i++) {
-   if (register_blkdev(sd_major(i), "sd") != 0)
+   if (__register_blkdev(sd_major(i), "sd", sd_default_probe))
continue;
majors++;
-   blk_register_region(sd_major(i), SD_MINORS, NULL,
-   sd_default_probe, NULL, NULL);
}
 
if (!majors)
@@ -3750,10 +3743,8 @@ static void __exit exit_sd(void)
 
class_unregister(_disk_class);
 
-   for (i = 0; i < SD_MAJORS; i++) {
-   blk_unregister_region(sd_major(i), SD_MINORS);
+   for (i = 0; i < SD_MAJORS; i++)
unregister_blkdev(sd_major(i), "sd");
-   }
 }
 
 module_init(init_sd);
-- 
2.28.0



[PATCH 09/19] sd: use __register_blkdev to avoid a modprobe for an unregistered dev_t

2020-08-30 Thread Christoph Hellwig
Switch from using blk_register_region to the probe callback passed to
__register_blkdev to disable the request_module call for an unclaimed
dev_t in the SD majors.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/sd.c | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 95018e650f2d0c..ece87b1aab1b78 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -596,13 +596,11 @@ static struct scsi_driver sd_template = {
 };
 
 /*
- * Dummy kobj_map->probe function.
- * The default ->probe function will call modprobe, which is
- * pointless as this module is already loaded.
+ * Don't request a new module, as that could deadlock in multipath
+ * environment.
  */
-static struct kobject *sd_default_probe(dev_t devt, int *partno, void *data)
+static void sd_default_probe(dev_t devt)
 {
-   return NULL;
 }
 
 /*
@@ -3479,9 +3477,6 @@ static int sd_remove(struct device *dev)
 
free_opal_dev(sdkp->opal_dev);
 
-   blk_register_region(devt, SD_MINORS, NULL,
-   sd_default_probe, NULL, NULL);
-
mutex_lock(_ref_mutex);
dev_set_drvdata(dev, NULL);
put_device(>dev);
@@ -3671,11 +3666,9 @@ static int __init init_sd(void)
SCSI_LOG_HLQUEUE(3, printk("init_sd: sd driver entry point\n"));
 
for (i = 0; i < SD_MAJORS; i++) {
-   if (register_blkdev(sd_major(i), "sd") != 0)
+   if (__register_blkdev(sd_major(i), "sd", sd_default_probe))
continue;
majors++;
-   blk_register_region(sd_major(i), SD_MINORS, NULL,
-   sd_default_probe, NULL, NULL);
}
 
if (!majors)
@@ -3748,10 +3741,8 @@ static void __exit exit_sd(void)
 
class_unregister(_disk_class);
 
-   for (i = 0; i < SD_MAJORS; i++) {
-   blk_unregister_region(sd_major(i), SD_MINORS);
+   for (i = 0; i < SD_MAJORS; i++)
unregister_blkdev(sd_major(i), "sd");
-   }
 }
 
 module_init(init_sd);
-- 
2.28.0



[PATCH 09/19] sd: use __register_blkdev to avoid a modprobe for an unregistered dev_t

2020-08-26 Thread Christoph Hellwig
Switch from using blk_register_region to the probe callback passed to
__register_blkdev to disable the request_module call for an unclaimed
dev_t in the SD majors.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/sd.c | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 95018e650f2d0c..ece87b1aab1b78 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -596,13 +596,11 @@ static struct scsi_driver sd_template = {
 };
 
 /*
- * Dummy kobj_map->probe function.
- * The default ->probe function will call modprobe, which is
- * pointless as this module is already loaded.
+ * Don't request a new module, as that could deadlock in multipath
+ * environment.
  */
-static struct kobject *sd_default_probe(dev_t devt, int *partno, void *data)
+static void sd_default_probe(dev_t devt)
 {
-   return NULL;
 }
 
 /*
@@ -3479,9 +3477,6 @@ static int sd_remove(struct device *dev)
 
free_opal_dev(sdkp->opal_dev);
 
-   blk_register_region(devt, SD_MINORS, NULL,
-   sd_default_probe, NULL, NULL);
-
mutex_lock(_ref_mutex);
dev_set_drvdata(dev, NULL);
put_device(>dev);
@@ -3671,11 +3666,9 @@ static int __init init_sd(void)
SCSI_LOG_HLQUEUE(3, printk("init_sd: sd driver entry point\n"));
 
for (i = 0; i < SD_MAJORS; i++) {
-   if (register_blkdev(sd_major(i), "sd") != 0)
+   if (__register_blkdev(sd_major(i), "sd", sd_default_probe))
continue;
majors++;
-   blk_register_region(sd_major(i), SD_MINORS, NULL,
-   sd_default_probe, NULL, NULL);
}
 
if (!majors)
@@ -3748,10 +3741,8 @@ static void __exit exit_sd(void)
 
class_unregister(_disk_class);
 
-   for (i = 0; i < SD_MAJORS; i++) {
-   blk_unregister_region(sd_major(i), SD_MINORS);
+   for (i = 0; i < SD_MAJORS; i++)
unregister_blkdev(sd_major(i), "sd");
-   }
 }
 
 module_init(init_sd);
-- 
2.28.0