Commit bc118fe4c4a8cfa453491ba77c0a146a6d0e73e0
Committed by
Nicholas Bellinger
1 parent
51d9c41d19
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 20 additions and 26 deletions Side-by-side Diff
drivers/target/target_core_pr.c
... | ... | @@ -1995,18 +1995,18 @@ |
1995 | 1995 | |
1996 | 1996 | static sense_reason_t |
1997 | 1997 | core_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 | 2000 | struct se_session *se_sess = cmd->se_sess; |
2001 | 2001 | struct se_device *dev = cmd->se_dev; |
2002 | 2002 | struct se_dev_entry *se_deve; |
2003 | 2003 | struct se_lun *se_lun = cmd->se_lun; |
2004 | 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 | 2006 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
2007 | 2007 | unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; |
2008 | 2008 | sense_reason_t ret = TCM_NO_SENSE; |
2009 | - int pr_holder = 0, type; | |
2009 | + int pr_holder = 0; | |
2010 | 2010 | |
2011 | 2011 | if (!se_sess || !se_lun) { |
2012 | 2012 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); |
... | ... | @@ -2024,8 +2024,8 @@ |
2024 | 2024 | /* |
2025 | 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); | |
2028 | - if (!pr_reg_e) { | |
2027 | + pr_reg = core_scsi3_locate_pr_reg(dev, se_sess->se_node_acl, se_sess); | |
2028 | + if (!pr_reg) { | |
2029 | 2029 | if (res_key) { |
2030 | 2030 | pr_warn("SPC-3 PR: Reservation Key non-zero" |
2031 | 2031 | " for SA REGISTER, returning CONFLICT\n"); |
2032 | 2032 | |
2033 | 2033 | |
... | ... | @@ -2069,29 +2069,23 @@ |
2069 | 2069 | return core_scsi3_update_and_write_aptpl(dev, aptpl); |
2070 | 2070 | } |
2071 | 2071 | |
2072 | - /* | |
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; | |
2072 | + /* ok, existing registration */ | |
2077 | 2073 | |
2078 | - if (register_type == REGISTER) { | |
2079 | - if (res_key != pr_reg->pr_res_key) { | |
2080 | - pr_err("SPC-3 PR REGISTER: Received" | |
2081 | - " res_key: 0x%016Lx does not match" | |
2082 | - " existing SA REGISTER res_key:" | |
2083 | - " 0x%016Lx\n", res_key, | |
2084 | - pr_reg->pr_res_key); | |
2085 | - ret = TCM_RESERVATION_CONFLICT; | |
2086 | - goto out_put_pr_reg; | |
2087 | - } | |
2074 | + if ((register_type == REGISTER) && (res_key != pr_reg->pr_res_key)) { | |
2075 | + pr_err("SPC-3 PR REGISTER: Received" | |
2076 | + " res_key: 0x%016Lx does not match" | |
2077 | + " existing SA REGISTER res_key:" | |
2078 | + " 0x%016Lx\n", res_key, | |
2079 | + pr_reg->pr_res_key); | |
2080 | + ret = TCM_RESERVATION_CONFLICT; | |
2081 | + goto out; | |
2088 | 2082 | } |
2089 | 2083 | |
2090 | 2084 | if (spec_i_pt) { |
2091 | 2085 | pr_err("SPC-3 PR REGISTER: SPEC_I_PT" |
2092 | 2086 | " set on a registered nexus\n"); |
2093 | 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 @@ |
2103 | 2097 | " registration exists, but ALL_TG_PT=1 bit not" |
2104 | 2098 | " present in received PROUT\n"); |
2105 | 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 @@ |
2132 | 2126 | cmd->se_dev, pr_reg); |
2133 | 2127 | if (pr_holder < 0) { |
2134 | 2128 | ret = TCM_RESERVATION_CONFLICT; |
2135 | - goto out_put_pr_reg; | |
2129 | + goto out; | |
2136 | 2130 | } |
2137 | 2131 | |
2138 | 2132 | spin_lock(&pr_tmpl->registration_lock); |
... | ... | @@ -2177,8 +2171,8 @@ |
2177 | 2171 | * RESERVATIONS RELEASED. |
2178 | 2172 | */ |
2179 | 2173 | if (pr_holder && |
2180 | - (type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY || | |
2181 | - type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY)) { | |
2174 | + (pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY || | |
2175 | + pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY)) { | |
2182 | 2176 | list_for_each_entry(pr_reg_p, |
2183 | 2177 | &pr_tmpl->registration_list, |
2184 | 2178 | pr_reg_list) { |
... | ... | @@ -2196,7 +2190,7 @@ |
2196 | 2190 | |
2197 | 2191 | ret = core_scsi3_update_and_write_aptpl(dev, aptpl); |
2198 | 2192 | |
2199 | -out_put_pr_reg: | |
2193 | +out: | |
2200 | 2194 | core_scsi3_put_pr_reg(pr_reg); |
2201 | 2195 | return ret; |
2202 | 2196 | } |