diff mbox

[V6,02/18] scsi: sysfs: don't add scsi_device if its already added

Message ID 1411648356-3883-3-git-send-email-draviv@codeaurora.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Dolev Raviv Sept. 25, 2014, 12:32 p.m. UTC
From: Subhash Jadavani <subhashj@codeaurora.org>

If LLD has added scsi device (by calling scsi_add_device) before scheduling
async scsi_scan_host then scsi_finish_async_scan() will end up calling
scsi_sysfs_add_sdev for scsi device which was already added by LLD.
This patch fixes this issue by skipping the call to scsi_sysfs_add_sdev()
if it's already visible to rest of the kernel.

Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>

Comments

Christoph Hellwig Sept. 26, 2014, 8:14 a.m. UTC | #1
Looks fine to me, just want a cross check from Martin or Hannes.

On Thu, Sep 25, 2014 at 03:32:20PM +0300, Dolev Raviv wrote:
> From: Subhash Jadavani <subhashj@codeaurora.org>
> 
> If LLD has added scsi device (by calling scsi_add_device) before scheduling
> async scsi_scan_host then scsi_finish_async_scan() will end up calling
> scsi_sysfs_add_sdev for scsi device which was already added by LLD.
> This patch fixes this issue by skipping the call to scsi_sysfs_add_sdev()
> if it's already visible to rest of the kernel.
> 
> Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
> Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
> 
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index 1095d5a..c6c5716 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -1746,6 +1746,9 @@ static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
>  		/* target removed before the device could be added */
>  		if (sdev->sdev_state == SDEV_DEL)
>  			continue;
> +		/* If device is already visible, skip adding it to sysfs */
> +		if (sdev->is_visible)
> +			continue;
>  		if (!scsi_host_scan_allowed(shost) ||
>  		    scsi_sysfs_add_sdev(sdev) != 0)
>  			__scsi_remove_device(sdev);
> -- 
> 1.8.5.2
> -- 
> QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
> of Code Aurora Forum, hosted by The Linux Foundation
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
---end quoted text---
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hannes Reinecke Sept. 26, 2014, 1:41 p.m. UTC | #2
On 09/26/2014 10:14 AM, Christoph Hellwig wrote:
> Looks fine to me, just want a cross check from Martin or Hannes.
> 
> On Thu, Sep 25, 2014 at 03:32:20PM +0300, Dolev Raviv wrote:
>> From: Subhash Jadavani <subhashj@codeaurora.org>
>>
>> If LLD has added scsi device (by calling scsi_add_device) before scheduling
>> async scsi_scan_host then scsi_finish_async_scan() will end up calling
>> scsi_sysfs_add_sdev for scsi device which was already added by LLD.
>> This patch fixes this issue by skipping the call to scsi_sysfs_add_sdev()
>> if it's already visible to rest of the kernel.
>>
>> Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
>> Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
>>
>> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
>> index 1095d5a..c6c5716 100644
>> --- a/drivers/scsi/scsi_scan.c
>> +++ b/drivers/scsi/scsi_scan.c
>> @@ -1746,6 +1746,9 @@ static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
>>  		/* target removed before the device could be added */
>>  		if (sdev->sdev_state == SDEV_DEL)
>>  			continue;
>> +		/* If device is already visible, skip adding it to sysfs */
>> +		if (sdev->is_visible)
>> +			continue;
>>  		if (!scsi_host_scan_allowed(shost) ||
>>  		    scsi_sysfs_add_sdev(sdev) != 0)
>>  			__scsi_remove_device(sdev);
>> -- 
>> 1.8.5.2
>> -- 
>> QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
>> of Code Aurora Forum, hosted by The Linux Foundation
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> ---end quoted text---
> --
Looks okay.

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Martin K. Petersen Sept. 30, 2014, 9:54 p.m. UTC | #3
>>>>> "Christoph" == Christoph Hellwig <hch@infradead.org> writes:

>> If LLD has added scsi device (by calling scsi_add_device) before
>> scheduling async scsi_scan_host then scsi_finish_async_scan() will
>> end up calling scsi_sysfs_add_sdev for scsi device which was already
>> added by LLD.  This patch fixes this issue by skipping the call to
>> scsi_sysfs_add_sdev() if it's already visible to rest of the kernel.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
diff mbox

Patch

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 1095d5a..c6c5716 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1746,6 +1746,9 @@  static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
 		/* target removed before the device could be added */
 		if (sdev->sdev_state == SDEV_DEL)
 			continue;
+		/* If device is already visible, skip adding it to sysfs */
+		if (sdev->is_visible)
+			continue;
 		if (!scsi_host_scan_allowed(shost) ||
 		    scsi_sysfs_add_sdev(sdev) != 0)
 			__scsi_remove_device(sdev);