All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] target: Fix bugs when dealing with unconfigured devices
@ 2013-01-31 23:19 Nicholas A. Bellinger
  2013-01-31 23:19 ` [PATCH 1/2] target: Fix regression allowing unconfigured devices to fabric port link Nicholas A. Bellinger
  2013-01-31 23:19 ` [PATCH 2/2] target: Fix divide by zero bug in fabric_max_sectors for unconfigured devices Nicholas A. Bellinger
  0 siblings, 2 replies; 3+ messages in thread
From: Nicholas A. Bellinger @ 2013-01-31 23:19 UTC (permalink / raw)
  To: target-devel; +Cc: linux-scsi, Nicholas Bellinger

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

Hi folks,

These two patches address two bugs that I've ran across when dealing with
backend devices that have failed to be successfully enabled, and remain
in an unconfigured state.

The first is a v3.8-rc1 specific regression due to fallout from the removal
of struct se_subsystem_dev, and the second is to avoid a possible divide by
zero when writing fabric_max_sectors when no block_size has been set by the
device.

The latter is being CC'ed to stable.

Thanks,

--nab

Nicholas Bellinger (2):
  target: Fix regression allowing unconfigured devices to fabric port
    link
  target: Fix divide by zero bug in fabric_max_sectors for unconfigured
    devices

 drivers/target/target_core_device.c          |    8 +++++++-
 drivers/target/target_core_fabric_configfs.c |    5 +++++
 2 files changed, 12 insertions(+), 1 deletions(-)

-- 
1.7.2.5


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

* [PATCH 1/2] target: Fix regression allowing unconfigured devices to fabric port link
  2013-01-31 23:19 [PATCH 0/2] target: Fix bugs when dealing with unconfigured devices Nicholas A. Bellinger
@ 2013-01-31 23:19 ` Nicholas A. Bellinger
  2013-01-31 23:19 ` [PATCH 2/2] target: Fix divide by zero bug in fabric_max_sectors for unconfigured devices Nicholas A. Bellinger
  1 sibling, 0 replies; 3+ messages in thread
From: Nicholas A. Bellinger @ 2013-01-31 23:19 UTC (permalink / raw)
  To: target-devel; +Cc: linux-scsi, Nicholas Bellinger, Christoph Hellwig

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

This patch fixes a v3.8-rc1 regression bug where an unconfigured se_device
was incorrectly allowed to perform a fabric port-link.  This bug was
introduced in commit:

  commit 0fd97ccf45be26fb01b3a412f1f6c6b5044b2f16
  Author: Christoph Hellwig <hch@infradead.org>
  Date:   Mon Oct 8 00:03:19 2012 -0400

      target: kill struct se_subsystem_dev

which ended up dropping the original se_subsystem_dev->se_dev_ptr check
preventing this from happening with pre commit 0fd97ccf code.

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_fabric_configfs.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index 810263d..c57bbbc 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -754,6 +754,11 @@ static int target_fabric_port_link(
 		return -EFAULT;
 	}
 
+	if (!(dev->dev_flags & DF_CONFIGURED)) {
+		pr_err("se_device not configured yet, cannot port link\n");
+		return -ENODEV;
+	}
+
 	tpg_ci = &lun_ci->ci_parent->ci_group->cg_item;
 	se_tpg = container_of(to_config_group(tpg_ci),
 				struct se_portal_group, tpg_group);
-- 
1.7.2.5

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

* [PATCH 2/2] target: Fix divide by zero bug in fabric_max_sectors for unconfigured devices
  2013-01-31 23:19 [PATCH 0/2] target: Fix bugs when dealing with unconfigured devices Nicholas A. Bellinger
  2013-01-31 23:19 ` [PATCH 1/2] target: Fix regression allowing unconfigured devices to fabric port link Nicholas A. Bellinger
@ 2013-01-31 23:19 ` Nicholas A. Bellinger
  1 sibling, 0 replies; 3+ messages in thread
From: Nicholas A. Bellinger @ 2013-01-31 23:19 UTC (permalink / raw)
  To: target-devel; +Cc: linux-scsi, Nicholas Bellinger, stable

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

This patch fixes a possible divide by zero bug when the fabric_max_sectors
device attribute is written and backend se_device failed to be successfully
configured -> enabled.

Go ahead and use block_size=512 within se_dev_set_fabric_max_sectors()
in the event of a target_configure_device() failure case, as no valid
dev->dev_attrib.block_size value will have been setup yet.

Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_device.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index e269510..f2aa754 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -941,6 +941,8 @@ int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth)
 
 int se_dev_set_fabric_max_sectors(struct se_device *dev, u32 fabric_max_sectors)
 {
+	int block_size = dev->dev_attrib.block_size;
+
 	if (dev->export_count) {
 		pr_err("dev[%p]: Unable to change SE Device"
 			" fabric_max_sectors while export_count is %d\n",
@@ -978,8 +980,12 @@ int se_dev_set_fabric_max_sectors(struct se_device *dev, u32 fabric_max_sectors)
 	/*
 	 * Align max_sectors down to PAGE_SIZE to follow transport_allocate_data_tasks()
 	 */
+	if (!block_size) {
+		block_size = 512;
+		pr_warn("Defaulting to 512 for zero block_size\n");
+	}
 	fabric_max_sectors = se_dev_align_max_sectors(fabric_max_sectors,
-						      dev->dev_attrib.block_size);
+						      block_size);
 
 	dev->dev_attrib.fabric_max_sectors = fabric_max_sectors;
 	pr_debug("dev[%p]: SE Device max_sectors changed to %u\n",
-- 
1.7.2.5

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

end of thread, other threads:[~2013-01-31 23:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-31 23:19 [PATCH 0/2] target: Fix bugs when dealing with unconfigured devices Nicholas A. Bellinger
2013-01-31 23:19 ` [PATCH 1/2] target: Fix regression allowing unconfigured devices to fabric port link Nicholas A. Bellinger
2013-01-31 23:19 ` [PATCH 2/2] target: Fix divide by zero bug in fabric_max_sectors for unconfigured devices Nicholas A. Bellinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.