diff options
author | Dan Williams <dan.j.williams@intel.com> | 2012-03-22 20:05:11 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-05-17 04:10:46 -0400 |
commit | a7a20d103994fd760766e6c9d494daa569cbfe06 (patch) | |
tree | 60c16b37708a399c298b61ae9ab5760747cb6263 | |
parent | e85c59746957fd6e3595d02cf614370056b5816e (diff) |
[SCSI] sd: limit the scope of the async probe domain
sd injects and synchronizes probe work on the global kernel-wide domain.
This runs into conflict with PM that wants to perform resume actions in
async context:
[ 494.237079] INFO: task kworker/u:3:554 blocked for more than 120 seconds.
[ 494.294396] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 494.360809] kworker/u:3 D 0000000000000000 0 554 2 0x00000000
[ 494.420739] ffff88012e4d3af0 0000000000000046 ffff88013200c160 ffff88012e4d3fd8
[ 494.484392] ffff88012e4d3fd8 0000000000012500 ffff8801394ea0b0 ffff88013200c160
[ 494.548038] ffff88012e4d3ae0 00000000000001e3 ffffffff81a249e0 ffff8801321c5398
[ 494.611685] Call Trace:
[ 494.632649] [<ffffffff8149dd25>] schedule+0x5a/0x5c
[ 494.674687] [<ffffffff8104b968>] async_synchronize_cookie_domain+0xb6/0x112
[ 494.734177] [<ffffffff810461ff>] ? __init_waitqueue_head+0x50/0x50
[ 494.787134] [<ffffffff8131a224>] ? scsi_remove_target+0x48/0x48
[ 494.837900] [<ffffffff8104b9d9>] async_synchronize_cookie+0x15/0x17
[ 494.891567] [<ffffffff8104ba49>] async_synchronize_full+0x54/0x70 <-- here we wait for async contexts to complete
[ 494.943783] [<ffffffff8104b9f5>] ? async_synchronize_full_domain+0x1a/0x1a
[ 495.002547] [<ffffffffa00114b1>] sd_remove+0x2c/0xa2 [sd_mod]
[ 495.051861] [<ffffffff812fe94f>] __device_release_driver+0x86/0xcf
[ 495.104807] [<ffffffff812fe9bd>] device_release_driver+0x25/0x32 <-- here we take device_lock()
[ 853.511341] INFO: task kworker/u:4:549 blocked for more than 120 seconds.
[ 853.568693] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 853.635119] kworker/u:4 D ffff88013097b5d0 0 549 2 0x00000000
[ 853.695129] ffff880132773c40 0000000000000046 ffff880130790000 ffff880132773fd8
[ 853.758990] ffff880132773fd8 0000000000012500 ffff88013288a0b0 ffff880130790000
[ 853.822796] 0000000000000246 0000000000000040 ffff88013097b5c8 ffff880130790000
[ 853.886633] Call Trace:
[ 853.907631] [<ffffffff8149dd25>] schedule+0x5a/0x5c
[ 853.949670] [<ffffffff8149cc44>] __mutex_lock_common+0x220/0x351
[ 854.001225] [<ffffffff81304bd7>] ? device_resume+0x58/0x1c4
[ 854.049082] [<ffffffff81304bd7>] ? device_resume+0x58/0x1c4
[ 854.097011] [<ffffffff8149ce48>] mutex_lock_nested+0x2f/0x36 <-- here we wait for device_lock()
[ 854.145591] [<ffffffff81304bd7>] device_resume+0x58/0x1c4
[ 854.192066] [<ffffffff81304d61>] async_resume+0x1e/0x45
[ 854.237019] [<ffffffff8104bc93>] async_run_entry_fn+0xc6/0x173 <-- ...while running in async context
Provide a 'scsi_sd_probe_domain' so that async probe actions actions can
be flushed without regard for the state of PM, and allow for the resume
path to handle devices that have transitioned from SDEV_QUIESCE to
SDEV_DEL prior to resume.
Acked-by: Alan Stern <stern@rowland.harvard.edu>
[alan: uplevel scsi_sd_probe_domain, clarify scsi_device_resume]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
[jejb: remove unneeded config guards in include file]
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | drivers/scsi/scsi.c | 6 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 10 | ||||
-rw-r--r-- | drivers/scsi/scsi_pm.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi_priv.h | 2 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 5 |
5 files changed, 19 insertions, 6 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 07322ecff90d..61c82a345f82 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -90,6 +90,12 @@ unsigned int scsi_logging_level; | |||
90 | EXPORT_SYMBOL(scsi_logging_level); | 90 | EXPORT_SYMBOL(scsi_logging_level); |
91 | #endif | 91 | #endif |
92 | 92 | ||
93 | #if IS_ENABLED(CONFIG_PM) || IS_ENABLED(CONFIG_BLK_DEV_SD) | ||
94 | /* sd and scsi_pm need to coordinate flushing async actions */ | ||
95 | LIST_HEAD(scsi_sd_probe_domain); | ||
96 | EXPORT_SYMBOL(scsi_sd_probe_domain); | ||
97 | #endif | ||
98 | |||
93 | /* NB: These are exposed through /proc/scsi/scsi and form part of the ABI. | 99 | /* NB: These are exposed through /proc/scsi/scsi and form part of the ABI. |
94 | * You may not alter any existing entry (although adding new ones is | 100 | * You may not alter any existing entry (although adding new ones is |
95 | * encouraged once assigned by ANSI/INCITS T10 | 101 | * encouraged once assigned by ANSI/INCITS T10 |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ead6405f3e51..dbe43924d7ae 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -2348,10 +2348,14 @@ EXPORT_SYMBOL(scsi_device_quiesce); | |||
2348 | * | 2348 | * |
2349 | * Must be called with user context, may sleep. | 2349 | * Must be called with user context, may sleep. |
2350 | */ | 2350 | */ |
2351 | void | 2351 | void scsi_device_resume(struct scsi_device *sdev) |
2352 | scsi_device_resume(struct scsi_device *sdev) | ||
2353 | { | 2352 | { |
2354 | if(scsi_device_set_state(sdev, SDEV_RUNNING)) | 2353 | /* check if the device state was mutated prior to resume, and if |
2354 | * so assume the state is being managed elsewhere (for example | ||
2355 | * device deleted during suspend) | ||
2356 | */ | ||
2357 | if (sdev->sdev_state != SDEV_QUIESCE || | ||
2358 | scsi_device_set_state(sdev, SDEV_RUNNING)) | ||
2355 | return; | 2359 | return; |
2356 | scsi_run_queue(sdev->request_queue); | 2360 | scsi_run_queue(sdev->request_queue); |
2357 | } | 2361 | } |
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c index c4670642d023..f661a41fa4c6 100644 --- a/drivers/scsi/scsi_pm.c +++ b/drivers/scsi/scsi_pm.c | |||
@@ -97,7 +97,7 @@ static int scsi_bus_prepare(struct device *dev) | |||
97 | { | 97 | { |
98 | if (scsi_is_sdev_device(dev)) { | 98 | if (scsi_is_sdev_device(dev)) { |
99 | /* sd probing uses async_schedule. Wait until it finishes. */ | 99 | /* sd probing uses async_schedule. Wait until it finishes. */ |
100 | async_synchronize_full(); | 100 | async_synchronize_full_domain(&scsi_sd_probe_domain); |
101 | 101 | ||
102 | } else if (scsi_is_host_device(dev)) { | 102 | } else if (scsi_is_host_device(dev)) { |
103 | /* Wait until async scanning is finished */ | 103 | /* Wait until async scanning is finished */ |
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index be4fa6d179b1..07ce3f51701d 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h | |||
@@ -163,6 +163,8 @@ static inline int scsi_autopm_get_host(struct Scsi_Host *h) { return 0; } | |||
163 | static inline void scsi_autopm_put_host(struct Scsi_Host *h) {} | 163 | static inline void scsi_autopm_put_host(struct Scsi_Host *h) {} |
164 | #endif /* CONFIG_PM_RUNTIME */ | 164 | #endif /* CONFIG_PM_RUNTIME */ |
165 | 165 | ||
166 | extern struct list_head scsi_sd_probe_domain; | ||
167 | |||
166 | /* | 168 | /* |
167 | * internal scsi timeout functions: for use by mid-layer and transport | 169 | * internal scsi timeout functions: for use by mid-layer and transport |
168 | * classes. | 170 | * classes. |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 5ba5c2a9e8e9..6f0a4c612b3b 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -65,6 +65,7 @@ | |||
65 | #include <scsi/scsicam.h> | 65 | #include <scsi/scsicam.h> |
66 | 66 | ||
67 | #include "sd.h" | 67 | #include "sd.h" |
68 | #include "scsi_priv.h" | ||
68 | #include "scsi_logging.h" | 69 | #include "scsi_logging.h" |
69 | 70 | ||
70 | MODULE_AUTHOR("Eric Youngdale"); | 71 | MODULE_AUTHOR("Eric Youngdale"); |
@@ -2722,7 +2723,7 @@ static int sd_probe(struct device *dev) | |||
2722 | dev_set_drvdata(dev, sdkp); | 2723 | dev_set_drvdata(dev, sdkp); |
2723 | 2724 | ||
2724 | get_device(&sdkp->dev); /* prevent release before async_schedule */ | 2725 | get_device(&sdkp->dev); /* prevent release before async_schedule */ |
2725 | async_schedule(sd_probe_async, sdkp); | 2726 | async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain); |
2726 | 2727 | ||
2727 | return 0; | 2728 | return 0; |
2728 | 2729 | ||
@@ -2756,7 +2757,7 @@ static int sd_remove(struct device *dev) | |||
2756 | sdkp = dev_get_drvdata(dev); | 2757 | sdkp = dev_get_drvdata(dev); |
2757 | scsi_autopm_get_device(sdkp->device); | 2758 | scsi_autopm_get_device(sdkp->device); |
2758 | 2759 | ||
2759 | async_synchronize_full(); | 2760 | async_synchronize_full_domain(&scsi_sd_probe_domain); |
2760 | blk_queue_prep_rq(sdkp->device->request_queue, scsi_prep_fn); | 2761 | blk_queue_prep_rq(sdkp->device->request_queue, scsi_prep_fn); |
2761 | blk_queue_unprep_rq(sdkp->device->request_queue, NULL); | 2762 | blk_queue_unprep_rq(sdkp->device->request_queue, NULL); |
2762 | device_del(&sdkp->dev); | 2763 | device_del(&sdkp->dev); |