1 /*******************************************************************************
2 * This file contains iSCSI Target Portal Group related functions.
4 * (c) Copyright 2007-2013 Datera, Inc.
6 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 ******************************************************************************/
19 #include <target/target_core_base.h>
20 #include <target/target_core_fabric.h>
21 #include <target/target_core_configfs.h>
23 #include "iscsi_target_core.h"
24 #include "iscsi_target_erl0.h"
25 #include "iscsi_target_login.h"
26 #include "iscsi_target_nodeattrib.h"
27 #include "iscsi_target_tpg.h"
28 #include "iscsi_target_util.h"
29 #include "iscsi_target.h"
30 #include "iscsi_target_parameters.h"
32 #include <target/iscsi/iscsi_transport.h>
34 struct iscsi_portal_group *iscsit_alloc_portal_group(struct iscsi_tiqn *tiqn, u16 tpgt)
36 struct iscsi_portal_group *tpg;
38 tpg = kzalloc(sizeof(struct iscsi_portal_group), GFP_KERNEL);
40 pr_err("Unable to allocate struct iscsi_portal_group\n");
45 tpg->tpg_state = TPG_STATE_FREE;
47 INIT_LIST_HEAD(&tpg->tpg_gnp_list);
48 INIT_LIST_HEAD(&tpg->tpg_list);
49 mutex_init(&tpg->tpg_access_lock);
50 sema_init(&tpg->np_login_sem, 1);
51 spin_lock_init(&tpg->tpg_state_lock);
52 spin_lock_init(&tpg->tpg_np_lock);
57 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *);
59 int iscsit_load_discovery_tpg(void)
61 struct iscsi_param *param;
62 struct iscsi_portal_group *tpg;
65 tpg = iscsit_alloc_portal_group(NULL, 1);
67 pr_err("Unable to allocate struct iscsi_portal_group\n");
71 ret = core_tpg_register(
72 &lio_target_fabric_configfs->tf_ops,
73 NULL, &tpg->tpg_se_tpg, tpg,
74 TRANSPORT_TPG_TYPE_DISCOVERY);
80 tpg->sid = 1; /* First Assigned LIO Session ID */
81 iscsit_set_default_tpg_attribs(tpg);
83 if (iscsi_create_default_params(&tpg->param_list) < 0)
86 * By default we disable authentication for discovery sessions,
87 * this can be changed with:
89 * /sys/kernel/config/target/iscsi/discovery_auth/enforce_discovery_auth
91 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
95 if (iscsi_update_param_value(param, "CHAP,None") < 0)
98 tpg->tpg_attrib.authentication = 0;
100 spin_lock(&tpg->tpg_state_lock);
101 tpg->tpg_state = TPG_STATE_ACTIVE;
102 spin_unlock(&tpg->tpg_state_lock);
104 iscsit_global->discovery_tpg = tpg;
105 pr_debug("CORE[0] - Allocated Discovery TPG\n");
110 core_tpg_deregister(&tpg->tpg_se_tpg);
115 void iscsit_release_discovery_tpg(void)
117 struct iscsi_portal_group *tpg = iscsit_global->discovery_tpg;
122 core_tpg_deregister(&tpg->tpg_se_tpg);
125 iscsit_global->discovery_tpg = NULL;
128 struct iscsi_portal_group *iscsit_get_tpg_from_np(
129 struct iscsi_tiqn *tiqn,
131 struct iscsi_tpg_np **tpg_np_out)
133 struct iscsi_portal_group *tpg = NULL;
134 struct iscsi_tpg_np *tpg_np;
136 spin_lock(&tiqn->tiqn_tpg_lock);
137 list_for_each_entry(tpg, &tiqn->tiqn_tpg_list, tpg_list) {
139 spin_lock(&tpg->tpg_state_lock);
140 if (tpg->tpg_state == TPG_STATE_FREE) {
141 spin_unlock(&tpg->tpg_state_lock);
144 spin_unlock(&tpg->tpg_state_lock);
146 spin_lock(&tpg->tpg_np_lock);
147 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
148 if (tpg_np->tpg_np == np) {
149 *tpg_np_out = tpg_np;
150 kref_get(&tpg_np->tpg_np_kref);
151 spin_unlock(&tpg->tpg_np_lock);
152 spin_unlock(&tiqn->tiqn_tpg_lock);
156 spin_unlock(&tpg->tpg_np_lock);
158 spin_unlock(&tiqn->tiqn_tpg_lock);
164 struct iscsi_portal_group *tpg)
168 ret = mutex_lock_interruptible(&tpg->tpg_access_lock);
169 return ((ret != 0) || signal_pending(current)) ? -1 : 0;
172 void iscsit_put_tpg(struct iscsi_portal_group *tpg)
174 mutex_unlock(&tpg->tpg_access_lock);
177 static void iscsit_clear_tpg_np_login_thread(
178 struct iscsi_tpg_np *tpg_np,
179 struct iscsi_portal_group *tpg,
182 if (!tpg_np->tpg_np) {
183 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
187 iscsit_reset_np_thread(tpg_np->tpg_np, tpg_np, tpg, shutdown);
190 void iscsit_clear_tpg_np_login_threads(
191 struct iscsi_portal_group *tpg,
194 struct iscsi_tpg_np *tpg_np;
196 spin_lock(&tpg->tpg_np_lock);
197 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
198 if (!tpg_np->tpg_np) {
199 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
202 spin_unlock(&tpg->tpg_np_lock);
203 iscsit_clear_tpg_np_login_thread(tpg_np, tpg, shutdown);
204 spin_lock(&tpg->tpg_np_lock);
206 spin_unlock(&tpg->tpg_np_lock);
209 void iscsit_tpg_dump_params(struct iscsi_portal_group *tpg)
211 iscsi_print_params(tpg->param_list);
214 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *tpg)
216 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
218 a->authentication = TA_AUTHENTICATION;
219 a->login_timeout = TA_LOGIN_TIMEOUT;
220 a->netif_timeout = TA_NETIF_TIMEOUT;
221 a->default_cmdsn_depth = TA_DEFAULT_CMDSN_DEPTH;
222 a->generate_node_acls = TA_GENERATE_NODE_ACLS;
223 a->cache_dynamic_acls = TA_CACHE_DYNAMIC_ACLS;
224 a->demo_mode_write_protect = TA_DEMO_MODE_WRITE_PROTECT;
225 a->prod_mode_write_protect = TA_PROD_MODE_WRITE_PROTECT;
226 a->demo_mode_discovery = TA_DEMO_MODE_DISCOVERY;
229 int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg)
231 if (tpg->tpg_state != TPG_STATE_FREE) {
232 pr_err("Unable to add iSCSI Target Portal Group: %d"
233 " while not in TPG_STATE_FREE state.\n", tpg->tpgt);
236 iscsit_set_default_tpg_attribs(tpg);
238 if (iscsi_create_default_params(&tpg->param_list) < 0)
241 tpg->tpg_attrib.tpg = tpg;
243 spin_lock(&tpg->tpg_state_lock);
244 tpg->tpg_state = TPG_STATE_INACTIVE;
245 spin_unlock(&tpg->tpg_state_lock);
247 spin_lock(&tiqn->tiqn_tpg_lock);
248 list_add_tail(&tpg->tpg_list, &tiqn->tiqn_tpg_list);
250 pr_debug("CORE[%s]_TPG[%hu] - Added iSCSI Target Portal Group\n",
251 tiqn->tiqn, tpg->tpgt);
252 spin_unlock(&tiqn->tiqn_tpg_lock);
256 if (tpg->param_list) {
257 iscsi_release_param_list(tpg->param_list);
258 tpg->param_list = NULL;
264 int iscsit_tpg_del_portal_group(
265 struct iscsi_tiqn *tiqn,
266 struct iscsi_portal_group *tpg,
269 u8 old_state = tpg->tpg_state;
271 spin_lock(&tpg->tpg_state_lock);
272 tpg->tpg_state = TPG_STATE_INACTIVE;
273 spin_unlock(&tpg->tpg_state_lock);
275 iscsit_clear_tpg_np_login_threads(tpg, true);
277 if (iscsit_release_sessions_for_tpg(tpg, force) < 0) {
278 pr_err("Unable to delete iSCSI Target Portal Group:"
279 " %hu while active sessions exist, and force=0\n",
281 tpg->tpg_state = old_state;
285 core_tpg_clear_object_luns(&tpg->tpg_se_tpg);
287 if (tpg->param_list) {
288 iscsi_release_param_list(tpg->param_list);
289 tpg->param_list = NULL;
292 core_tpg_deregister(&tpg->tpg_se_tpg);
294 spin_lock(&tpg->tpg_state_lock);
295 tpg->tpg_state = TPG_STATE_FREE;
296 spin_unlock(&tpg->tpg_state_lock);
298 spin_lock(&tiqn->tiqn_tpg_lock);
300 list_del(&tpg->tpg_list);
301 spin_unlock(&tiqn->tiqn_tpg_lock);
303 pr_debug("CORE[%s]_TPG[%hu] - Deleted iSCSI Target Portal Group\n",
304 tiqn->tiqn, tpg->tpgt);
310 int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
312 struct iscsi_param *param;
313 struct iscsi_tiqn *tiqn = tpg->tpg_tiqn;
316 spin_lock(&tpg->tpg_state_lock);
317 if (tpg->tpg_state == TPG_STATE_ACTIVE) {
318 pr_err("iSCSI target portal group: %hu is already"
319 " active, ignoring request.\n", tpg->tpgt);
320 spin_unlock(&tpg->tpg_state_lock);
324 * Make sure that AuthMethod does not contain None as an option
325 * unless explictly disabled. Set the default to CHAP if authentication
326 * is enforced (as per default), and remove the NONE option.
328 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
330 spin_unlock(&tpg->tpg_state_lock);
334 if (tpg->tpg_attrib.authentication) {
335 if (!strcmp(param->value, NONE)) {
336 ret = iscsi_update_param_value(param, CHAP);
341 ret = iscsit_ta_authentication(tpg, 1);
346 tpg->tpg_state = TPG_STATE_ACTIVE;
347 spin_unlock(&tpg->tpg_state_lock);
349 spin_lock(&tiqn->tiqn_tpg_lock);
350 tiqn->tiqn_active_tpgs++;
351 pr_debug("iSCSI_TPG[%hu] - Enabled iSCSI Target Portal Group\n",
353 spin_unlock(&tiqn->tiqn_tpg_lock);
358 spin_unlock(&tpg->tpg_state_lock);
362 int iscsit_tpg_disable_portal_group(struct iscsi_portal_group *tpg, int force)
364 struct iscsi_tiqn *tiqn;
365 u8 old_state = tpg->tpg_state;
367 spin_lock(&tpg->tpg_state_lock);
368 if (tpg->tpg_state == TPG_STATE_INACTIVE) {
369 pr_err("iSCSI Target Portal Group: %hu is already"
370 " inactive, ignoring request.\n", tpg->tpgt);
371 spin_unlock(&tpg->tpg_state_lock);
374 tpg->tpg_state = TPG_STATE_INACTIVE;
375 spin_unlock(&tpg->tpg_state_lock);
377 iscsit_clear_tpg_np_login_threads(tpg, false);
379 if (iscsit_release_sessions_for_tpg(tpg, force) < 0) {
380 spin_lock(&tpg->tpg_state_lock);
381 tpg->tpg_state = old_state;
382 spin_unlock(&tpg->tpg_state_lock);
383 pr_err("Unable to disable iSCSI Target Portal Group:"
384 " %hu while active sessions exist, and force=0\n",
389 tiqn = tpg->tpg_tiqn;
390 if (!tiqn || (tpg == iscsit_global->discovery_tpg))
393 spin_lock(&tiqn->tiqn_tpg_lock);
394 tiqn->tiqn_active_tpgs--;
395 pr_debug("iSCSI_TPG[%hu] - Disabled iSCSI Target Portal Group\n",
397 spin_unlock(&tiqn->tiqn_tpg_lock);
402 struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(
403 struct iscsi_session *sess)
405 struct se_session *se_sess = sess->se_sess;
406 struct se_node_acl *se_nacl = se_sess->se_node_acl;
407 struct iscsi_node_acl *acl = container_of(se_nacl, struct iscsi_node_acl,
410 return &acl->node_attrib;
413 struct iscsi_tpg_np *iscsit_tpg_locate_child_np(
414 struct iscsi_tpg_np *tpg_np,
415 int network_transport)
417 struct iscsi_tpg_np *tpg_np_child, *tpg_np_child_tmp;
419 spin_lock(&tpg_np->tpg_np_parent_lock);
420 list_for_each_entry_safe(tpg_np_child, tpg_np_child_tmp,
421 &tpg_np->tpg_np_parent_list, tpg_np_child_list) {
422 if (tpg_np_child->tpg_np->np_network_transport ==
424 spin_unlock(&tpg_np->tpg_np_parent_lock);
428 spin_unlock(&tpg_np->tpg_np_parent_lock);
433 static bool iscsit_tpg_check_network_portal(
434 struct iscsi_tiqn *tiqn,
435 struct __kernel_sockaddr_storage *sockaddr,
436 int network_transport)
438 struct iscsi_portal_group *tpg;
439 struct iscsi_tpg_np *tpg_np;
443 spin_lock(&tiqn->tiqn_tpg_lock);
444 list_for_each_entry(tpg, &tiqn->tiqn_tpg_list, tpg_list) {
446 spin_lock(&tpg->tpg_np_lock);
447 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
450 match = iscsit_check_np_match(sockaddr, np,
455 spin_unlock(&tpg->tpg_np_lock);
457 spin_unlock(&tiqn->tiqn_tpg_lock);
462 struct iscsi_tpg_np *iscsit_tpg_add_network_portal(
463 struct iscsi_portal_group *tpg,
464 struct __kernel_sockaddr_storage *sockaddr,
466 struct iscsi_tpg_np *tpg_np_parent,
467 int network_transport)
470 struct iscsi_tpg_np *tpg_np;
472 if (!tpg_np_parent) {
473 if (iscsit_tpg_check_network_portal(tpg->tpg_tiqn, sockaddr,
474 network_transport) == true) {
475 pr_err("Network Portal: %s already exists on a"
476 " different TPG on %s\n", ip_str,
477 tpg->tpg_tiqn->tiqn);
478 return ERR_PTR(-EEXIST);
482 tpg_np = kzalloc(sizeof(struct iscsi_tpg_np), GFP_KERNEL);
484 pr_err("Unable to allocate memory for"
485 " struct iscsi_tpg_np.\n");
486 return ERR_PTR(-ENOMEM);
489 np = iscsit_add_np(sockaddr, ip_str, network_transport);
495 INIT_LIST_HEAD(&tpg_np->tpg_np_list);
496 INIT_LIST_HEAD(&tpg_np->tpg_np_child_list);
497 INIT_LIST_HEAD(&tpg_np->tpg_np_parent_list);
498 spin_lock_init(&tpg_np->tpg_np_parent_lock);
499 init_completion(&tpg_np->tpg_np_comp);
500 kref_init(&tpg_np->tpg_np_kref);
504 spin_lock(&tpg->tpg_np_lock);
505 list_add_tail(&tpg_np->tpg_np_list, &tpg->tpg_gnp_list);
508 tpg->tpg_tiqn->tiqn_num_tpg_nps++;
509 spin_unlock(&tpg->tpg_np_lock);
512 tpg_np->tpg_np_parent = tpg_np_parent;
513 spin_lock(&tpg_np_parent->tpg_np_parent_lock);
514 list_add_tail(&tpg_np->tpg_np_child_list,
515 &tpg_np_parent->tpg_np_parent_list);
516 spin_unlock(&tpg_np_parent->tpg_np_parent_lock);
519 pr_debug("CORE[%s] - Added Network Portal: %s:%hu,%hu on %s\n",
520 tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt,
521 np->np_transport->name);
526 static int iscsit_tpg_release_np(
527 struct iscsi_tpg_np *tpg_np,
528 struct iscsi_portal_group *tpg,
531 iscsit_clear_tpg_np_login_thread(tpg_np, tpg, true);
533 pr_debug("CORE[%s] - Removed Network Portal: %s:%hu,%hu on %s\n",
534 tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt,
535 np->np_transport->name);
537 tpg_np->tpg_np = NULL;
541 * iscsit_del_np() will shutdown struct iscsi_np when last TPG reference is released.
543 return iscsit_del_np(np);
546 int iscsit_tpg_del_network_portal(
547 struct iscsi_portal_group *tpg,
548 struct iscsi_tpg_np *tpg_np)
551 struct iscsi_tpg_np *tpg_np_child, *tpg_np_child_tmp;
556 pr_err("Unable to locate struct iscsi_np from"
557 " struct iscsi_tpg_np\n");
561 if (!tpg_np->tpg_np_parent) {
563 * We are the parent tpg network portal. Release all of the
564 * child tpg_np's (eg: the non ISCSI_TCP ones) on our parent
567 list_for_each_entry_safe(tpg_np_child, tpg_np_child_tmp,
568 &tpg_np->tpg_np_parent_list,
570 ret = iscsit_tpg_del_network_portal(tpg, tpg_np_child);
572 pr_err("iscsit_tpg_del_network_portal()"
573 " failed: %d\n", ret);
577 * We are not the parent ISCSI_TCP tpg network portal. Release
578 * our own network portals from the child list.
580 spin_lock(&tpg_np->tpg_np_parent->tpg_np_parent_lock);
581 list_del(&tpg_np->tpg_np_child_list);
582 spin_unlock(&tpg_np->tpg_np_parent->tpg_np_parent_lock);
585 spin_lock(&tpg->tpg_np_lock);
586 list_del(&tpg_np->tpg_np_list);
589 tpg->tpg_tiqn->tiqn_num_tpg_nps--;
590 spin_unlock(&tpg->tpg_np_lock);
592 return iscsit_tpg_release_np(tpg_np, tpg, np);
595 int iscsit_tpg_set_initiator_node_queue_depth(
596 struct iscsi_portal_group *tpg,
597 unsigned char *initiatorname,
601 return core_tpg_set_initiator_node_queue_depth(&tpg->tpg_se_tpg,
602 initiatorname, queue_depth, force);
605 int iscsit_ta_authentication(struct iscsi_portal_group *tpg, u32 authentication)
607 unsigned char buf1[256], buf2[256], *none = NULL;
609 struct iscsi_param *param;
610 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
612 if ((authentication != 1) && (authentication != 0)) {
613 pr_err("Illegal value for authentication parameter:"
614 " %u, ignoring request.\n", authentication);
618 memset(buf1, 0, sizeof(buf1));
619 memset(buf2, 0, sizeof(buf2));
621 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
625 if (authentication) {
626 snprintf(buf1, sizeof(buf1), "%s", param->value);
627 none = strstr(buf1, NONE);
630 if (!strncmp(none + 4, ",", 1)) {
631 if (!strcmp(buf1, none))
632 sprintf(buf2, "%s", none+5);
636 len = sprintf(buf2, "%s", buf1);
638 sprintf(buf2 + len, "%s", none);
643 sprintf(buf2, "%s", buf1);
645 if (iscsi_update_param_value(param, buf2) < 0)
648 snprintf(buf1, sizeof(buf1), "%s", param->value);
649 none = strstr(buf1, NONE);
652 strncat(buf1, ",", strlen(","));
653 strncat(buf1, NONE, strlen(NONE));
654 if (iscsi_update_param_value(param, buf1) < 0)
659 a->authentication = authentication;
660 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
661 a->authentication ? "Enforcing" : "Disabling", tpg->tpgt);
666 int iscsit_ta_login_timeout(
667 struct iscsi_portal_group *tpg,
670 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
672 if (login_timeout > TA_LOGIN_TIMEOUT_MAX) {
673 pr_err("Requested Login Timeout %u larger than maximum"
674 " %u\n", login_timeout, TA_LOGIN_TIMEOUT_MAX);
676 } else if (login_timeout < TA_LOGIN_TIMEOUT_MIN) {
677 pr_err("Requested Logout Timeout %u smaller than"
678 " minimum %u\n", login_timeout, TA_LOGIN_TIMEOUT_MIN);
682 a->login_timeout = login_timeout;
683 pr_debug("Set Logout Timeout to %u for Target Portal Group"
684 " %hu\n", a->login_timeout, tpg->tpgt);
689 int iscsit_ta_netif_timeout(
690 struct iscsi_portal_group *tpg,
693 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
695 if (netif_timeout > TA_NETIF_TIMEOUT_MAX) {
696 pr_err("Requested Network Interface Timeout %u larger"
697 " than maximum %u\n", netif_timeout,
698 TA_NETIF_TIMEOUT_MAX);
700 } else if (netif_timeout < TA_NETIF_TIMEOUT_MIN) {
701 pr_err("Requested Network Interface Timeout %u smaller"
702 " than minimum %u\n", netif_timeout,
703 TA_NETIF_TIMEOUT_MIN);
707 a->netif_timeout = netif_timeout;
708 pr_debug("Set Network Interface Timeout to %u for"
709 " Target Portal Group %hu\n", a->netif_timeout, tpg->tpgt);
714 int iscsit_ta_generate_node_acls(
715 struct iscsi_portal_group *tpg,
718 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
720 if ((flag != 0) && (flag != 1)) {
721 pr_err("Illegal value %d\n", flag);
725 a->generate_node_acls = flag;
726 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
727 tpg->tpgt, (a->generate_node_acls) ? "Enabled" : "Disabled");
729 if (flag == 1 && a->cache_dynamic_acls == 0) {
730 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
731 "generate_node_acls=1\n");
732 a->cache_dynamic_acls = 1;
738 int iscsit_ta_default_cmdsn_depth(
739 struct iscsi_portal_group *tpg,
742 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
744 if (tcq_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
745 pr_err("Requested Default Queue Depth: %u larger"
746 " than maximum %u\n", tcq_depth,
747 TA_DEFAULT_CMDSN_DEPTH_MAX);
749 } else if (tcq_depth < TA_DEFAULT_CMDSN_DEPTH_MIN) {
750 pr_err("Requested Default Queue Depth: %u smaller"
751 " than minimum %u\n", tcq_depth,
752 TA_DEFAULT_CMDSN_DEPTH_MIN);
756 a->default_cmdsn_depth = tcq_depth;
757 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
758 tpg->tpgt, a->default_cmdsn_depth);
763 int iscsit_ta_cache_dynamic_acls(
764 struct iscsi_portal_group *tpg,
767 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
769 if ((flag != 0) && (flag != 1)) {
770 pr_err("Illegal value %d\n", flag);
774 if (a->generate_node_acls == 1 && flag == 0) {
775 pr_debug("Skipping cache_dynamic_acls=0 when"
776 " generate_node_acls=1\n");
780 a->cache_dynamic_acls = flag;
781 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
782 " ACLs %s\n", tpg->tpgt, (a->cache_dynamic_acls) ?
783 "Enabled" : "Disabled");
788 int iscsit_ta_demo_mode_write_protect(
789 struct iscsi_portal_group *tpg,
792 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
794 if ((flag != 0) && (flag != 1)) {
795 pr_err("Illegal value %d\n", flag);
799 a->demo_mode_write_protect = flag;
800 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
801 tpg->tpgt, (a->demo_mode_write_protect) ? "ON" : "OFF");
806 int iscsit_ta_prod_mode_write_protect(
807 struct iscsi_portal_group *tpg,
810 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
812 if ((flag != 0) && (flag != 1)) {
813 pr_err("Illegal value %d\n", flag);
817 a->prod_mode_write_protect = flag;
818 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
819 " %s\n", tpg->tpgt, (a->prod_mode_write_protect) ?
825 int iscsit_ta_demo_mode_discovery(
826 struct iscsi_portal_group *tpg,
829 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
831 if ((flag != 0) && (flag != 1)) {
832 pr_err("Illegal value %d\n", flag);
836 a->demo_mode_discovery = flag;
837 pr_debug("iSCSI_TPG[%hu] - Demo Mode Discovery bit:"
838 " %s\n", tpg->tpgt, (a->demo_mode_discovery) ?