.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /******************************************************************************* |
---|
2 | 3 | * Filename: target_core_pr.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
7 | 8 | * (c) Copyright 2009-2013 Datera, Inc. |
---|
8 | 9 | * |
---|
9 | 10 | * 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. |
---|
24 | 11 | * |
---|
25 | 12 | ******************************************************************************/ |
---|
26 | 13 | |
---|
.. | .. |
---|
111 | 98 | break; |
---|
112 | 99 | } |
---|
113 | 100 | |
---|
114 | | - if (!dev->dev_reserved_node_acl || !sess) |
---|
| 101 | + if (!dev->reservation_holder || !sess) |
---|
115 | 102 | return 0; |
---|
116 | 103 | |
---|
117 | | - if (dev->dev_reserved_node_acl != sess->se_node_acl) |
---|
| 104 | + if (dev->reservation_holder->se_node_acl != sess->se_node_acl) |
---|
118 | 105 | return TCM_RESERVATION_CONFLICT; |
---|
119 | 106 | |
---|
120 | 107 | if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS_WITH_ISID) { |
---|
.. | .. |
---|
200 | 187 | return 0; |
---|
201 | 188 | } |
---|
202 | 189 | |
---|
| 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 | + |
---|
203 | 200 | sense_reason_t |
---|
204 | 201 | target_scsi2_reservation_release(struct se_cmd *cmd) |
---|
205 | 202 | { |
---|
.. | .. |
---|
217 | 214 | return TCM_RESERVATION_CONFLICT; |
---|
218 | 215 | |
---|
219 | 216 | spin_lock(&dev->dev_reservation_lock); |
---|
220 | | - if (!dev->dev_reserved_node_acl || !sess) |
---|
| 217 | + if (!dev->reservation_holder || !sess) |
---|
221 | 218 | goto out_unlock; |
---|
222 | 219 | |
---|
223 | | - if (dev->dev_reserved_node_acl != sess->se_node_acl) |
---|
| 220 | + if (dev->reservation_holder->se_node_acl != sess->se_node_acl) |
---|
224 | 221 | goto out_unlock; |
---|
225 | 222 | |
---|
226 | 223 | if (dev->dev_res_bin_isid != sess->sess_bin_isid) |
---|
227 | 224 | goto out_unlock; |
---|
228 | 225 | |
---|
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); |
---|
235 | 227 | tpg = sess->se_tpg; |
---|
236 | 228 | pr_debug("SCSI-2 Released reservation for %s LUN: %llu ->" |
---|
237 | 229 | " MAPPED LUN: %llu for %s\n", |
---|
238 | | - tpg->se_tpg_tfo->get_fabric_name(), |
---|
| 230 | + tpg->se_tpg_tfo->fabric_name, |
---|
239 | 231 | cmd->se_lun->unpacked_lun, cmd->orig_fe_lun, |
---|
240 | 232 | sess->se_node_acl->initiatorname); |
---|
241 | 233 | |
---|
.. | .. |
---|
275 | 267 | |
---|
276 | 268 | tpg = sess->se_tpg; |
---|
277 | 269 | 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) { |
---|
280 | 272 | 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); |
---|
282 | 274 | pr_err("Original reserver LUN: %llu %s\n", |
---|
283 | 275 | cmd->se_lun->unpacked_lun, |
---|
284 | | - dev->dev_reserved_node_acl->initiatorname); |
---|
| 276 | + dev->reservation_holder->se_node_acl->initiatorname); |
---|
285 | 277 | pr_err("Current attempt - LUN: %llu -> MAPPED LUN: %llu" |
---|
286 | 278 | " from %s \n", cmd->se_lun->unpacked_lun, |
---|
287 | 279 | cmd->orig_fe_lun, |
---|
.. | .. |
---|
290 | 282 | goto out_unlock; |
---|
291 | 283 | } |
---|
292 | 284 | |
---|
293 | | - dev->dev_reserved_node_acl = sess->se_node_acl; |
---|
| 285 | + dev->reservation_holder = sess; |
---|
294 | 286 | dev->dev_reservation_flags |= DRF_SPC2_RESERVATIONS; |
---|
295 | 287 | if (sess->sess_bin_isid != 0) { |
---|
296 | 288 | dev->dev_res_bin_isid = sess->sess_bin_isid; |
---|
297 | 289 | dev->dev_reservation_flags |= DRF_SPC2_RESERVATIONS_WITH_ISID; |
---|
298 | 290 | } |
---|
299 | 291 | 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, |
---|
301 | 293 | cmd->se_lun->unpacked_lun, cmd->orig_fe_lun, |
---|
302 | 294 | sess->se_node_acl->initiatorname); |
---|
303 | 295 | |
---|
.. | .. |
---|
353 | 345 | break; |
---|
354 | 346 | case PR_TYPE_WRITE_EXCLUSIVE_REGONLY: |
---|
355 | 347 | we = 1; |
---|
356 | | - /* fall through */ |
---|
| 348 | + fallthrough; |
---|
357 | 349 | case PR_TYPE_EXCLUSIVE_ACCESS_REGONLY: |
---|
358 | 350 | /* |
---|
359 | 351 | * Some commands are only allowed for registered I_T Nexuses. |
---|
.. | .. |
---|
362 | 354 | break; |
---|
363 | 355 | case PR_TYPE_WRITE_EXCLUSIVE_ALLREG: |
---|
364 | 356 | we = 1; |
---|
365 | | - /* fall through */ |
---|
| 357 | + fallthrough; |
---|
366 | 358 | case PR_TYPE_EXCLUSIVE_ACCESS_ALLREG: |
---|
367 | 359 | /* |
---|
368 | 360 | * Each registered I_T Nexus is a reservation holder. |
---|
.. | .. |
---|
914 | 906 | |
---|
915 | 907 | pr_debug("SPC-3 PR [%s] Service Action: APTPL RESERVE created" |
---|
916 | 908 | " 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, |
---|
918 | 910 | core_scsi3_pr_dump_type(pr_reg->pr_res_type), |
---|
919 | 911 | (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); |
---|
920 | 912 | 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, |
---|
922 | 914 | i_buf); |
---|
923 | 915 | } |
---|
924 | 916 | |
---|
.. | .. |
---|
1036 | 1028 | core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); |
---|
1037 | 1029 | |
---|
1038 | 1030 | 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) ? |
---|
1040 | 1032 | "_AND_MOVE" : (register_type == REGISTER_AND_IGNORE_EXISTING_KEY) ? |
---|
1041 | 1033 | "_AND_IGNORE_EXISTING_KEY" : "", nacl->initiatorname, |
---|
1042 | 1034 | i_buf); |
---|
1043 | 1035 | 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), |
---|
1045 | 1037 | tfo->tpg_get_tag(se_tpg)); |
---|
1046 | 1038 | 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, |
---|
1048 | 1040 | (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE", |
---|
1049 | 1041 | dev->transport->name); |
---|
1050 | 1042 | 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, |
---|
1052 | 1044 | pr_reg->pr_res_key, pr_reg->pr_res_generation, |
---|
1053 | 1045 | pr_reg->pr_reg_aptpl); |
---|
1054 | 1046 | } |
---|
.. | .. |
---|
1167 | 1159 | { |
---|
1168 | 1160 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
---|
1169 | 1161 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; |
---|
1170 | | - struct se_portal_group *tpg; |
---|
1171 | 1162 | |
---|
1172 | 1163 | spin_lock(&pr_tmpl->registration_lock); |
---|
1173 | 1164 | list_for_each_entry_safe(pr_reg, pr_reg_tmp, |
---|
.. | .. |
---|
1178 | 1169 | if (pr_reg->pr_reg_nacl != nacl) |
---|
1179 | 1170 | continue; |
---|
1180 | 1171 | |
---|
1181 | | - tpg = pr_reg->pr_reg_nacl->se_tpg; |
---|
1182 | 1172 | /* |
---|
1183 | 1173 | * If this registration does NOT contain a fabric provided |
---|
1184 | 1174 | * ISID, then we have found a match. |
---|
1185 | 1175 | */ |
---|
1186 | 1176 | 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 | | - } |
---|
1196 | 1177 | atomic_inc_mb(&pr_reg->pr_res_holders); |
---|
1197 | 1178 | spin_unlock(&pr_tmpl->registration_lock); |
---|
1198 | 1179 | return pr_reg; |
---|
.. | .. |
---|
1290 | 1271 | return ret; |
---|
1291 | 1272 | } |
---|
1292 | 1273 | |
---|
1293 | | -/* |
---|
1294 | | - * Called with struct t10_reservation->registration_lock held. |
---|
1295 | | - */ |
---|
1296 | 1274 | static void __core_scsi3_free_registration( |
---|
1297 | 1275 | struct se_device *dev, |
---|
1298 | 1276 | struct t10_pr_registration *pr_reg, |
---|
.. | .. |
---|
1307 | 1285 | struct se_node_acl *nacl = pr_reg->pr_reg_nacl; |
---|
1308 | 1286 | struct se_dev_entry *deve; |
---|
1309 | 1287 | char i_buf[PR_REG_ISID_ID_LEN]; |
---|
| 1288 | + |
---|
| 1289 | + lockdep_assert_held(&pr_tmpl->registration_lock); |
---|
1310 | 1290 | |
---|
1311 | 1291 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); |
---|
1312 | 1292 | core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); |
---|
.. | .. |
---|
1329 | 1309 | */ |
---|
1330 | 1310 | while (atomic_read(&pr_reg->pr_res_holders) != 0) { |
---|
1331 | 1311 | pr_debug("SPC-3 PR [%s] waiting for pr_res_holders\n", |
---|
1332 | | - tfo->get_fabric_name()); |
---|
| 1312 | + tfo->fabric_name); |
---|
1333 | 1313 | cpu_relax(); |
---|
1334 | 1314 | } |
---|
1335 | 1315 | |
---|
.. | .. |
---|
1341 | 1321 | |
---|
1342 | 1322 | spin_lock(&pr_tmpl->registration_lock); |
---|
1343 | 1323 | 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, |
---|
1345 | 1325 | pr_reg->pr_reg_nacl->initiatorname, |
---|
1346 | 1326 | i_buf); |
---|
1347 | 1327 | 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, |
---|
1349 | 1329 | (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE", |
---|
1350 | 1330 | dev->transport->name); |
---|
1351 | 1331 | 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, |
---|
1353 | 1333 | pr_reg->pr_res_generation); |
---|
1354 | 1334 | |
---|
1355 | 1335 | if (!preempt_and_abort_list) { |
---|
.. | .. |
---|
1539 | 1519 | kfree(tidh_new); |
---|
1540 | 1520 | return TCM_INSUFFICIENT_REGISTRATION_RESOURCES; |
---|
1541 | 1521 | } |
---|
| 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 | + |
---|
1542 | 1531 | 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; |
---|
1549 | 1532 | list_add_tail(&tidh_new->dest_list, &tid_dest_list); |
---|
1550 | 1533 | |
---|
1551 | 1534 | if (cmd->data_length < 28) { |
---|
.. | .. |
---|
1600 | 1583 | continue; |
---|
1601 | 1584 | dest_rtpi = tmp_lun->lun_rtpi; |
---|
1602 | 1585 | |
---|
| 1586 | + iport_ptr = NULL; |
---|
1603 | 1587 | i_str = target_parse_pr_out_transport_id(tmp_tpg, |
---|
1604 | 1588 | ptr, &tid_len, &iport_ptr); |
---|
1605 | 1589 | if (!i_str) |
---|
1606 | 1590 | 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 | + } |
---|
1607 | 1605 | |
---|
1608 | 1606 | atomic_inc_mb(&tmp_tpg->tpg_pr_ref_count); |
---|
1609 | 1607 | spin_unlock(&dev->se_port_lock); |
---|
.. | .. |
---|
1645 | 1643 | dest_tpg = tmp_tpg; |
---|
1646 | 1644 | pr_debug("SPC-3 PR SPEC_I_PT: Located %s Node:" |
---|
1647 | 1645 | " %s Port RTPI: %hu\n", |
---|
1648 | | - dest_tpg->se_tpg_tfo->get_fabric_name(), |
---|
| 1646 | + dest_tpg->se_tpg_tfo->fabric_name, |
---|
1649 | 1647 | dest_node_acl->initiatorname, dest_rtpi); |
---|
1650 | 1648 | |
---|
1651 | 1649 | spin_lock(&dev->se_port_lock); |
---|
.. | .. |
---|
1662 | 1660 | |
---|
1663 | 1661 | pr_debug("SPC-3 PR SPEC_I_PT: Got %s data_length: %u tpdl: %u" |
---|
1664 | 1662 | " 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, |
---|
1666 | 1664 | tpdl, tid_len, i_str, iport_ptr); |
---|
1667 | 1665 | |
---|
1668 | 1666 | if (tid_len > tpdl) { |
---|
.. | .. |
---|
1683 | 1681 | if (!dest_se_deve) { |
---|
1684 | 1682 | pr_err("Unable to locate %s dest_se_deve" |
---|
1685 | 1683 | " from destination RTPI: %hu\n", |
---|
1686 | | - dest_tpg->se_tpg_tfo->get_fabric_name(), |
---|
| 1684 | + dest_tpg->se_tpg_tfo->fabric_name, |
---|
1687 | 1685 | dest_rtpi); |
---|
1688 | 1686 | |
---|
1689 | 1687 | core_scsi3_nodeacl_undepend_item(dest_node_acl); |
---|
.. | .. |
---|
1704 | 1702 | |
---|
1705 | 1703 | pr_debug("SPC-3 PR SPEC_I_PT: Located %s Node: %s" |
---|
1706 | 1704 | " dest_se_deve mapped_lun: %llu\n", |
---|
1707 | | - dest_tpg->se_tpg_tfo->get_fabric_name(), |
---|
| 1705 | + dest_tpg->se_tpg_tfo->fabric_name, |
---|
1708 | 1706 | dest_node_acl->initiatorname, dest_se_deve->mapped_lun); |
---|
1709 | 1707 | |
---|
1710 | 1708 | /* |
---|
.. | .. |
---|
1815 | 1813 | |
---|
1816 | 1814 | pr_debug("SPC-3 PR [%s] SPEC_I_PT: Successfully" |
---|
1817 | 1815 | " 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, |
---|
1819 | 1817 | dest_node_acl->initiatorname, i_buf, (dest_se_deve) ? |
---|
1820 | 1818 | dest_se_deve->mapped_lun : 0); |
---|
1821 | 1819 | |
---|
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) |
---|
1825 | 1821 | continue; |
---|
1826 | | - } |
---|
1827 | | - core_scsi3_lunacl_undepend_item(dest_se_deve); |
---|
| 1822 | + |
---|
1828 | 1823 | core_scsi3_nodeacl_undepend_item(dest_node_acl); |
---|
1829 | 1824 | core_scsi3_tpg_undepend_item(dest_tpg); |
---|
1830 | 1825 | } |
---|
.. | .. |
---|
1838 | 1833 | * including *dest_pr_reg and the configfs dependances.. |
---|
1839 | 1834 | */ |
---|
1840 | 1835 | list_for_each_entry_safe(tidh, tidh_tmp, &tid_dest_list, dest_list) { |
---|
| 1836 | + bool is_local = false; |
---|
| 1837 | + |
---|
1841 | 1838 | dest_tpg = tidh->dest_tpg; |
---|
1842 | 1839 | dest_node_acl = tidh->dest_node_acl; |
---|
1843 | 1840 | dest_se_deve = tidh->dest_se_deve; |
---|
1844 | 1841 | dest_pr_reg = tidh->dest_pr_reg; |
---|
| 1842 | + |
---|
| 1843 | + if (dest_pr_reg == local_pr_reg) |
---|
| 1844 | + is_local = true; |
---|
1845 | 1845 | |
---|
1846 | 1846 | list_del(&tidh->dest_list); |
---|
1847 | 1847 | kfree(tidh); |
---|
.. | .. |
---|
1858 | 1858 | } |
---|
1859 | 1859 | |
---|
1860 | 1860 | 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 | | - } |
---|
1867 | 1861 | core_scsi3_lunacl_undepend_item(dest_se_deve); |
---|
| 1862 | + |
---|
| 1863 | + if (is_local) |
---|
| 1864 | + continue; |
---|
| 1865 | + |
---|
1868 | 1866 | core_scsi3_nodeacl_undepend_item(dest_node_acl); |
---|
1869 | 1867 | core_scsi3_tpg_undepend_item(dest_tpg); |
---|
1870 | 1868 | } |
---|
.. | .. |
---|
1913 | 1911 | "res_holder=1\nres_type=%02x\n" |
---|
1914 | 1912 | "res_scope=%02x\nres_all_tg_pt=%d\n" |
---|
1915 | 1913 | "mapped_lun=%llu\n", reg_count, |
---|
1916 | | - tpg->se_tpg_tfo->get_fabric_name(), |
---|
| 1914 | + tpg->se_tpg_tfo->fabric_name, |
---|
1917 | 1915 | pr_reg->pr_reg_nacl->initiatorname, isid_buf, |
---|
1918 | 1916 | pr_reg->pr_res_key, pr_reg->pr_res_type, |
---|
1919 | 1917 | pr_reg->pr_res_scope, pr_reg->pr_reg_all_tg_pt, |
---|
.. | .. |
---|
1923 | 1921 | "initiator_fabric=%s\ninitiator_node=%s\n%s" |
---|
1924 | 1922 | "sa_res_key=%llu\nres_holder=0\n" |
---|
1925 | 1923 | "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, |
---|
1927 | 1925 | pr_reg->pr_reg_nacl->initiatorname, isid_buf, |
---|
1928 | 1926 | pr_reg->pr_res_key, pr_reg->pr_reg_all_tg_pt, |
---|
1929 | 1927 | pr_reg->pr_res_mapped_lun); |
---|
.. | .. |
---|
1942 | 1940 | */ |
---|
1943 | 1941 | snprintf(tmp, 512, "target_fabric=%s\ntarget_node=%s\n" |
---|
1944 | 1942 | "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, |
---|
1946 | 1944 | tpg->se_tpg_tfo->tpg_get_wwn(tpg), |
---|
1947 | 1945 | tpg->se_tpg_tfo->tpg_get_tag(tpg), |
---|
1948 | 1946 | pr_reg->tg_pt_sep_rtpi, pr_reg->pr_aptpl_target_lun, |
---|
.. | .. |
---|
2168 | 2166 | pr_reg->pr_res_key = sa_res_key; |
---|
2169 | 2167 | pr_debug("SPC-3 PR [%s] REGISTER%s: Changed Reservation" |
---|
2170 | 2168 | " 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, |
---|
2172 | 2170 | (register_type == REGISTER_AND_IGNORE_EXISTING_KEY) ? "_AND_IGNORE_EXISTING_KEY" : "", |
---|
2173 | 2171 | pr_reg->pr_reg_nacl->initiatorname, |
---|
2174 | 2172 | pr_reg->pr_res_key, pr_reg->pr_res_generation); |
---|
.. | .. |
---|
2356 | 2354 | pr_err("SPC-3 PR: Attempted RESERVE from" |
---|
2357 | 2355 | " [%s]: %s while reservation already held by" |
---|
2358 | 2356 | " [%s]: %s, returning RESERVATION_CONFLICT\n", |
---|
2359 | | - cmd->se_tfo->get_fabric_name(), |
---|
| 2357 | + cmd->se_tfo->fabric_name, |
---|
2360 | 2358 | 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, |
---|
2362 | 2360 | pr_res_holder->pr_reg_nacl->initiatorname); |
---|
2363 | 2361 | |
---|
2364 | 2362 | spin_unlock(&dev->dev_reservation_lock); |
---|
.. | .. |
---|
2379 | 2377 | " [%s]: %s trying to change TYPE and/or SCOPE," |
---|
2380 | 2378 | " while reservation already held by [%s]: %s," |
---|
2381 | 2379 | " returning RESERVATION_CONFLICT\n", |
---|
2382 | | - cmd->se_tfo->get_fabric_name(), |
---|
| 2380 | + cmd->se_tfo->fabric_name, |
---|
2383 | 2381 | 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, |
---|
2385 | 2383 | pr_res_holder->pr_reg_nacl->initiatorname); |
---|
2386 | 2384 | |
---|
2387 | 2385 | spin_unlock(&dev->dev_reservation_lock); |
---|
.. | .. |
---|
2414 | 2412 | |
---|
2415 | 2413 | pr_debug("SPC-3 PR [%s] Service Action: RESERVE created new" |
---|
2416 | 2414 | " 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), |
---|
2418 | 2416 | (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); |
---|
2419 | 2417 | pr_debug("SPC-3 PR [%s] RESERVE Node: %s%s\n", |
---|
2420 | | - cmd->se_tfo->get_fabric_name(), |
---|
| 2418 | + cmd->se_tfo->fabric_name, |
---|
2421 | 2419 | se_sess->se_node_acl->initiatorname, |
---|
2422 | 2420 | i_buf); |
---|
2423 | 2421 | spin_unlock(&dev->dev_reservation_lock); |
---|
.. | .. |
---|
2450 | 2448 | } |
---|
2451 | 2449 | } |
---|
2452 | 2450 | |
---|
2453 | | -/* |
---|
2454 | | - * Called with struct se_device->dev_reservation_lock held. |
---|
2455 | | - */ |
---|
2456 | 2451 | static void __core_scsi3_complete_pro_release( |
---|
2457 | 2452 | struct se_device *dev, |
---|
2458 | 2453 | struct se_node_acl *se_nacl, |
---|
.. | .. |
---|
2463 | 2458 | const struct target_core_fabric_ops *tfo = se_nacl->se_tpg->se_tpg_tfo; |
---|
2464 | 2459 | char i_buf[PR_REG_ISID_ID_LEN]; |
---|
2465 | 2460 | int pr_res_type = 0, pr_res_scope = 0; |
---|
| 2461 | + |
---|
| 2462 | + lockdep_assert_held(&dev->dev_reservation_lock); |
---|
2466 | 2463 | |
---|
2467 | 2464 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); |
---|
2468 | 2465 | core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); |
---|
.. | .. |
---|
2506 | 2503 | if (!dev->dev_pr_res_holder) { |
---|
2507 | 2504 | pr_debug("SPC-3 PR [%s] Service Action: %s RELEASE cleared" |
---|
2508 | 2505 | " reservation holder TYPE: %s ALL_TG_PT: %d\n", |
---|
2509 | | - tfo->get_fabric_name(), (explicit) ? "explicit" : |
---|
| 2506 | + tfo->fabric_name, (explicit) ? "explicit" : |
---|
2510 | 2507 | "implicit", core_scsi3_pr_dump_type(pr_res_type), |
---|
2511 | 2508 | (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); |
---|
2512 | 2509 | } |
---|
2513 | 2510 | 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, |
---|
2515 | 2512 | i_buf); |
---|
2516 | 2513 | /* |
---|
2517 | 2514 | * Clear TYPE and SCOPE for the next PROUT Service Action: RESERVE |
---|
.. | .. |
---|
2609 | 2606 | " reservation from [%s]: %s with different TYPE " |
---|
2610 | 2607 | "and/or SCOPE while reservation already held by" |
---|
2611 | 2608 | " [%s]: %s, returning RESERVATION_CONFLICT\n", |
---|
2612 | | - cmd->se_tfo->get_fabric_name(), |
---|
| 2609 | + cmd->se_tfo->fabric_name, |
---|
2613 | 2610 | 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, |
---|
2615 | 2612 | pr_res_holder->pr_reg_nacl->initiatorname); |
---|
2616 | 2613 | |
---|
2617 | 2614 | spin_unlock(&dev->dev_reservation_lock); |
---|
.. | .. |
---|
2752 | 2749 | spin_unlock(&pr_tmpl->registration_lock); |
---|
2753 | 2750 | |
---|
2754 | 2751 | pr_debug("SPC-3 PR [%s] Service Action: CLEAR complete\n", |
---|
2755 | | - cmd->se_tfo->get_fabric_name()); |
---|
| 2752 | + cmd->se_tfo->fabric_name); |
---|
2756 | 2753 | |
---|
2757 | 2754 | core_scsi3_update_and_write_aptpl(cmd->se_dev, false); |
---|
2758 | 2755 | |
---|
.. | .. |
---|
2760 | 2757 | return 0; |
---|
2761 | 2758 | } |
---|
2762 | 2759 | |
---|
2763 | | -/* |
---|
2764 | | - * Called with struct se_device->dev_reservation_lock held. |
---|
2765 | | - */ |
---|
2766 | 2760 | static void __core_scsi3_complete_pro_preempt( |
---|
2767 | 2761 | struct se_device *dev, |
---|
2768 | 2762 | struct t10_pr_registration *pr_reg, |
---|
.. | .. |
---|
2774 | 2768 | struct se_node_acl *nacl = pr_reg->pr_reg_nacl; |
---|
2775 | 2769 | const struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo; |
---|
2776 | 2770 | char i_buf[PR_REG_ISID_ID_LEN]; |
---|
| 2771 | + |
---|
| 2772 | + lockdep_assert_held(&dev->dev_reservation_lock); |
---|
2777 | 2773 | |
---|
2778 | 2774 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); |
---|
2779 | 2775 | core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); |
---|
.. | .. |
---|
2791 | 2787 | |
---|
2792 | 2788 | pr_debug("SPC-3 PR [%s] Service Action: PREEMPT%s created new" |
---|
2793 | 2789 | " 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" : "", |
---|
2795 | 2791 | core_scsi3_pr_dump_type(type), |
---|
2796 | 2792 | (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); |
---|
2797 | 2793 | 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" : "", |
---|
2799 | 2795 | nacl->initiatorname, i_buf); |
---|
2800 | 2796 | /* |
---|
2801 | 2797 | * For PREEMPT_AND_ABORT, add the preempting reservation's |
---|
.. | .. |
---|
3282 | 3278 | " proto_ident: 0x%02x does not match ident: 0x%02x" |
---|
3283 | 3279 | " from fabric: %s\n", proto_ident, |
---|
3284 | 3280 | dest_se_tpg->proto_id, |
---|
3285 | | - dest_tf_ops->get_fabric_name()); |
---|
| 3281 | + dest_tf_ops->fabric_name); |
---|
3286 | 3282 | ret = TCM_INVALID_PARAMETER_LIST; |
---|
3287 | 3283 | goto out; |
---|
3288 | 3284 | } |
---|
.. | .. |
---|
3299 | 3295 | buf = NULL; |
---|
3300 | 3296 | |
---|
3301 | 3297 | 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) ? |
---|
3303 | 3299 | "port" : "device", initiator_str, (iport_ptr != NULL) ? |
---|
3304 | 3300 | iport_ptr : ""); |
---|
3305 | 3301 | /* |
---|
.. | .. |
---|
3344 | 3340 | |
---|
3345 | 3341 | if (!dest_node_acl) { |
---|
3346 | 3342 | 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, |
---|
3348 | 3344 | initiator_str); |
---|
3349 | 3345 | ret = TCM_INVALID_PARAMETER_LIST; |
---|
3350 | 3346 | goto out; |
---|
.. | .. |
---|
3360 | 3356 | } |
---|
3361 | 3357 | |
---|
3362 | 3358 | 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, |
---|
3364 | 3360 | dest_node_acl->initiatorname); |
---|
3365 | 3361 | |
---|
3366 | 3362 | /* |
---|
.. | .. |
---|
3370 | 3366 | dest_se_deve = core_get_se_deve_from_rtpi(dest_node_acl, rtpi); |
---|
3371 | 3367 | if (!dest_se_deve) { |
---|
3372 | 3368 | 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); |
---|
3374 | 3370 | ret = TCM_INVALID_PARAMETER_LIST; |
---|
3375 | 3371 | goto out; |
---|
3376 | 3372 | } |
---|
.. | .. |
---|
3385 | 3381 | |
---|
3386 | 3382 | pr_debug("SPC-3 PR REGISTER_AND_MOVE: Located %s node %s LUN" |
---|
3387 | 3383 | " 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, |
---|
3389 | 3385 | dest_se_deve->mapped_lun); |
---|
3390 | 3386 | |
---|
3391 | 3387 | /* |
---|
.. | .. |
---|
3501 | 3497 | |
---|
3502 | 3498 | pr_debug("SPC-3 PR [%s] Service Action: REGISTER_AND_MOVE" |
---|
3503 | 3499 | " 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, |
---|
3505 | 3501 | core_scsi3_pr_dump_type(type), rtpi, |
---|
3506 | 3502 | dest_pr_reg->pr_res_generation); |
---|
3507 | 3503 | pr_debug("SPC-3 PR Successfully moved reservation from" |
---|
3508 | 3504 | " %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, |
---|
3511 | 3507 | dest_node_acl->initiatorname, (iport_ptr != NULL) ? |
---|
3512 | 3508 | iport_ptr : ""); |
---|
3513 | 3509 | /* |
---|
.. | .. |
---|
4102 | 4098 | return 0; |
---|
4103 | 4099 | if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE) |
---|
4104 | 4100 | 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) |
---|
4106 | 4104 | return 0; |
---|
4107 | 4105 | |
---|
4108 | 4106 | spin_lock(&dev->dev_reservation_lock); |
---|