From patchwork Fri Mar 27 08:04:54 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: 6103921 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 D52219F399 for ; Fri, 27 Mar 2015 08:06:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB15E203E5 for ; Fri, 27 Mar 2015 08:06:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68CCC20411 for ; Fri, 27 Mar 2015 08:06:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752797AbbC0IGQ (ORCPT ); Fri, 27 Mar 2015 04:06:16 -0400 Received: from mail-oi0-f46.google.com ([209.85.218.46]:33629 "EHLO mail-oi0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753172AbbC0IGG (ORCPT ); Fri, 27 Mar 2015 04:06:06 -0400 Received: by oifl3 with SMTP id l3so70046342oif.0 for ; Fri, 27 Mar 2015 01:06:06 -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=ywtFU0A73q5kJqIVfrsZfAvVoKjMWXGCYrCE+SFAbKM=; b=W9a58Er4xVce1IOaiT78Y6BiOee3lzkhiPi3CmMlwCK2Na5lp3MaZrcargwaOngiYM Ud8XR4VIwRdAbxrSGHKZp6Tk4eywbG1SaG6TUf+gUrae8SesezPhBzQ5/KvE4RiUnH9L gOz83RcggP5zmQSnNNxvPxcqzCDYCtXpnedFaPSxljPcXMrRo2kNyM0cX4rzEwACfalQ 7k3aniPnG6o6NVRqZrPcwlB21Jb5mtS1ba5vQX42KEgbEeVxZA5v4Y3YlKHC0liAGDSJ AjikriFx5mElauhx23BraiS3WT+nn1PhwB7R4NQ0fN1h5DkT2jNUtIeD6L55CQifQNep 6r1w== X-Gm-Message-State: ALoCoQmpm2lKQBUuXWkwFost7ofn3qzhJeFCT8TvpjcHCFLozAbNwyUyoVjPFgkYao6OxUMn8Bh5 X-Received: by 10.60.158.73 with SMTP id ws9mr15445983oeb.24.1427443566002; Fri, 27 Mar 2015 01:06:06 -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.05 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 27 Mar 2015 01:06:05 -0700 (PDT) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , Hannes Reinecke , Christoph Hellwig , Sagi Grimberg , Nicholas Bellinger Subject: [RFC 04/22] target/configfs: Convert mappedlun link/unlink to RCU reader Date: Fri, 27 Mar 2015 08:04:54 +0000 Message-Id: <1427443512-8925-5-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 This patch converts fabric independent configfs link/unlink to use RCU read path macros for se_node_acl->lun_entry_hlist[] access. Also, update show_write_protect attribute access as well. Cc: Hannes Reinecke Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_fabric_configfs.c | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c index 0c3f901..86ad50d 100644 --- a/drivers/target/target_core_fabric_configfs.c +++ b/drivers/target/target_core_fabric_configfs.c @@ -111,8 +111,8 @@ static int target_fabric_mappedlun_link( * which be will write protected (READ-ONLY) when * tpg_1/attrib/demo_mode_write_protect=1 */ - spin_lock_irq(&lacl->se_lun_nacl->device_list_lock); - deve = lacl->se_lun_nacl->device_list[lacl->mapped_lun]; + rcu_read_lock(); + deve = rcu_dereference(lacl->se_lun_nacl->lun_entry_hlist[lacl->mapped_lun]); if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) lun_access = deve->lun_flags; else @@ -120,7 +120,7 @@ static int target_fabric_mappedlun_link( (se_tpg->se_tpg_tfo->tpg_check_prod_mode_write_protect( se_tpg)) ? TRANSPORT_LUNFLAGS_READ_ONLY : TRANSPORT_LUNFLAGS_READ_WRITE; - spin_unlock_irq(&lacl->se_lun_nacl->device_list_lock); + rcu_read_unlock(); /* * Determine the actual mapped LUN value user wants.. * @@ -141,14 +141,18 @@ static int target_fabric_mappedlun_unlink( struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci), struct se_lun_acl, se_lun_group); struct se_node_acl *nacl = lacl->se_lun_nacl; - struct se_dev_entry *deve = nacl->device_list[lacl->mapped_lun]; + struct se_dev_entry *deve; struct se_portal_group *se_tpg; /* * Determine if the underlying MappedLUN has already been released.. */ - if (!deve->se_lun) + rcu_read_lock(); + deve = rcu_dereference(nacl->lun_entry_hlist[lacl->mapped_lun]); + if (!deve || !deve->se_lun) { + rcu_read_lock(); return 0; - + } + rcu_read_unlock(); lun = container_of(to_config_group(lun_ci), struct se_lun, lun_group); se_tpg = lun->lun_sep->sep_tpg; @@ -171,12 +175,13 @@ static ssize_t target_fabric_mappedlun_show_write_protect( struct se_dev_entry *deve; ssize_t len; - spin_lock_irq(&se_nacl->device_list_lock); - deve = se_nacl->device_list[lacl->mapped_lun]; - len = sprintf(page, "%d\n", - (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) ? - 1 : 0); - spin_unlock_irq(&se_nacl->device_list_lock); + rcu_read_lock(); + deve = rcu_dereference(se_nacl->lun_entry_hlist[lacl->mapped_lun]); + if (deve) { + len = sprintf(page, "%d\n", + (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) ? 1 : 0); + } + rcu_read_unlock(); return len; }