From: Hannes Reinecke <hare@suse.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: hck@suse.de,
James Bottomley <james.bottomley@hansenpartnership.com>,
Bart van Assche <bart.vanassche@sandisk.com>,
linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
Hannes Reinecke <hare@suse.com>
Subject: [PATCH] sd: use async_probe cookie to avoid deadlocks
Date: Tue, 21 Mar 2017 13:14:35 +0100 [thread overview]
Message-ID: <1490098475-21884-1-git-send-email-hare@suse.de> (raw)
With the current design we're waiting for all async probes to
finish when removing any sd device.
This might lead to a livelock where the 'remove' call is blocking
for any probe calls to finish, and the probe calls are waiting for
a response, which will never be processes as the thread handling
the responses is waiting for the remove call to finish.
Which is completely pointless as we only _really_ care for the
probe on _this_ device to be completed; any other probing can
happily continue for all we care.
So save the async probing cookie in the structure and only wait
if this specific probe is still active.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
drivers/scsi/sd.c | 7 ++++---
drivers/scsi/sd.h | 3 +++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index fb9b4d2..9f932e4 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -48,7 +48,6 @@
#include <linux/delay.h>
#include <linux/mutex.h>
#include <linux/string_helpers.h>
-#include <linux/async.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <linux/pr.h>
@@ -3217,7 +3216,8 @@ static int sd_probe(struct device *dev)
dev_set_drvdata(dev, sdkp);
get_device(&sdkp->dev); /* prevent release before async_schedule */
- async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain);
+ sdkp->async_probe = async_schedule_domain(sd_probe_async, sdkp,
+ &scsi_sd_probe_domain);
return 0;
@@ -3256,7 +3256,8 @@ static int sd_remove(struct device *dev)
scsi_autopm_get_device(sdkp->device);
async_synchronize_full_domain(&scsi_sd_pm_domain);
- async_synchronize_full_domain(&scsi_sd_probe_domain);
+ async_synchronize_cookie_domain(sdkp->async_probe,
+ &scsi_sd_probe_domain);
device_del(&sdkp->dev);
del_gendisk(sdkp->disk);
sd_shutdown(dev);
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 4dac35e..d4b5826 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -1,6 +1,8 @@
#ifndef _SCSI_DISK_H
#define _SCSI_DISK_H
+#include <linux/async.h>
+
/*
* More than enough for everybody ;) The huge number of majors
* is a leftover from 16bit dev_t days, we don't really need that
@@ -73,6 +75,7 @@ struct scsi_disk {
unsigned int zones_optimal_nonseq;
unsigned int zones_max_open;
#endif
+ async_cookie_t async_probe;
atomic_t openers;
sector_t capacity; /* size in logical blocks */
u32 max_xfer_blocks;
--
1.8.5.6
next reply other threads:[~2017-03-21 12:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 12:14 Hannes Reinecke [this message]
2017-03-21 13:02 ` [PATCH] sd: use async_probe cookie to avoid deadlocks Bart Van Assche
2017-03-21 13:05 ` James Bottomley
2017-03-21 13:30 ` Bart Van Assche
2017-03-21 13:33 ` James Bottomley
2017-03-21 13:42 ` Bart Van Assche
2017-03-21 15:32 ` Hannes Reinecke
2017-03-21 15:25 ` Hannes Reinecke
2017-03-21 15:33 ` James Bottomley
2017-03-21 16:21 ` Hannes Reinecke
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=1490098475-21884-1-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=bart.vanassche@sandisk.com \
--cc=hare@suse.com \
--cc=hck@suse.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox