lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sun, 14 Mar 2010 01:17:45 -0800
From:	"Nicholas A. Bellinger" <nab@...ux-iscsi.org>
To:	linux-kernel <linux-kernel@...r.kernel.org>,
	linux-scsi <linux-scsi@...r.kernel.org>,
	LIO-Target devel <linux-iscsi-target-dev@...glegroups.com>,
	Douglas Gilbert <dgilbert@...erlog.com>,
	"Martin K. Petersen" <martin.petersen@...cle.com>,
	FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>,
	Mike Christie <michaelc@...wisc.edu>,
	Hannes Reinecke <hare@...e.de>,
	Joe Eykholt <jeykholt@...co.com>,
	James Bottomley <James.Bottomley@...e.de>
Cc:	Nicholas Bellinger <nab@...ux-iscsi.org>
Subject: [PATCH 1/3] [TCM/PR]: Add TPG, NodeACL and MappedLUN wrappers for configfs_[un]depend_item()

From: Nicholas Bellinger <nab@...ux-iscsi.org>

This patch adds TPG, NodeACL and MappedLUN wrappers for configfs_depend_item() and
configfs_undepend_item() to properly handler the reference counting of *pr_ref_count
during multi-fabric SPEC_I_PT=1 TransportID and REGISTER_AND_MOVE processing.

For the NodeACL and MappedLUN wrappers, there is also logic to handle the
NAF_DYNAMIC_NODE_ACL case so that demo-mode (eg: no explict node ACLs) works for
SPEC_I_PT=1 TransportID and REGISTER_AND_MOVE as well.

Signed-off-by: Nicholas A. Bellinger <nab@...ux-iscsi.org>
---
 drivers/target/target_core_pr.c |   85 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 5b23767..03f40e3 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -54,6 +54,7 @@
 struct pr_transport_id_holder {
 	int dest_local_nexus;
 	struct t10_pr_registration_s *dest_pr_reg;
+	struct se_portal_group_s *dest_tpg;
 	struct se_node_acl_s *dest_node_acl;
 	struct se_dev_entry_s *dest_se_deve;
 	struct list_head dest_list;
@@ -1035,6 +1036,90 @@ void core_scsi3_free_all_registrations(
 	spin_unlock(&pr_tmpl->aptpl_reg_lock);
 }
 
+static int core_scsi3_tpg_depend_item(se_portal_group_t *tpg)
+{
+	return configfs_depend_item(TPG_TFO(tpg)->tf_subsys,
+			&tpg->tpg_group.cg_item);
+}
+
+static void core_scsi3_tpg_undepend_item(se_portal_group_t *tpg)
+{
+	configfs_undepend_item(TPG_TFO(tpg)->tf_subsys,
+			&tpg->tpg_group.cg_item);
+
+	atomic_dec(&tpg->tpg_pr_ref_count);
+	smp_mb__after_atomic_dec();
+}
+
+static int core_scsi3_nodeacl_depend_item(se_node_acl_t *nacl)
+{
+	se_portal_group_t *tpg = nacl->se_tpg;
+
+	if (nacl->nodeacl_flags & NAF_DYNAMIC_NODE_ACL)
+		return 0;
+
+	return configfs_depend_item(TPG_TFO(tpg)->tf_subsys,
+			&nacl->acl_group.cg_item);
+}
+
+static void core_scsi3_nodeacl_undepend_item(se_node_acl_t *nacl)
+{
+	se_portal_group_t *tpg = nacl->se_tpg;
+
+	if (nacl->nodeacl_flags & NAF_DYNAMIC_NODE_ACL) {
+		atomic_dec(&nacl->acl_pr_ref_count);
+		smp_mb__after_atomic_dec();
+		return;
+	}
+
+	configfs_undepend_item(TPG_TFO(tpg)->tf_subsys,
+			&nacl->acl_group.cg_item);	
+
+	atomic_dec(&nacl->acl_pr_ref_count);
+	smp_mb__after_atomic_dec();
+}
+
+static int core_scsi3_lunacl_depend_item(se_dev_entry_t *se_deve)
+{
+	se_lun_acl_t *lun_acl = se_deve->se_lun_acl;
+	se_node_acl_t *nacl;
+	se_portal_group_t *tpg;
+	/*
+	 * For nacl->nodeacl_flags & NAF_DYNAMIC_NODE_ACL)
+	 */
+	if (!(lun_acl))
+		return 0;
+
+	nacl = lun_acl->se_lun_nacl;
+	tpg = nacl->se_tpg;
+
+	return configfs_depend_item(TPG_TFO(tpg)->tf_subsys,
+			&lun_acl->se_lun_group.cg_item);
+}
+
+static void core_scsi3_lunacl_undepend_item(se_dev_entry_t *se_deve)
+{
+	se_lun_acl_t *lun_acl = se_deve->se_lun_acl;
+	se_node_acl_t *nacl;
+	se_portal_group_t *tpg;
+	/*
+	 * For nacl->nodeacl_flags & NAF_DYNAMIC_NODE_ACL)
+	 */
+	if (!(lun_acl)) {
+		atomic_dec(&se_deve->pr_ref_count);
+		smp_mb__after_atomic_dec();
+		return;	
+	}
+	nacl = lun_acl->se_lun_nacl;
+	tpg = nacl->se_tpg;
+
+	configfs_undepend_item(TPG_TFO(tpg)->tf_subsys,
+			&lun_acl->se_lun_group.cg_item);
+
+	atomic_dec(&se_deve->pr_ref_count);
+	smp_mb__after_atomic_dec();
+}
+
 static int core_scsi3_decode_spec_i_port(
 	se_cmd_t *cmd,
 	se_portal_group_t *tpg,
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ