Re: [PATCH v5 0/4] Avoid that __scsi_remove_device() hangs

2017-04-26 Thread Bart Van Assche
On Tue, 2017-04-25 at 13:53 -0700, Bart Van Assche wrote:
> __scsi_remove_device() hangs if it is waiting for the SYNCHRONIZE CACHE
> command submitted by the sd driver to finish if the block layer queue is
> stopped and does not get restarted. This patch series avoids that that
> hang occurs.
> [ ... ]

Hello Martin and James,

Even with this version of this patch series there is still a lockup possible,
namely if the sd events checker submits a TUR while a SCSI device is blocked
and before __scsi_remove_device() calls device_del(). The latter function
namely waits for sd_check_events() to finish.

Bart.

[PATCH v5 0/4] Avoid that __scsi_remove_device() hangs

2017-04-25 Thread Bart Van Assche
__scsi_remove_device() hangs if it is waiting for the SYNCHRONIZE CACHE
command submitted by the sd driver to finish if the block layer queue is
stopped and does not get restarted. This patch series avoids that that
hang occurs.

Changes compared to v4:
- Fixed the deadlock reported by the 0-day bot by changing a blk_put_request()
  call into __blk_put_request().

Changes compared to v3:
- Removed the logging statements from sd_sync_cache_done() that triggered
  a crash due to a use-after-free.

Changes compared to v2:
- Moved the "stop_disk" assignment after the sdkp check in the sd driver.
- Added a completion function for asynchronous SYNCHRONIZE CACHE commands.
- Added "disk" and "done" arguments to scsi_execute_async().

Changes compared to v1:
- Reworked the approach of this patch series.

Bart Van Assche (4):
  Introduce scsi_start_queue()
  Introduce scsi_execute_async()
  sd: Make synchronize cache upon shutdown asynchronous
  Avoid that __scsi_remove_device() hangs

 drivers/scsi/scsi_lib.c| 114 ++---
 drivers/scsi/scsi_priv.h   |   1 +
 drivers/scsi/scsi_sysfs.c  |   9 
 drivers/scsi/sd.c  |  45 --
 include/scsi/scsi_device.h |   5 ++
 5 files changed, 142 insertions(+), 32 deletions(-)

-- 
2.12.2