linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] target: Remove TRANSPORT_LUNFLAGS_READ_WRITE
@ 2014-11-13 20:50 Andy Grover
  2014-11-13 20:50 ` [PATCH 2/3] target: Remove TRANSPORT_LUNFLAGS_NO_ACCESS Andy Grover
  2014-11-13 20:50 ` [PATCH 3/3] target: Change some fabric functions to return bool Andy Grover
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Grover @ 2014-11-13 20:50 UTC (permalink / raw)
  To: target-devel; +Cc: linux-scsi, hch, nab

LUNFLAGS_READ_WRITE is always the inverse of LUNFLAGS_READ_ONLY.

Removing this enum value resulted in some spots where a parameter's value
can be just true or false, which we can represent with a bool instead of
u32. Change to a bool named "lun_access_ro".

Signed-off-by: Andy Grover <agrover@redhat.com>
---
 drivers/target/target_core_device.c          | 46 ++++++++++------------------
 drivers/target/target_core_fabric_configfs.c | 18 +++++------
 drivers/target/target_core_internal.h        |  6 ++--
 drivers/target/target_core_tpg.c             | 16 +++++-----
 include/target/target_core_base.h            |  1 -
 5 files changed, 34 insertions(+), 53 deletions(-)

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index c45f9e9..f32a02d 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -275,20 +275,17 @@ int core_free_device_list_for_node(
 
 void core_update_device_list_access(
 	u32 mapped_lun,
-	u32 lun_access,
+	bool lun_access_ro,
 	struct se_node_acl *nacl)
 {
 	struct se_dev_entry *deve;
 
 	spin_lock_irq(&nacl->device_list_lock);
 	deve = nacl->device_list[mapped_lun];
-	if (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) {
-		deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY;
-		deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_WRITE;
-	} else {
-		deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_WRITE;
+	if (lun_access_ro)
 		deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY;
-	}
+	else
+		deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY;
 	spin_unlock_irq(&nacl->device_list_lock);
 }
 
@@ -300,7 +297,7 @@ int core_enable_device_list_for_node(
 	struct se_lun *lun,
 	struct se_lun_acl *lun_acl,
 	u32 mapped_lun,
-	u32 lun_access,
+	bool lun_access_ro,
 	struct se_node_acl *nacl,
 	struct se_portal_group *tpg)
 {
@@ -333,13 +330,10 @@ int core_enable_device_list_for_node(
 		}
 		deve->se_lun_acl = lun_acl;
 
-		if (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) {
-			deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY;
-			deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_WRITE;
-		} else {
-			deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_WRITE;
+		if (lun_access_ro)
 			deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY;
-		}
+		else
+			deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY;
 
 		spin_unlock_irq(&nacl->device_list_lock);
 		return 0;
@@ -350,13 +344,10 @@ int core_enable_device_list_for_node(
 	deve->mapped_lun = mapped_lun;
 	deve->lun_flags |= TRANSPORT_LUNFLAGS_INITIATOR_ACCESS;
 
-	if (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) {
-		deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY;
-		deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_WRITE;
-	} else {
-		deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_WRITE;
+	if (lun_access_ro)
 		deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY;
-	}
+	else
+		deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY;
 
 	deve->creation_time = get_jiffies_64();
 	deve->attach_count++;
@@ -1231,8 +1222,7 @@ struct se_lun *core_dev_add_lun(
 	if (IS_ERR(lun))
 		return lun;
 
-	rc = core_tpg_add_lun(tpg, lun,
-				TRANSPORT_LUNFLAGS_READ_WRITE, dev);
+	rc = core_tpg_add_lun(tpg, lun, false, dev);
 	if (rc < 0)
 		return ERR_PTR(rc);
 
@@ -1374,7 +1364,7 @@ int core_dev_add_initiator_node_lun_acl(
 	struct se_portal_group *tpg,
 	struct se_lun_acl *lacl,
 	u32 unpacked_lun,
-	u32 lun_access)
+	bool lun_access_ro)
 {
 	struct se_lun *lun;
 	struct se_node_acl *nacl;
@@ -1392,14 +1382,13 @@ int core_dev_add_initiator_node_lun_acl(
 	if (!nacl)
 		return -EINVAL;
 
-	if ((lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) &&
-	    (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE))
-		lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
+	if (lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY)
+	    lun_access_ro = true;
 
 	lacl->se_lun = lun;
 
 	if (core_enable_device_list_for_node(lun, lacl, lacl->mapped_lun,
-			lun_access, nacl, tpg) < 0)
+			lun_access_ro, nacl, tpg) < 0)
 		return -EINVAL;
 
 	spin_lock(&lun->lun_acl_lock);
@@ -1410,8 +1399,7 @@ int core_dev_add_initiator_node_lun_acl(
 	pr_debug("%s_TPG[%hu]_LUN[%u->%u] - Added %s ACL for "
 		" InitiatorNode: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
 		tpg->se_tpg_tfo->tpg_get_tag(tpg), unpacked_lun, lacl->mapped_lun,
-		(lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) ? "RW" : "RO",
-		lacl->initiatorname);
+		lun_access_ro ? "RO" : "RW", lacl->initiatorname);
 	/*
 	 * Check to see if there are any existing persistent reservation APTPL
 	 * pre-registrations that need to be enabled for this LUN ACL..
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index 0c3f901..8a5d735 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -69,7 +69,8 @@ static int target_fabric_mappedlun_link(
 			struct se_lun_acl, se_lun_group);
 	struct se_portal_group *se_tpg;
 	struct config_item *nacl_ci, *tpg_ci, *tpg_ci_s, *wwn_ci, *wwn_ci_s;
-	int ret = 0, lun_access;
+	int ret = 0;
+	bool lun_access_ro;
 
 	if (lun->lun_link_magic != SE_LUN_LINK_MAGIC) {
 		pr_err("Bad lun->lun_link_magic, not a valid lun_ci pointer:"
@@ -114,12 +115,10 @@ static int target_fabric_mappedlun_link(
 	spin_lock_irq(&lacl->se_lun_nacl->device_list_lock);
 	deve = lacl->se_lun_nacl->device_list[lacl->mapped_lun];
 	if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)
-		lun_access = deve->lun_flags;
+		lun_access_ro = (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY);
 	else
-		lun_access =
-			(se_tpg->se_tpg_tfo->tpg_check_prod_mode_write_protect(
-				se_tpg)) ? TRANSPORT_LUNFLAGS_READ_ONLY :
-					   TRANSPORT_LUNFLAGS_READ_WRITE;
+		lun_access_ro = se_tpg->se_tpg_tfo->tpg_check_prod_mode_write_protect(
+			se_tpg);
 	spin_unlock_irq(&lacl->se_lun_nacl->device_list_lock);
 	/*
 	 * Determine the actual mapped LUN value user wants..
@@ -128,7 +127,7 @@ static int target_fabric_mappedlun_link(
 	 * iscsi/$IQN/$TPGT/lun/lun_* as on their SCSI Initiator Ports.
 	 */
 	ret = core_dev_add_initiator_node_lun_acl(se_tpg, lacl,
-			lun->unpacked_lun, lun_access);
+			lun->unpacked_lun, lun_access_ro);
 
 	return (ret < 0) ? -EINVAL : 0;
 }
@@ -198,10 +197,7 @@ static ssize_t target_fabric_mappedlun_store_write_protect(
 	if ((op != 1) && (op != 0))
 		return -EINVAL;
 
-	core_update_device_list_access(lacl->mapped_lun, (op) ?
-			TRANSPORT_LUNFLAGS_READ_ONLY :
-			TRANSPORT_LUNFLAGS_READ_WRITE,
-			lacl->se_lun_nacl);
+	core_update_device_list_access(lacl->mapped_lun, op, lacl->se_lun_nacl);
 
 	pr_debug("%s_ConfigFS: Changed Initiator ACL: %s"
 		" Mapped LUN: %u Write Protect bit to %s\n",
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index e31f42f..2aab22b 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -8,9 +8,9 @@ extern struct t10_alua_lu_gp *default_lu_gp;
 struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16);
 int	core_free_device_list_for_node(struct se_node_acl *,
 		struct se_portal_group *);
-void	core_update_device_list_access(u32, u32, struct se_node_acl *);
+void	core_update_device_list_access(u32, bool, struct se_node_acl *);
 int	core_enable_device_list_for_node(struct se_lun *, struct se_lun_acl *,
-		u32, u32, struct se_node_acl *, struct se_portal_group *);
+		u32, bool, struct se_node_acl *, struct se_portal_group *);
 int	core_disable_device_list_for_node(struct se_lun *, struct se_lun_acl *,
 		u32, u32, struct se_node_acl *, struct se_portal_group *);
 void	core_clear_lun_from_tpg(struct se_lun *, struct se_portal_group *);
@@ -52,7 +52,7 @@ struct se_lun *core_get_lun_from_tpg(struct se_portal_group *, u32);
 struct se_lun_acl *core_dev_init_initiator_node_lun_acl(struct se_portal_group *,
 		struct se_node_acl *, u32, int *);
 int	core_dev_add_initiator_node_lun_acl(struct se_portal_group *,
-		struct se_lun_acl *, u32, u32);
+		struct se_lun_acl *, u32, bool);
 int	core_dev_del_initiator_node_lun_acl(struct se_portal_group *,
 		struct se_lun *, struct se_lun_acl *);
 void	core_dev_free_initiator_node_lun_acl(struct se_portal_group *,
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 0696de9..da21294 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -128,7 +128,7 @@ void core_tpg_add_node_to_devs(
 	struct se_portal_group *tpg)
 {
 	int i = 0;
-	u32 lun_access = 0;
+	bool lun_access_ro = true;
 	struct se_lun *lun;
 	struct se_device *dev;
 
@@ -146,27 +146,26 @@ void core_tpg_add_node_to_devs(
 		 * demo_mode_write_protect is ON, or READ_ONLY;
 		 */
 		if (!tpg->se_tpg_tfo->tpg_check_demo_mode_write_protect(tpg)) {
-			lun_access = TRANSPORT_LUNFLAGS_READ_WRITE;
+			lun_access_ro = false;
 		} else {
 			/*
 			 * Allow only optical drives to issue R/W in default RO
 			 * demo mode.
 			 */
 			if (dev->transport->get_device_type(dev) == TYPE_DISK)
-				lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
+				lun_access_ro = true;
 			else
-				lun_access = TRANSPORT_LUNFLAGS_READ_WRITE;
+				lun_access_ro = false;
 		}
 
 		pr_debug("TARGET_CORE[%s]->TPG[%u]_LUN[%u] - Adding %s"
 			" access for LUN in Demo Mode\n",
 			tpg->se_tpg_tfo->get_fabric_name(),
 			tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
-			(lun_access == TRANSPORT_LUNFLAGS_READ_WRITE) ?
-			"READ-WRITE" : "READ-ONLY");
+			lun_access_ro ? "RO" : "RW");
 
 		core_enable_device_list_for_node(lun, NULL, lun->unpacked_lun,
-				lun_access, acl, tpg);
+				lun_access_ro, acl, tpg);
 		/*
 		 * Check to see if there are any existing persistent reservation
 		 * APTPL pre-registrations that need to be enabled for this dynamic
@@ -652,7 +651,6 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)
 	/* Set in core_dev_setup_virtual_lun0() */
 	struct se_device *dev = g_lun0_dev;
 	struct se_lun *lun = &se_tpg->tpg_virt_lun0;
-	u32 lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
 	int ret;
 
 	lun->unpacked_lun = 0;
@@ -664,7 +662,7 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)
 	spin_lock_init(&lun->lun_sep_lock);
 	init_completion(&lun->lun_ref_comp);
 
-	ret = core_tpg_add_lun(se_tpg, lun, lun_access, dev);
+	ret = core_tpg_add_lun(se_tpg, lun, true, dev);
 	if (ret < 0)
 		return ret;
 
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 23c518a..1a3aa44 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -178,7 +178,6 @@ enum transport_lunflags_table {
 	TRANSPORT_LUNFLAGS_NO_ACCESS		= 0x00,
 	TRANSPORT_LUNFLAGS_INITIATOR_ACCESS	= 0x01,
 	TRANSPORT_LUNFLAGS_READ_ONLY		= 0x02,
-	TRANSPORT_LUNFLAGS_READ_WRITE		= 0x04,
 };
 
 /*
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] target: Remove TRANSPORT_LUNFLAGS_NO_ACCESS
  2014-11-13 20:50 [PATCH 1/3] target: Remove TRANSPORT_LUNFLAGS_READ_WRITE Andy Grover
@ 2014-11-13 20:50 ` Andy Grover
  2014-11-13 20:50 ` [PATCH 3/3] target: Change some fabric functions to return bool Andy Grover
  1 sibling, 0 replies; 5+ messages in thread
From: Andy Grover @ 2014-11-13 20:50 UTC (permalink / raw)
  To: target-devel; +Cc: linux-scsi, hch, nab

Only used as a param to core_disable_device_list_for_node(), but that
function doesn't use it.

Change function signature to remove that param, and change all callsites
to not pass LUNFLAGS_NO_ACCESS.

Signed-off-by: Andy Grover <agrover@redhat.com>
---
 drivers/target/target_core_device.c   | 8 +++-----
 drivers/target/target_core_internal.h | 2 +-
 drivers/target/target_core_tpg.c      | 2 +-
 include/target/target_core_base.h     | 1 -
 4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index f32a02d..5a511c6 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -262,7 +262,7 @@ int core_free_device_list_for_node(
 
 		spin_unlock_irq(&nacl->device_list_lock);
 		core_disable_device_list_for_node(lun, NULL, deve->mapped_lun,
-			TRANSPORT_LUNFLAGS_NO_ACCESS, nacl, tpg);
+			nacl, tpg);
 		spin_lock_irq(&nacl->device_list_lock);
 	}
 	spin_unlock_irq(&nacl->device_list_lock);
@@ -368,7 +368,6 @@ int core_disable_device_list_for_node(
 	struct se_lun *lun,
 	struct se_lun_acl *lun_acl,
 	u32 mapped_lun,
-	u32 lun_access,
 	struct se_node_acl *nacl,
 	struct se_portal_group *tpg)
 {
@@ -436,8 +435,7 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct se_portal_group *tpg)
 			spin_unlock_irq(&nacl->device_list_lock);
 
 			core_disable_device_list_for_node(lun, NULL,
-				deve->mapped_lun, TRANSPORT_LUNFLAGS_NO_ACCESS,
-				nacl, tpg);
+				deve->mapped_lun, nacl, tpg);
 
 			spin_lock_irq(&nacl->device_list_lock);
 		}
@@ -1430,7 +1428,7 @@ int core_dev_del_initiator_node_lun_acl(
 	spin_unlock(&lun->lun_acl_lock);
 
 	core_disable_device_list_for_node(lun, NULL, lacl->mapped_lun,
-		TRANSPORT_LUNFLAGS_NO_ACCESS, nacl, tpg);
+		nacl, tpg);
 
 	lacl->se_lun = NULL;
 
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index 2aab22b..1b54f3c 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -12,7 +12,7 @@ void	core_update_device_list_access(u32, bool, struct se_node_acl *);
 int	core_enable_device_list_for_node(struct se_lun *, struct se_lun_acl *,
 		u32, bool, struct se_node_acl *, struct se_portal_group *);
 int	core_disable_device_list_for_node(struct se_lun *, struct se_lun_acl *,
-		u32, u32, struct se_node_acl *, struct se_portal_group *);
+		u32, struct se_node_acl *, struct se_portal_group *);
 void	core_clear_lun_from_tpg(struct se_lun *, struct se_portal_group *);
 int	core_dev_export(struct se_device *, struct se_portal_group *,
 		struct se_lun *);
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index da21294..bc9ff92 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -76,7 +76,7 @@ static void core_clear_initiator_node_from_tpg(
 		lun = deve->se_lun;
 		spin_unlock_irq(&nacl->device_list_lock);
 		core_disable_device_list_for_node(lun, NULL, deve->mapped_lun,
-			TRANSPORT_LUNFLAGS_NO_ACCESS, nacl, tpg);
+			nacl, tpg);
 
 		spin_lock_irq(&nacl->device_list_lock);
 	}
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 1a3aa44..0558782 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -175,7 +175,6 @@ enum se_cmd_flags_table {
 
 /* struct se_dev_entry->lun_flags and struct se_lun->lun_access */
 enum transport_lunflags_table {
-	TRANSPORT_LUNFLAGS_NO_ACCESS		= 0x00,
 	TRANSPORT_LUNFLAGS_INITIATOR_ACCESS	= 0x01,
 	TRANSPORT_LUNFLAGS_READ_ONLY		= 0x02,
 };
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] target: Change some fabric functions to return bool
  2014-11-13 20:50 [PATCH 1/3] target: Remove TRANSPORT_LUNFLAGS_READ_WRITE Andy Grover
  2014-11-13 20:50 ` [PATCH 2/3] target: Remove TRANSPORT_LUNFLAGS_NO_ACCESS Andy Grover
@ 2014-11-13 20:50 ` Andy Grover
  2014-11-14  7:06   ` Christoph Hellwig
  1 sibling, 1 reply; 5+ messages in thread
From: Andy Grover @ 2014-11-13 20:50 UTC (permalink / raw)
  To: target-devel; +Cc: linux-scsi, hch, nab

The tpg_check_* functions in the fabric_ops struct return 1 or 0,
so we can make their return type bool. Change fabrics to match.

Signed-off-by: Andy Grover <agrover@redhat.com>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c        |  8 ++++----
 drivers/scsi/qla2xxx/tcm_qla2xxx.c           | 10 +++++-----
 drivers/target/iscsi/iscsi_target_configfs.c |  8 ++++----
 drivers/target/loopback/tcm_loop.c           | 16 ++++++++--------
 drivers/target/sbp/sbp_target.c              |  8 ++++----
 drivers/target/tcm_fc/tfc_conf.c             |  4 ++--
 drivers/vhost/scsi.c                         |  8 ++++----
 include/target/target_core_fabric.h          | 10 +++++-----
 8 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 7206547..b505d98 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -3377,14 +3377,14 @@ static struct ib_client srpt_client = {
 	.remove = srpt_remove_one
 };
 
-static int srpt_check_true(struct se_portal_group *se_tpg)
+static bool srpt_check_true(struct se_portal_group *se_tpg)
 {
-	return 1;
+	return true;
 }
 
-static int srpt_check_false(struct se_portal_group *se_tpg)
+static bool srpt_check_false(struct se_portal_group *se_tpg)
 {
-	return 0;
+	return false;
 }
 
 static char *srpt_get_fabric_name(void)
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 73f9fee..d5558d0 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -296,7 +296,7 @@ static char *tcm_qla2xxx_parse_pr_out_transport_id(
 	return tid;
 }
 
-static int tcm_qla2xxx_check_demo_mode(struct se_portal_group *se_tpg)
+static bool tcm_qla2xxx_check_demo_mode(struct se_portal_group *se_tpg)
 {
 	struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
 				struct tcm_qla2xxx_tpg, se_tpg);
@@ -304,7 +304,7 @@ static int tcm_qla2xxx_check_demo_mode(struct se_portal_group *se_tpg)
 	return tpg->tpg_attrib.generate_node_acls;
 }
 
-static int tcm_qla2xxx_check_demo_mode_cache(struct se_portal_group *se_tpg)
+static bool tcm_qla2xxx_check_demo_mode_cache(struct se_portal_group *se_tpg)
 {
 	struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
 				struct tcm_qla2xxx_tpg, se_tpg);
@@ -312,7 +312,7 @@ static int tcm_qla2xxx_check_demo_mode_cache(struct se_portal_group *se_tpg)
 	return tpg->tpg_attrib.cache_dynamic_acls;
 }
 
-static int tcm_qla2xxx_check_demo_write_protect(struct se_portal_group *se_tpg)
+static bool tcm_qla2xxx_check_demo_write_protect(struct se_portal_group *se_tpg)
 {
 	struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
 				struct tcm_qla2xxx_tpg, se_tpg);
@@ -320,7 +320,7 @@ static int tcm_qla2xxx_check_demo_write_protect(struct se_portal_group *se_tpg)
 	return tpg->tpg_attrib.demo_mode_write_protect;
 }
 
-static int tcm_qla2xxx_check_prod_write_protect(struct se_portal_group *se_tpg)
+static bool tcm_qla2xxx_check_prod_write_protect(struct se_portal_group *se_tpg)
 {
 	struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
 				struct tcm_qla2xxx_tpg, se_tpg);
@@ -328,7 +328,7 @@ static int tcm_qla2xxx_check_prod_write_protect(struct se_portal_group *se_tpg)
 	return tpg->tpg_attrib.prod_mode_write_protect;
 }
 
-static int tcm_qla2xxx_check_demo_mode_login_only(struct se_portal_group *se_tpg)
+static bool tcm_qla2xxx_check_demo_mode_login_only(struct se_portal_group *se_tpg)
 {
 	struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
 				struct tcm_qla2xxx_tpg, se_tpg);
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index 9059c1e..a89b0dc 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -1847,21 +1847,21 @@ static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg)
 	return tpg->tpg_attrib.default_cmdsn_depth;
 }
 
-static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
+static bool lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
 {
 	struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
 
 	return tpg->tpg_attrib.generate_node_acls;
 }
 
-static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
+static bool lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
 {
 	struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
 
 	return tpg->tpg_attrib.cache_dynamic_acls;
 }
 
-static int lio_tpg_check_demo_mode_write_protect(
+static bool lio_tpg_check_demo_mode_write_protect(
 	struct se_portal_group *se_tpg)
 {
 	struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
@@ -1869,7 +1869,7 @@ static int lio_tpg_check_demo_mode_write_protect(
 	return tpg->tpg_attrib.demo_mode_write_protect;
 }
 
-static int lio_tpg_check_prod_mode_write_protect(
+static bool lio_tpg_check_prod_mode_write_protect(
 	struct se_portal_group *se_tpg)
 {
 	struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index ab3ab27..48a5b42 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -750,23 +750,23 @@ static char *tcm_loop_parse_pr_out_transport_id(
  * Returning (1) here allows for target_core_mod struct se_node_acl to be generated
  * based upon the incoming fabric dependent SCSI Initiator Port
  */
-static int tcm_loop_check_demo_mode(struct se_portal_group *se_tpg)
+static bool tcm_loop_check_demo_mode(struct se_portal_group *se_tpg)
 {
-	return 1;
+	return true;
 }
 
-static int tcm_loop_check_demo_mode_cache(struct se_portal_group *se_tpg)
+static bool tcm_loop_check_demo_mode_cache(struct se_portal_group *se_tpg)
 {
-	return 0;
+	return false;
 }
 
 /*
  * Allow I_T Nexus full READ-WRITE access without explict Initiator Node ACLs for
  * local virtual Linux/SCSI LLD passthrough into VM hypervisor guest
  */
-static int tcm_loop_check_demo_mode_write_protect(struct se_portal_group *se_tpg)
+static bool tcm_loop_check_demo_mode_write_protect(struct se_portal_group *se_tpg)
 {
-	return 0;
+	return false;
 }
 
 /*
@@ -774,9 +774,9 @@ static int tcm_loop_check_demo_mode_write_protect(struct se_portal_group *se_tpg
  * never be called for TCM_Loop by target_core_fabric_configfs.c code.
  * It has been added here as a nop for target_fabric_tf_ops_check()
  */
-static int tcm_loop_check_prod_mode_write_protect(struct se_portal_group *se_tpg)
+static bool tcm_loop_check_prod_mode_write_protect(struct se_portal_group *se_tpg)
 {
-	return 0;
+	return false;
 }
 
 static struct se_node_acl *tcm_loop_tpg_alloc_fabric_acl(
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index e7e9372..d56bfce 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -1679,14 +1679,14 @@ static void sbp_management_agent_unregister(struct sbp_management_agent *agent)
 	kfree(agent);
 }
 
-static int sbp_check_true(struct se_portal_group *se_tpg)
+static bool sbp_check_true(struct se_portal_group *se_tpg)
 {
-	return 1;
+	return true;
 }
 
-static int sbp_check_false(struct se_portal_group *se_tpg)
+static bool sbp_check_false(struct se_portal_group *se_tpg)
 {
-	return 0;
+	return false;
 }
 
 static char *sbp_get_fabric_name(void)
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index efdcb96..b35b283 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -491,9 +491,9 @@ static u32 ft_get_default_depth(struct se_portal_group *se_tpg)
 	return 1;
 }
 
-static int ft_check_false(struct se_portal_group *se_tpg)
+static bool ft_check_false(struct se_portal_group *se_tpg)
 {
-	return 0;
+	return false;
 }
 
 static void ft_set_default_node_attr(struct se_node_acl *se_nacl)
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 69906ca..48a44ba 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -278,14 +278,14 @@ static void tcm_vhost_put_inflight(struct vhost_scsi_inflight *inflight)
 	kref_put(&inflight->kref, tcm_vhost_done_inflight);
 }
 
-static int tcm_vhost_check_true(struct se_portal_group *se_tpg)
+static bool tcm_vhost_check_true(struct se_portal_group *se_tpg)
 {
-	return 1;
+	return true;
 }
 
-static int tcm_vhost_check_false(struct se_portal_group *se_tpg)
+static bool tcm_vhost_check_false(struct se_portal_group *se_tpg)
 {
-	return 0;
+	return false;
 }
 
 static char *tcm_vhost_get_fabric_name(void)
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index 22a4e98..bc1e9f6 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -17,16 +17,16 @@ struct target_core_fabric_ops {
 				struct t10_pr_registration *, int *);
 	char *(*tpg_parse_pr_out_transport_id)(struct se_portal_group *,
 				const char *, u32 *, char **);
-	int (*tpg_check_demo_mode)(struct se_portal_group *);
-	int (*tpg_check_demo_mode_cache)(struct se_portal_group *);
-	int (*tpg_check_demo_mode_write_protect)(struct se_portal_group *);
-	int (*tpg_check_prod_mode_write_protect)(struct se_portal_group *);
+	bool (*tpg_check_demo_mode)(struct se_portal_group *);
+	bool (*tpg_check_demo_mode_cache)(struct se_portal_group *);
+	bool (*tpg_check_demo_mode_write_protect)(struct se_portal_group *);
+	bool (*tpg_check_prod_mode_write_protect)(struct se_portal_group *);
 	/*
 	 * Optionally used by fabrics to allow demo-mode login, but not
 	 * expose any TPG LUNs, and return 'not connected' in standard
 	 * inquiry response
 	 */
-	int (*tpg_check_demo_mode_login_only)(struct se_portal_group *);
+	bool (*tpg_check_demo_mode_login_only)(struct se_portal_group *);
 	struct se_node_acl *(*tpg_alloc_fabric_acl)(
 					struct se_portal_group *);
 	void (*tpg_release_fabric_acl)(struct se_portal_group *,
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] target: Change some fabric functions to return bool
  2014-11-13 20:50 ` [PATCH 3/3] target: Change some fabric functions to return bool Andy Grover
@ 2014-11-14  7:06   ` Christoph Hellwig
  2014-11-17 22:58     ` Andy Grover
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2014-11-14  7:06 UTC (permalink / raw)
  To: Andy Grover; +Cc: target-devel, linux-scsi, hch, nab

On Thu, Nov 13, 2014 at 12:50:58PM -0800, Andy Grover wrote:
> The tpg_check_* functions in the fabric_ops struct return 1 or 0,
> so we can make their return type bool. Change fabrics to match.

All these true/false stub sounds like some of them methods should be
optional, and a useful default should be assumed if they aren't present.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] target: Change some fabric functions to return bool
  2014-11-14  7:06   ` Christoph Hellwig
@ 2014-11-17 22:58     ` Andy Grover
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Grover @ 2014-11-17 22:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: target-devel, linux-scsi, nab

On 11/13/2014 11:06 PM, Christoph Hellwig wrote:
> On Thu, Nov 13, 2014 at 12:50:58PM -0800, Andy Grover wrote:
>> The tpg_check_* functions in the fabric_ops struct return 1 or 0,
>> so we can make their return type bool. Change fabrics to match.
>
> All these true/false stub sounds like some of them methods should be
> optional, and a useful default should be assumed if they aren't present.

This may be true but I couldn't determine a useful default, or a change 
that would make the code shorter or clearer, so I left it for now.

-- Andy

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-17 22:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-13 20:50 [PATCH 1/3] target: Remove TRANSPORT_LUNFLAGS_READ_WRITE Andy Grover
2014-11-13 20:50 ` [PATCH 2/3] target: Remove TRANSPORT_LUNFLAGS_NO_ACCESS Andy Grover
2014-11-13 20:50 ` [PATCH 3/3] target: Change some fabric functions to return bool Andy Grover
2014-11-14  7:06   ` Christoph Hellwig
2014-11-17 22:58     ` Andy Grover

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).