On 6/30/22 01:57, Ming Lei wrote:
BTW, Changhui reported one very similar issue when running elevator
switch/scsi debug LUN hotplug.
From Changhui's report, the issue is basically same with what
f2b85040acec tried to address, but the try_module_get() in
scsi_device_dev_release() may fail, so the scsi_debug module
still can be unloaded.
The thing is that sdev can be released in async style, and target/host
release is triggered by scsi_device_dev_release_usercontext().
So after scsi_host_remove() returns, the shost may still be live from
driver core/sysfs viewpoint, and its release handler can be called
after the LLD module is unloaded. Then this kind of issue is triggered.
Seems there are at least two approaches for fixing the issue:
1) the one suggested in this thread:
- moving any reference to shost->hostt in host release handler into
scsi_host_remove(), and scsi_mq_destroy_tags()/scsi_proc_hostdir_rm(shost->hostt)()
should be covered at least
2) wait until all targets are released in scsi_host_remove()
I am fine with either of the two approaches.
Bart, please let me know if you are working towards the approach in 1).
If not, I have one patch which implements 2).
BTW, after either 1) or 2) is done, commit f2b85040acec can be reverted.
Hi Ming,
All I need is that all activity on the host tag set has stopped by the
time scsi_forget_host() returns. I do not need (1) or (2) to fix the bug
reported in the description of the patch at the start of this thread.
Thanks,
Bart.