All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] scsi_dh update
@ 2008-07-17 23:52 Chandra Seetharaman
  2008-07-17 23:52 ` [PATCH 1/8] scsi_dh: Implement common device table handling Chandra Seetharaman
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Chandra Seetharaman @ 2008-07-17 23:52 UTC (permalink / raw)
  To: James.Bottomley, hare, linux-scsi; +Cc: dm-devel

Hi James, Hannes,

These are the same set of patches that Hannes sent early this morning with the 
prelog below.

I just ported it to compile clean on top of 2.6.26-git6.

Made 3 additional changes:
 1. Added a break under MODE_SELECT option in function get_req() (in 3/8)
 2. Added the ifndef portion for scsi_dh_attach() and scsi_dh_detach (in 6/8)
 3. Moved the definition of SCSI_DH_DEV_UNSUPP from 6/8 to 3/8.

regards,

chandra
------ Here is the 0/8 from Hannes's original patchset. -----------

Hi James,

this is the (hopefully final) update to my scsi_dh patchset.
Features are:

- Move device-table matching into the device_handler infrastructure,
 so that individual drivers don't have to implement it themselves
- Adds a 'dh_state' sysfs attribute for manually attaching device
 handler to new or unknown disks; this allows to override the
 internal device tables
- Update the dm-multipath code to attach the device handler
 specified in the multipath configuration
- Add a cache to speed up lookup of several identical devices
- Update existing EMC, RDAC, and hp_sw device handler to use
 the new infrastructure
- Add new SPC-3 ALUA device handler

The NetApp device handler has been left out for now as it's still
under development.

Please apply.

Cheers,

Hannes
--------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH 2/8] scsi_dh: Add 'dh_state' sysfs attribute
@ 2008-07-17  7:38 Hannes Reinecke
  0 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2008-07-17  7:38 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi


Implement a 'dh_state' sdev attribute for dynamic device handler
manipulation. A read on the attribute will return the name of
the currently attached device handler or 'detached' if no handler
is attached.
The attribute allows the following strings to be written:
- The name of the device handler to be attached if the state is
  'detached'.
- 'activate' to trigger path activation if a device handler
  is attached.
- 'detach' to detach the currently attached device handler.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/device_handler/scsi_dh.c |  103 ++++++++++++++++++++++++++++++++-
 1 files changed, 102 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
index 3f79817..e90df9d 100644
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -84,7 +84,7 @@ static int scsi_dh_handler_attach(struct scsi_device *sdev,
  * @scsi_dh - Device handler to be detached
  *
  * Detach from a device handler. If a device handler is specified,
- * only detach if the currently attached handler is equal to it.
+ * only detach if the currently attached handler matches @scsi_dh.
  */
 static void scsi_dh_handler_detach(struct scsi_device *sdev,
 				   struct scsi_device_handler *scsi_dh)
@@ -103,6 +103,98 @@ static void scsi_dh_handler_detach(struct scsi_device *sdev,
 }
 
 /*
+ * Functions for sysfs attribute 'dh_state'
+ */
+static ssize_t
+store_dh_state(struct device *dev, struct device_attribute *attr,
+	       const char *buf, size_t count)
+{
+	struct scsi_device *sdev = to_scsi_device(dev);
+	struct scsi_device_handler *scsi_dh;
+	int err = -EINVAL;
+
+	if (!sdev->scsi_dh_data) {
+		/*
+		 * Attach to a device handler
+		 */
+		if (!(scsi_dh = get_device_handler(buf)))
+			return err;
+		err = scsi_dh_handler_attach(sdev, scsi_dh);
+	} else {
+		scsi_dh = sdev->scsi_dh_data->scsi_dh;
+		if (!strncmp(buf, "detach", 6)) {
+			/*
+			 * Detach from a device handler
+			 */
+			scsi_dh_handler_detach(sdev, scsi_dh);
+			err = 0;
+		} else if (!strncmp(buf, "activate", 8)) {
+			/*
+			 * Activate a device handler
+			 */
+			if (scsi_dh->activate)
+				err = scsi_dh->activate(sdev);
+			else
+				err = 0;
+		}
+	}
+
+	return err<0?err:count;
+}
+
+static ssize_t
+show_dh_state(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct scsi_device *sdev = to_scsi_device(dev);
+
+	if (!sdev->scsi_dh_data)
+		return snprintf(buf, 20, "detached\n");
+
+	return snprintf(buf, 20, "%s\n", sdev->scsi_dh_data->scsi_dh->name);
+}
+
+static struct device_attribute scsi_dh_state_attr =
+	__ATTR(dh_state, S_IRUGO | S_IWUSR, show_dh_state,
+	       store_dh_state);
+
+/*
+ * scsi_dh_sysfs_attr_add - Callback for scsi_init_dh
+ */
+static int scsi_dh_sysfs_attr_add(struct device *dev, void *data)
+{
+	struct scsi_device *sdev;
+	int err;
+
+	if (!scsi_is_sdev_device(dev))
+		return 0;
+
+	sdev = to_scsi_device(dev);
+
+	err = device_create_file(&sdev->sdev_gendev,
+				 &scsi_dh_state_attr);
+
+	return 0;
+}
+
+/*
+ * scsi_dh_sysfs_attr_remove - Callback for scsi_exit_dh
+ */
+static int scsi_dh_sysfs_attr_remove(struct device *dev, void *data)
+{
+	struct scsi_device *sdev;
+
+	if (!scsi_is_sdev_device(dev))
+		return 0;
+
+	sdev = to_scsi_device(dev);
+
+	device_remove_file(&sdev->sdev_gendev,
+			   &scsi_dh_state_attr);
+
+	return 0;
+}
+
+/*
  * scsi_dh_notifier - notifier chain callback
  */
 static int scsi_dh_notifier(struct notifier_block *nb,
@@ -132,7 +224,10 @@ static int scsi_dh_notifier(struct notifier_block *nb,
 
 	if (action == BUS_NOTIFY_ADD_DEVICE) {
 		err = scsi_dh_handler_attach(sdev, devinfo);
+		if (!err)
+			err = device_create_file(dev, &scsi_dh_state_attr);
 	} else if (action == BUS_NOTIFY_DEL_DEVICE) {
+		device_remove_file(dev, &scsi_dh_state_attr);
 		scsi_dh_handler_detach(sdev, NULL);
 	}
 out:
@@ -284,11 +379,17 @@ static int __init scsi_dh_init(void)
 
 	r = bus_register_notifier(&scsi_bus_type, &scsi_dh_nb);
 
+	if (!r)
+		bus_for_each_dev(&scsi_bus_type, NULL, NULL,
+				 scsi_dh_sysfs_attr_add);
+
 	return r;
 }
 
 static void __exit scsi_dh_exit(void)
 {
+	bus_for_each_dev(&scsi_bus_type, NULL, NULL,
+			 scsi_dh_sysfs_attr_remove);
 	bus_unregister_notifier(&scsi_bus_type, &scsi_dh_nb);
 }
 
-- 
1.5.2.4


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

end of thread, other threads:[~2008-07-18  0:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-17 23:52 [PATCH 0/8] scsi_dh update Chandra Seetharaman
2008-07-17 23:52 ` [PATCH 1/8] scsi_dh: Implement common device table handling Chandra Seetharaman
2008-07-17 23:52 ` [PATCH 2/8] scsi_dh: Add 'dh_state' sysfs attribute Chandra Seetharaman
2008-07-17 23:53 ` [PATCH 3/8] scsi_dh: Update EMC handler Chandra Seetharaman
2008-07-17 23:53 ` [PATCH 4/8] scsi_dh: Update hp_sw hardware handler Chandra Seetharaman
2008-07-17 23:53 ` [PATCH 5/8] scsi_dh: Update RDAC device handler Chandra Seetharaman
2008-07-17 23:53 ` [PATCH 6/8] scsi_dh: add generic SPC-3 alua handler Chandra Seetharaman
2008-07-17 23:53 ` [PATCH 7/8] scsi_dh: attach to hardware handler from dm-mpath Chandra Seetharaman
2008-07-18  0:08   ` Alasdair G Kergon
2008-07-18  0:49     ` [dm-devel] " Chandra Seetharaman
2008-07-17 23:53 ` [PATCH 8/8] scsi_dh: create lookup cache Chandra Seetharaman
  -- strict thread matches above, loose matches on Subject: below --
2008-07-17  7:38 [PATCH 2/8] scsi_dh: Add 'dh_state' sysfs attribute Hannes Reinecke

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.