From: "Nicholas A. Bellinger" <nab@daterainc.com>
To: target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
Hannes Reinecke <hare@suse.de>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagig@mellanox.com>,
Nicholas Bellinger <nab@linux-iscsi.org>
Subject: [RFC 02/22] target: Convert enable/disable ->device_list to RCU updater
Date: Fri, 27 Mar 2015 08:04:52 +0000 [thread overview]
Message-ID: <1427443512-8925-3-git-send-email-nab@daterainc.com> (raw)
In-Reply-To: <1427443512-8925-1-git-send-email-nab@daterainc.com>
From: Nicholas Bellinger <nab@linux-iscsi.org>
This patch converts core_[enable,disable]_device_list_for_node() to RCU
updater path code when modifying se_dev_entry pointers.
It includes protected rcu_assign_pointer() and invokes synchronize_rcu()
to wait for RCU read paths to finish.
Required for subsequent conversion to se_deve->pr_ref percpu-refcount.
Cc: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
drivers/target/target_core_device.c | 50 ++++++++++++++++---------------------
1 file changed, 22 insertions(+), 28 deletions(-)
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index be893c8..9385e16 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -324,31 +324,16 @@ int core_enable_device_list_for_node(
struct se_port *port = lun->lun_sep;
struct se_dev_entry *deve;
- spin_lock_irq(&nacl->device_list_lock);
-
- deve = nacl->device_list[mapped_lun];
-
/*
* Check if the call is handling demo mode -> explicit LUN ACL
* 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);
+ deve = nacl->lun_entry_hlist[mapped_lun];
if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
- if (deve->se_lun_acl != NULL) {
- pr_err("struct se_dev_entry->se_lun_acl"
- " already set for demo mode -> explicit"
- " LUN ACL transition\n");
- spin_unlock_irq(&nacl->device_list_lock);
- return -EINVAL;
- }
- if (deve->se_lun != lun) {
- pr_err("struct se_dev_entry->se_lun does"
- " match passed struct se_lun for demo mode"
- " -> explicit LUN ACL transition\n");
- spin_unlock_irq(&nacl->device_list_lock);
- return -EINVAL;
- }
- deve->se_lun_acl = lun_acl;
+ BUG_ON(deve->se_lun_acl != NULL);
+ BUG_ON(deve->se_lun != lun);
if (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) {
deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY;
@@ -357,13 +342,13 @@ int core_enable_device_list_for_node(
deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_WRITE;
deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY;
}
+ rcu_assign_pointer(deve->se_lun_acl, lun_acl);
+ spin_unlock_irq(&nacl->lun_entry_lock);
- spin_unlock_irq(&nacl->device_list_lock);
+ synchronize_rcu();
return 0;
}
- deve->se_lun = lun;
- deve->se_lun_acl = lun_acl;
deve->mapped_lun = mapped_lun;
deve->lun_flags |= TRANSPORT_LUNFLAGS_INITIATOR_ACCESS;
@@ -377,12 +362,16 @@ int core_enable_device_list_for_node(
deve->creation_time = get_jiffies_64();
deve->attach_count++;
- spin_unlock_irq(&nacl->device_list_lock);
+
+ rcu_assign_pointer(deve->se_lun, lun);
+ rcu_assign_pointer(deve->se_lun_acl, lun_acl);
+ spin_unlock_irq(&nacl->lun_entry_lock);
spin_lock_bh(&port->sep_alua_lock);
list_add_tail(&deve->alua_port_list, &port->sep_alua_list);
spin_unlock_bh(&port->sep_alua_lock);
+ synchronize_rcu();
return 0;
}
@@ -399,8 +388,10 @@ int core_disable_device_list_for_node(
struct se_portal_group *tpg)
{
struct se_port *port = lun->lun_sep;
- struct se_dev_entry *deve = nacl->device_list[mapped_lun];
+ struct se_dev_entry *deve;
+ rcu_read_lock();
+ deve = rcu_dereference(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
@@ -424,17 +415,20 @@ int core_disable_device_list_for_node(
while (atomic_read(&deve->pr_ref_count) != 0)
cpu_relax();
- spin_lock_irq(&nacl->device_list_lock);
/*
* Disable struct se_dev_entry LUN ACL mapping
*/
+ spin_lock_irq(&nacl->lun_entry_lock);
core_scsi3_ua_release_all(deve);
- deve->se_lun = NULL;
- deve->se_lun_acl = NULL;
+ rcu_assign_pointer(deve->se_lun, NULL);
+ rcu_assign_pointer(deve->se_lun_acl, NULL);
deve->lun_flags = 0;
deve->creation_time = 0;
deve->attach_count--;
- spin_unlock_irq(&nacl->device_list_lock);
+ spin_unlock_irq(&nacl->lun_entry_lock);
+ rcu_read_unlock();
+
+ synchronize_rcu();
core_scsi3_free_pr_reg_from_nacl(lun->lun_se_dev, nacl);
return 0;
--
1.9.1
next prev parent reply other threads:[~2015-03-27 8:06 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-27 8:04 [RFC 00/22] target: se_node_acl LUN list RCU conversion Nicholas A. Bellinger
2015-03-27 8:04 ` [RFC 01/22] target: Convert transport_lookup_*_lun to RCU reader Nicholas A. Bellinger
2015-03-29 6:38 ` Sagi Grimberg
2015-03-27 8:04 ` Nicholas A. Bellinger [this message]
2015-03-29 6:51 ` [RFC 02/22] target: Convert enable/disable ->device_list to RCU updater Sagi Grimberg
2015-03-27 8:04 ` [RFC 03/22] target/device: Convert se_node_acl->device_list access to RCU reader Nicholas A. Bellinger
2015-03-27 8:04 ` [RFC 04/22] target/configfs: Convert mappedlun link/unlink " Nicholas A. Bellinger
2015-03-27 8:04 ` [RFC 05/22] target/configfs: Convert SCSI MIB attrs " Nicholas A. Bellinger
2015-03-27 8:04 ` [RFC 06/22] target/spc: Convert REPORT_LUN + MODE_SENSE " Nicholas A. Bellinger
2015-03-27 8:04 ` [RFC 07/22] target/pscsi: Convert MODE_SENSE special case " Nicholas A. Bellinger
2015-03-27 8:04 ` [RFC 08/22] target/pr: Convert se_dev_entry to percpu-refcount for RCU Nicholas A. Bellinger
2015-03-27 8:04 ` [RFC 09/22] target/pr: Convert registration check to RCU pointer Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 10/22] target/pr: Change alloc_registration to avoid pr_reg_tg_pt_lun Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 11/22] target: Convert UNIT_ATTENTION logic to RCU reader Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 12/22] target: Convert se_tpg->tpg_lun_lock to ->tpg_lun_mutex Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 13/22] target: Convert se_tpg->acl_node_lock to ->acl_node_mutex Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 14/22] target: Convert se_node_acl->lun_entry_lock to ->lun_entry_mutex Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 15/22] target: Convert core_tpg_deregister to use list splice Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 16/22] target: Drop se_lun->lun_acl_list Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 17/22] target: Drop core_tpg_clear_object_luns Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 18/22] target: Rename TPG initiator_node_acl to target_* prefix Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 19/22] target: Rename TPG register/deregister " Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 20/22] target: Rename LUN lookup/add/remove " Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 21/22] target: Rename se_node_acl->lun_entry_hlist " Nicholas A. Bellinger
2015-03-27 8:05 ` [RFC 22/22] target: Rename se_port/se_device export " Nicholas A. Bellinger
2015-03-30 12:08 ` [RFC 00/22] target: se_node_acl LUN list RCU conversion Christoph Hellwig
2015-03-30 19:16 ` Andy Grover
2015-03-30 19:21 ` Christoph Hellwig
2015-03-30 19:35 ` Andy Grover
2015-03-31 9:23 ` Christoph Hellwig
2015-04-01 6:51 ` Nicholas A. Bellinger
2015-04-01 7:04 ` Christoph Hellwig
2015-04-02 5:37 ` Nicholas A. Bellinger
2015-04-02 8:56 ` Christoph Hellwig
2015-04-02 20:57 ` Nicholas A. Bellinger
2015-04-07 6:17 ` Christoph Hellwig
2015-04-08 6:31 ` Nicholas A. Bellinger
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=1427443512-8925-3-git-send-email-nab@daterainc.com \
--to=nab@daterainc.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=sagig@mellanox.com \
--cc=target-devel@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;
as well as URLs for NNTP newsgroup(s).