Return-Path: Received: from mx2.suse.de ([195.135.220.15]:43176 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751635AbdATI4I (ORCPT ); Fri, 20 Jan 2017 03:56:08 -0500 From: Jiri Slaby To: stable@vger.kernel.org Cc: Wei Fang , "Martin K . Petersen" , Jiri Slaby Subject: [patch added to 3.12-stable] scsi: avoid a permanent stop of the scsi device's request queue Date: Fri, 20 Jan 2017 09:55:46 +0100 Message-Id: <20170120085559.25003-10-jslaby@suse.cz> In-Reply-To: <20170120085559.25003-1-jslaby@suse.cz> References: <20170120085559.25003-1-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org List-ID: From: Wei Fang This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit d2a145252c52792bc59e4767b486b26c430af4bb upstream. A race between scanning and fc_remote_port_delete() may result in a permanent stop if the device gets blocked before scsi_sysfs_add_sdev() and unblocked after. The reason is that blocking a device sets both the SDEV_BLOCKED state and the QUEUE_FLAG_STOPPED. However, scsi_sysfs_add_sdev() unconditionally sets SDEV_RUNNING which causes the device to be ignored by scsi_target_unblock() and thus never have its QUEUE_FLAG_STOPPED cleared leading to a device which is apparently running but has a stopped queue. We actually have two places where SDEV_RUNNING is set: once in scsi_add_lun() which respects the blocked flag and once in scsi_sysfs_add_sdev() which doesn't. Since the second set is entirely spurious, simply remove it to fix the problem. Reported-by: Zengxi Chen Signed-off-by: Wei Fang Reviewed-by: Ewan D. Milne Signed-off-by: Martin K. Petersen Signed-off-by: Jiri Slaby --- drivers/scsi/scsi_sysfs.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 14ad111b2851..970f655f8532 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -905,10 +905,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) struct request_queue *rq = sdev->request_queue; struct scsi_target *starget = sdev->sdev_target; - error = scsi_device_set_state(sdev, SDEV_RUNNING); - if (error) - return error; - error = scsi_target_add(starget); if (error) return error; -- 2.11.0