aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2012-12-11 19:30:53 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2012-12-13 17:18:09 -0500
commit79e62fc3827bd437c304c1810f36896fc1e717b1 (patch)
treefe58b9e0bb253699f22b32412f1e0d4a42865206
parent9f4ad44b264f8bb61ffdd607148215566568430d (diff)
target/iscsi_target: Add NodeACL tags for initiator group support
Thanks for reviews, looking a lot better. ---- 8< ---- Initiator access config could be easier. The way other storage vendors have addressed this is to support initiator groups: the admin adds initiator WWNs to the group, and then LUN permissions can be granted for the entire group at once. Instead of changing ktarget's configfs interface, this patch keeps the configfs interface per-initiator-wwn and just adds a 'tag' field for each. This should be enough for user tools like targetcli to group initiator ACLs and sync their configurations. acl_tag is not used internally, but needs to be kept in configfs so that all user tools can avoid dependencies on each other. Code tested to work, although userspace pieces still to be implemented. Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/iscsi/iscsi_target_configfs.c24
-rw-r--r--drivers/target/target_core_tpg.c23
-rw-r--r--include/target/target_core_base.h2
-rw-r--r--include/target/target_core_fabric.h2
4 files changed, 51 insertions, 0 deletions
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index 542641c504a6..5201d5ef9700 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -754,9 +754,33 @@ static ssize_t lio_target_nacl_store_cmdsn_depth(
754 754
755TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR); 755TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR);
756 756
757static ssize_t lio_target_nacl_show_tag(
758 struct se_node_acl *se_nacl,
759 char *page)
760{
761 return snprintf(page, PAGE_SIZE, "%s", se_nacl->acl_tag);
762}
763
764static ssize_t lio_target_nacl_store_tag(
765 struct se_node_acl *se_nacl,
766 const char *page,
767 size_t count)
768{
769 int ret;
770
771 ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page);
772
773 if (ret < 0)
774 return ret;
775 return count;
776}
777
778TF_NACL_BASE_ATTR(lio_target, tag, S_IRUGO | S_IWUSR);
779
757static struct configfs_attribute *lio_target_initiator_attrs[] = { 780static struct configfs_attribute *lio_target_initiator_attrs[] = {
758 &lio_target_nacl_info.attr, 781 &lio_target_nacl_info.attr,
759 &lio_target_nacl_cmdsn_depth.attr, 782 &lio_target_nacl_cmdsn_depth.attr,
783 &lio_target_nacl_tag.attr,
760 NULL, 784 NULL,
761}; 785};
762 786
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 0163309e2aba..5192ac0337f7 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -616,6 +616,29 @@ int core_tpg_set_initiator_node_queue_depth(
616} 616}
617EXPORT_SYMBOL(core_tpg_set_initiator_node_queue_depth); 617EXPORT_SYMBOL(core_tpg_set_initiator_node_queue_depth);
618 618
619/* core_tpg_set_initiator_node_tag():
620 *
621 * Initiator nodeacl tags are not used internally, but may be used by
622 * userspace to emulate aliases or groups.
623 * Returns length of newly-set tag or -EINVAL.
624 */
625int core_tpg_set_initiator_node_tag(
626 struct se_portal_group *tpg,
627 struct se_node_acl *acl,
628 const char *new_tag)
629{
630 if (strlen(new_tag) >= MAX_ACL_TAG_SIZE)
631 return -EINVAL;
632
633 if (!strncmp("NULL", new_tag, 4)) {
634 acl->acl_tag[0] = '\0';
635 return 0;
636 }
637
638 return snprintf(acl->acl_tag, MAX_ACL_TAG_SIZE, "%s", new_tag);
639}
640EXPORT_SYMBOL(core_tpg_set_initiator_node_tag);
641
619static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg) 642static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)
620{ 643{
621 /* Set in core_dev_setup_virtual_lun0() */ 644 /* Set in core_dev_setup_virtual_lun0() */
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 1346ee04db5e..7cae2360221e 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -507,6 +507,8 @@ struct se_node_acl {
507 bool acl_stop:1; 507 bool acl_stop:1;
508 u32 queue_depth; 508 u32 queue_depth;
509 u32 acl_index; 509 u32 acl_index;
510#define MAX_ACL_TAG_SIZE 64
511 char acl_tag[MAX_ACL_TAG_SIZE];
510 u64 num_cmds; 512 u64 num_cmds;
511 u64 read_bytes; 513 u64 read_bytes;
512 u64 write_bytes; 514 u64 write_bytes;
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index 9087b200e552..aaa1ee6ab391 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -142,6 +142,8 @@ int core_tpg_del_initiator_node_acl(struct se_portal_group *,
142 struct se_node_acl *, int); 142 struct se_node_acl *, int);
143int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *, 143int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *,
144 unsigned char *, u32, int); 144 unsigned char *, u32, int);
145int core_tpg_set_initiator_node_tag(struct se_portal_group *,
146 struct se_node_acl *, const char *);
145int core_tpg_register(struct target_core_fabric_ops *, struct se_wwn *, 147int core_tpg_register(struct target_core_fabric_ops *, struct se_wwn *,
146 struct se_portal_group *, void *, int); 148 struct se_portal_group *, void *, int);
147int core_tpg_deregister(struct se_portal_group *); 149int core_tpg_deregister(struct se_portal_group *);