Merge tag 'byteswap-for-linus-20121219' of git://git.infradead.org/users/dwmw2/byteswap
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / target / target_core_tpg.c
index a531fe2..5192ac0 100644 (file)
@@ -3,10 +3,7 @@
  *
  * This file contains generic Target Portal Group related functions.
  *
- * Copyright (c) 2002, 2003, 2004, 2005 PyX Technologies, Inc.
- * Copyright (c) 2005, 2006, 2007 SBE, Inc.
- * Copyright (c) 2007-2010 Rising Tide Systems
- * Copyright (c) 2008-2010 Linux-iSCSI.org
+ * (c) Copyright 2002-2012 RisingTide Systems LLC.
  *
  * Nicholas A. Bellinger <nab@kernel.org>
  *
@@ -619,6 +616,29 @@ int core_tpg_set_initiator_node_queue_depth(
 }
 EXPORT_SYMBOL(core_tpg_set_initiator_node_queue_depth);
 
+/*     core_tpg_set_initiator_node_tag():
+ *
+ *     Initiator nodeacl tags are not used internally, but may be used by
+ *     userspace to emulate aliases or groups.
+ *     Returns length of newly-set tag or -EINVAL.
+ */
+int core_tpg_set_initiator_node_tag(
+       struct se_portal_group *tpg,
+       struct se_node_acl *acl,
+       const char *new_tag)
+{
+       if (strlen(new_tag) >= MAX_ACL_TAG_SIZE)
+               return -EINVAL;
+
+       if (!strncmp("NULL", new_tag, 4)) {
+               acl->acl_tag[0] = '\0';
+               return 0;
+       }
+
+       return snprintf(acl->acl_tag, MAX_ACL_TAG_SIZE, "%s", new_tag);
+}
+EXPORT_SYMBOL(core_tpg_set_initiator_node_tag);
+
 static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)
 {
        /* Set in core_dev_setup_virtual_lun0() */
@@ -672,6 +692,7 @@ int core_tpg_register(
        for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) {
                lun = se_tpg->tpg_lun_list[i];
                lun->unpacked_lun = i;
+               lun->lun_link_magic = SE_LUN_LINK_MAGIC;
                lun->lun_status = TRANSPORT_LUN_STATUS_FREE;
                atomic_set(&lun->lun_acl_count, 0);
                init_completion(&lun->lun_shutdown_comp);