1 /*******************************************************************************
2 * This file contains iSCSI Target Portal Group related functions.
4 * \u00a9 Copyright 2007-2011 RisingTide Systems LLC.
6 * Licensed to the Linux Foundation under the General Public License (GPL) version 2.
8 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
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.
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 ******************************************************************************/
21 #include <target/target_core_base.h>
22 #include <target/target_core_fabric.h>
23 #include <target/target_core_configfs.h>
25 #include "iscsi_target_core.h"
26 #include "iscsi_target_erl0.h"
27 #include "iscsi_target_login.h"
28 #include "iscsi_target_nodeattrib.h"
29 #include "iscsi_target_tpg.h"
30 #include "iscsi_target_util.h"
31 #include "iscsi_target.h"
32 #include "iscsi_target_parameters.h"
34 #include <target/iscsi/iscsi_transport.h>
36 struct iscsi_portal_group
*iscsit_alloc_portal_group(struct iscsi_tiqn
*tiqn
, u16 tpgt
)
38 struct iscsi_portal_group
*tpg
;
40 tpg
= kzalloc(sizeof(struct iscsi_portal_group
), GFP_KERNEL
);
42 pr_err("Unable to allocate struct iscsi_portal_group\n");
47 tpg
->tpg_state
= TPG_STATE_FREE
;
49 INIT_LIST_HEAD(&tpg
->tpg_gnp_list
);
50 INIT_LIST_HEAD(&tpg
->tpg_list
);
51 mutex_init(&tpg
->tpg_access_lock
);
52 mutex_init(&tpg
->np_login_lock
);
53 spin_lock_init(&tpg
->tpg_state_lock
);
54 spin_lock_init(&tpg
->tpg_np_lock
);
59 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group
*);
61 int iscsit_load_discovery_tpg(void)
63 struct iscsi_param
*param
;
64 struct iscsi_portal_group
*tpg
;
67 tpg
= iscsit_alloc_portal_group(NULL
, 1);
69 pr_err("Unable to allocate struct iscsi_portal_group\n");
73 ret
= core_tpg_register(
74 &lio_target_fabric_configfs
->tf_ops
,
75 NULL
, &tpg
->tpg_se_tpg
, tpg
,
76 TRANSPORT_TPG_TYPE_DISCOVERY
);
82 tpg
->sid
= 1; /* First Assigned LIO Session ID */
83 iscsit_set_default_tpg_attribs(tpg
);
85 if (iscsi_create_default_params(&tpg
->param_list
) < 0)
88 * By default we disable authentication for discovery sessions,
89 * this can be changed with:
91 * /sys/kernel/config/target/iscsi/discovery_auth/enforce_discovery_auth
93 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
97 if (iscsi_update_param_value(param
, "CHAP,None") < 0)
100 tpg
->tpg_attrib
.authentication
= 0;
102 spin_lock(&tpg
->tpg_state_lock
);
103 tpg
->tpg_state
= TPG_STATE_ACTIVE
;
104 spin_unlock(&tpg
->tpg_state_lock
);
106 iscsit_global
->discovery_tpg
= tpg
;
107 pr_debug("CORE[0] - Allocated Discovery TPG\n");
112 core_tpg_deregister(&tpg
->tpg_se_tpg
);
117 void iscsit_release_discovery_tpg(void)
119 struct iscsi_portal_group
*tpg
= iscsit_global
->discovery_tpg
;
124 core_tpg_deregister(&tpg
->tpg_se_tpg
);
127 iscsit_global
->discovery_tpg
= NULL
;
130 struct iscsi_portal_group
*iscsit_get_tpg_from_np(
131 struct iscsi_tiqn
*tiqn
,
134 struct iscsi_portal_group
*tpg
= NULL
;
135 struct iscsi_tpg_np
*tpg_np
;
137 spin_lock(&tiqn
->tiqn_tpg_lock
);
138 list_for_each_entry(tpg
, &tiqn
->tiqn_tpg_list
, tpg_list
) {
140 spin_lock(&tpg
->tpg_state_lock
);
141 if (tpg
->tpg_state
== TPG_STATE_FREE
) {
142 spin_unlock(&tpg
->tpg_state_lock
);
145 spin_unlock(&tpg
->tpg_state_lock
);
147 spin_lock(&tpg
->tpg_np_lock
);
148 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
149 if (tpg_np
->tpg_np
== np
) {
150 spin_unlock(&tpg
->tpg_np_lock
);
151 spin_unlock(&tiqn
->tiqn_tpg_lock
);
155 spin_unlock(&tpg
->tpg_np_lock
);
157 spin_unlock(&tiqn
->tiqn_tpg_lock
);
163 struct iscsi_portal_group
*tpg
)
167 ret
= mutex_lock_interruptible(&tpg
->tpg_access_lock
);
168 return ((ret
!= 0) || signal_pending(current
)) ? -1 : 0;
171 void iscsit_put_tpg(struct iscsi_portal_group
*tpg
)
173 mutex_unlock(&tpg
->tpg_access_lock
);
176 static void iscsit_clear_tpg_np_login_thread(
177 struct iscsi_tpg_np
*tpg_np
,
178 struct iscsi_portal_group
*tpg
)
180 if (!tpg_np
->tpg_np
) {
181 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
185 iscsit_reset_np_thread(tpg_np
->tpg_np
, tpg_np
, tpg
);
188 void iscsit_clear_tpg_np_login_threads(
189 struct iscsi_portal_group
*tpg
)
191 struct iscsi_tpg_np
*tpg_np
;
193 spin_lock(&tpg
->tpg_np_lock
);
194 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
195 if (!tpg_np
->tpg_np
) {
196 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
199 spin_unlock(&tpg
->tpg_np_lock
);
200 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
);
201 spin_lock(&tpg
->tpg_np_lock
);
203 spin_unlock(&tpg
->tpg_np_lock
);
206 void iscsit_tpg_dump_params(struct iscsi_portal_group
*tpg
)
208 iscsi_print_params(tpg
->param_list
);
211 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group
*tpg
)
213 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
215 a
->authentication
= TA_AUTHENTICATION
;
216 a
->login_timeout
= TA_LOGIN_TIMEOUT
;
217 a
->netif_timeout
= TA_NETIF_TIMEOUT
;
218 a
->default_cmdsn_depth
= TA_DEFAULT_CMDSN_DEPTH
;
219 a
->generate_node_acls
= TA_GENERATE_NODE_ACLS
;
220 a
->cache_dynamic_acls
= TA_CACHE_DYNAMIC_ACLS
;
221 a
->demo_mode_write_protect
= TA_DEMO_MODE_WRITE_PROTECT
;
222 a
->prod_mode_write_protect
= TA_PROD_MODE_WRITE_PROTECT
;
225 int iscsit_tpg_add_portal_group(struct iscsi_tiqn
*tiqn
, struct iscsi_portal_group
*tpg
)
227 if (tpg
->tpg_state
!= TPG_STATE_FREE
) {
228 pr_err("Unable to add iSCSI Target Portal Group: %d"
229 " while not in TPG_STATE_FREE state.\n", tpg
->tpgt
);
232 iscsit_set_default_tpg_attribs(tpg
);
234 if (iscsi_create_default_params(&tpg
->param_list
) < 0)
237 ISCSI_TPG_ATTRIB(tpg
)->tpg
= tpg
;
239 spin_lock(&tpg
->tpg_state_lock
);
240 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
241 spin_unlock(&tpg
->tpg_state_lock
);
243 spin_lock(&tiqn
->tiqn_tpg_lock
);
244 list_add_tail(&tpg
->tpg_list
, &tiqn
->tiqn_tpg_list
);
246 pr_debug("CORE[%s]_TPG[%hu] - Added iSCSI Target Portal Group\n",
247 tiqn
->tiqn
, tpg
->tpgt
);
248 spin_unlock(&tiqn
->tiqn_tpg_lock
);
252 if (tpg
->param_list
) {
253 iscsi_release_param_list(tpg
->param_list
);
254 tpg
->param_list
= NULL
;
260 int iscsit_tpg_del_portal_group(
261 struct iscsi_tiqn
*tiqn
,
262 struct iscsi_portal_group
*tpg
,
265 u8 old_state
= tpg
->tpg_state
;
267 spin_lock(&tpg
->tpg_state_lock
);
268 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
269 spin_unlock(&tpg
->tpg_state_lock
);
271 if (iscsit_release_sessions_for_tpg(tpg
, force
) < 0) {
272 pr_err("Unable to delete iSCSI Target Portal Group:"
273 " %hu while active sessions exist, and force=0\n",
275 tpg
->tpg_state
= old_state
;
279 core_tpg_clear_object_luns(&tpg
->tpg_se_tpg
);
281 if (tpg
->param_list
) {
282 iscsi_release_param_list(tpg
->param_list
);
283 tpg
->param_list
= NULL
;
286 core_tpg_deregister(&tpg
->tpg_se_tpg
);
288 spin_lock(&tpg
->tpg_state_lock
);
289 tpg
->tpg_state
= TPG_STATE_FREE
;
290 spin_unlock(&tpg
->tpg_state_lock
);
292 spin_lock(&tiqn
->tiqn_tpg_lock
);
294 list_del(&tpg
->tpg_list
);
295 spin_unlock(&tiqn
->tiqn_tpg_lock
);
297 pr_debug("CORE[%s]_TPG[%hu] - Deleted iSCSI Target Portal Group\n",
298 tiqn
->tiqn
, tpg
->tpgt
);
304 int iscsit_tpg_enable_portal_group(struct iscsi_portal_group
*tpg
)
306 struct iscsi_param
*param
;
307 struct iscsi_tiqn
*tiqn
= tpg
->tpg_tiqn
;
310 spin_lock(&tpg
->tpg_state_lock
);
311 if (tpg
->tpg_state
== TPG_STATE_ACTIVE
) {
312 pr_err("iSCSI target portal group: %hu is already"
313 " active, ignoring request.\n", tpg
->tpgt
);
314 spin_unlock(&tpg
->tpg_state_lock
);
318 * Make sure that AuthMethod does not contain None as an option
319 * unless explictly disabled. Set the default to CHAP if authentication
320 * is enforced (as per default), and remove the NONE option.
322 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
324 spin_unlock(&tpg
->tpg_state_lock
);
328 if (ISCSI_TPG_ATTRIB(tpg
)->authentication
) {
329 if (!strcmp(param
->value
, NONE
)) {
330 ret
= iscsi_update_param_value(param
, CHAP
);
335 ret
= iscsit_ta_authentication(tpg
, 1);
340 tpg
->tpg_state
= TPG_STATE_ACTIVE
;
341 spin_unlock(&tpg
->tpg_state_lock
);
343 spin_lock(&tiqn
->tiqn_tpg_lock
);
344 tiqn
->tiqn_active_tpgs
++;
345 pr_debug("iSCSI_TPG[%hu] - Enabled iSCSI Target Portal Group\n",
347 spin_unlock(&tiqn
->tiqn_tpg_lock
);
352 spin_unlock(&tpg
->tpg_state_lock
);
356 int iscsit_tpg_disable_portal_group(struct iscsi_portal_group
*tpg
, int force
)
358 struct iscsi_tiqn
*tiqn
;
359 u8 old_state
= tpg
->tpg_state
;
361 spin_lock(&tpg
->tpg_state_lock
);
362 if (tpg
->tpg_state
== TPG_STATE_INACTIVE
) {
363 pr_err("iSCSI Target Portal Group: %hu is already"
364 " inactive, ignoring request.\n", tpg
->tpgt
);
365 spin_unlock(&tpg
->tpg_state_lock
);
368 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
369 spin_unlock(&tpg
->tpg_state_lock
);
371 iscsit_clear_tpg_np_login_threads(tpg
);
373 if (iscsit_release_sessions_for_tpg(tpg
, force
) < 0) {
374 spin_lock(&tpg
->tpg_state_lock
);
375 tpg
->tpg_state
= old_state
;
376 spin_unlock(&tpg
->tpg_state_lock
);
377 pr_err("Unable to disable iSCSI Target Portal Group:"
378 " %hu while active sessions exist, and force=0\n",
383 tiqn
= tpg
->tpg_tiqn
;
384 if (!tiqn
|| (tpg
== iscsit_global
->discovery_tpg
))
387 spin_lock(&tiqn
->tiqn_tpg_lock
);
388 tiqn
->tiqn_active_tpgs
--;
389 pr_debug("iSCSI_TPG[%hu] - Disabled iSCSI Target Portal Group\n",
391 spin_unlock(&tiqn
->tiqn_tpg_lock
);
396 struct iscsi_node_attrib
*iscsit_tpg_get_node_attrib(
397 struct iscsi_session
*sess
)
399 struct se_session
*se_sess
= sess
->se_sess
;
400 struct se_node_acl
*se_nacl
= se_sess
->se_node_acl
;
401 struct iscsi_node_acl
*acl
= container_of(se_nacl
, struct iscsi_node_acl
,
404 return &acl
->node_attrib
;
407 struct iscsi_tpg_np
*iscsit_tpg_locate_child_np(
408 struct iscsi_tpg_np
*tpg_np
,
409 int network_transport
)
411 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
413 spin_lock(&tpg_np
->tpg_np_parent_lock
);
414 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
415 &tpg_np
->tpg_np_parent_list
, tpg_np_child_list
) {
416 if (tpg_np_child
->tpg_np
->np_network_transport
==
418 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
422 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
427 static bool iscsit_tpg_check_network_portal(
428 struct iscsi_tiqn
*tiqn
,
429 struct __kernel_sockaddr_storage
*sockaddr
,
430 int network_transport
)
432 struct iscsi_portal_group
*tpg
;
433 struct iscsi_tpg_np
*tpg_np
;
437 spin_lock(&tiqn
->tiqn_tpg_lock
);
438 list_for_each_entry(tpg
, &tiqn
->tiqn_tpg_list
, tpg_list
) {
440 spin_lock(&tpg
->tpg_np_lock
);
441 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
444 match
= iscsit_check_np_match(sockaddr
, np
,
449 spin_unlock(&tpg
->tpg_np_lock
);
451 spin_unlock(&tiqn
->tiqn_tpg_lock
);
456 struct iscsi_tpg_np
*iscsit_tpg_add_network_portal(
457 struct iscsi_portal_group
*tpg
,
458 struct __kernel_sockaddr_storage
*sockaddr
,
460 struct iscsi_tpg_np
*tpg_np_parent
,
461 int network_transport
)
464 struct iscsi_tpg_np
*tpg_np
;
466 if (!tpg_np_parent
) {
467 if (iscsit_tpg_check_network_portal(tpg
->tpg_tiqn
, sockaddr
,
468 network_transport
) == true) {
469 pr_err("Network Portal: %s already exists on a"
470 " different TPG on %s\n", ip_str
,
471 tpg
->tpg_tiqn
->tiqn
);
472 return ERR_PTR(-EEXIST
);
476 tpg_np
= kzalloc(sizeof(struct iscsi_tpg_np
), GFP_KERNEL
);
478 pr_err("Unable to allocate memory for"
479 " struct iscsi_tpg_np.\n");
480 return ERR_PTR(-ENOMEM
);
483 np
= iscsit_add_np(sockaddr
, ip_str
, network_transport
);
489 INIT_LIST_HEAD(&tpg_np
->tpg_np_list
);
490 INIT_LIST_HEAD(&tpg_np
->tpg_np_child_list
);
491 INIT_LIST_HEAD(&tpg_np
->tpg_np_parent_list
);
492 spin_lock_init(&tpg_np
->tpg_np_parent_lock
);
496 spin_lock(&tpg
->tpg_np_lock
);
497 list_add_tail(&tpg_np
->tpg_np_list
, &tpg
->tpg_gnp_list
);
500 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
++;
501 spin_unlock(&tpg
->tpg_np_lock
);
504 tpg_np
->tpg_np_parent
= tpg_np_parent
;
505 spin_lock(&tpg_np_parent
->tpg_np_parent_lock
);
506 list_add_tail(&tpg_np
->tpg_np_child_list
,
507 &tpg_np_parent
->tpg_np_parent_list
);
508 spin_unlock(&tpg_np_parent
->tpg_np_parent_lock
);
511 pr_debug("CORE[%s] - Added Network Portal: %s:%hu,%hu on %s\n",
512 tpg
->tpg_tiqn
->tiqn
, np
->np_ip
, np
->np_port
, tpg
->tpgt
,
513 np
->np_transport
->name
);
518 static int iscsit_tpg_release_np(
519 struct iscsi_tpg_np
*tpg_np
,
520 struct iscsi_portal_group
*tpg
,
523 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
);
525 pr_debug("CORE[%s] - Removed Network Portal: %s:%hu,%hu on %s\n",
526 tpg
->tpg_tiqn
->tiqn
, np
->np_ip
, np
->np_port
, tpg
->tpgt
,
527 np
->np_transport
->name
);
529 tpg_np
->tpg_np
= NULL
;
533 * iscsit_del_np() will shutdown struct iscsi_np when last TPG reference is released.
535 return iscsit_del_np(np
);
538 int iscsit_tpg_del_network_portal(
539 struct iscsi_portal_group
*tpg
,
540 struct iscsi_tpg_np
*tpg_np
)
543 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
548 pr_err("Unable to locate struct iscsi_np from"
549 " struct iscsi_tpg_np\n");
553 if (!tpg_np
->tpg_np_parent
) {
555 * We are the parent tpg network portal. Release all of the
556 * child tpg_np's (eg: the non ISCSI_TCP ones) on our parent
559 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
560 &tpg_np
->tpg_np_parent_list
,
562 ret
= iscsit_tpg_del_network_portal(tpg
, tpg_np_child
);
564 pr_err("iscsit_tpg_del_network_portal()"
565 " failed: %d\n", ret
);
569 * We are not the parent ISCSI_TCP tpg network portal. Release
570 * our own network portals from the child list.
572 spin_lock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
573 list_del(&tpg_np
->tpg_np_child_list
);
574 spin_unlock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
577 spin_lock(&tpg
->tpg_np_lock
);
578 list_del(&tpg_np
->tpg_np_list
);
581 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
--;
582 spin_unlock(&tpg
->tpg_np_lock
);
584 return iscsit_tpg_release_np(tpg_np
, tpg
, np
);
587 int iscsit_tpg_set_initiator_node_queue_depth(
588 struct iscsi_portal_group
*tpg
,
589 unsigned char *initiatorname
,
593 return core_tpg_set_initiator_node_queue_depth(&tpg
->tpg_se_tpg
,
594 initiatorname
, queue_depth
, force
);
597 int iscsit_ta_authentication(struct iscsi_portal_group
*tpg
, u32 authentication
)
599 unsigned char buf1
[256], buf2
[256], *none
= NULL
;
601 struct iscsi_param
*param
;
602 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
604 if ((authentication
!= 1) && (authentication
!= 0)) {
605 pr_err("Illegal value for authentication parameter:"
606 " %u, ignoring request.\n", authentication
);
610 memset(buf1
, 0, sizeof(buf1
));
611 memset(buf2
, 0, sizeof(buf2
));
613 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
617 if (authentication
) {
618 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
619 none
= strstr(buf1
, NONE
);
622 if (!strncmp(none
+ 4, ",", 1)) {
623 if (!strcmp(buf1
, none
))
624 sprintf(buf2
, "%s", none
+5);
628 len
= sprintf(buf2
, "%s", buf1
);
630 sprintf(buf2
+ len
, "%s", none
);
635 sprintf(buf2
, "%s", buf1
);
637 if (iscsi_update_param_value(param
, buf2
) < 0)
640 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
641 none
= strstr(buf1
, NONE
);
644 strncat(buf1
, ",", strlen(","));
645 strncat(buf1
, NONE
, strlen(NONE
));
646 if (iscsi_update_param_value(param
, buf1
) < 0)
651 a
->authentication
= authentication
;
652 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
653 a
->authentication
? "Enforcing" : "Disabling", tpg
->tpgt
);
658 int iscsit_ta_login_timeout(
659 struct iscsi_portal_group
*tpg
,
662 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
664 if (login_timeout
> TA_LOGIN_TIMEOUT_MAX
) {
665 pr_err("Requested Login Timeout %u larger than maximum"
666 " %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MAX
);
668 } else if (login_timeout
< TA_LOGIN_TIMEOUT_MIN
) {
669 pr_err("Requested Logout Timeout %u smaller than"
670 " minimum %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MIN
);
674 a
->login_timeout
= login_timeout
;
675 pr_debug("Set Logout Timeout to %u for Target Portal Group"
676 " %hu\n", a
->login_timeout
, tpg
->tpgt
);
681 int iscsit_ta_netif_timeout(
682 struct iscsi_portal_group
*tpg
,
685 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
687 if (netif_timeout
> TA_NETIF_TIMEOUT_MAX
) {
688 pr_err("Requested Network Interface Timeout %u larger"
689 " than maximum %u\n", netif_timeout
,
690 TA_NETIF_TIMEOUT_MAX
);
692 } else if (netif_timeout
< TA_NETIF_TIMEOUT_MIN
) {
693 pr_err("Requested Network Interface Timeout %u smaller"
694 " than minimum %u\n", netif_timeout
,
695 TA_NETIF_TIMEOUT_MIN
);
699 a
->netif_timeout
= netif_timeout
;
700 pr_debug("Set Network Interface Timeout to %u for"
701 " Target Portal Group %hu\n", a
->netif_timeout
, tpg
->tpgt
);
706 int iscsit_ta_generate_node_acls(
707 struct iscsi_portal_group
*tpg
,
710 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
712 if ((flag
!= 0) && (flag
!= 1)) {
713 pr_err("Illegal value %d\n", flag
);
717 a
->generate_node_acls
= flag
;
718 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
719 tpg
->tpgt
, (a
->generate_node_acls
) ? "Enabled" : "Disabled");
721 if (flag
== 1 && a
->cache_dynamic_acls
== 0) {
722 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
723 "generate_node_acls=1\n");
724 a
->cache_dynamic_acls
= 1;
730 int iscsit_ta_default_cmdsn_depth(
731 struct iscsi_portal_group
*tpg
,
734 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
736 if (tcq_depth
> TA_DEFAULT_CMDSN_DEPTH_MAX
) {
737 pr_err("Requested Default Queue Depth: %u larger"
738 " than maximum %u\n", tcq_depth
,
739 TA_DEFAULT_CMDSN_DEPTH_MAX
);
741 } else if (tcq_depth
< TA_DEFAULT_CMDSN_DEPTH_MIN
) {
742 pr_err("Requested Default Queue Depth: %u smaller"
743 " than minimum %u\n", tcq_depth
,
744 TA_DEFAULT_CMDSN_DEPTH_MIN
);
748 a
->default_cmdsn_depth
= tcq_depth
;
749 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
750 tpg
->tpgt
, a
->default_cmdsn_depth
);
755 int iscsit_ta_cache_dynamic_acls(
756 struct iscsi_portal_group
*tpg
,
759 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
761 if ((flag
!= 0) && (flag
!= 1)) {
762 pr_err("Illegal value %d\n", flag
);
766 if (a
->generate_node_acls
== 1 && flag
== 0) {
767 pr_debug("Skipping cache_dynamic_acls=0 when"
768 " generate_node_acls=1\n");
772 a
->cache_dynamic_acls
= flag
;
773 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
774 " ACLs %s\n", tpg
->tpgt
, (a
->cache_dynamic_acls
) ?
775 "Enabled" : "Disabled");
780 int iscsit_ta_demo_mode_write_protect(
781 struct iscsi_portal_group
*tpg
,
784 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
786 if ((flag
!= 0) && (flag
!= 1)) {
787 pr_err("Illegal value %d\n", flag
);
791 a
->demo_mode_write_protect
= flag
;
792 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
793 tpg
->tpgt
, (a
->demo_mode_write_protect
) ? "ON" : "OFF");
798 int iscsit_ta_prod_mode_write_protect(
799 struct iscsi_portal_group
*tpg
,
802 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
804 if ((flag
!= 0) && (flag
!= 1)) {
805 pr_err("Illegal value %d\n", flag
);
809 a
->prod_mode_write_protect
= flag
;
810 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
811 " %s\n", tpg
->tpgt
, (a
->prod_mode_write_protect
) ?