| .. | .. | 
|---|
|  | 1 | +// SPDX-License-Identifier: GPL-2.0-or-later | 
|---|
| 1 | 2 | /******************************************************************************* | 
|---|
| 2 | 3 | * Filename:  target_core_tpg.c | 
|---|
| 3 | 4 | * | 
|---|
| .. | .. | 
|---|
| 6 | 7 | * (c) Copyright 2002-2013 Datera, Inc. | 
|---|
| 7 | 8 | * | 
|---|
| 8 | 9 | * Nicholas A. Bellinger <nab@kernel.org> | 
|---|
| 9 |  | - * | 
|---|
| 10 |  | - * This program is free software; you can redistribute it and/or modify | 
|---|
| 11 |  | - * it under the terms of the GNU General Public License as published by | 
|---|
| 12 |  | - * the Free Software Foundation; either version 2 of the License, or | 
|---|
| 13 |  | - * (at your option) any later version. | 
|---|
| 14 |  | - * | 
|---|
| 15 |  | - * This program is distributed in the hope that it will be useful, | 
|---|
| 16 |  | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 17 |  | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 18 |  | - * GNU General Public License for more details. | 
|---|
| 19 |  | - * | 
|---|
| 20 |  | - * You should have received a copy of the GNU General Public License | 
|---|
| 21 |  | - * along with this program; if not, write to the Free Software | 
|---|
| 22 |  | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 
|---|
| 23 | 10 | * | 
|---|
| 24 | 11 | ******************************************************************************/ | 
|---|
| 25 | 12 |  | 
|---|
| .. | .. | 
|---|
| 44 | 31 | #include "target_core_ua.h" | 
|---|
| 45 | 32 |  | 
|---|
| 46 | 33 | extern struct se_device *g_lun0_dev; | 
|---|
| 47 |  | - | 
|---|
| 48 |  | -static DEFINE_SPINLOCK(tpg_lock); | 
|---|
| 49 |  | -static LIST_HEAD(tpg_list); | 
|---|
| 50 | 34 |  | 
|---|
| 51 | 35 | /*	__core_tpg_get_initiator_node_acl(): | 
|---|
| 52 | 36 | * | 
|---|
| .. | .. | 
|---|
| 151 | 135 |  | 
|---|
| 152 | 136 | pr_debug("TARGET_CORE[%s]->TPG[%u]_LUN[%llu] - Adding %s" | 
|---|
| 153 | 137 | " access for LUN in Demo Mode\n", | 
|---|
| 154 |  | -			tpg->se_tpg_tfo->get_fabric_name(), | 
|---|
|  | 138 | +			tpg->se_tpg_tfo->fabric_name, | 
|---|
| 155 | 139 | tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun, | 
|---|
| 156 | 140 | lun_access_ro ? "READ-ONLY" : "READ-WRITE"); | 
|---|
| 157 | 141 |  | 
|---|
| .. | .. | 
|---|
| 176 | 160 |  | 
|---|
| 177 | 161 | if (!acl->queue_depth) { | 
|---|
| 178 | 162 | pr_warn("Queue depth for %s Initiator Node: %s is 0," | 
|---|
| 179 |  | -			"defaulting to 1.\n", tpg->se_tpg_tfo->get_fabric_name(), | 
|---|
|  | 163 | +			"defaulting to 1.\n", tpg->se_tpg_tfo->fabric_name, | 
|---|
| 180 | 164 | acl->initiatorname); | 
|---|
| 181 | 165 | acl->queue_depth = 1; | 
|---|
| 182 | 166 | } | 
|---|
| .. | .. | 
|---|
| 227 | 211 |  | 
|---|
| 228 | 212 | pr_debug("%s_TPG[%hu] - Added %s ACL with TCQ Depth: %d for %s" | 
|---|
| 229 | 213 | " Initiator Node: %s\n", | 
|---|
| 230 |  | -		tpg->se_tpg_tfo->get_fabric_name(), | 
|---|
|  | 214 | +		tpg->se_tpg_tfo->fabric_name, | 
|---|
| 231 | 215 | tpg->se_tpg_tfo->tpg_get_tag(tpg), | 
|---|
| 232 | 216 | acl->dynamic_node_acl ? "DYNAMIC" : "", | 
|---|
| 233 | 217 | acl->queue_depth, | 
|---|
| 234 |  | -		tpg->se_tpg_tfo->get_fabric_name(), | 
|---|
|  | 218 | +		tpg->se_tpg_tfo->fabric_name, | 
|---|
| 235 | 219 | acl->initiatorname); | 
|---|
| 236 | 220 | } | 
|---|
| 237 | 221 |  | 
|---|
| .. | .. | 
|---|
| 313 | 297 | if (acl->dynamic_node_acl) { | 
|---|
| 314 | 298 | acl->dynamic_node_acl = 0; | 
|---|
| 315 | 299 | pr_debug("%s_TPG[%u] - Replacing dynamic ACL" | 
|---|
| 316 |  | -				" for %s\n", tpg->se_tpg_tfo->get_fabric_name(), | 
|---|
|  | 300 | +				" for %s\n", tpg->se_tpg_tfo->fabric_name, | 
|---|
| 317 | 301 | tpg->se_tpg_tfo->tpg_get_tag(tpg), initiatorname); | 
|---|
| 318 | 302 | mutex_unlock(&tpg->acl_node_mutex); | 
|---|
| 319 | 303 | return acl; | 
|---|
| .. | .. | 
|---|
| 321 | 305 |  | 
|---|
| 322 | 306 | pr_err("ACL entry for %s Initiator" | 
|---|
| 323 | 307 | " Node %s already exists for TPG %u, ignoring" | 
|---|
| 324 |  | -			" request.\n",  tpg->se_tpg_tfo->get_fabric_name(), | 
|---|
|  | 308 | +			" request.\n",  tpg->se_tpg_tfo->fabric_name, | 
|---|
| 325 | 309 | initiatorname, tpg->se_tpg_tfo->tpg_get_tag(tpg)); | 
|---|
| 326 | 310 | mutex_unlock(&tpg->acl_node_mutex); | 
|---|
| 327 | 311 | return ERR_PTR(-EEXIST); | 
|---|
| .. | .. | 
|---|
| 380 | 364 | core_free_device_list_for_node(acl, tpg); | 
|---|
| 381 | 365 |  | 
|---|
| 382 | 366 | pr_debug("%s_TPG[%hu] - Deleted ACL with TCQ Depth: %d for %s" | 
|---|
| 383 |  | -		" Initiator Node: %s\n", tpg->se_tpg_tfo->get_fabric_name(), | 
|---|
|  | 367 | +		" Initiator Node: %s\n", tpg->se_tpg_tfo->fabric_name, | 
|---|
| 384 | 368 | tpg->se_tpg_tfo->tpg_get_tag(tpg), acl->queue_depth, | 
|---|
| 385 |  | -		tpg->se_tpg_tfo->get_fabric_name(), acl->initiatorname); | 
|---|
|  | 369 | +		tpg->se_tpg_tfo->fabric_name, acl->initiatorname); | 
|---|
| 386 | 370 |  | 
|---|
| 387 | 371 | kfree(acl); | 
|---|
| 388 | 372 | } | 
|---|
| .. | .. | 
|---|
| 418 | 402 |  | 
|---|
| 419 | 403 | pr_debug("Successfully changed queue depth to: %d for Initiator" | 
|---|
| 420 | 404 | " Node: %s on %s Target Portal Group: %u\n", acl->queue_depth, | 
|---|
| 421 |  | -		acl->initiatorname, tpg->se_tpg_tfo->get_fabric_name(), | 
|---|
|  | 405 | +		acl->initiatorname, tpg->se_tpg_tfo->fabric_name, | 
|---|
| 422 | 406 | tpg->se_tpg_tfo->tpg_get_tag(tpg)); | 
|---|
| 423 | 407 |  | 
|---|
| 424 | 408 | return 0; | 
|---|
| .. | .. | 
|---|
| 488 | 472 | se_tpg->se_tpg_wwn = se_wwn; | 
|---|
| 489 | 473 | atomic_set(&se_tpg->tpg_pr_ref_count, 0); | 
|---|
| 490 | 474 | INIT_LIST_HEAD(&se_tpg->acl_node_list); | 
|---|
| 491 |  | -	INIT_LIST_HEAD(&se_tpg->se_tpg_node); | 
|---|
| 492 | 475 | INIT_LIST_HEAD(&se_tpg->tpg_sess_list); | 
|---|
| 493 | 476 | spin_lock_init(&se_tpg->session_lock); | 
|---|
| 494 | 477 | mutex_init(&se_tpg->tpg_lun_mutex); | 
|---|
| .. | .. | 
|---|
| 507 | 490 | } | 
|---|
| 508 | 491 | } | 
|---|
| 509 | 492 |  | 
|---|
| 510 |  | -	spin_lock_bh(&tpg_lock); | 
|---|
| 511 |  | -	list_add_tail(&se_tpg->se_tpg_node, &tpg_list); | 
|---|
| 512 |  | -	spin_unlock_bh(&tpg_lock); | 
|---|
| 513 |  | - | 
|---|
| 514 | 493 | pr_debug("TARGET_CORE[%s]: Allocated portal_group for endpoint: %s, " | 
|---|
| 515 |  | -		 "Proto: %d, Portal Tag: %u\n", se_tpg->se_tpg_tfo->get_fabric_name(), | 
|---|
|  | 494 | +		 "Proto: %d, Portal Tag: %u\n", se_tpg->se_tpg_tfo->fabric_name, | 
|---|
| 516 | 495 | se_tpg->se_tpg_tfo->tpg_get_wwn(se_tpg) ? | 
|---|
| 517 | 496 | se_tpg->se_tpg_tfo->tpg_get_wwn(se_tpg) : NULL, | 
|---|
| 518 | 497 | se_tpg->proto_id, se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg)); | 
|---|
| .. | .. | 
|---|
| 528 | 507 | LIST_HEAD(node_list); | 
|---|
| 529 | 508 |  | 
|---|
| 530 | 509 | pr_debug("TARGET_CORE[%s]: Deallocating portal_group for endpoint: %s, " | 
|---|
| 531 |  | -		 "Proto: %d, Portal Tag: %u\n", tfo->get_fabric_name(), | 
|---|
|  | 510 | +		 "Proto: %d, Portal Tag: %u\n", tfo->fabric_name, | 
|---|
| 532 | 511 | tfo->tpg_get_wwn(se_tpg) ? tfo->tpg_get_wwn(se_tpg) : NULL, | 
|---|
| 533 | 512 | se_tpg->proto_id, tfo->tpg_get_tag(se_tpg)); | 
|---|
| 534 |  | - | 
|---|
| 535 |  | -	spin_lock_bh(&tpg_lock); | 
|---|
| 536 |  | -	list_del(&se_tpg->se_tpg_node); | 
|---|
| 537 |  | -	spin_unlock_bh(&tpg_lock); | 
|---|
| 538 | 513 |  | 
|---|
| 539 | 514 | while (atomic_read(&se_tpg->tpg_pr_ref_count) != 0) | 
|---|
| 540 | 515 | cpu_relax(); | 
|---|
| .. | .. | 
|---|
| 577 | 552 | } | 
|---|
| 578 | 553 | lun->unpacked_lun = unpacked_lun; | 
|---|
| 579 | 554 | atomic_set(&lun->lun_acl_count, 0); | 
|---|
| 580 |  | -	init_completion(&lun->lun_ref_comp); | 
|---|
| 581 | 555 | init_completion(&lun->lun_shutdown_comp); | 
|---|
| 582 | 556 | INIT_LIST_HEAD(&lun->lun_deve_list); | 
|---|
| 583 | 557 | INIT_LIST_HEAD(&lun->lun_dev_link); | 
|---|
| .. | .. | 
|---|
| 608 | 582 | if (ret) | 
|---|
| 609 | 583 | goto out_kill_ref; | 
|---|
| 610 | 584 |  | 
|---|
| 611 |  | -	if (!(dev->transport->transport_flags & | 
|---|
| 612 |  | -	     TRANSPORT_FLAG_PASSTHROUGH_ALUA) && | 
|---|
|  | 585 | +	if (!(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) && | 
|---|
| 613 | 586 | !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) | 
|---|
| 614 | 587 | target_attach_tg_pt_gp(lun, dev->t10_alua.default_tg_pt_gp); | 
|---|
| 615 | 588 |  | 
|---|