Skip to contentSkip to conversation

scsi: core: Fix a procfs host directory removal regression

PATCH Applied Bart Van Assche 4 participants 4 messages Mar 7, 2023 – Mar 10, 2023 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: core: Fix a procfs host directory removal regression

scsi_proc_hostdir_rm() decreases a reference counter and hence must only be called once per host that is removed. This change does not require a scsi_add_host_with_dma() change since scsi_add_host_with_dma() will return 0 (success) if scsi_proc_host_add() is called.

Cc John Garry <[email protected]>
Reported-by [email protected]
Fixes fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name} directory earlier")
---
 drivers/scsi/hosts.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/scsi/hosts.c +0 -3
index f7f62e56afca..9b6fbbe15d92 100644
@@ -341,9 +341,6 @@ static void scsi_host_dev_release(struct device *dev)
 	struct Scsi_Host *shost = dev_to_shost(dev);
 	struct device *parent = dev->parent;
 
-	/* In case scsi_remove_host() has not been called. */
-	scsi_proc_hostdir_rm(shost->hostt);
-
 	/* Wait for functions invoked through call_rcu(&scmd->rcu, ...) */
 	rcu_barrier();
 
Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Bart Van Assche

scsi_proc_hostdir_rm() decreases a reference counter and hence must only be called once per host that is removed. This change does not require a scsi_add_host_with_dma() change since scsi_add_host_with_dma() will return 0 (success) if scsi_proc_host_add() is called.

Cc John Garry <[email protected]>
Reported-by [email protected]
Fixes fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name} directory earlier")

Well that seemed to fix my issue, so:

I don't really know why we ever had this call in scsi_host_dev_release() or what races which fc663711b944 was trying to fix.

BTW, maybe later we combine the calls to scsi_proc_host_rm() and scsi_proc_hostdir_rm() - they're only ever called together AFAICS.

Thanks,
John

Quoted 18 lines
---
  drivers/scsi/hosts.c | 3 ---
  1 file changed, 3 deletions(-)
drivers/scsi/hosts.c +0 -3
index f7f62e56afca..9b6fbbe15d92 100644
@@ -341,9 +341,6 @@ static void scsi_host_dev_release(struct device *dev)
  	struct Scsi_Host *shost = dev_to_shost(dev);
  	struct device *parent = dev->parent;
 
-	/* In case scsi_remove_host() has not been called. */
-	scsi_proc_hostdir_rm(shost->hostt);
-
  	/* Wait for functions invoked through call_rcu(&scmd->rcu, ...) */
  	rcu_barrier();
 
Tested-by on v1 1/1
#2 lore raw
In reply to Bart Van Assche
Quoted 10 lines · Bart Van Assche

scsi_proc_hostdir_rm() decreases a reference counter and hence must only be called once per host that is removed. This change does not require a scsi_add_host_with_dma() change since scsi_add_host_with_dma() will return 0 (success) if scsi_proc_host_add() is called.

Cc John Garry <[email protected]>
Reported-by [email protected]
Fixes fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name} directory earlier")

When I ran blktests test case block/001 on the linux kernel v6.3-rc1, I observed WARNs in remove_proc_entry(). I found this patch avoids the WARNs. Thanks.

Signature · 1 line
Shin'ichiro Kawasaki
#3 lore raw
In reply to Bart Van Assche
Quoted 6 lines · Bart Van Assche

scsi_proc_hostdir_rm() decreases a reference counter and hence must only be called once per host that is removed. This change does not require a scsi_add_host_with_dma() change since scsi_add_host_with_dma() will return 0 (success) if scsi_proc_host_add() is called.

Applied to 6.3/scsi-fixes, thanks!

[1/1] scsi: core: Fix a procfs host directory removal regression

      https://git.kernel.org/mkp/scsi/c/be03df3d4bfe
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering