target: add virtual remote target
Subsystems (2)
PATCH RESEND 1/1 target: add virtual remote target
Create virtual remote target module.
It can be used to see a whole acl/lun/tpg configuration from all nodes in storage cluster.
For example, it allows to setup remote ports in ALUA port groups. To report all ports in a cluster in REPORT TARGET PORT GROUP command.
---
This patch have a valueble sence only with patchset "scsi: target: make RTPI an TPG identifier" to configure RPTI on remote/tpg_x same as on tpg on remote nodes.
On its own it can be used as a dummy fabric driver for test purposes
or whatever.
--- drivers/target/Kconfig | 1 + drivers/target/Makefile | 1 + drivers/target/tcm_remote/Kconfig | 8 + drivers/target/tcm_remote/Makefile | 2 + drivers/target/tcm_remote/tcm_remote.c | 352 +++++++++++++++++++++++++ drivers/target/tcm_remote/tcm_remote.h | 20 ++ 6 files changed, 384 insertions(+) create mode 100644 drivers/target/tcm_remote/Kconfig create mode 100644 drivers/target/tcm_remote/Makefile create mode 100644 drivers/target/tcm_remote/tcm_remote.c create mode 100644 drivers/target/tcm_remote/tcm_remote.h
drivers/target/Kconfig +1 -0
@@ -53,5 +53,6 @@ source "drivers/target/loopback/Kconfig" source "drivers/target/tcm_fc/Kconfig" source "drivers/target/iscsi/Kconfig" source "drivers/target/sbp/Kconfig" +source "drivers/target/tcm_remote/Kconfig" endif
drivers/target/Makefile +1 -0
@@ -30,5 +30,6 @@ obj-$(CONFIG_LOOPBACK_TARGET) += loopback/ obj-$(CONFIG_TCM_FC) += tcm_fc/ obj-$(CONFIG_ISCSI_TARGET) += iscsi/ obj-$(CONFIG_SBP_TARGET) += sbp/ +obj-$(CONFIG_REMOTE_TARGET) += tcm_remote/ obj-$(CONFIG_DLM_CKV) += dlm_ckv.o
drivers/target/tcm_remote/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only +config REMOTE_TARGET + tristate "TCM Virtual Remote target" + depends on SCSI + help + Say Y here to enable the TCM Virtual Remote fabric + That fabric is a dummy fabric to tell TCM about configuration + of TPG/ACL/LUN on peer nodes in a cluster.
drivers/target/tcm_remote/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_REMOTE_TARGET) += tcm_remote.o
drivers/target/tcm_remote/tcm_remote.c new file +352 -0
352 lines not on this page · raw message
drivers/target/tcm_remote/tcm_remote.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include <linux/types.h> +#include <linux/device.h> + +#define TCM_REMOTE_VERSION "v0.1" +#define TL_WWN_ADDR_LEN 256 +#define TL_TPGS_PER_HBA 32 + +struct tcm_remote_tpg { +unsigned short remote_tpgt; +struct se_portal_group remote_se_tpg; +struct tcm_remote_hba *remote_hba; +}; + +struct tcm_remote_hba { +u8 remote_proto_id; +unsigned char remote_wwn_address[TL_WWN_ADDR_LEN ]; +struct tcm_remote_tpg remote_hba_tpgs[TL_TPGS_PER_HBA ]; +struct se_wwn remote_hba_wwn; +};
Signature · 1 line
2.25.1
Quoted 6 lines · Dmitry Bogdanov
drivers/target/tcm_remote/tcm_remote.c new file +6
-0+ +static void tcm_remote_port_unlink ( +struct se_portal_group *se_tpg, +struct se_lun *lun) +{ + pr_debug("TCM_Remote_ConfigFS: Port Unlink LUN %lld Successful\n",
drivers/target/tcm_remote/tcm_remote.c line 146
Quoted 10 lines
drivers/target/tcm_remote/tcm_remote.c new file +10
-0+ lun->unpacked_lun); +} + +/* End items for tcm_remote_port_cit */ + +/* Start items for tcm_remote_naa_cit */ + +static struct se_portal_group *tcm_remote_make_tpg (struct se_wwn *wwn, +const char *name) +{
The patch seems ok.
My only comments are on coding style:
1. I know we have a mismatch in other lio code like above where sometimes we don't put any args on the first line after the "(" in tcm_remote_port_unlink and sometimes we do the above. Since this is new code, could you do the more standard style?
2. Maybe for some of these callouts where most drivers are returning the same hard coded value we shouldn't make them mandatory. target_fabric_tf_ops_check should just set a default callout.
Quoted 21 lines · Mike Christie
Quoted 6 lines · Dmitry Bogdanov
drivers/target/tcm_remote/tcm_remote.c new file +6
-0+ +static void tcm_remote_port_unlink ( +struct se_portal_group *se_tpg, +struct se_lun *lun) +{ + pr_debug("TCM_Remote_ConfigFS: Port Unlink LUN %lld Successful\n",drivers/target/tcm_remote/tcm_remote.c line 146
Quoted 10 lines
drivers/target/tcm_remote/tcm_remote.c new file +10
-0+ lun->unpacked_lun); +} + +/* End items for tcm_remote_port_cit */ + +/* Start items for tcm_remote_naa_cit */ + +static struct se_portal_group *tcm_remote_make_tpg (struct se_wwn *wwn, +const char *name) +{The patch seems ok.
Quoted 6 lines
My only comments are on coding style:
1. I know we have a mismatch in other lio code like above where sometimes we don't put any args on the first line after the "(" in
tcm_remote_port_unlinkand sometimes we do the above. Since this is new code, could you do the more standard style?
Yes, I will do it.
Quoted 3 lines
2. Maybe for some of these callouts where most drivers are returning the same hard coded value we shouldn't make them mandatory.
target_fabric_tf_ops_checkshould just set a default callout.
I see that those hardcoded values are different (0 or 1) in the drivers :) Most likely they can be the same, but those values are exported to sysfs and potentially it could break some userspace. That would add a much of questions.
I would like to keep this patch as much as simple.
BR,
Dmitry
Quoted 31 lines · Dmitry Bogdanov
Quoted 21 lines · Mike Christie
Quoted 6 lines · Dmitry Bogdanov
drivers/target/tcm_remote/tcm_remote.c new file +6
-0+ +static void tcm_remote_port_unlink ( +struct se_portal_group *se_tpg, +struct se_lun *lun) +{ + pr_debug("TCM_Remote_ConfigFS: Port Unlink LUN %lld Successful\n",drivers/target/tcm_remote/tcm_remote.c line 146
Quoted 10 lines
drivers/target/tcm_remote/tcm_remote.c new file +10
-0+ lun->unpacked_lun); +} + +/* End items for tcm_remote_port_cit */ + +/* Start items for tcm_remote_naa_cit */ + +static struct se_portal_group *tcm_remote_make_tpg (struct se_wwn *wwn, +const char *name) +{The patch seems ok.
Quoted 6 lines
My only comments are on coding style:
1. I know we have a mismatch in other lio code like above where sometimes we don't put any args on the first line after the "(" in
tcm_remote_port_unlinkand sometimes we do the above. Since this is new code, could you do the more standard style?Yes, I will do it.
Quoted 8 lines
Quoted 3 lines
2. Maybe for some of these callouts where most drivers are returning the same hard coded value we shouldn't make them mandatory.
target_fabric_tf_ops_checkshould just set a default callout.I see that those hardcoded values are different (0 or 1) in the drivers :) Most likely they can be the same, but those values are exported to sysfs and potentially it could break some userspace. That would add a much of questions.
I think you misunderstood me. I'm not saying we change any values. We just:
1. Add default callouts which are set if the driver does not have one and/or
2. Remove the requirement for some callouts.
so drivers don't have to know about some of the LIO details and don't need to fill the same thing for these callouts.
For example for the drivers that typically hard code values or have empty callouts similar to the new driver then we could normally have a default callout that LIO sets:
srp ibmv loop sbp fcoe usb vhost xen
tpg_check_demo_mode
0 1 1 1 0 1 1 1tpg_check_demo_mode_cache
1 1 0 1 0 0 1 0tpg_check_demo_mode_write_protect
1 0 0 0 0 0 0 0tpg_check_prod_mode_write_protect
0 0 0 0 0 0 0 0tpg_check_prod_mode_write_protect
0 0 0 0 0 0 0 0tpg_get_inst_index
1 1 1 1 user 1 1 1sess_get_index
0 0 1 0 user 0 0 0set_default_node_attributes (only used by iscsi)
empty empty empty empty empty empty empty empty
Notes:
1. qla, iscsi and efct allow users to set some of these values so I didn't include them as they would would always set the callout.
So you could probably have:
if (!tfo->tpg_check_demo_mode)
tfo->tpg_check_demo_mode = target_enable_feature,
/*
* This one is a weird one. I think vhost should actually be disabled
* like xen/usb/loop. I think srp/fcoe/efct should have worked like
* iscsi/qla. So just make it disabled by default below, then let
* srp/fcoe/efct/iscsi/qla/vhost set a callout to override for now so
* the behavior doesn't change.
*/
if (!tfo->tpg_check_demo_mode_cache)
tfo->tpg_check_demo_mode_cache = target_disable_feature,
if (!tfo->tpg_check_demo_mode_write_protect)
tfo->tpg_check_demo_mode_write_protect = target_disable_feature,...
/* * I think we want to have tcm_remote_sess_get_index use 0 like * all the drivers but loop/fcoe, and can use the default then. */ if (!tfo->sess_get_index) /* this would return 0 */ tfo->sess_get_index = target_get_def_sess_index; if (!tfo->tpg_get_inst_index) /* this would return 1 */ tfo->tpg_get_inst_index = target_get_def_inst_index; ... if (!tfo->set_default_node_attributes) tfo->set_default_node_attributes = target_set_no_attrs;
Or instead of making us always having a callout, then make it optional. set_default_node_attributes can probably be optional because only iscsi uses it.
Quoted 2 lines
I would like to keep this patch as much as simple.
I think for new drivers and features it's common to add new code and improve the infrastructure you are going to use. If you think my suggestion does not improve the code then I can see that.
Quoted 56 lines · Mike Christie
Quoted 31 lines · Dmitry Bogdanov
Quoted 21 lines · Mike Christie
Quoted 6 lines · Dmitry Bogdanov
drivers/target/tcm_remote/tcm_remote.c new file +6
-0+ +static void tcm_remote_port_unlink ( +struct se_portal_group *se_tpg, +struct se_lun *lun) +{ + pr_debug("TCM_Remote_ConfigFS: Port Unlink LUN %lld Successful\n",drivers/target/tcm_remote/tcm_remote.c line 146
Quoted 10 lines
drivers/target/tcm_remote/tcm_remote.c new file +10
-0+ lun->unpacked_lun); +} + +/* End items for tcm_remote_port_cit */ + +/* Start items for tcm_remote_naa_cit */ + +static struct se_portal_group *tcm_remote_make_tpg (struct se_wwn *wwn, +const char *name) +{The patch seems ok.
Quoted 6 lines
My only comments are on coding style:
1. I know we have a mismatch in other lio code like above where sometimes we don't put any args on the first line after the "(" in
tcm_remote_port_unlinkand sometimes we do the above. Since this is new code, could you do the more standard style?Yes, I will do it.
Quoted 8 lines
Quoted 3 lines
2. Maybe for some of these callouts where most drivers are returning the same hard coded value we shouldn't make them mandatory.
target_fabric_tf_ops_checkshould just set a default callout.I see that those hardcoded values are different (0 or 1) in the drivers :) Most likely they can be the same, but those values are exported to sysfs and potentially it could break some userspace. That would add a much of questions.
I think you misunderstood me. I'm not saying we change any values. We just:
1. Add default callouts which are set if the driver does not have one and/or
2. Remove the requirement for some callouts.so drivers don't have to know about some of the LIO details and don't need to fill the same thing for these callouts.
For example for the drivers that typically hard code values or have empty callouts similar to the new driver then we could normally have a default callout that LIO sets:
srp ibmv loop sbp fcoe usb vhost xen
Quoted 16 lines
tpg_check_demo_mode
0 1 1 1 0 1 1 1tpg_check_demo_mode_cache
1 1 0 1 0 0 1 0tpg_check_demo_mode_write_protect
1 0 0 0 0 0 0 0tpg_check_prod_mode_write_protect
0 0 0 0 0 0 0 0tpg_check_prod_mode_write_protect
0 0 0 0 0 0 0 0tpg_get_inst_index
1 1 1 1 user 1 1 1sess_get_index
0 0 1 0 user 0 0 0set_default_node_attributes(only used by iscsi)
empty empty empty empty empty empty empty empty
Thank you for the table! I was looking only at sess_get_index that has 1 or 0. Actually I may make sess_get_index_def return 0 and for tcm_loop keep its own sess_get_index function with 1 to keep backward compatibility.
Quoted 43 lines
Notes:
1. qla, iscsi and efct allow users to set some of these values so I didn't include them as they would would always set the callout.So you could probably have:
if (!tfo->tpg_check_demo_mode) tfo->tpg_check_demo_mode = target_enable_feature, /* * This one is a weird one. I think vhost should actually be disabled * like xen/usb/loop. I think srp/fcoe/efct should have worked like * iscsi/qla. So just make it disabled by default below, then let * srp/fcoe/efct/iscsi/qla/vhost set a callout to override for now so * the behavior doesn't change. */ if (!tfo->tpg_check_demo_mode_cache) tfo->tpg_check_demo_mode_cache = target_disable_feature, if (!tfo->tpg_check_demo_mode_write_protect) tfo->tpg_check_demo_mode_write_protect = target_disable_feature,...
/* * I think we want to have tcm_remote_sess_get_index use 0 like * all the drivers but loop/fcoe, and can use the default then. */ if (!tfo->sess_get_index) /* this would return 0 */ tfo->sess_get_index = target_get_def_sess_index; if (!tfo->tpg_get_inst_index) /* this would return 1 */ tfo->tpg_get_inst_index = target_get_def_inst_index; ... if (!tfo->set_default_node_attributes) tfo->set_default_node_attributes = target_set_no_attrs;Or instead of making us always having a callout, then make it optional.
set_default_node_attributescan probably be optional because only iscsi uses it.
Quoted 7 lines
Quoted 2 lines
I would like to keep this patch as much as simple.
I think for new drivers and features it's common to add new code and improve the infrastructure you are going to use. If you think my suggestion does not improve the code then I can see that.
You've convinced me, I will do it.
BR,
Dmitry