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_ACTIVE
) {
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");
188 tpg_np
->tpg_np
->enabled
= false;
189 iscsit_reset_np_thread(tpg_np
->tpg_np
, tpg_np
, tpg
, shutdown
);
192 void iscsit_clear_tpg_np_login_threads(
193 struct iscsi_portal_group
*tpg
,
196 struct iscsi_tpg_np
*tpg_np
;
198 spin_lock(&tpg
->tpg_np_lock
);
199 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
200 if (!tpg_np
->tpg_np
) {
201 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
204 spin_unlock(&tpg
->tpg_np_lock
);
205 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
, shutdown
);
206 spin_lock(&tpg
->tpg_np_lock
);
208 spin_unlock(&tpg
->tpg_np_lock
);
211 void iscsit_tpg_dump_params(struct iscsi_portal_group
*tpg
)
213 iscsi_print_params(tpg
->param_list
);
216 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group
*tpg
)
218 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
220 a
->authentication
= TA_AUTHENTICATION
;
221 a
->login_timeout
= TA_LOGIN_TIMEOUT
;
222 a
->netif_timeout
= TA_NETIF_TIMEOUT
;
223 a
->default_cmdsn_depth
= TA_DEFAULT_CMDSN_DEPTH
;
224 a
->generate_node_acls
= TA_GENERATE_NODE_ACLS
;
225 a
->cache_dynamic_acls
= TA_CACHE_DYNAMIC_ACLS
;
226 a
->demo_mode_write_protect
= TA_DEMO_MODE_WRITE_PROTECT
;
227 a
->prod_mode_write_protect
= TA_PROD_MODE_WRITE_PROTECT
;
230 int iscsit_tpg_add_portal_group(struct iscsi_tiqn
*tiqn
, struct iscsi_portal_group
*tpg
)
232 if (tpg
->tpg_state
!= TPG_STATE_FREE
) {
233 pr_err("Unable to add iSCSI Target Portal Group: %d"
234 " while not in TPG_STATE_FREE state.\n", tpg
->tpgt
);
237 iscsit_set_default_tpg_attribs(tpg
);
239 if (iscsi_create_default_params(&tpg
->param_list
) < 0)
242 ISCSI_TPG_ATTRIB(tpg
)->tpg
= tpg
;
244 spin_lock(&tpg
->tpg_state_lock
);
245 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
246 spin_unlock(&tpg
->tpg_state_lock
);
248 spin_lock(&tiqn
->tiqn_tpg_lock
);
249 list_add_tail(&tpg
->tpg_list
, &tiqn
->tiqn_tpg_list
);
251 pr_debug("CORE[%s]_TPG[%hu] - Added iSCSI Target Portal Group\n",
252 tiqn
->tiqn
, tpg
->tpgt
);
253 spin_unlock(&tiqn
->tiqn_tpg_lock
);
257 if (tpg
->param_list
) {
258 iscsi_release_param_list(tpg
->param_list
);
259 tpg
->param_list
= NULL
;
265 int iscsit_tpg_del_portal_group(
266 struct iscsi_tiqn
*tiqn
,
267 struct iscsi_portal_group
*tpg
,
270 u8 old_state
= tpg
->tpg_state
;
272 spin_lock(&tpg
->tpg_state_lock
);
273 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
274 spin_unlock(&tpg
->tpg_state_lock
);
276 iscsit_clear_tpg_np_login_threads(tpg
, true);
278 if (iscsit_release_sessions_for_tpg(tpg
, force
) < 0) {
279 pr_err("Unable to delete iSCSI Target Portal Group:"
280 " %hu while active sessions exist, and force=0\n",
282 tpg
->tpg_state
= old_state
;
286 core_tpg_clear_object_luns(&tpg
->tpg_se_tpg
);
288 if (tpg
->param_list
) {
289 iscsi_release_param_list(tpg
->param_list
);
290 tpg
->param_list
= NULL
;
293 core_tpg_deregister(&tpg
->tpg_se_tpg
);
295 spin_lock(&tpg
->tpg_state_lock
);
296 tpg
->tpg_state
= TPG_STATE_FREE
;
297 spin_unlock(&tpg
->tpg_state_lock
);
299 spin_lock(&tiqn
->tiqn_tpg_lock
);
301 list_del(&tpg
->tpg_list
);
302 spin_unlock(&tiqn
->tiqn_tpg_lock
);
304 pr_debug("CORE[%s]_TPG[%hu] - Deleted iSCSI Target Portal Group\n",
305 tiqn
->tiqn
, tpg
->tpgt
);
311 int iscsit_tpg_enable_portal_group(struct iscsi_portal_group
*tpg
)
313 struct iscsi_param
*param
;
314 struct iscsi_tiqn
*tiqn
= tpg
->tpg_tiqn
;
317 spin_lock(&tpg
->tpg_state_lock
);
318 if (tpg
->tpg_state
== TPG_STATE_ACTIVE
) {
319 pr_err("iSCSI target portal group: %hu is already"
320 " active, ignoring request.\n", tpg
->tpgt
);
321 spin_unlock(&tpg
->tpg_state_lock
);
325 * Make sure that AuthMethod does not contain None as an option
326 * unless explictly disabled. Set the default to CHAP if authentication
327 * is enforced (as per default), and remove the NONE option.
329 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
331 spin_unlock(&tpg
->tpg_state_lock
);
335 if (ISCSI_TPG_ATTRIB(tpg
)->authentication
) {
336 if (!strcmp(param
->value
, NONE
)) {
337 ret
= iscsi_update_param_value(param
, CHAP
);
342 ret
= iscsit_ta_authentication(tpg
, 1);
347 tpg
->tpg_state
= TPG_STATE_ACTIVE
;
348 spin_unlock(&tpg
->tpg_state_lock
);
350 spin_lock(&tiqn
->tiqn_tpg_lock
);
351 tiqn
->tiqn_active_tpgs
++;
352 pr_debug("iSCSI_TPG[%hu] - Enabled iSCSI Target Portal Group\n",
354 spin_unlock(&tiqn
->tiqn_tpg_lock
);
359 spin_unlock(&tpg
->tpg_state_lock
);
363 int iscsit_tpg_disable_portal_group(struct iscsi_portal_group
*tpg
, int force
)
365 struct iscsi_tiqn
*tiqn
;
366 u8 old_state
= tpg
->tpg_state
;
368 spin_lock(&tpg
->tpg_state_lock
);
369 if (tpg
->tpg_state
== TPG_STATE_INACTIVE
) {
370 pr_err("iSCSI Target Portal Group: %hu is already"
371 " inactive, ignoring request.\n", tpg
->tpgt
);
372 spin_unlock(&tpg
->tpg_state_lock
);
375 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
376 spin_unlock(&tpg
->tpg_state_lock
);
378 iscsit_clear_tpg_np_login_threads(tpg
, false);
380 if (iscsit_release_sessions_for_tpg(tpg
, force
) < 0) {
381 spin_lock(&tpg
->tpg_state_lock
);
382 tpg
->tpg_state
= old_state
;
383 spin_unlock(&tpg
->tpg_state_lock
);
384 pr_err("Unable to disable iSCSI Target Portal Group:"
385 " %hu while active sessions exist, and force=0\n",
390 tiqn
= tpg
->tpg_tiqn
;
391 if (!tiqn
|| (tpg
== iscsit_global
->discovery_tpg
))
394 spin_lock(&tiqn
->tiqn_tpg_lock
);
395 tiqn
->tiqn_active_tpgs
--;
396 pr_debug("iSCSI_TPG[%hu] - Disabled iSCSI Target Portal Group\n",
398 spin_unlock(&tiqn
->tiqn_tpg_lock
);
403 struct iscsi_node_attrib
*iscsit_tpg_get_node_attrib(
404 struct iscsi_session
*sess
)
406 struct se_session
*se_sess
= sess
->se_sess
;
407 struct se_node_acl
*se_nacl
= se_sess
->se_node_acl
;
408 struct iscsi_node_acl
*acl
= container_of(se_nacl
, struct iscsi_node_acl
,
411 return &acl
->node_attrib
;
414 struct iscsi_tpg_np
*iscsit_tpg_locate_child_np(
415 struct iscsi_tpg_np
*tpg_np
,
416 int network_transport
)
418 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
420 spin_lock(&tpg_np
->tpg_np_parent_lock
);
421 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
422 &tpg_np
->tpg_np_parent_list
, tpg_np_child_list
) {
423 if (tpg_np_child
->tpg_np
->np_network_transport
==
425 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
429 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
434 static bool iscsit_tpg_check_network_portal(
435 struct iscsi_tiqn
*tiqn
,
436 struct __kernel_sockaddr_storage
*sockaddr
,
437 int network_transport
)
439 struct iscsi_portal_group
*tpg
;
440 struct iscsi_tpg_np
*tpg_np
;
444 spin_lock(&tiqn
->tiqn_tpg_lock
);
445 list_for_each_entry(tpg
, &tiqn
->tiqn_tpg_list
, tpg_list
) {
447 spin_lock(&tpg
->tpg_np_lock
);
448 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
451 match
= iscsit_check_np_match(sockaddr
, np
,
456 spin_unlock(&tpg
->tpg_np_lock
);
458 spin_unlock(&tiqn
->tiqn_tpg_lock
);
463 struct iscsi_tpg_np
*iscsit_tpg_add_network_portal(
464 struct iscsi_portal_group
*tpg
,
465 struct __kernel_sockaddr_storage
*sockaddr
,
467 struct iscsi_tpg_np
*tpg_np_parent
,
468 int network_transport
)
471 struct iscsi_tpg_np
*tpg_np
;
473 if (!tpg_np_parent
) {
474 if (iscsit_tpg_check_network_portal(tpg
->tpg_tiqn
, sockaddr
,
475 network_transport
) == true) {
476 pr_err("Network Portal: %s already exists on a"
477 " different TPG on %s\n", ip_str
,
478 tpg
->tpg_tiqn
->tiqn
);
479 return ERR_PTR(-EEXIST
);
483 tpg_np
= kzalloc(sizeof(struct iscsi_tpg_np
), GFP_KERNEL
);
485 pr_err("Unable to allocate memory for"
486 " struct iscsi_tpg_np.\n");
487 return ERR_PTR(-ENOMEM
);
490 np
= iscsit_add_np(sockaddr
, ip_str
, network_transport
);
496 INIT_LIST_HEAD(&tpg_np
->tpg_np_list
);
497 INIT_LIST_HEAD(&tpg_np
->tpg_np_child_list
);
498 INIT_LIST_HEAD(&tpg_np
->tpg_np_parent_list
);
499 spin_lock_init(&tpg_np
->tpg_np_parent_lock
);
500 init_completion(&tpg_np
->tpg_np_comp
);
501 kref_init(&tpg_np
->tpg_np_kref
);
505 spin_lock(&tpg
->tpg_np_lock
);
506 list_add_tail(&tpg_np
->tpg_np_list
, &tpg
->tpg_gnp_list
);
509 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
++;
510 spin_unlock(&tpg
->tpg_np_lock
);
513 tpg_np
->tpg_np_parent
= tpg_np_parent
;
514 spin_lock(&tpg_np_parent
->tpg_np_parent_lock
);
515 list_add_tail(&tpg_np
->tpg_np_child_list
,
516 &tpg_np_parent
->tpg_np_parent_list
);
517 spin_unlock(&tpg_np_parent
->tpg_np_parent_lock
);
520 pr_debug("CORE[%s] - Added Network Portal: %s:%hu,%hu on %s\n",
521 tpg
->tpg_tiqn
->tiqn
, np
->np_ip
, np
->np_port
, tpg
->tpgt
,
522 np
->np_transport
->name
);
527 static int iscsit_tpg_release_np(
528 struct iscsi_tpg_np
*tpg_np
,
529 struct iscsi_portal_group
*tpg
,
532 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
, true);
534 pr_debug("CORE[%s] - Removed Network Portal: %s:%hu,%hu on %s\n",
535 tpg
->tpg_tiqn
->tiqn
, np
->np_ip
, np
->np_port
, tpg
->tpgt
,
536 np
->np_transport
->name
);
538 tpg_np
->tpg_np
= NULL
;
542 * iscsit_del_np() will shutdown struct iscsi_np when last TPG reference is released.
544 return iscsit_del_np(np
);
547 int iscsit_tpg_del_network_portal(
548 struct iscsi_portal_group
*tpg
,
549 struct iscsi_tpg_np
*tpg_np
)
552 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
557 pr_err("Unable to locate struct iscsi_np from"
558 " struct iscsi_tpg_np\n");
562 if (!tpg_np
->tpg_np_parent
) {
564 * We are the parent tpg network portal. Release all of the
565 * child tpg_np's (eg: the non ISCSI_TCP ones) on our parent
568 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
569 &tpg_np
->tpg_np_parent_list
,
571 ret
= iscsit_tpg_del_network_portal(tpg
, tpg_np_child
);
573 pr_err("iscsit_tpg_del_network_portal()"
574 " failed: %d\n", ret
);
578 * We are not the parent ISCSI_TCP tpg network portal. Release
579 * our own network portals from the child list.
581 spin_lock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
582 list_del(&tpg_np
->tpg_np_child_list
);
583 spin_unlock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
586 spin_lock(&tpg
->tpg_np_lock
);
587 list_del(&tpg_np
->tpg_np_list
);
590 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
--;
591 spin_unlock(&tpg
->tpg_np_lock
);
593 return iscsit_tpg_release_np(tpg_np
, tpg
, np
);
596 int iscsit_tpg_set_initiator_node_queue_depth(
597 struct iscsi_portal_group
*tpg
,
598 unsigned char *initiatorname
,
602 return core_tpg_set_initiator_node_queue_depth(&tpg
->tpg_se_tpg
,
603 initiatorname
, queue_depth
, force
);
606 int iscsit_ta_authentication(struct iscsi_portal_group
*tpg
, u32 authentication
)
608 unsigned char buf1
[256], buf2
[256], *none
= NULL
;
610 struct iscsi_param
*param
;
611 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
613 if ((authentication
!= 1) && (authentication
!= 0)) {
614 pr_err("Illegal value for authentication parameter:"
615 " %u, ignoring request.\n", authentication
);
619 memset(buf1
, 0, sizeof(buf1
));
620 memset(buf2
, 0, sizeof(buf2
));
622 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
626 if (authentication
) {
627 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
628 none
= strstr(buf1
, NONE
);
631 if (!strncmp(none
+ 4, ",", 1)) {
632 if (!strcmp(buf1
, none
))
633 sprintf(buf2
, "%s", none
+5);
637 len
= sprintf(buf2
, "%s", buf1
);
639 sprintf(buf2
+ len
, "%s", none
);
644 sprintf(buf2
, "%s", buf1
);
646 if (iscsi_update_param_value(param
, buf2
) < 0)
649 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
650 none
= strstr(buf1
, NONE
);
653 strncat(buf1
, ",", strlen(","));
654 strncat(buf1
, NONE
, strlen(NONE
));
655 if (iscsi_update_param_value(param
, buf1
) < 0)
660 a
->authentication
= authentication
;
661 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
662 a
->authentication
? "Enforcing" : "Disabling", tpg
->tpgt
);
667 int iscsit_ta_login_timeout(
668 struct iscsi_portal_group
*tpg
,
671 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
673 if (login_timeout
> TA_LOGIN_TIMEOUT_MAX
) {
674 pr_err("Requested Login Timeout %u larger than maximum"
675 " %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MAX
);
677 } else if (login_timeout
< TA_LOGIN_TIMEOUT_MIN
) {
678 pr_err("Requested Logout Timeout %u smaller than"
679 " minimum %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MIN
);
683 a
->login_timeout
= login_timeout
;
684 pr_debug("Set Logout Timeout to %u for Target Portal Group"
685 " %hu\n", a
->login_timeout
, tpg
->tpgt
);
690 int iscsit_ta_netif_timeout(
691 struct iscsi_portal_group
*tpg
,
694 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
696 if (netif_timeout
> TA_NETIF_TIMEOUT_MAX
) {
697 pr_err("Requested Network Interface Timeout %u larger"
698 " than maximum %u\n", netif_timeout
,
699 TA_NETIF_TIMEOUT_MAX
);
701 } else if (netif_timeout
< TA_NETIF_TIMEOUT_MIN
) {
702 pr_err("Requested Network Interface Timeout %u smaller"
703 " than minimum %u\n", netif_timeout
,
704 TA_NETIF_TIMEOUT_MIN
);
708 a
->netif_timeout
= netif_timeout
;
709 pr_debug("Set Network Interface Timeout to %u for"
710 " Target Portal Group %hu\n", a
->netif_timeout
, tpg
->tpgt
);
715 int iscsit_ta_generate_node_acls(
716 struct iscsi_portal_group
*tpg
,
719 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
721 if ((flag
!= 0) && (flag
!= 1)) {
722 pr_err("Illegal value %d\n", flag
);
726 a
->generate_node_acls
= flag
;
727 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
728 tpg
->tpgt
, (a
->generate_node_acls
) ? "Enabled" : "Disabled");
730 if (flag
== 1 && a
->cache_dynamic_acls
== 0) {
731 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
732 "generate_node_acls=1\n");
733 a
->cache_dynamic_acls
= 1;
739 int iscsit_ta_default_cmdsn_depth(
740 struct iscsi_portal_group
*tpg
,
743 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
745 if (tcq_depth
> TA_DEFAULT_CMDSN_DEPTH_MAX
) {
746 pr_err("Requested Default Queue Depth: %u larger"
747 " than maximum %u\n", tcq_depth
,
748 TA_DEFAULT_CMDSN_DEPTH_MAX
);
750 } else if (tcq_depth
< TA_DEFAULT_CMDSN_DEPTH_MIN
) {
751 pr_err("Requested Default Queue Depth: %u smaller"
752 " than minimum %u\n", tcq_depth
,
753 TA_DEFAULT_CMDSN_DEPTH_MIN
);
757 a
->default_cmdsn_depth
= tcq_depth
;
758 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
759 tpg
->tpgt
, a
->default_cmdsn_depth
);
764 int iscsit_ta_cache_dynamic_acls(
765 struct iscsi_portal_group
*tpg
,
768 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
770 if ((flag
!= 0) && (flag
!= 1)) {
771 pr_err("Illegal value %d\n", flag
);
775 if (a
->generate_node_acls
== 1 && flag
== 0) {
776 pr_debug("Skipping cache_dynamic_acls=0 when"
777 " generate_node_acls=1\n");
781 a
->cache_dynamic_acls
= flag
;
782 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
783 " ACLs %s\n", tpg
->tpgt
, (a
->cache_dynamic_acls
) ?
784 "Enabled" : "Disabled");
789 int iscsit_ta_demo_mode_write_protect(
790 struct iscsi_portal_group
*tpg
,
793 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
795 if ((flag
!= 0) && (flag
!= 1)) {
796 pr_err("Illegal value %d\n", flag
);
800 a
->demo_mode_write_protect
= flag
;
801 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
802 tpg
->tpgt
, (a
->demo_mode_write_protect
) ? "ON" : "OFF");
807 int iscsit_ta_prod_mode_write_protect(
808 struct iscsi_portal_group
*tpg
,
811 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
813 if ((flag
!= 0) && (flag
!= 1)) {
814 pr_err("Illegal value %d\n", flag
);
818 a
->prod_mode_write_protect
= flag
;
819 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
820 " %s\n", tpg
->tpgt
, (a
->prod_mode_write_protect
) ?