target/iscsi: clustered SendTargets handling
cover target/iscsi: clustered SendTargets handling
For active/active clustered iSCSI targets (e.g. LIO + Ceph RBD), SendTargets responses from any single node should include portal details for remote cluster nodes.
This patch-set adds a TPG discoverable_while_disabled attribute, which when set sees LIO include details for a disabled TPG in SendTargets responses.
This allows for the use of a common configuration for cluster nodes, with TPGT/enable set on a node specific basis.
A patch-set to ensure that LIO doesn't listen/accept connections via disabled TPGs will follow once I've finished cleaning it up.
Feedback appreciated.
Cheers, David
RFC PATCH 1/2 target/iscsi: discoverable_while_disabled TPGT attr
Add a new discoverable_while_disabled target portal group attribute, which will in future be used to govern whether entries for disabled TPGTs are present in SendTargets responses.
--- drivers/target/iscsi/iscsi_target_configfs.c | 6 ++++++ drivers/target/iscsi/iscsi_target_tpg.c | 20 ++++++++++++++++++++ drivers/target/iscsi/iscsi_target_tpg.h | 2 ++ include/target/iscsi/iscsi_target_core.h | 2 ++ 4 files changed, 30 insertions(+)
drivers/target/iscsi/iscsi_target_configfs.c +6 -0
@@ -1010,6 +1010,11 @@ TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR);*/ DEF_TPG_ATTRIB (fabric_prot_type);TPG_ATTR (fabric_prot_type,S_IRUGO |S_IWUSR ); +/* +* Define iscsi_tpg_attrib_s_discoverable_while_disabled, +*/ +DEF_TPG_ATTRIB (discoverable_while_disabled); +TPG_ATTR (discoverable_while_disabled,S_IRUGO |S_IWUSR );static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { &iscsi_tpg_attrib_authentication.attr,
@@ -1024,6 +1029,7 @@ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { &iscsi_tpg_attrib_default_erl.attr, &iscsi_tpg_attrib_t10_pi.attr, &iscsi_tpg_attrib_fabric_prot_type.attr, + &iscsi_tpg_attrib_discoverable_while_disabled.attr, NULL, };
drivers/target/iscsi/iscsi_target_tpg.c +20 -0
@@ -226,6 +226,7 @@ static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *tpg) a->default_erl =TA_DEFAULT_ERL ; a->t10_pi =TA_DEFAULT_T10_PI ; a->fabric_prot_type =TA_DEFAULT_FABRIC_PROT_TYPE ; + a->discoverable_while_disabled =TA_DEFAULT_DISCOVERABLE_WHILE_DISABLED ; }int iscsit_tpg_add_portal_group (struct iscsi_tiqn *tiqn,struct iscsi_portal_group *tpg)
@@ -892,3 +893,22 @@ int iscsit_ta_fabric_prot_type(return 0 ; } + +int iscsit_ta_discoverable_while_disabled ( +struct iscsi_portal_group *tpg, +u32 flag) +{ +struct iscsi_tpg_attrib *a = &tpg->tpg_attrib; + +if ((flag !=0 ) && (flag !=1 )) { +pr_err ("Illegal value %d\n" , flag); +return -EINVAL ; + } + + a->discoverable_while_disabled = flag; +pr_debug ("iSCSI_TPG[%hu] - Discoverable while disabled:" +" %s\n" , tpg->tpgt, (a->discoverable_while_disabled) ? +"ON" :"OFF" ); + +return 0 ; +}
drivers/target/iscsi/iscsi_target_tpg.h +2 -0
@@ -40,5 +40,7 @@ extern int iscsit_ta_demo_mode_discovery(struct iscsi_portal_group *, u32);extern int iscsit_ta_default_erl (struct iscsi_portal_group *,u32 );extern int iscsit_ta_t10_pi (struct iscsi_portal_group *,u32 );extern int iscsit_ta_fabric_prot_type (struct iscsi_portal_group *,u32 ); +extern int iscsit_ta_discoverable_while_disabled (struct iscsi_portal_group *, +u32 );#endif /* ISCSI_TARGET_TPG_H */
include/target/iscsi/iscsi_target_core.h +2 -0
@@ -62,6 +62,7 @@/* T10 protection information disabled by default */ #define TA_DEFAULT_T10_PI 0#define TA_DEFAULT_FABRIC_PROT_TYPE 0 +#define TA_DEFAULT_DISCOVERABLE_WHILE_DISABLED 0#define ISCSI_IOV_DATA_BUFFER 5
@@ -763,6 +764,7 @@ struct iscsi_tpg_attrib {u32 default_erl;u8 t10_pi;u32 fabric_prot_type; +u32 discoverable_while_disabled;struct iscsi_portal_group *tpg; };
Signature · 1 line
2.1.4
RFC PATCH 2/2 target/iscsi: discoverable_while_disabled SendTargets
In reply to David DisseldorpIf the discoverable_while_disabled TPGT attribute is set, then add a corresponding entry to the SendTargets response, regardless of whether the TPGT is enabled or not.
This functionality is usefull for clustered iSCSI targets, where TPGTs handled on remote cluster nodes should be advertised in the SendTargets response.
--- drivers/target/iscsi/iscsi_target.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +2 -1
@@ -3453,7 +3453,8 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,spin_lock (&tpg->tpg_state_lock);if ((tpg->tpg_state ==TPG_STATE_FREE ) || - (tpg->tpg_state ==TPG_STATE_INACTIVE )) { + ((tpg->tpg_state ==TPG_STATE_INACTIVE ) + && (tpg->tpg_attrib.discoverable_while_disabled ==0 ))) {spin_unlock (&tpg->tpg_state_lock);continue ; }
Signature · 1 line
2.1.4
Hi David,
Apologies for the delayed follow-up on your original patch.
Quoted 8 lines · David Disseldorp
For active/active clustered iSCSI targets (e.g. LIO + Ceph RBD), SendTargets responses from any single node should include portal details for remote cluster nodes.
This patch-set adds a TPG
discoverable_while_disabledattribute, which when set sees LIO include details for a disabled TPG in SendTargets responses.
Quoted 7 lines
This allows for the use of a common configuration for cluster nodes, with TPGT/enable set on a node specific basis.
A patch-set to ensure that LIO doesn't listen/accept connections via disabled TPGs will follow once I've finished cleaning it up.
Feedback appreciated.
No objections to adding an attribute to allow disabled TPGs to be included in sendtargets discovery information, but I think this particular configfs attribute can use a better name..
How about the following instead..?
--nab
From 688da43134cddb8ff12ab1056c636cf1eb4f4f8f Mon Sep 17 00:00:00 2001
From: David Disseldorp <[email protected]>
Date: Sat, 1 Aug 2015 00:10:12 -0700
Subject: [PATCH] iscsi-target: Add tpg_enabled_sendtargets for disabled
discovery
This patch adds a new tpg_enabled_sendtargets configfs attribute to allow in-band sendtargets discovery information to include target-portal-groups (TPGs) in !TPG_STATE_ACTIVE state.
This functionality is useful for clustered iSCSI targets, where TPGTs handled on remote cluster nodes should be advertised in the SendTargets response.
By default, this new attribute retains the default behaviour of existing code which to ignore portal-groups in !TPG_STATE_ACTIVE state.
--- drivers/target/iscsi/iscsi_target.c | 10 +++++----- drivers/target/iscsi/iscsi_target_configfs.c | 6 ++++++ drivers/target/iscsi/iscsi_target_tpg.c | 19 +++++++++++++++++++ drivers/target/iscsi/iscsi_target_tpg.h | 1 + include/target/iscsi/iscsi_target_core.h | 3 +++ 5 files changed, 34 insertions(+), 5 deletions(-)
drivers/target/iscsi/iscsi_target.c +5 -5
@@ -3398,6 +3398,7 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,int target_name_printed;unsigned char buf[ISCSI_IQN_LEN +12 ];/* iqn + "TargetName=" + \0 */ unsigned char *text_in = cmd->text_in_ptr, *text_ptr =NULL ; +bool active; buffer_len =min (conn->conn_ops->MaxRecvDataSegmentLength,SENDTARGETS_BUF_LIMIT );
@@ -3451,13 +3452,12 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd, }spin_lock (&tpg->tpg_state_lock); -if ((tpg->tpg_state ==TPG_STATE_FREE ) || - (tpg->tpg_state ==TPG_STATE_INACTIVE )) { -spin_unlock (&tpg->tpg_state_lock); -continue ; - } + active = (tpg->tpg_state ==TPG_STATE_ACTIVE );spin_unlock (&tpg->tpg_state_lock); +if (!active && tpg->tpg_attrib.tpg_enabled_sendtargets) +continue ; +spin_lock (&tpg->tpg_np_lock);list_for_each_entry (tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
drivers/target/iscsi/iscsi_target_configfs.c +6 -0
@@ -1010,6 +1010,11 @@ TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR);*/ DEF_TPG_ATTRIB (fabric_prot_type);TPG_ATTR (fabric_prot_type,S_IRUGO |S_IWUSR ); +/* +* Define iscsi_tpg_attrib_s_tpg_enabled_sendtargets +*/ +DEF_TPG_ATTRIB (tpg_enabled_sendtargets); +TPG_ATTR (tpg_enabled_sendtargets,S_IRUGO |S_IWUSR );static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { &iscsi_tpg_attrib_authentication.attr,
@@ -1024,6 +1029,7 @@ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { &iscsi_tpg_attrib_default_erl.attr, &iscsi_tpg_attrib_t10_pi.attr, &iscsi_tpg_attrib_fabric_prot_type.attr, + &iscsi_tpg_attrib_tpg_enabled_sendtargets.attr, NULL, };
drivers/target/iscsi/iscsi_target_tpg.c +19 -0
@@ -226,6 +226,7 @@ static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *tpg) a->default_erl =TA_DEFAULT_ERL ; a->t10_pi =TA_DEFAULT_T10_PI ; a->fabric_prot_type =TA_DEFAULT_FABRIC_PROT_TYPE ; + a->tpg_enabled_sendtargets =TA_DEFAULT_TPG_ENABLED_SENDTARGETS ; }int iscsit_tpg_add_portal_group (struct iscsi_tiqn *tiqn,struct iscsi_portal_group *tpg)
@@ -892,3 +893,21 @@ int iscsit_ta_fabric_prot_type(return 0 ; } + +int iscsit_ta_tpg_enabled_sendtargets ( +struct iscsi_portal_group *tpg, +u32 flag) +{ +struct iscsi_tpg_attrib *a = &tpg->tpg_attrib; + +if ((flag !=0 ) && (flag !=1 )) { +pr_err ("Illegal value %d\n" , flag); +return -EINVAL ; + } + + a->tpg_enabled_sendtargets = flag; +pr_debug ("iSCSI_TPG[%hu] - TPG enabled bit required for SendTargets:" +" %s\n" , tpg->tpgt, (a->tpg_enabled_sendtargets) ?"ON" :"OFF" ); + +return 0 ; +}
drivers/target/iscsi/iscsi_target_tpg.h +1 -0
@@ -40,5 +40,6 @@ extern int iscsit_ta_demo_mode_discovery(struct iscsi_portal_group *, u32);extern int iscsit_ta_default_erl (struct iscsi_portal_group *,u32 );extern int iscsit_ta_t10_pi (struct iscsi_portal_group *,u32 );extern int iscsit_ta_fabric_prot_type (struct iscsi_portal_group *,u32 ); +extern int iscsit_ta_tpg_enabled_sendtargets (struct iscsi_portal_group *,u32 );#endif /* ISCSI_TARGET_TPG_H */
include/target/iscsi/iscsi_target_core.h +3 -0
@@ -62,6 +62,8 @@/* T10 protection information disabled by default */ #define TA_DEFAULT_T10_PI 0#define TA_DEFAULT_FABRIC_PROT_TYPE 0 +/* TPG status needs to be enabled to return sendtargets discovery endpoint info */ +#define TA_DEFAULT_TPG_ENABLED_SENDTARGETS 1#define ISCSI_IOV_DATA_BUFFER 5
@@ -763,6 +765,7 @@ struct iscsi_tpg_attrib {u32 default_erl;u8 t10_pi;u32 fabric_prot_type; +u32 tpg_enabled_sendtargets;struct iscsi_portal_group *tpg; };
Signature · 1 line
1.9.1
Hi Nicholas,
Quoted 3 lines · Nicholas A. Bellinger
Hi David,
Apologies for the delayed follow-up on your original patch.
No problem - thanks for the feedback!
Quoted 12 lines · David Disseldorp
Quoted 11 lines
For active/active clustered iSCSI targets (e.g. LIO + Ceph RBD), SendTargets responses from any single node should include portal details for remote cluster nodes.
This patch-set adds a TPG
discoverable_while_disabledattribute, which when set sees LIO include details for a disabled TPG in SendTargets responses.This allows for the use of a common configuration for cluster nodes, with TPGT/enable set on a node specific basis.
Quoted 8 lines
Quoted 4 lines
A patch-set to ensure that LIO doesn't listen/accept connections via disabled TPGs will follow once I've finished cleaning it up.
Feedback appreciated.
No objections to adding an attribute to allow disabled TPGs to be included in sendtargets discovery information, but I think this particular configfs attribute can use a better name..
Heh, yeah I also wasn't a fan of discoverable_while_disabled, but couldn't think of anything better.
Quoted 1 line
How about the following instead..?
Looks like an improvement to me.
Cheers, David
Nicholas A. Bellinger
AppliedQuoted 31 lines · David Disseldorp
Hi Nicholas,
Quoted 3 lines · Nicholas A. Bellinger
Hi David,
Apologies for the delayed follow-up on your original patch.
No problem - thanks for the feedback!
Quoted 12 lines · David Disseldorp
Quoted 11 lines
For active/active clustered iSCSI targets (e.g. LIO + Ceph RBD), SendTargets responses from any single node should include portal details for remote cluster nodes.
This patch-set adds a TPG
discoverable_while_disabledattribute, which when set sees LIO include details for a disabled TPG in SendTargets responses.This allows for the use of a common configuration for cluster nodes, with TPGT/enable set on a node specific basis.
Quoted 8 lines
Quoted 4 lines
A patch-set to ensure that LIO doesn't listen/accept connections via disabled TPGs will follow once I've finished cleaning it up.
Feedback appreciated.
No objections to adding an attribute to allow disabled TPGs to be included in sendtargets discovery information, but I think this particular configfs attribute can use a better name..
Quoted 7 lines
Heh, yeah I also wasn't a fan of
discoverable_while_disabled, but couldn't think of anything better.Quoted 1 line
How about the following instead..?
Looks like an improvement to me.
Applied to target-pending/for-next with your original authorship + signed-off-by for the patch.
Thanks!