From: Dexuan Cui <decui@microsoft.com>
To: jejb@linux.ibm.com, martin.petersen@oracle.com,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
hch@lst.de, bvanassche@acm.org, hare@suse.de,
mikelley@microsoft.com, longli@microsoft.com,
ming.lei@redhat.com
Cc: linux-hyperv@vger.kernel.org, wei.liu@kernel.org,
sthemmin@microsoft.com, haiyangz@microsoft.com,
kys@microsoft.com, Dexuan Cui <decui@microsoft.com>
Subject: [PATCH] scsi: storvsc: Fix a panic in the hibernation procedure
Date: Tue, 21 Apr 2020 17:17:24 -0700 [thread overview]
Message-ID: <1587514644-47058-1-git-send-email-decui@microsoft.com> (raw)
During hibernation, the sdevs are suspended automatically in
drivers/scsi/scsi_pm.c before storvsc_suspend(), so after
storvsc_suspend(), there is no disk I/O from the file systems, but there
can still be disk I/O from the kernel space, e.g. disk_check_events() ->
sr_block_check_events() -> cdrom_check_events() can still submit I/O
to the storvsc driver, which causes a paic of NULL pointer dereference,
since storvsc has closed the vmbus channel in storvsc_suspend(): refer
to the below links for more info:
https://lkml.org/lkml/2020/4/10/47
https://lkml.org/lkml/2020/4/17/1103
Fix the panic by blocking/unblocking all the I/O queues properly.
Note: this patch depends on another patch "scsi: core: Allow the state
change from SDEV_QUIESCE to SDEV_BLOCK" (refer to the second link above).
Fixes: 56fb10585934 ("scsi: storvsc: Add the support of hibernation")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
drivers/scsi/storvsc_drv.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index fb41636519ee..fd51d2f03778 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1948,6 +1948,11 @@ static int storvsc_suspend(struct hv_device *hv_dev)
struct storvsc_device *stor_device = hv_get_drvdata(hv_dev);
struct Scsi_Host *host = stor_device->host;
struct hv_host_device *host_dev = shost_priv(host);
+ int ret;
+
+ ret = scsi_host_block(host);
+ if (ret)
+ return ret;
storvsc_wait_to_drain(stor_device);
@@ -1968,10 +1973,15 @@ static int storvsc_suspend(struct hv_device *hv_dev)
static int storvsc_resume(struct hv_device *hv_dev)
{
+ struct storvsc_device *stor_device = hv_get_drvdata(hv_dev);
+ struct Scsi_Host *host = stor_device->host;
int ret;
ret = storvsc_connect_to_vsp(hv_dev, storvsc_ringbuffer_size,
hv_dev_is_fc(hv_dev));
+ if (!ret)
+ ret = scsi_host_unblock(host, SDEV_RUNNING);
+
return ret;
}
--
2.19.1
next reply other threads:[~2020-04-22 0:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 0:17 Dexuan Cui [this message]
2020-04-22 1:28 ` [PATCH] scsi: storvsc: Fix a panic in the hibernation procedure Ming Lei
2020-04-22 1:48 ` Dexuan Cui
2020-04-22 2:01 ` Ming Lei
2020-04-22 3:08 ` Paul E. McKenney
2020-04-22 4:16 ` Ming Lei
2020-04-22 4:58 ` Dexuan Cui
2020-04-22 9:23 ` Ming Lei
2020-04-22 16:19 ` Paul E. McKenney
2020-04-22 18:01 ` Dexuan Cui
2020-04-22 2:06 ` Ming Lei
2020-04-22 5:02 ` Bart Van Assche
2020-04-22 6:24 ` Dexuan Cui
2020-04-22 19:56 ` Bart Van Assche
2020-04-23 7:04 ` Dexuan Cui
2020-04-23 16:37 ` Bart Van Assche
2020-04-23 18:29 ` Dexuan Cui
2020-04-23 23:25 ` Bart Van Assche
2020-04-24 2:40 ` Dexuan Cui
2020-04-24 3:45 ` Dexuan Cui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1587514644-47058-1-git-send-email-decui@microsoft.com \
--to=decui@microsoft.com \
--cc=bvanassche@acm.org \
--cc=haiyangz@microsoft.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=martin.petersen@oracle.com \
--cc=mikelley@microsoft.com \
--cc=ming.lei@redhat.com \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.