From patchwork Fri Mar 27 08:05:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 6104021 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ACADD9F399 for ; Fri, 27 Mar 2015 08:07:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6CDF2203E5 for ; Fri, 27 Mar 2015 08:07:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BD57203FB for ; Fri, 27 Mar 2015 08:07:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753680AbbC0IGw (ORCPT ); Fri, 27 Mar 2015 04:06:52 -0400 Received: from mail-oi0-f45.google.com ([209.85.218.45]:35220 "EHLO mail-oi0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753606AbbC0IGY (ORCPT ); Fri, 27 Mar 2015 04:06:24 -0400 Received: by oiag65 with SMTP id g65so69893471oia.2 for ; Fri, 27 Mar 2015 01:06:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BU64uekiFvQhOxVKG6MTQho99KCJrW0aTzWf65uhRRM=; b=NSCmHpXUMpFsx0wYuFPO1/c5RHdATgevXj30c+xOeG0fM6UPIClGJ7Koyd9eV8Yj+Y nkfzh9JNqBBwVG3qE/Omc1yoALsByDdW/37FqWiQC9JjvmKSF97+gR9Dv1Z55Fl2d3DG c3cRp44dpF/H2f5GfBSJllBYre2y/C7oZzY66QOfKEKHWqzJX26FDZP8EeGo6jl3oKkt 0ni9RRzDYnW+DQCysA7ajPPV5ipPuOzO3GksAdDif7rxBuKPIf9ztbyrICbaOzKHsKkn 0320oV5vZJKwmFjkVcORW/HPwrZNTvxRfQh3NPNRkM21uriTs1YY6HyWHZSN8jVnYb8K fycQ== X-Gm-Message-State: ALoCoQlU/8UFGfQR/UZ4Q+g/NJsrsRhKminXGa5xqzho4qwWjzxI+lScn9+WDhzlV+aQb79qBmiU X-Received: by 10.60.133.144 with SMTP id pc16mr4338161oeb.0.1427443583127; Fri, 27 Mar 2015 01:06:23 -0700 (PDT) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by mx.google.com with ESMTPSA id h4sm711520obr.18.2015.03.27.01.06.22 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 27 Mar 2015 01:06:22 -0700 (PDT) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , Hannes Reinecke , Christoph Hellwig , Sagi Grimberg , Nicholas Bellinger Subject: [RFC 14/22] target: Convert se_node_acl->lun_entry_lock to ->lun_entry_mutex Date: Fri, 27 Mar 2015 08:05:04 +0000 Message-Id: <1427443512-8925-15-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1427443512-8925-1-git-send-email-nab@daterainc.com> References: <1427443512-8925-1-git-send-email-nab@daterainc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger Now that se_node_acl->lun_entry_hlist[] fast path access uses RCU, go ahead and convert se_node_acl->lun_entry_lock to struct mutex, for non fast-path RCU updater code. Cc: Hannes Reinecke Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_device.c | 18 ++++++++---------- drivers/target/target_core_pr.c | 12 ++++++------ drivers/target/target_core_tpg.c | 14 ++++++-------- include/target/target_core_base.h | 3 +-- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 965d81e..2a5fa88 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -304,7 +304,7 @@ void core_update_device_list_access( { struct se_dev_entry *deve; - spin_lock_irq(&nacl->lun_entry_lock); + mutex_lock(&nacl->lun_entry_mutex); deve = rcu_dereference(nacl->lun_entry_hlist[mapped_lun]); if (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) { deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY; @@ -313,7 +313,7 @@ void core_update_device_list_access( deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_WRITE; deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY; } - spin_unlock_irq(&nacl->lun_entry_lock); + mutex_unlock(&nacl->lun_entry_mutex); synchronize_rcu(); } @@ -345,7 +345,7 @@ int core_enable_device_list_for_node( * transition. This transition must be for the same struct se_lun * + mapped_lun that was setup in demo mode.. */ - spin_lock_irq(&nacl->lun_entry_lock); + mutex_lock(&nacl->lun_entry_mutex); deve = nacl->lun_entry_hlist[mapped_lun]; if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { BUG_ON(deve->se_lun_acl != NULL); @@ -359,7 +359,7 @@ int core_enable_device_list_for_node( deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY; } rcu_assign_pointer(deve->se_lun_acl, lun_acl); - spin_unlock_irq(&nacl->lun_entry_lock); + mutex_unlock(&nacl->lun_entry_mutex); synchronize_rcu(); return 0; @@ -384,7 +384,7 @@ int core_enable_device_list_for_node( rcu_assign_pointer(deve->se_lun, lun); rcu_assign_pointer(deve->se_lun_acl, lun_acl); - spin_unlock_irq(&nacl->lun_entry_lock); + mutex_unlock(&nacl->lun_entry_mutex); spin_lock_bh(&port->sep_alua_lock); list_add_tail(&deve->alua_port_list, &port->sep_alua_list); @@ -409,8 +409,8 @@ int core_disable_device_list_for_node( struct se_port *port = lun->lun_sep; struct se_dev_entry *deve; - rcu_read_lock(); - deve = rcu_dereference(nacl->lun_entry_hlist[mapped_lun]); + mutex_lock(&nacl->lun_entry_mutex); + deve = (nacl->lun_entry_hlist[mapped_lun]); /* * If the MappedLUN entry is being disabled, the entry in * port->sep_alua_list must be removed now before clearing the @@ -430,7 +430,6 @@ int core_disable_device_list_for_node( /* * Disable struct se_dev_entry LUN ACL mapping */ - spin_lock_irq(&nacl->lun_entry_lock); core_scsi3_ua_release_all(deve); rcu_assign_pointer(deve->pr_reg, NULL); rcu_assign_pointer(deve->se_lun, NULL); @@ -438,8 +437,7 @@ int core_disable_device_list_for_node( deve->lun_flags = 0; deve->creation_time = 0; deve->attach_count--; - spin_unlock_irq(&nacl->lun_entry_lock); - rcu_read_unlock(); + mutex_unlock(&nacl->lun_entry_mutex); /* * Wait for RCU read critical sections to complete after diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 3b83026..93e109e 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -1030,10 +1030,10 @@ static void __core_scsi3_add_registration( __core_scsi3_dump_registration(tfo, dev, nacl, pr_reg, register_type); spin_unlock(&pr_tmpl->registration_lock); - spin_lock(&nacl->lun_entry_lock); + mutex_lock(&nacl->lun_entry_mutex); deve = nacl->lun_entry_hlist[pr_reg->pr_res_mapped_lun]; rcu_assign_pointer(deve->pr_reg, pr_reg); - spin_unlock(&nacl->lun_entry_lock); + mutex_unlock(&nacl->lun_entry_mutex); /* * Wait for read path critical RCU in core_scsi3_pr_seq_non_holder() * conditional checks for deve->pr_reg pointer access complete. @@ -1065,10 +1065,10 @@ static void __core_scsi3_add_registration( register_type); spin_unlock(&pr_tmpl->registration_lock); - spin_lock(&nacl->lun_entry_lock); + mutex_lock(&nacl->lun_entry_mutex); deve = nacl_tmp->lun_entry_hlist[pr_reg_tmp->pr_res_mapped_lun]; rcu_assign_pointer(deve->pr_reg, pr_reg_tmp); - spin_unlock(&nacl->lun_entry_lock); + mutex_unlock(&nacl->lun_entry_mutex); /* * Wait for read path critical RCU in core_scsi3_pr_seq_non_holder() * conditional checks for deve->pr_reg pointer access complete. @@ -1280,10 +1280,10 @@ static void __core_scsi3_free_registration( cpu_relax(); } - spin_lock(&nacl->lun_entry_lock); + mutex_lock(&nacl->lun_entry_mutex); deve = nacl->lun_entry_hlist[pr_reg->pr_res_mapped_lun]; rcu_assign_pointer(deve->pr_reg, NULL); - spin_unlock(&nacl->lun_entry_lock); + mutex_unlock(&nacl->lun_entry_mutex); /* * Wait for read path critical RCU in core_scsi3_pr_seq_non_holder() * conditional checks for deve->pr_reg pointer access complete. diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 027707a..3d81a72 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c @@ -275,9 +275,8 @@ struct se_node_acl *core_tpg_check_initiator_node_acl( INIT_LIST_HEAD(&acl->acl_sess_list); kref_init(&acl->acl_kref); init_completion(&acl->acl_free_comp); - spin_lock_init(&acl->device_list_lock); spin_lock_init(&acl->nacl_sess_lock); - spin_lock_init(&acl->lun_entry_lock); + mutex_init(&acl->lun_entry_mutex); atomic_set(&acl->acl_pr_ref_count, 0); acl->queue_depth = tpg->se_tpg_tfo->tpg_get_default_depth(tpg); snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); @@ -331,7 +330,7 @@ void core_tpg_clear_object_luns(struct se_portal_group *tpg) int i; struct se_lun *lun; - spin_lock(&tpg->tpg_lun_lock); + mutex_lock(&tpg->tpg_lun_mutex); for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { lun = tpg->tpg_lun_list[i]; @@ -339,11 +338,11 @@ void core_tpg_clear_object_luns(struct se_portal_group *tpg) (lun->lun_se_dev == NULL)) continue; - spin_unlock(&tpg->tpg_lun_lock); + mutex_unlock(&tpg->tpg_lun_mutex); core_dev_del_lun(tpg, lun); - spin_lock(&tpg->tpg_lun_lock); + mutex_lock(&tpg->tpg_lun_mutex); } - spin_unlock(&tpg->tpg_lun_lock); + mutex_unlock(&tpg->tpg_lun_mutex); } EXPORT_SYMBOL(core_tpg_clear_object_luns); @@ -403,9 +402,8 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( INIT_LIST_HEAD(&acl->acl_sess_list); kref_init(&acl->acl_kref); init_completion(&acl->acl_free_comp); - spin_lock_init(&acl->device_list_lock); spin_lock_init(&acl->nacl_sess_lock); - spin_lock_init(&acl->lun_entry_lock); + mutex_init(&acl->lun_entry_mutex); atomic_set(&acl->acl_pr_ref_count, 0); acl->queue_depth = queue_depth; snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 20b01cf..ab25709 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -599,8 +599,7 @@ struct se_node_acl { struct se_dev_entry **device_list; struct se_session *nacl_sess; struct se_portal_group *se_tpg; - spinlock_t device_list_lock; - spinlock_t lun_entry_lock; + struct mutex lun_entry_mutex; spinlock_t nacl_sess_lock; struct config_group acl_group; struct config_group acl_attrib_group;