Re: [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message -----
> From: "Ewan D. Milne" <emilne@xxxxxxxxxx>
> To: linux-scsi@xxxxxxxxxxxxxxx
> Sent: Friday, May 20, 2016 8:56:14 AM
> Subject: [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data
> 
> From: "Ewan D. Milne" <emilne@xxxxxxxxxx>
> 
> A spinlock is sufficient for this purpose, and much smaller.
> 
> Signed-off-by: Ewan D. Milne <emilne@xxxxxxxxxx>
> ---
>  drivers/scsi/scsi.c        | 8 ++++----
>  drivers/scsi/scsi_scan.c   | 2 +-
>  include/scsi/scsi_device.h | 2 +-
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 1deb6ad..330d807 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -829,11 +829,11 @@ retry_pg80:
>  			kfree(vpd_buf);
>  			goto retry_pg80;
>  		}
> -		mutex_lock(&sdev->inquiry_mutex);
> +		spin_lock(&sdev->inquiry_lock);
>  		orig_vpd_buf = sdev->vpd_pg80;
>  		sdev->vpd_pg80_len = result;
>  		rcu_assign_pointer(sdev->vpd_pg80, vpd_buf);
> -		mutex_unlock(&sdev->inquiry_mutex);
> +		spin_unlock(&sdev->inquiry_lock);
>  		synchronize_rcu();
>  		if (orig_vpd_buf) {
>  			kfree(orig_vpd_buf);
> @@ -858,11 +858,11 @@ retry_pg83:
>  			kfree(vpd_buf);
>  			goto retry_pg83;
>  		}
> -		mutex_lock(&sdev->inquiry_mutex);
> +		spin_lock(&sdev->inquiry_lock);
>  		orig_vpd_buf = sdev->vpd_pg83;
>  		sdev->vpd_pg83_len = result;
>  		rcu_assign_pointer(sdev->vpd_pg83, vpd_buf);
> -		mutex_unlock(&sdev->inquiry_mutex);
> +		spin_unlock(&sdev->inquiry_lock);
>  		synchronize_rcu();
>  		if (orig_vpd_buf)
>  			kfree(orig_vpd_buf);
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index e0a78f5..f445615 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -240,7 +240,7 @@ static struct scsi_device *scsi_alloc_sdev(struct
> scsi_target *starget,
>  	INIT_LIST_HEAD(&sdev->starved_entry);
>  	INIT_LIST_HEAD(&sdev->event_list);
>  	spin_lock_init(&sdev->list_lock);
> -	mutex_init(&sdev->inquiry_mutex);
> +	spin_lock_init(&sdev->inquiry_lock);
>  	INIT_WORK(&sdev->event_work, scsi_evt_thread);
>  	INIT_WORK(&sdev->requeue_work, scsi_requeue_run_queue);
>  
> diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
> index a6c346d..0410ed8 100644
> --- a/include/scsi/scsi_device.h
> +++ b/include/scsi/scsi_device.h
> @@ -115,7 +115,7 @@ struct scsi_device {
>  	char type;
>  	char scsi_level;
>  	char inq_periph_qual;	/* PQ from INQUIRY data */
> -	struct mutex inquiry_mutex;
> +	spinlock_t inquiry_lock;
>  	unsigned char inquiry_len;	/* valid bytes in 'inquiry' */
>  	unsigned char * inquiry;	/* INQUIRY response data */
>  	const char * vendor;		/* [back_compat] point into 'inquiry' ... */
> --
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Look fine to me:
Reviewed by: Laurence Oberman <loberman@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux