hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/target/target_core_pr.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*******************************************************************************
23 * Filename: target_core_pr.c
34 *
....@@ -7,20 +8,6 @@
78 * (c) Copyright 2009-2013 Datera, Inc.
89 *
910 * Nicholas A. Bellinger <nab@kernel.org>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; either version 2 of the License, or
14
- * (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to the Free Software
23
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2411 *
2512 ******************************************************************************/
2613
....@@ -111,10 +98,10 @@
11198 break;
11299 }
113100
114
- if (!dev->dev_reserved_node_acl || !sess)
101
+ if (!dev->reservation_holder || !sess)
115102 return 0;
116103
117
- if (dev->dev_reserved_node_acl != sess->se_node_acl)
104
+ if (dev->reservation_holder->se_node_acl != sess->se_node_acl)
118105 return TCM_RESERVATION_CONFLICT;
119106
120107 if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS_WITH_ISID) {
....@@ -200,6 +187,16 @@
200187 return 0;
201188 }
202189
190
+void target_release_reservation(struct se_device *dev)
191
+{
192
+ dev->reservation_holder = NULL;
193
+ dev->dev_reservation_flags &= ~DRF_SPC2_RESERVATIONS;
194
+ if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS_WITH_ISID) {
195
+ dev->dev_res_bin_isid = 0;
196
+ dev->dev_reservation_flags &= ~DRF_SPC2_RESERVATIONS_WITH_ISID;
197
+ }
198
+}
199
+
203200 sense_reason_t
204201 target_scsi2_reservation_release(struct se_cmd *cmd)
205202 {
....@@ -217,25 +214,20 @@
217214 return TCM_RESERVATION_CONFLICT;
218215
219216 spin_lock(&dev->dev_reservation_lock);
220
- if (!dev->dev_reserved_node_acl || !sess)
217
+ if (!dev->reservation_holder || !sess)
221218 goto out_unlock;
222219
223
- if (dev->dev_reserved_node_acl != sess->se_node_acl)
220
+ if (dev->reservation_holder->se_node_acl != sess->se_node_acl)
224221 goto out_unlock;
225222
226223 if (dev->dev_res_bin_isid != sess->sess_bin_isid)
227224 goto out_unlock;
228225
229
- dev->dev_reserved_node_acl = NULL;
230
- dev->dev_reservation_flags &= ~DRF_SPC2_RESERVATIONS;
231
- if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS_WITH_ISID) {
232
- dev->dev_res_bin_isid = 0;
233
- dev->dev_reservation_flags &= ~DRF_SPC2_RESERVATIONS_WITH_ISID;
234
- }
226
+ target_release_reservation(dev);
235227 tpg = sess->se_tpg;
236228 pr_debug("SCSI-2 Released reservation for %s LUN: %llu ->"
237229 " MAPPED LUN: %llu for %s\n",
238
- tpg->se_tpg_tfo->get_fabric_name(),
230
+ tpg->se_tpg_tfo->fabric_name,
239231 cmd->se_lun->unpacked_lun, cmd->orig_fe_lun,
240232 sess->se_node_acl->initiatorname);
241233
....@@ -275,13 +267,13 @@
275267
276268 tpg = sess->se_tpg;
277269 spin_lock(&dev->dev_reservation_lock);
278
- if (dev->dev_reserved_node_acl &&
279
- (dev->dev_reserved_node_acl != sess->se_node_acl)) {
270
+ if (dev->reservation_holder &&
271
+ dev->reservation_holder->se_node_acl != sess->se_node_acl) {
280272 pr_err("SCSI-2 RESERVATION CONFLIFT for %s fabric\n",
281
- tpg->se_tpg_tfo->get_fabric_name());
273
+ tpg->se_tpg_tfo->fabric_name);
282274 pr_err("Original reserver LUN: %llu %s\n",
283275 cmd->se_lun->unpacked_lun,
284
- dev->dev_reserved_node_acl->initiatorname);
276
+ dev->reservation_holder->se_node_acl->initiatorname);
285277 pr_err("Current attempt - LUN: %llu -> MAPPED LUN: %llu"
286278 " from %s \n", cmd->se_lun->unpacked_lun,
287279 cmd->orig_fe_lun,
....@@ -290,14 +282,14 @@
290282 goto out_unlock;
291283 }
292284
293
- dev->dev_reserved_node_acl = sess->se_node_acl;
285
+ dev->reservation_holder = sess;
294286 dev->dev_reservation_flags |= DRF_SPC2_RESERVATIONS;
295287 if (sess->sess_bin_isid != 0) {
296288 dev->dev_res_bin_isid = sess->sess_bin_isid;
297289 dev->dev_reservation_flags |= DRF_SPC2_RESERVATIONS_WITH_ISID;
298290 }
299291 pr_debug("SCSI-2 Reserved %s LUN: %llu -> MAPPED LUN: %llu"
300
- " for %s\n", tpg->se_tpg_tfo->get_fabric_name(),
292
+ " for %s\n", tpg->se_tpg_tfo->fabric_name,
301293 cmd->se_lun->unpacked_lun, cmd->orig_fe_lun,
302294 sess->se_node_acl->initiatorname);
303295
....@@ -353,7 +345,7 @@
353345 break;
354346 case PR_TYPE_WRITE_EXCLUSIVE_REGONLY:
355347 we = 1;
356
- /* fall through */
348
+ fallthrough;
357349 case PR_TYPE_EXCLUSIVE_ACCESS_REGONLY:
358350 /*
359351 * Some commands are only allowed for registered I_T Nexuses.
....@@ -362,7 +354,7 @@
362354 break;
363355 case PR_TYPE_WRITE_EXCLUSIVE_ALLREG:
364356 we = 1;
365
- /* fall through */
357
+ fallthrough;
366358 case PR_TYPE_EXCLUSIVE_ACCESS_ALLREG:
367359 /*
368360 * Each registered I_T Nexus is a reservation holder.
....@@ -914,11 +906,11 @@
914906
915907 pr_debug("SPC-3 PR [%s] Service Action: APTPL RESERVE created"
916908 " new reservation holder TYPE: %s ALL_TG_PT: %d\n",
917
- tpg->se_tpg_tfo->get_fabric_name(),
909
+ tpg->se_tpg_tfo->fabric_name,
918910 core_scsi3_pr_dump_type(pr_reg->pr_res_type),
919911 (pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
920912 pr_debug("SPC-3 PR [%s] RESERVE Node: %s%s\n",
921
- tpg->se_tpg_tfo->get_fabric_name(), node_acl->initiatorname,
913
+ tpg->se_tpg_tfo->fabric_name, node_acl->initiatorname,
922914 i_buf);
923915 }
924916
....@@ -1036,19 +1028,19 @@
10361028 core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
10371029
10381030 pr_debug("SPC-3 PR [%s] Service Action: REGISTER%s Initiator"
1039
- " Node: %s%s\n", tfo->get_fabric_name(), (register_type == REGISTER_AND_MOVE) ?
1031
+ " Node: %s%s\n", tfo->fabric_name, (register_type == REGISTER_AND_MOVE) ?
10401032 "_AND_MOVE" : (register_type == REGISTER_AND_IGNORE_EXISTING_KEY) ?
10411033 "_AND_IGNORE_EXISTING_KEY" : "", nacl->initiatorname,
10421034 i_buf);
10431035 pr_debug("SPC-3 PR [%s] registration on Target Port: %s,0x%04x\n",
1044
- tfo->get_fabric_name(), tfo->tpg_get_wwn(se_tpg),
1036
+ tfo->fabric_name, tfo->tpg_get_wwn(se_tpg),
10451037 tfo->tpg_get_tag(se_tpg));
10461038 pr_debug("SPC-3 PR [%s] for %s TCM Subsystem %s Object Target"
1047
- " Port(s)\n", tfo->get_fabric_name(),
1039
+ " Port(s)\n", tfo->fabric_name,
10481040 (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE",
10491041 dev->transport->name);
10501042 pr_debug("SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:"
1051
- " 0x%08x APTPL: %d\n", tfo->get_fabric_name(),
1043
+ " 0x%08x APTPL: %d\n", tfo->fabric_name,
10521044 pr_reg->pr_res_key, pr_reg->pr_res_generation,
10531045 pr_reg->pr_reg_aptpl);
10541046 }
....@@ -1167,7 +1159,6 @@
11671159 {
11681160 struct t10_reservation *pr_tmpl = &dev->t10_pr;
11691161 struct t10_pr_registration *pr_reg, *pr_reg_tmp;
1170
- struct se_portal_group *tpg;
11711162
11721163 spin_lock(&pr_tmpl->registration_lock);
11731164 list_for_each_entry_safe(pr_reg, pr_reg_tmp,
....@@ -1178,21 +1169,11 @@
11781169 if (pr_reg->pr_reg_nacl != nacl)
11791170 continue;
11801171
1181
- tpg = pr_reg->pr_reg_nacl->se_tpg;
11821172 /*
11831173 * If this registration does NOT contain a fabric provided
11841174 * ISID, then we have found a match.
11851175 */
11861176 if (!pr_reg->isid_present_at_reg) {
1187
- /*
1188
- * Determine if this SCSI device server requires that
1189
- * SCSI Intiatior TransportID w/ ISIDs is enforced
1190
- * for fabric modules (iSCSI) requiring them.
1191
- */
1192
- if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) {
1193
- if (dev->dev_attrib.enforce_pr_isids)
1194
- continue;
1195
- }
11961177 atomic_inc_mb(&pr_reg->pr_res_holders);
11971178 spin_unlock(&pr_tmpl->registration_lock);
11981179 return pr_reg;
....@@ -1290,9 +1271,6 @@
12901271 return ret;
12911272 }
12921273
1293
-/*
1294
- * Called with struct t10_reservation->registration_lock held.
1295
- */
12961274 static void __core_scsi3_free_registration(
12971275 struct se_device *dev,
12981276 struct t10_pr_registration *pr_reg,
....@@ -1307,6 +1285,8 @@
13071285 struct se_node_acl *nacl = pr_reg->pr_reg_nacl;
13081286 struct se_dev_entry *deve;
13091287 char i_buf[PR_REG_ISID_ID_LEN];
1288
+
1289
+ lockdep_assert_held(&pr_tmpl->registration_lock);
13101290
13111291 memset(i_buf, 0, PR_REG_ISID_ID_LEN);
13121292 core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
....@@ -1329,7 +1309,7 @@
13291309 */
13301310 while (atomic_read(&pr_reg->pr_res_holders) != 0) {
13311311 pr_debug("SPC-3 PR [%s] waiting for pr_res_holders\n",
1332
- tfo->get_fabric_name());
1312
+ tfo->fabric_name);
13331313 cpu_relax();
13341314 }
13351315
....@@ -1341,15 +1321,15 @@
13411321
13421322 spin_lock(&pr_tmpl->registration_lock);
13431323 pr_debug("SPC-3 PR [%s] Service Action: UNREGISTER Initiator"
1344
- " Node: %s%s\n", tfo->get_fabric_name(),
1324
+ " Node: %s%s\n", tfo->fabric_name,
13451325 pr_reg->pr_reg_nacl->initiatorname,
13461326 i_buf);
13471327 pr_debug("SPC-3 PR [%s] for %s TCM Subsystem %s Object Target"
1348
- " Port(s)\n", tfo->get_fabric_name(),
1328
+ " Port(s)\n", tfo->fabric_name,
13491329 (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE",
13501330 dev->transport->name);
13511331 pr_debug("SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:"
1352
- " 0x%08x\n", tfo->get_fabric_name(), pr_reg->pr_res_key,
1332
+ " 0x%08x\n", tfo->fabric_name, pr_reg->pr_res_key,
13531333 pr_reg->pr_res_generation);
13541334
13551335 if (!preempt_and_abort_list) {
....@@ -1539,13 +1519,16 @@
15391519 kfree(tidh_new);
15401520 return TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
15411521 }
1522
+
1523
+ if (core_scsi3_lunacl_depend_item(local_pr_reg->pr_reg_deve)) {
1524
+ kfree(tidh_new);
1525
+ kref_put(&local_pr_reg->pr_reg_deve->pr_kref,
1526
+ target_pr_kref_release);
1527
+ kmem_cache_free(t10_pr_reg_cache, local_pr_reg);
1528
+ return TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
1529
+ }
1530
+
15421531 tidh_new->dest_pr_reg = local_pr_reg;
1543
- /*
1544
- * The local I_T nexus does not hold any configfs dependances,
1545
- * so we set tidh_new->dest_se_deve to NULL to prevent the
1546
- * configfs_undepend_item() calls in the tid_dest_list loops below.
1547
- */
1548
- tidh_new->dest_se_deve = NULL;
15491532 list_add_tail(&tidh_new->dest_list, &tid_dest_list);
15501533
15511534 if (cmd->data_length < 28) {
....@@ -1600,10 +1583,25 @@
16001583 continue;
16011584 dest_rtpi = tmp_lun->lun_rtpi;
16021585
1586
+ iport_ptr = NULL;
16031587 i_str = target_parse_pr_out_transport_id(tmp_tpg,
16041588 ptr, &tid_len, &iport_ptr);
16051589 if (!i_str)
16061590 continue;
1591
+ /*
1592
+ * Determine if this SCSI device server requires that
1593
+ * SCSI Intiatior TransportID w/ ISIDs is enforced
1594
+ * for fabric modules (iSCSI) requiring them.
1595
+ */
1596
+ if (tpg->se_tpg_tfo->sess_get_initiator_sid &&
1597
+ dev->dev_attrib.enforce_pr_isids &&
1598
+ !iport_ptr) {
1599
+ pr_warn("SPC-PR: enforce_pr_isids is set but a isid has not been sent in the SPEC_I_PT data for %s.",
1600
+ i_str);
1601
+ ret = TCM_INVALID_PARAMETER_LIST;
1602
+ spin_unlock(&dev->se_port_lock);
1603
+ goto out_unmap;
1604
+ }
16071605
16081606 atomic_inc_mb(&tmp_tpg->tpg_pr_ref_count);
16091607 spin_unlock(&dev->se_port_lock);
....@@ -1645,7 +1643,7 @@
16451643 dest_tpg = tmp_tpg;
16461644 pr_debug("SPC-3 PR SPEC_I_PT: Located %s Node:"
16471645 " %s Port RTPI: %hu\n",
1648
- dest_tpg->se_tpg_tfo->get_fabric_name(),
1646
+ dest_tpg->se_tpg_tfo->fabric_name,
16491647 dest_node_acl->initiatorname, dest_rtpi);
16501648
16511649 spin_lock(&dev->se_port_lock);
....@@ -1662,7 +1660,7 @@
16621660
16631661 pr_debug("SPC-3 PR SPEC_I_PT: Got %s data_length: %u tpdl: %u"
16641662 " tid_len: %d for %s + %s\n",
1665
- dest_tpg->se_tpg_tfo->get_fabric_name(), cmd->data_length,
1663
+ dest_tpg->se_tpg_tfo->fabric_name, cmd->data_length,
16661664 tpdl, tid_len, i_str, iport_ptr);
16671665
16681666 if (tid_len > tpdl) {
....@@ -1683,7 +1681,7 @@
16831681 if (!dest_se_deve) {
16841682 pr_err("Unable to locate %s dest_se_deve"
16851683 " from destination RTPI: %hu\n",
1686
- dest_tpg->se_tpg_tfo->get_fabric_name(),
1684
+ dest_tpg->se_tpg_tfo->fabric_name,
16871685 dest_rtpi);
16881686
16891687 core_scsi3_nodeacl_undepend_item(dest_node_acl);
....@@ -1704,7 +1702,7 @@
17041702
17051703 pr_debug("SPC-3 PR SPEC_I_PT: Located %s Node: %s"
17061704 " dest_se_deve mapped_lun: %llu\n",
1707
- dest_tpg->se_tpg_tfo->get_fabric_name(),
1705
+ dest_tpg->se_tpg_tfo->fabric_name,
17081706 dest_node_acl->initiatorname, dest_se_deve->mapped_lun);
17091707
17101708 /*
....@@ -1815,16 +1813,13 @@
18151813
18161814 pr_debug("SPC-3 PR [%s] SPEC_I_PT: Successfully"
18171815 " registered Transport ID for Node: %s%s Mapped LUN:"
1818
- " %llu\n", dest_tpg->se_tpg_tfo->get_fabric_name(),
1816
+ " %llu\n", dest_tpg->se_tpg_tfo->fabric_name,
18191817 dest_node_acl->initiatorname, i_buf, (dest_se_deve) ?
18201818 dest_se_deve->mapped_lun : 0);
18211819
1822
- if (!dest_se_deve) {
1823
- kref_put(&local_pr_reg->pr_reg_deve->pr_kref,
1824
- target_pr_kref_release);
1820
+ if (dest_pr_reg == local_pr_reg)
18251821 continue;
1826
- }
1827
- core_scsi3_lunacl_undepend_item(dest_se_deve);
1822
+
18281823 core_scsi3_nodeacl_undepend_item(dest_node_acl);
18291824 core_scsi3_tpg_undepend_item(dest_tpg);
18301825 }
....@@ -1838,10 +1833,15 @@
18381833 * including *dest_pr_reg and the configfs dependances..
18391834 */
18401835 list_for_each_entry_safe(tidh, tidh_tmp, &tid_dest_list, dest_list) {
1836
+ bool is_local = false;
1837
+
18411838 dest_tpg = tidh->dest_tpg;
18421839 dest_node_acl = tidh->dest_node_acl;
18431840 dest_se_deve = tidh->dest_se_deve;
18441841 dest_pr_reg = tidh->dest_pr_reg;
1842
+
1843
+ if (dest_pr_reg == local_pr_reg)
1844
+ is_local = true;
18451845
18461846 list_del(&tidh->dest_list);
18471847 kfree(tidh);
....@@ -1858,13 +1858,11 @@
18581858 }
18591859
18601860 kmem_cache_free(t10_pr_reg_cache, dest_pr_reg);
1861
-
1862
- if (!dest_se_deve) {
1863
- kref_put(&local_pr_reg->pr_reg_deve->pr_kref,
1864
- target_pr_kref_release);
1865
- continue;
1866
- }
18671861 core_scsi3_lunacl_undepend_item(dest_se_deve);
1862
+
1863
+ if (is_local)
1864
+ continue;
1865
+
18681866 core_scsi3_nodeacl_undepend_item(dest_node_acl);
18691867 core_scsi3_tpg_undepend_item(dest_tpg);
18701868 }
....@@ -1913,7 +1911,7 @@
19131911 "res_holder=1\nres_type=%02x\n"
19141912 "res_scope=%02x\nres_all_tg_pt=%d\n"
19151913 "mapped_lun=%llu\n", reg_count,
1916
- tpg->se_tpg_tfo->get_fabric_name(),
1914
+ tpg->se_tpg_tfo->fabric_name,
19171915 pr_reg->pr_reg_nacl->initiatorname, isid_buf,
19181916 pr_reg->pr_res_key, pr_reg->pr_res_type,
19191917 pr_reg->pr_res_scope, pr_reg->pr_reg_all_tg_pt,
....@@ -1923,7 +1921,7 @@
19231921 "initiator_fabric=%s\ninitiator_node=%s\n%s"
19241922 "sa_res_key=%llu\nres_holder=0\n"
19251923 "res_all_tg_pt=%d\nmapped_lun=%llu\n",
1926
- reg_count, tpg->se_tpg_tfo->get_fabric_name(),
1924
+ reg_count, tpg->se_tpg_tfo->fabric_name,
19271925 pr_reg->pr_reg_nacl->initiatorname, isid_buf,
19281926 pr_reg->pr_res_key, pr_reg->pr_reg_all_tg_pt,
19291927 pr_reg->pr_res_mapped_lun);
....@@ -1942,7 +1940,7 @@
19421940 */
19431941 snprintf(tmp, 512, "target_fabric=%s\ntarget_node=%s\n"
19441942 "tpgt=%hu\nport_rtpi=%hu\ntarget_lun=%llu\nPR_REG_END:"
1945
- " %d\n", tpg->se_tpg_tfo->get_fabric_name(),
1943
+ " %d\n", tpg->se_tpg_tfo->fabric_name,
19461944 tpg->se_tpg_tfo->tpg_get_wwn(tpg),
19471945 tpg->se_tpg_tfo->tpg_get_tag(tpg),
19481946 pr_reg->tg_pt_sep_rtpi, pr_reg->pr_aptpl_target_lun,
....@@ -2168,7 +2166,7 @@
21682166 pr_reg->pr_res_key = sa_res_key;
21692167 pr_debug("SPC-3 PR [%s] REGISTER%s: Changed Reservation"
21702168 " Key for %s to: 0x%016Lx PRgeneration:"
2171
- " 0x%08x\n", cmd->se_tfo->get_fabric_name(),
2169
+ " 0x%08x\n", cmd->se_tfo->fabric_name,
21722170 (register_type == REGISTER_AND_IGNORE_EXISTING_KEY) ? "_AND_IGNORE_EXISTING_KEY" : "",
21732171 pr_reg->pr_reg_nacl->initiatorname,
21742172 pr_reg->pr_res_key, pr_reg->pr_res_generation);
....@@ -2356,9 +2354,9 @@
23562354 pr_err("SPC-3 PR: Attempted RESERVE from"
23572355 " [%s]: %s while reservation already held by"
23582356 " [%s]: %s, returning RESERVATION_CONFLICT\n",
2359
- cmd->se_tfo->get_fabric_name(),
2357
+ cmd->se_tfo->fabric_name,
23602358 se_sess->se_node_acl->initiatorname,
2361
- pr_res_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
2359
+ pr_res_nacl->se_tpg->se_tpg_tfo->fabric_name,
23622360 pr_res_holder->pr_reg_nacl->initiatorname);
23632361
23642362 spin_unlock(&dev->dev_reservation_lock);
....@@ -2379,9 +2377,9 @@
23792377 " [%s]: %s trying to change TYPE and/or SCOPE,"
23802378 " while reservation already held by [%s]: %s,"
23812379 " returning RESERVATION_CONFLICT\n",
2382
- cmd->se_tfo->get_fabric_name(),
2380
+ cmd->se_tfo->fabric_name,
23832381 se_sess->se_node_acl->initiatorname,
2384
- pr_res_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
2382
+ pr_res_nacl->se_tpg->se_tpg_tfo->fabric_name,
23852383 pr_res_holder->pr_reg_nacl->initiatorname);
23862384
23872385 spin_unlock(&dev->dev_reservation_lock);
....@@ -2414,10 +2412,10 @@
24142412
24152413 pr_debug("SPC-3 PR [%s] Service Action: RESERVE created new"
24162414 " reservation holder TYPE: %s ALL_TG_PT: %d\n",
2417
- cmd->se_tfo->get_fabric_name(), core_scsi3_pr_dump_type(type),
2415
+ cmd->se_tfo->fabric_name, core_scsi3_pr_dump_type(type),
24182416 (pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
24192417 pr_debug("SPC-3 PR [%s] RESERVE Node: %s%s\n",
2420
- cmd->se_tfo->get_fabric_name(),
2418
+ cmd->se_tfo->fabric_name,
24212419 se_sess->se_node_acl->initiatorname,
24222420 i_buf);
24232421 spin_unlock(&dev->dev_reservation_lock);
....@@ -2450,9 +2448,6 @@
24502448 }
24512449 }
24522450
2453
-/*
2454
- * Called with struct se_device->dev_reservation_lock held.
2455
- */
24562451 static void __core_scsi3_complete_pro_release(
24572452 struct se_device *dev,
24582453 struct se_node_acl *se_nacl,
....@@ -2463,6 +2458,8 @@
24632458 const struct target_core_fabric_ops *tfo = se_nacl->se_tpg->se_tpg_tfo;
24642459 char i_buf[PR_REG_ISID_ID_LEN];
24652460 int pr_res_type = 0, pr_res_scope = 0;
2461
+
2462
+ lockdep_assert_held(&dev->dev_reservation_lock);
24662463
24672464 memset(i_buf, 0, PR_REG_ISID_ID_LEN);
24682465 core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
....@@ -2506,12 +2503,12 @@
25062503 if (!dev->dev_pr_res_holder) {
25072504 pr_debug("SPC-3 PR [%s] Service Action: %s RELEASE cleared"
25082505 " reservation holder TYPE: %s ALL_TG_PT: %d\n",
2509
- tfo->get_fabric_name(), (explicit) ? "explicit" :
2506
+ tfo->fabric_name, (explicit) ? "explicit" :
25102507 "implicit", core_scsi3_pr_dump_type(pr_res_type),
25112508 (pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
25122509 }
25132510 pr_debug("SPC-3 PR [%s] RELEASE Node: %s%s\n",
2514
- tfo->get_fabric_name(), se_nacl->initiatorname,
2511
+ tfo->fabric_name, se_nacl->initiatorname,
25152512 i_buf);
25162513 /*
25172514 * Clear TYPE and SCOPE for the next PROUT Service Action: RESERVE
....@@ -2609,9 +2606,9 @@
26092606 " reservation from [%s]: %s with different TYPE "
26102607 "and/or SCOPE while reservation already held by"
26112608 " [%s]: %s, returning RESERVATION_CONFLICT\n",
2612
- cmd->se_tfo->get_fabric_name(),
2609
+ cmd->se_tfo->fabric_name,
26132610 se_sess->se_node_acl->initiatorname,
2614
- pr_res_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
2611
+ pr_res_nacl->se_tpg->se_tpg_tfo->fabric_name,
26152612 pr_res_holder->pr_reg_nacl->initiatorname);
26162613
26172614 spin_unlock(&dev->dev_reservation_lock);
....@@ -2752,7 +2749,7 @@
27522749 spin_unlock(&pr_tmpl->registration_lock);
27532750
27542751 pr_debug("SPC-3 PR [%s] Service Action: CLEAR complete\n",
2755
- cmd->se_tfo->get_fabric_name());
2752
+ cmd->se_tfo->fabric_name);
27562753
27572754 core_scsi3_update_and_write_aptpl(cmd->se_dev, false);
27582755
....@@ -2760,9 +2757,6 @@
27602757 return 0;
27612758 }
27622759
2763
-/*
2764
- * Called with struct se_device->dev_reservation_lock held.
2765
- */
27662760 static void __core_scsi3_complete_pro_preempt(
27672761 struct se_device *dev,
27682762 struct t10_pr_registration *pr_reg,
....@@ -2774,6 +2768,8 @@
27742768 struct se_node_acl *nacl = pr_reg->pr_reg_nacl;
27752769 const struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
27762770 char i_buf[PR_REG_ISID_ID_LEN];
2771
+
2772
+ lockdep_assert_held(&dev->dev_reservation_lock);
27772773
27782774 memset(i_buf, 0, PR_REG_ISID_ID_LEN);
27792775 core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
....@@ -2791,11 +2787,11 @@
27912787
27922788 pr_debug("SPC-3 PR [%s] Service Action: PREEMPT%s created new"
27932789 " reservation holder TYPE: %s ALL_TG_PT: %d\n",
2794
- tfo->get_fabric_name(), (preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "",
2790
+ tfo->fabric_name, (preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "",
27952791 core_scsi3_pr_dump_type(type),
27962792 (pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
27972793 pr_debug("SPC-3 PR [%s] PREEMPT%s from Node: %s%s\n",
2798
- tfo->get_fabric_name(), (preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "",
2794
+ tfo->fabric_name, (preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "",
27992795 nacl->initiatorname, i_buf);
28002796 /*
28012797 * For PREEMPT_AND_ABORT, add the preempting reservation's
....@@ -3282,7 +3278,7 @@
32823278 " proto_ident: 0x%02x does not match ident: 0x%02x"
32833279 " from fabric: %s\n", proto_ident,
32843280 dest_se_tpg->proto_id,
3285
- dest_tf_ops->get_fabric_name());
3281
+ dest_tf_ops->fabric_name);
32863282 ret = TCM_INVALID_PARAMETER_LIST;
32873283 goto out;
32883284 }
....@@ -3299,7 +3295,7 @@
32993295 buf = NULL;
33003296
33013297 pr_debug("SPC-3 PR [%s] Extracted initiator %s identifier: %s"
3302
- " %s\n", dest_tf_ops->get_fabric_name(), (iport_ptr != NULL) ?
3298
+ " %s\n", dest_tf_ops->fabric_name, (iport_ptr != NULL) ?
33033299 "port" : "device", initiator_str, (iport_ptr != NULL) ?
33043300 iport_ptr : "");
33053301 /*
....@@ -3344,7 +3340,7 @@
33443340
33453341 if (!dest_node_acl) {
33463342 pr_err("Unable to locate %s dest_node_acl for"
3347
- " TransportID%s\n", dest_tf_ops->get_fabric_name(),
3343
+ " TransportID%s\n", dest_tf_ops->fabric_name,
33483344 initiator_str);
33493345 ret = TCM_INVALID_PARAMETER_LIST;
33503346 goto out;
....@@ -3360,7 +3356,7 @@
33603356 }
33613357
33623358 pr_debug("SPC-3 PR REGISTER_AND_MOVE: Found %s dest_node_acl:"
3363
- " %s from TransportID\n", dest_tf_ops->get_fabric_name(),
3359
+ " %s from TransportID\n", dest_tf_ops->fabric_name,
33643360 dest_node_acl->initiatorname);
33653361
33663362 /*
....@@ -3370,7 +3366,7 @@
33703366 dest_se_deve = core_get_se_deve_from_rtpi(dest_node_acl, rtpi);
33713367 if (!dest_se_deve) {
33723368 pr_err("Unable to locate %s dest_se_deve from RTPI:"
3373
- " %hu\n", dest_tf_ops->get_fabric_name(), rtpi);
3369
+ " %hu\n", dest_tf_ops->fabric_name, rtpi);
33743370 ret = TCM_INVALID_PARAMETER_LIST;
33753371 goto out;
33763372 }
....@@ -3385,7 +3381,7 @@
33853381
33863382 pr_debug("SPC-3 PR REGISTER_AND_MOVE: Located %s node %s LUN"
33873383 " ACL for dest_se_deve->mapped_lun: %llu\n",
3388
- dest_tf_ops->get_fabric_name(), dest_node_acl->initiatorname,
3384
+ dest_tf_ops->fabric_name, dest_node_acl->initiatorname,
33893385 dest_se_deve->mapped_lun);
33903386
33913387 /*
....@@ -3501,13 +3497,13 @@
35013497
35023498 pr_debug("SPC-3 PR [%s] Service Action: REGISTER_AND_MOVE"
35033499 " created new reservation holder TYPE: %s on object RTPI:"
3504
- " %hu PRGeneration: 0x%08x\n", dest_tf_ops->get_fabric_name(),
3500
+ " %hu PRGeneration: 0x%08x\n", dest_tf_ops->fabric_name,
35053501 core_scsi3_pr_dump_type(type), rtpi,
35063502 dest_pr_reg->pr_res_generation);
35073503 pr_debug("SPC-3 PR Successfully moved reservation from"
35083504 " %s Fabric Node: %s%s -> %s Fabric Node: %s %s\n",
3509
- tf_ops->get_fabric_name(), pr_reg_nacl->initiatorname,
3510
- i_buf, dest_tf_ops->get_fabric_name(),
3505
+ tf_ops->fabric_name, pr_reg_nacl->initiatorname,
3506
+ i_buf, dest_tf_ops->fabric_name,
35113507 dest_node_acl->initiatorname, (iport_ptr != NULL) ?
35123508 iport_ptr : "");
35133509 /*
....@@ -4102,7 +4098,9 @@
41024098 return 0;
41034099 if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)
41044100 return 0;
4105
- if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)
4101
+ if (!dev->dev_attrib.emulate_pr)
4102
+ return 0;
4103
+ if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)
41064104 return 0;
41074105
41084106 spin_lock(&dev->dev_reservation_lock);