From: "Nicholas A. Bellinger" <nab@daterainc.com>
To: target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Hannes Reinecke <hare@suse.de>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagig@mellanox.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH-v2 4/9] target/pr: cleanup core_scsi3_pr_seq_non_holder
Date: Fri, 22 May 2015 06:11:06 +0000 [thread overview]
Message-ID: <1432275071-28882-5-git-send-email-nab@daterainc.com> (raw)
In-Reply-To: <1432275071-28882-1-git-send-email-nab@daterainc.com>
From: Christoph Hellwig <hch@lst.de>
Clean up the mess of registered variables, and pass the isid mismatch
flag explicitly instead of overloading the registration type.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
drivers/target/target_core_pr.c | 43 ++++++++++++++++-------------------------
1 file changed, 17 insertions(+), 26 deletions(-)
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 94a136f..36bcc60 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -312,34 +312,30 @@ out:
* This function is called by those initiator ports who are *NOT*
* the active PR reservation holder when a reservation is present.
*/
-static int core_scsi3_pr_seq_non_holder(
- struct se_cmd *cmd,
- u32 pr_reg_type)
+static int core_scsi3_pr_seq_non_holder(struct se_cmd *cmd, u32 pr_reg_type,
+ bool isid_mismatch)
{
unsigned char *cdb = cmd->t_task_cdb;
- struct se_dev_entry *se_deve;
struct se_session *se_sess = cmd->se_sess;
struct se_node_acl *nacl = se_sess->se_node_acl;
- int other_cdb = 0, ignore_reg;
+ int other_cdb = 0;
int registered_nexus = 0, ret = 1; /* Conflict by default */
int all_reg = 0, reg_only = 0; /* ALL_REG, REG_ONLY */
int we = 0; /* Write Exclusive */
int legacy = 0; /* Act like a legacy device and return
* RESERVATION CONFLICT on some CDBs */
- bool registered = false;
- rcu_read_lock();
- se_deve = target_nacl_find_deve(nacl, cmd->orig_fe_lun);
- if (se_deve)
- registered = test_bit(1, &se_deve->pr_reg);
- rcu_read_unlock();
- /*
- * Determine if the registration should be ignored due to
- * non-matching ISIDs in target_scsi3_pr_reservation_check().
- */
- ignore_reg = (pr_reg_type & 0x80000000);
- if (ignore_reg)
- pr_reg_type &= ~0x80000000;
+ if (isid_mismatch) {
+ registered_nexus = 0;
+ } else {
+ struct se_dev_entry *se_deve;
+
+ rcu_read_lock();
+ se_deve = target_nacl_find_deve(nacl, cmd->orig_fe_lun);
+ if (se_deve)
+ registered_nexus = test_bit(1, &se_deve->pr_reg);
+ rcu_read_unlock();
+ }
switch (pr_reg_type) {
case PR_TYPE_WRITE_EXCLUSIVE:
@@ -349,8 +345,6 @@ static int core_scsi3_pr_seq_non_holder(
* Some commands are only allowed for the persistent reservation
* holder.
*/
- if ((registered) && !(ignore_reg))
- registered_nexus = 1;
break;
case PR_TYPE_WRITE_EXCLUSIVE_REGONLY:
we = 1;
@@ -359,8 +353,6 @@ static int core_scsi3_pr_seq_non_holder(
* Some commands are only allowed for registered I_T Nexuses.
*/
reg_only = 1;
- if ((registered) && !(ignore_reg))
- registered_nexus = 1;
break;
case PR_TYPE_WRITE_EXCLUSIVE_ALLREG:
we = 1;
@@ -369,8 +361,6 @@ static int core_scsi3_pr_seq_non_holder(
* Each registered I_T Nexus is a reservation holder.
*/
all_reg = 1;
- if ((registered) && !(ignore_reg))
- registered_nexus = 1;
break;
default:
return -EINVAL;
@@ -576,6 +566,7 @@ target_scsi3_pr_reservation_check(struct se_cmd *cmd)
struct se_device *dev = cmd->se_dev;
struct se_session *sess = cmd->se_sess;
u32 pr_reg_type;
+ bool isid_mismatch = false;
if (!dev->dev_pr_res_holder)
return 0;
@@ -588,7 +579,7 @@ target_scsi3_pr_reservation_check(struct se_cmd *cmd)
if (dev->dev_pr_res_holder->isid_present_at_reg) {
if (dev->dev_pr_res_holder->pr_reg_bin_isid !=
sess->sess_bin_isid) {
- pr_reg_type |= 0x80000000;
+ isid_mismatch = true;
goto check_nonholder;
}
}
@@ -596,7 +587,7 @@ target_scsi3_pr_reservation_check(struct se_cmd *cmd)
return 0;
check_nonholder:
- if (core_scsi3_pr_seq_non_holder(cmd, pr_reg_type))
+ if (core_scsi3_pr_seq_non_holder(cmd, pr_reg_type, isid_mismatch))
return TCM_RESERVATION_CONFLICT;
return 0;
}
--
1.9.1
next prev parent reply other threads:[~2015-05-22 6:14 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 6:11 [PATCH-v2 0/9] target: se_node_acl + se_lun RCU conversions Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 1/9] target: Convert se_node_acl->device_list[] to RCU hlist Nicholas A. Bellinger
2015-05-22 8:24 ` Christoph Hellwig
2015-05-22 8:55 ` Nicholas A. Bellinger
2015-05-22 11:31 ` Christoph Hellwig
2015-05-25 22:14 ` Nicholas A. Bellinger
2015-05-26 4:11 ` Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 2/9] target/pr: Use atomic bitop for se_dev_entry->pr_reg reservation check Nicholas A. Bellinger
2015-05-22 8:26 ` Christoph Hellwig
2015-05-22 9:05 ` Nicholas A. Bellinger
2015-05-22 11:34 ` Christoph Hellwig
2015-05-25 22:25 ` Nicholas A. Bellinger
2015-05-22 10:12 ` Bart Van Assche
2015-05-25 21:59 ` Nicholas A. Bellinger
2015-05-22 11:52 ` Christoph Hellwig
2015-05-25 22:54 ` Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 3/9] target/pr: Change alloc_registration to avoid pr_reg_tg_pt_lun Nicholas A. Bellinger
2015-05-22 6:11 ` Nicholas A. Bellinger [this message]
2015-05-22 8:26 ` [PATCH-v2 4/9] target/pr: cleanup core_scsi3_pr_seq_non_holder Christoph Hellwig
2015-05-22 6:11 ` [PATCH-v2 5/9] target: Convert se_portal_group->tpg_lun_list[] to RCU hlist Nicholas A. Bellinger
2015-05-22 8:31 ` Christoph Hellwig
2015-05-22 8:48 ` Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 6/9] target: Convert se_tpg->acl_node_lock to ->acl_node_mutex Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 7/9] target: Convert core_tpg_deregister to use list splice Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 8/9] target: Drop unused se_lun->lun_acl_list Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 9/9] target: Only reset specific dynamic entries during lun_group creation Nicholas A. Bellinger
2015-05-22 6:23 ` [PATCH-v2 0/9] target: se_node_acl + se_lun RCU conversions Hannes Reinecke
2015-05-22 8:07 ` Christoph Hellwig
2015-05-22 8:18 ` Nicholas A. Bellinger
2015-05-22 10:15 ` Bart Van Assche
2015-05-25 22:01 ` 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=1432275071-28882-5-git-send-email-nab@daterainc.com \
--to=nab@daterainc.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--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
all inboxes | Powered by JetHome®