From: Laurence Oberman <loberman@redhat.com>
To: "Ewan D. Milne" <emilne@redhat.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data
Date: Fri, 20 May 2016 10:33:05 -0400 (EDT) [thread overview]
Message-ID: <1424252122.37276521.1463754785510.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1463748974-31315-1-git-send-email-emilne@redhat.com>
----- Original Message -----
> From: "Ewan D. Milne" <emilne@redhat.com>
> To: linux-scsi@vger.kernel.org
> 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@redhat.com>
>
> A spinlock is sufficient for this purpose, and much smaller.
>
> Signed-off-by: Ewan D. Milne <emilne@redhat.com>
> ---
> 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@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Look fine to me:
Reviewed by: Laurence Oberman <loberman@redhat.com>
next prev parent reply other threads:[~2016-05-20 14:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-20 12:56 [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data Ewan D. Milne
2016-05-20 14:33 ` Laurence Oberman [this message]
2016-05-23 9:19 ` Johannes Thumshirn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1424252122.37276521.1463754785510.JavaMail.zimbra@redhat.com \
--to=loberman@redhat.com \
--cc=emilne@redhat.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox