From patchwork Fri May 20 12:56:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ewan Milne X-Patchwork-Id: 9129425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F1AAD6048B for ; Fri, 20 May 2016 12:56:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3E0620499 for ; Fri, 20 May 2016 12:56:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D887827BFE; Fri, 20 May 2016 12:56:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 810A020499 for ; Fri, 20 May 2016 12:56:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932638AbcETM4X (ORCPT ); Fri, 20 May 2016 08:56:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41928 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932617AbcETM4V (ORCPT ); Fri, 20 May 2016 08:56:21 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2657A552F6 for ; Fri, 20 May 2016 12:56:16 +0000 (UTC) Received: from emilne.csb (dhcp-25-104.bos.redhat.com [10.18.25.104]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4KCuFn7018479 for ; Fri, 20 May 2016 08:56:15 -0400 From: "Ewan D. Milne" To: linux-scsi@vger.kernel.org Subject: [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data Date: Fri, 20 May 2016 08:56:14 -0400 Message-Id: <1463748974-31315-1-git-send-email-emilne@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 20 May 2016 12:56:16 +0000 (UTC) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Ewan D. Milne" A spinlock is sufficient for this purpose, and much smaller. Signed-off-by: Ewan D. Milne Reviewed-by: Johannes Thumshirn --- 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' ... */