On Thu, May 23, 2019 at 11:18 AM Dexuan Cui <de...@microsoft.com> wrote: > > Hi, > I'm adding code to enable the hv_storvsc driver (drivers/scsi/storvsc_drv.c) > for hibernation (ACPI S5). I know how to save/restore the state of the virtual > Hyper-V SCSI adapter, but I don't know how to prevent the higher layer SCSI > driver(s) from submitting new I/O requests to the low level driver hv_storvsc, > before I disable the Hyper-V SCSI adapter in hv_storvsc. > > Note: I can not call scsi_remove_host(), because the SCSI host should not > disappear and re-appear on hibernation. > > scsi_target_block() calls scsi_internal_device_block() -> > blk_mq_quiesce_queue(), but it is only used in a few drivers > (scsi_transport_fc.c, scsi_transport_iscsi.c and scsi_transport_srp.c), so > I doubt it is suitable to me? > > scsi_block_requests() is used in a lot of drivers and hence is more likely > to be the API I'm looking for, but it only sets a flag > shost->host_self_blocked -- how can this prevent another CPU from > submitting I/O requests? > > I also checked scsi_bus_pm_ops, but it's only for "sdev": see > scsi_bus_suspend_common() -> "if (scsi_is_sdev_device(dev))...". > > Even for "sdev", it looks the scsi_dev_type_suspend() can't work for me, > because it looks the sdev's driver is sd, whose sd_pm_ops doesn't > define the .freeze and .thaw ops, which are needed in hibernation. > > sd_pm_ops does define .suspend and .resume, but it looks they are only > for suspend-to-memory (ACPI S3). > > Can you please recommend the standard way to prevent the higher layer > SCSI driver(s) from submitting new I/O requests? > > How do the other low level SCSI adapter drivers support hibernation? > > I checked some PCI HBA drivers, and they use scsi_block_requests(), but > as I described above, I don't know how setting a flag can prevent another > CPU from submitting I/O requests. > > Looking forward to your insights!
scsi_device_quiesce() has been called by scsi_dev_type_suspend() to prevent any non-pm request from entering queue. Or do you still see IO requests coming during hibernation? Thanks, Ming Lei