aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2013-05-16 13:41:04 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2013-06-14 03:05:48 -0400
commitbc118fe4c4a8cfa453491ba77c0a146a6d0e73e0 (patch)
treec8d463b373a76b3f86c0c9b64d9a79a510172f91 /drivers/target
parent51d9c41d190b6645c69a279b0610aad8e4ed9d72 (diff)
target: Further refactoring of core_scsi3_emulate_pro_register()
Use bool params when appropriate. Eliminate unneeded pr_reg_e and type variables. Just one goto label, so rename to 'out' from 'out_put_pr_reg'. Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_pr.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 6eb0dabb4ac9..05c3f426728a 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -1995,18 +1995,18 @@ static int core_scsi3_update_and_write_aptpl(struct se_device *dev, bool aptpl)
1995 1995
1996static sense_reason_t 1996static sense_reason_t
1997core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, 1997core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key,
1998 int aptpl, int all_tg_pt, int spec_i_pt, enum register_type register_type) 1998 bool aptpl, bool all_tg_pt, bool spec_i_pt, enum register_type register_type)
1999{ 1999{
2000 struct se_session *se_sess = cmd->se_sess; 2000 struct se_session *se_sess = cmd->se_sess;
2001 struct se_device *dev = cmd->se_dev; 2001 struct se_device *dev = cmd->se_dev;
2002 struct se_dev_entry *se_deve; 2002 struct se_dev_entry *se_deve;
2003 struct se_lun *se_lun = cmd->se_lun; 2003 struct se_lun *se_lun = cmd->se_lun;
2004 struct se_portal_group *se_tpg; 2004 struct se_portal_group *se_tpg;
2005 struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp, *pr_reg_e; 2005 struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp;
2006 struct t10_reservation *pr_tmpl = &dev->t10_pr; 2006 struct t10_reservation *pr_tmpl = &dev->t10_pr;
2007 unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; 2007 unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL;
2008 sense_reason_t ret = TCM_NO_SENSE; 2008 sense_reason_t ret = TCM_NO_SENSE;
2009 int pr_holder = 0, type; 2009 int pr_holder = 0;
2010 2010
2011 if (!se_sess || !se_lun) { 2011 if (!se_sess || !se_lun) {
2012 pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); 2012 pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n");
@@ -2024,8 +2024,8 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key,
2024 /* 2024 /*
2025 * Follow logic from spc4r17 Section 5.7.7, Register Behaviors Table 47 2025 * Follow logic from spc4r17 Section 5.7.7, Register Behaviors Table 47
2026 */ 2026 */
2027 pr_reg_e = core_scsi3_locate_pr_reg(dev, se_sess->se_node_acl, se_sess); 2027 pr_reg = core_scsi3_locate_pr_reg(dev, se_sess->se_node_acl, se_sess);
2028 if (!pr_reg_e) { 2028 if (!pr_reg) {
2029 if (res_key) { 2029 if (res_key) {
2030 pr_warn("SPC-3 PR: Reservation Key non-zero" 2030 pr_warn("SPC-3 PR: Reservation Key non-zero"
2031 " for SA REGISTER, returning CONFLICT\n"); 2031 " for SA REGISTER, returning CONFLICT\n");
@@ -2069,29 +2069,23 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key,
2069 return core_scsi3_update_and_write_aptpl(dev, aptpl); 2069 return core_scsi3_update_and_write_aptpl(dev, aptpl);
2070 } 2070 }
2071 2071
2072 /* 2072 /* ok, existing registration */
2073 * Locate the existing *pr_reg via struct se_node_acl pointers
2074 */
2075 pr_reg = pr_reg_e;
2076 type = pr_reg->pr_res_type;
2077 2073
2078 if (register_type == REGISTER) { 2074 if ((register_type == REGISTER) && (res_key != pr_reg->pr_res_key)) {
2079 if (res_key != pr_reg->pr_res_key) { 2075 pr_err("SPC-3 PR REGISTER: Received"
2080 pr_err("SPC-3 PR REGISTER: Received" 2076 " res_key: 0x%016Lx does not match"
2081 " res_key: 0x%016Lx does not match" 2077 " existing SA REGISTER res_key:"
2082 " existing SA REGISTER res_key:" 2078 " 0x%016Lx\n", res_key,
2083 " 0x%016Lx\n", res_key, 2079 pr_reg->pr_res_key);
2084 pr_reg->pr_res_key); 2080 ret = TCM_RESERVATION_CONFLICT;
2085 ret = TCM_RESERVATION_CONFLICT; 2081 goto out;
2086 goto out_put_pr_reg;
2087 }
2088 } 2082 }
2089 2083
2090 if (spec_i_pt) { 2084 if (spec_i_pt) {
2091 pr_err("SPC-3 PR REGISTER: SPEC_I_PT" 2085 pr_err("SPC-3 PR REGISTER: SPEC_I_PT"
2092 " set on a registered nexus\n"); 2086 " set on a registered nexus\n");
2093 ret = TCM_INVALID_PARAMETER_LIST; 2087 ret = TCM_INVALID_PARAMETER_LIST;
2094 goto out_put_pr_reg; 2088 goto out;
2095 } 2089 }
2096 2090
2097 /* 2091 /*
@@ -2103,7 +2097,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key,
2103 " registration exists, but ALL_TG_PT=1 bit not" 2097 " registration exists, but ALL_TG_PT=1 bit not"
2104 " present in received PROUT\n"); 2098 " present in received PROUT\n");
2105 ret = TCM_INVALID_CDB_FIELD; 2099 ret = TCM_INVALID_CDB_FIELD;
2106 goto out_put_pr_reg; 2100 goto out;
2107 } 2101 }
2108 2102
2109 /* 2103 /*
@@ -2132,7 +2126,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key,
2132 cmd->se_dev, pr_reg); 2126 cmd->se_dev, pr_reg);
2133 if (pr_holder < 0) { 2127 if (pr_holder < 0) {
2134 ret = TCM_RESERVATION_CONFLICT; 2128 ret = TCM_RESERVATION_CONFLICT;
2135 goto out_put_pr_reg; 2129 goto out;
2136 } 2130 }
2137 2131
2138 spin_lock(&pr_tmpl->registration_lock); 2132 spin_lock(&pr_tmpl->registration_lock);
@@ -2177,8 +2171,8 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key,
2177 * RESERVATIONS RELEASED. 2171 * RESERVATIONS RELEASED.
2178 */ 2172 */
2179 if (pr_holder && 2173 if (pr_holder &&
2180 (type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY || 2174 (pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY ||
2181 type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY)) { 2175 pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY)) {
2182 list_for_each_entry(pr_reg_p, 2176 list_for_each_entry(pr_reg_p,
2183 &pr_tmpl->registration_list, 2177 &pr_tmpl->registration_list,
2184 pr_reg_list) { 2178 pr_reg_list) {
@@ -2196,7 +2190,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key,
2196 2190
2197 ret = core_scsi3_update_and_write_aptpl(dev, aptpl); 2191 ret = core_scsi3_update_and_write_aptpl(dev, aptpl);
2198 2192
2199out_put_pr_reg: 2193out:
2200 core_scsi3_put_pr_reg(pr_reg); 2194 core_scsi3_put_pr_reg(pr_reg);
2201 return ret; 2195 return ret;
2202} 2196}