* [PATCH] scsi: core: Avoid doing rescan on suspended device
@ 2023-04-19 5:41 Kai-Heng Feng
2023-04-20 17:43 ` Benjamin Block
0 siblings, 1 reply; 3+ messages in thread
From: Kai-Heng Feng @ 2023-04-19 5:41 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: acelan.kao, Kai-Heng Feng, linux-scsi, linux-kernel
During system resume, if an EH is schduled after ATA host is resumed
(i.e. ATA_PFLAG_PM_PENDING cleared), but before the disk device is
resumed, the device_lock hold by scsi_rescan_device() is never released
so the dpm_resume() of the disk is blocked forerver.
That's because scsi_attach_vpd() is expecting the disk device is in
operational state, as it doesn't work on suspended device.
To avoid such deadlock, avoid doing rescan if the disk is still
suspended so the resume process of the disk device can proceed.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
drivers/scsi/scsi_scan.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index d217be323cc6..36680cb1535b 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1621,6 +1621,9 @@ void scsi_rescan_device(struct device *dev)
{
struct scsi_device *sdev = to_scsi_device(dev);
+ if (dev->power.is_prepared)
+ return;
+
device_lock(dev);
scsi_attach_vpd(sdev);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: core: Avoid doing rescan on suspended device
2023-04-19 5:41 [PATCH] scsi: core: Avoid doing rescan on suspended device Kai-Heng Feng
@ 2023-04-20 17:43 ` Benjamin Block
2023-04-24 3:30 ` Kai-Heng Feng
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Block @ 2023-04-20 17:43 UTC (permalink / raw)
To: Kai-Heng Feng; +Cc: jejb, martin.petersen, acelan.kao, linux-scsi, linux-kernel
On Wed, Apr 19, 2023 at 01:41:12PM +0800, Kai-Heng Feng wrote:
> During system resume, if an EH is schduled after ATA host is resumed
> (i.e. ATA_PFLAG_PM_PENDING cleared), but before the disk device is
> resumed, the device_lock hold by scsi_rescan_device() is never released
> so the dpm_resume() of the disk is blocked forerver.
>
> That's because scsi_attach_vpd() is expecting the disk device is in
> operational state, as it doesn't work on suspended device.
>
> To avoid such deadlock, avoid doing rescan if the disk is still
> suspended so the resume process of the disk device can proceed.
I'm no expert on suspend/resume, but wouldn't you then potentially miss
changes that have been done to the LUN during suspend?
What takes care of updating the VPDs, scsi-disk re-evaluation and such
in this case, when you block it initially during wakeup?
>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
> drivers/scsi/scsi_scan.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index d217be323cc6..36680cb1535b 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -1621,6 +1621,9 @@ void scsi_rescan_device(struct device *dev)
> {
> struct scsi_device *sdev = to_scsi_device(dev);
>
> + if (dev->power.is_prepared)
> + return;
> +
> device_lock(dev);
>
> scsi_attach_vpd(sdev);
> --
> 2.34.1
>
--
Best Regards, Benjamin Block / Linux on IBM Z Kernel Development
IBM Deutschland Research & Development GmbH / https://www.ibm.com/privacy
Vors. Aufs.-R.: Gregor Pillen / Geschäftsführung: David Faller
Sitz der Ges.: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: core: Avoid doing rescan on suspended device
2023-04-20 17:43 ` Benjamin Block
@ 2023-04-24 3:30 ` Kai-Heng Feng
0 siblings, 0 replies; 3+ messages in thread
From: Kai-Heng Feng @ 2023-04-24 3:30 UTC (permalink / raw)
To: Benjamin Block
Cc: jejb, martin.petersen, acelan.kao, linux-scsi, linux-kernel
On Fri, Apr 21, 2023 at 1:43 AM Benjamin Block <bblock@linux.ibm.com> wrote:
>
> On Wed, Apr 19, 2023 at 01:41:12PM +0800, Kai-Heng Feng wrote:
> > During system resume, if an EH is schduled after ATA host is resumed
> > (i.e. ATA_PFLAG_PM_PENDING cleared), but before the disk device is
> > resumed, the device_lock hold by scsi_rescan_device() is never released
> > so the dpm_resume() of the disk is blocked forerver.
> >
> > That's because scsi_attach_vpd() is expecting the disk device is in
> > operational state, as it doesn't work on suspended device.
> >
> > To avoid such deadlock, avoid doing rescan if the disk is still
> > suspended so the resume process of the disk device can proceed.
>
> I'm no expert on suspend/resume, but wouldn't you then potentially miss
> changes that have been done to the LUN during suspend?
This is a valid concern.
>
> What takes care of updating the VPDs, scsi-disk re-evaluation and such
> in this case, when you block it initially during wakeup?
The other approach is to perform the re-evaluation when the system
resume is about to be completed.
Let me send v2 to address that.
Kai-Heng
>
> >
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> > ---
> > drivers/scsi/scsi_scan.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> > index d217be323cc6..36680cb1535b 100644
> > --- a/drivers/scsi/scsi_scan.c
> > +++ b/drivers/scsi/scsi_scan.c
> > @@ -1621,6 +1621,9 @@ void scsi_rescan_device(struct device *dev)
> > {
> > struct scsi_device *sdev = to_scsi_device(dev);
> >
> > + if (dev->power.is_prepared)
> > + return;
> > +
> > device_lock(dev);
> >
> > scsi_attach_vpd(sdev);
> > --
> > 2.34.1
> >
>
> --
> Best Regards, Benjamin Block / Linux on IBM Z Kernel Development
> IBM Deutschland Research & Development GmbH / https://www.ibm.com/privacy
> Vors. Aufs.-R.: Gregor Pillen / Geschäftsführung: David Faller
> Sitz der Ges.: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-24 3:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-19 5:41 [PATCH] scsi: core: Avoid doing rescan on suspended device Kai-Heng Feng
2023-04-20 17:43 ` Benjamin Block
2023-04-24 3:30 ` Kai-Heng Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®