Re: [RFC][PATCH 2.6.11-rc2] Linux SCSI hotplug infrastructure
On Thu, Apr 14, 2005 at 01:24:33PM -0500, Matt Domsch wrote: I posted this back in February, with no response (good or bad). I still think this is useful, and would appreciate feedback. I don't like this at all. It's adding a kernel roundtrip for things that should be handled in userland. - To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC][PATCH 2.6.11-rc2] Linux SCSI hotplug infrastructure
On Mon, Feb 07, 2005 at 12:27:53PM -0600, Matt Domsch wrote: Below is a patch to add some hotplug infrastructure to the Linux SCSI subsystem. I've added and reworked the megaraid_mbox driver to make use of this new infrastructure. I'll send that patch next. The rest is unchanged from yesterday. I've put this work into a bkbits repo. This is a clone of Linus's linux-2.6, not of James' scsi-misc-2.6. bk pull http://mdomsch.bkbits.net/linux-2.6-scsi-hotplug This will update the following files: Documentation/scsi/ChangeLog.megaraid | 130 drivers/scsi/Kconfig | 10 drivers/scsi/Makefile |1 drivers/scsi/megaraid/Kconfig.megaraid |1 drivers/scsi/megaraid/mega_common.h|3 drivers/scsi/megaraid/megaraid_ioctl.h |1 drivers/scsi/megaraid/megaraid_mbox.c | 500 +++-- drivers/scsi/megaraid/megaraid_mbox.h | 28 + drivers/scsi/megaraid/megaraid_mm.c| 39 ++ drivers/scsi/megaraid/megaraid_mm.h|5 drivers/scsi/scsi_hotplug.c| 138 + include/scsi/scsi_hotplug.h| 41 ++ 12 files changed, 867 insertions, 30 deletions through these ChangeSets: [EMAIL PROTECTED] (05/02/08 1.2132.2.3) Release Date : Tue Feb 08 12:27:22 EST 2005 - Matt Domsch [EMAIL PROTECTED] Current Version : 2.20.4.6 (scsi module), 2.20.2.5 (cmm module) Older Version: 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) 1. Added two new megaraid_shost_attrs /sys/class/scsi_host |-- host0 | |-- logical_drive_created | |-- logical_drive_destroyed and helper functions for them. Written to from userspace by a management application, these invoke SCSI hotplug infrastructure for informing the kernel that a logical drive has been created, or will be destroyed quite soon. echo 2 logical_drive_created after creating logical drive #2 in the management app echo 4 logical_drive_destroyed immediately before destroying logical drive #4 in the management app. Eventually these functions should be called directly from the management app. 2. Made class_device_megaraid_mbox_app_hndl and dev_attr_megaraid_mbox_ld static. Signed-off-by: Matt Domsch [EMAIL PROTECTED] [EMAIL PROTECTED] (05/02/08 1.2132.2.2) megaraid_2.20.4.5.patch [EMAIL PROTECTED] (05/02/07 1.2048.2.1) Below is a patch to add some hotplug infrastructure to the Linux SCSI subsystem. New files: include/scsi/scsi_hotplug.h drivers/scsi/scsi_hotplug.c implements a new exported function: extern int scsi_topology_hctl_action(struct Scsi_Host *shost, unsigned int channel, unsigned int id, unsigned int lun, enum scsi_topology_action action); which invokes kobject_hotplug() on a temporary scsi_topology device. This device represents a target that exists on a topology (i.e. was just inserted into a hot plug enclosure, or was just created by a RAID controller management application) but is not yet hooked into the kernel. In addition, two more infrastructure pieces are necessary: udev-050-scsi_topology.patch - adds the subsystem name scsi_topology to the list of devices *not* to wait for the creation of files in sysfs for - scsi_topology devices aren't to be registered in sysfs. /etc/hotplug/scsi_topology.agent handles the hotplug call, and invokes /sys/class/scsi_host/hostX/scan and /sys/class/scsi_device/H:C:T:L:/device/delete as appropriate. The flow is as follows: # echo 2 /sys/class/scsi_host/host2/logical_drive_created (to be done by a management application that knows it just created logical drive #2 on the controller) megaraid_mbox.c sysfs method converts logical drive number to HCTL value, calls scsi_topology_hctl_action(). scsi_topology_hctl_action() invokes kobject_hotplug() with a scsi_topology subsystem device. kobject_hotplug() calls /sbin/hotplug or /sbin/udevsend (more likely the latter), which invokes /etc/hotplug/scsi_topology.agent with the ACTION={add,remove}. scsi_topology.agent invokes /sys/class/scsi_host/hostX/scan or /sys/class/scsi_device/H:C:T:L:/device/delete as appropriate. From this point, we're back into known territory, with the device being made known, or deleted from, the kernel's view. Signed-off-by: Matt Domsch [EMAIL PROTECTED] -- Matt Domsch Software Architect Dell Linux Solutions linux.dell.com www.dell.com/linux Linux on Dell mailing lists @ http://lists.us.dell.com - To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC][PATCH 2.6.11-rc2] Linux SCSI hotplug infrastructure
On Tue, Feb 08, 2005 at 05:19:23PM -0600, Matt Domsch wrote: I've added and reworked the megaraid_mbox driver to make use of this new infrastructure. I'll send that patch next. The rest is unchanged from yesterday. This is the megaraid_mbox 2.20.4.5 patch as submitted by LSI on-list last week. Signed-off-by: Matt Domsch [EMAIL PROTECTED] -- Matt Domsch Software Architect Dell Linux Solutions linux.dell.com www.dell.com/linux Linux on Dell mailing lists @ http://lists.us.dell.com You can import this changeset into BK by piping this whole message to '| bk receive [path to repository]' or apply the patch as usual. === [EMAIL PROTECTED], 2005-02-08 14:53:12-06:00, [EMAIL PROTECTED] megaraid_2.20.4.5.patch Documentation/scsi/ChangeLog.megaraid | 104 drivers/scsi/megaraid/Kconfig.megaraid |1 drivers/scsi/megaraid/mega_common.h|3 drivers/scsi/megaraid/megaraid_ioctl.h |1 drivers/scsi/megaraid/megaraid_mbox.c | 403 - drivers/scsi/megaraid/megaraid_mbox.h | 24 + drivers/scsi/megaraid/megaraid_mm.c| 39 +++ drivers/scsi/megaraid/megaraid_mm.h|5 8 files changed, 561 insertions, 19 deletions diff -Nru a/Documentation/scsi/ChangeLog.megaraid b/Documentation/scsi/ChangeLog.megaraid --- a/Documentation/scsi/ChangeLog.megaraid 2005-02-08 17:16:50 -06:00 +++ b/Documentation/scsi/ChangeLog.megaraid 2005-02-08 17:16:50 -06:00 @@ -1,3 +1,105 @@ +Release Date : Thu Feb 03 12:27:22 EST 2005 - Seokmann Ju [EMAIL PROTECTED] +Current Version: 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) +Older Version : 2.20.4.4 (scsi module), 2.20.2.4 (cmm module) + +1. Modified name of two attributes in scsi_host_template. + On Wed, 2005-02-02 at 10:56 -0500, Ju, Seokmann wrote: ++ .sdev_attrs = megaraid_device_attrs, ++ .shost_attrs= megaraid_class_device_attrs, + + These are, perhaps, slightly confusing names. + The terms device and class_device have well defined meanings in the + generic device model, neither of which is what you mean here. + Why not simply megaraid_sdev_attrs and megaraid_shost_attrs? + + Other than this, it looks fine to me too. + +Release Date : Thu Jan 27 00:01:03 EST 2005 - Atul Mukker [EMAIL PROTECTED] +Current Version: 2.20.4.4 (scsi module), 2.20.2.5 (cmm module) +Older Version : 2.20.4.3 (scsi module), 2.20.2.4 (cmm module) + +1. Bump up the version of scsi module due to its conflict. + +Release Date : Thu Jan 21 00:01:03 EST 2005 - Atul Mukker [EMAIL PROTECTED] +Current Version: 2.20.4.3 (scsi module), 2.20.2.5 (cmm module) +Older Version : 2.20.4.2 (scsi module), 2.20.2.4 (cmm module) + +1. Remove driver ioctl for logical drive to scsi address translation and + replace with the sysfs attribute. To remove drives and change + capacity, application shall now use the device attribute to get the + logical drive number for a scsi device. For adding newly created + logical drives, class device attribute would be required to uniquely + identify each controller. + - Atul Mukker [EMAIL PROTECTED] + + James, I've been thinking about this a little more, and you may be on + to something here. Let each driver add files as such: + + - Matt Domsch [EMAIL PROTECTED], 12.15.2004 +linux-scsi mailing list + + + Then, if you simply publish your LD number as an extra parameter of + the device, you can look through /sys to find it. + + - James Bottomley [EMAIL PROTECTED], 01.03.2005 +linux-scsi mailing list + + + I don't see why not ... it's your driver, you can publish whatever + extra information you need as scsi_device attributes; that was one of + the designs of the extensible attribute system. + + - James Bottomley [EMAIL PROTECTED], 01.06.2005 +linux-scsi mailing list + +2. Add AMI megaraid support - Brian King [EMAIL PROTECTED] + PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID3, + PCI_VENDOR_ID_AMI, PCI_SUBSYS_ID_PERC3_DC, + +3. Make some code static - Adrian Bunk [EMAIL PROTECTED] + Date: Mon, 15 Nov 2004 03:14:57 +0100 + + The patch below makes some needlessly global code static. + -wait_queue_head_t wait_q; + +static wait_queue_head_t wait_q; + + Signed-off-by: Adrian Bunk [EMAIL PROTECTED] + +4. Added NEC ROMB support - NEC MegaRAID PCI Express ROMB controller + PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_MEGARAID_NEC_ROMB_2E, + PCI_SUBSYS_ID_NEC, PCI_SUBSYS_ID_MEGARAID_NEC_ROMB_2E, + +5. Fixed Tape drive issue : For any Direct CDB command to physical device + including tape, timeout value set by driver was 10 minutes. With this
Re: [RFC][PATCH 2.6.11-rc2] Linux SCSI hotplug infrastructure
On Tue, Feb 08, 2005 at 05:19:23PM -0600, Matt Domsch wrote: On Mon, Feb 07, 2005 at 12:27:53PM -0600, Matt Domsch wrote: Below is a patch to add some hotplug infrastructure to the Linux SCSI subsystem. I've added and reworked the megaraid_mbox driver to make use of this new infrastructure. I'll send that patch next. The rest is unchanged from yesterday. And these are the changes megaid_mbox to use the new infrastructure. -- Matt Domsch Software Architect Dell Linux Solutions linux.dell.com www.dell.com/linux Linux on Dell mailing lists @ http://lists.us.dell.com You can import this changeset into BK by piping this whole message to '| bk receive [path to repository]' or apply the patch as usual. === [EMAIL PROTECTED], 2005-02-08 16:46:03-06:00, [EMAIL PROTECTED] Release Date : Tue Feb 08 12:27:22 EST 2005 - Matt Domsch [EMAIL PROTECTED] Current Version : 2.20.4.6 (scsi module), 2.20.2.5 (cmm module) Older Version : 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) 1.Added two new megaraid_shost_attrs /sys/class/scsi_host |-- host0 | |-- logical_drive_created | |-- logical_drive_destroyed and helper functions for them. Written to from userspace by a management application, these invoke SCSI hotplug infrastructure for informing the kernel that a logical drive has been created, or will be destroyed quite soon. echo 2 logical_drive_created after creating logical drive #2 in the management app echo 4 logical_drive_destroyed immediately before destroying logical drive #4 in the management app. Eventually these functions should be called directly from the management app. 2.Made class_device_megaraid_mbox_app_hndl and dev_attr_megaraid_mbox_ld static. Signed-off-by: Matt Domsch [EMAIL PROTECTED] Documentation/scsi/ChangeLog.megaraid | 26 + drivers/scsi/megaraid/megaraid_mbox.c | 97 ++ drivers/scsi/megaraid/megaraid_mbox.h |4 - 3 files changed, 116 insertions, 11 deletions diff -Nru a/Documentation/scsi/ChangeLog.megaraid b/Documentation/scsi/ChangeLog.megaraid --- a/Documentation/scsi/ChangeLog.megaraid 2005-02-08 17:16:27 -06:00 +++ b/Documentation/scsi/ChangeLog.megaraid 2005-02-08 17:16:27 -06:00 @@ -1,3 +1,29 @@ +Release Date : Tue Feb 08 12:27:22 EST 2005 - Matt Domsch [EMAIL PROTECTED] +Current Version: 2.20.4.6 (scsi module), 2.20.2.5 (cmm module) +Older Version : 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) + +1. Added two new megaraid_shost_attrs + /sys/class/scsi_host + |-- host0 + | |-- logical_drive_created + | |-- logical_drive_destroyed + + and helper functions for them. Written to from userspace by + a management application, these invoke SCSI hotplug + infrastructure for informing the kernel that a logical drive + has been created, or will be destroyed quite soon. + echo 2 logical_drive_created +after creating logical drive #2 in the management app + echo 4 logical_drive_destroyed + immediately before destroying logical drive #4 in the + management app. Eventually these functions should be called + directly from the management app. + +2. Made class_device_megaraid_mbox_app_hndl and +dev_attr_megaraid_mbox_ld static. + + + Release Date : Thu Feb 03 12:27:22 EST 2005 - Seokmann Ju [EMAIL PROTECTED] Current Version: 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) Older Version : 2.20.4.4 (scsi module), 2.20.2.4 (cmm module) diff -Nru a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c --- a/drivers/scsi/megaraid/megaraid_mbox.c 2005-02-08 17:16:27 -06:00 +++ b/drivers/scsi/megaraid/megaraid_mbox.c 2005-02-08 17:16:27 -06:00 @@ -69,6 +69,7 @@ * For history of changes, see Documentation/ChangeLog.megaraid */ +#include scsi/scsi_hotplug.h #include megaraid_mbox.h static int megaraid_init(void); @@ -470,29 +471,107 @@ } }; +/* + * sysfs class device support + * creates two files: + * /sys/class/scsi_host + * |-- host0 + * | |-- logical_drive_created + * | |-- logical_drive_destroyed + * + * These make the midlayer invoke /sbin/hotplug, which then calls back into sysfs + * /sys/class/scsi_host + * |-- host0 + * | |-- scan + * + * and + * + * /sys/devices/pci:0x/:0x:0x.0/host0 + * |-- 0:0:0:0 + * | |-- delete + * + * respectively. This allows userspace applications to work + * using their logical drive number, and lets the driver translate + * that into host, channel, id, and lun values which the other + * mechanisms require. This is similar to how hot plug CPU works. + */ +/** + * lda_to_hcil() + * @adapter + * @lda - logical drive address + * @host_no + *
Re: [RFC][PATCH 2.6.11-rc2] Linux SCSI hotplug infrastructure
On Mon, Feb 07, 2005 at 12:27:53PM -0600, Matt Domsch wrote: Modified files: drivers/scsi/megaraid/megaraid_mbox.c (will follow in a separate patch) is the user of this new function. For example. I will rework this to follow the patch submitted last week by LSI to accomplish something similar in their driver. -- Matt Domsch Software Architect Dell Linux Solutions linux.dell.com www.dell.com/linux Linux on Dell mailing lists @ http://lists.us.dell.com = drivers/scsi/megaraid/megaraid_mbox.c 1.12 vs edited = --- 1.12/drivers/scsi/megaraid/megaraid_mbox.c 2005-01-31 00:33:46 -06:00 +++ edited/drivers/scsi/megaraid/megaraid_mbox.c2005-02-06 23:35:08 -06:00 @@ -70,6 +70,7 @@ * For history of changes, see Documentation/ChangeLog.megaraid */ +#include scsi/scsi_hotplug.h #include megaraid_mbox.h static int megaraid_init(void); @@ -455,6 +456,100 @@ /* + * sysfs class device support + * creates three files: + * /sys/class/scsi_host + * |-- host0 + * | |-- logical_drive_created + * | |-- logical_drive_destroyed + * + * These make the midlayer invoke /sbin/hotplug, which then calls back into sysfs + * /sys/class/scsi_host + * |-- host0 + * | |-- scan + * + * and + * + * /sys/devices/pci:0x/:0x:0x.0/host0 + * |-- 0:0:0:0 + * | |-- delete + * + * respectively. This allows userspace applications to work + * using their logical drive number, and lets the driver translate + * that into host, channel, id, and lun values which the other + * mechanisms require. This is similar to how hot plug CPU works. + */ + +/** + * lda_to_hcil() + * @adapter + * @lda - logical drive address + * @host_no + * @channel + * @id + * @lun + * + * converts a logical drive address into a host, channel id, lun tuple. + */ + +static inline int megaraid_lda_to_hcil(struct Scsi_Host *shost, u32 lda, + u32 *host_no, u32 *channel, u32 *id, u32 *lun) +{ + if (lda MAX_LOGICAL_DRIVES_40LD) + return -EINVAL; + *host_no = shost-host_no; + *channel = shost-max_channel; + *id = (lda shost-this_id) ? lda : lda + 1; + *lun = 0; + return 0; +} + +static int megaraid_host_store(struct class_device *class_dev, const char *buf, size_t count, + enum scsi_topology_action action) +{ +struct Scsi_Host *shost = class_to_shost(class_dev); + int fields=0, rc=-EINVAL; + u32 lda=0, host_no=0, channel=0, id=0, lun=0; + fields = sscanf(buf, %u, lda); + if (fields != 1) + return rc; + if (lda MAX_LOGICAL_DRIVES_40LD) + return rc; + rc = megaraid_lda_to_hcil(shost, lda, host_no, channel, id, lun); + if (rc) + return rc; + + rc = scsi_topology_hctl_action(shost, channel, id, lun, action); + + if (rc) + return rc; + return count; +} + +static ssize_t megaraid_host_store_ld_created(struct class_device *class_dev, const char *buf, size_t count) +{ + return megaraid_host_store(class_dev, buf, count, SCSI_TOPOLOGY_ADDED); +} +static ssize_t megaraid_host_store_ld_destroyed(struct class_device *class_dev, const char *buf, size_t count) +{ + return megaraid_host_store(class_dev, buf, count, SCSI_TOPOLOGY_REMOVED); +} + + +#define MEGARAID_HOST_WOATTR(_name,_store) \ +CLASS_DEVICE_ATTR(_name, S_IWUSR|S_IWGRP, NULL, _store) + +static MEGARAID_HOST_WOATTR(logical_drive_created, megaraid_host_store_ld_created); +static MEGARAID_HOST_WOATTR(logical_drive_destroyed, megaraid_host_store_ld_destroyed); + +/* Host attributes initializer */ +static struct class_device_attribute *megaraid_host_attrs[] = { + class_device_attr_logical_drive_created, + class_device_attr_logical_drive_destroyed, + NULL, +}; + +/* * Scsi host template for megaraid unified driver */ static struct scsi_host_template megaraid_template_g = { @@ -467,6 +562,7 @@ .eh_bus_reset_handler = megaraid_reset_handler, .eh_host_reset_handler = megaraid_reset_handler, .use_clustering = ENABLE_CLUSTERING, + .shost_attrs= megaraid_host_attrs, }; - To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC][PATCH 2.6.11-rc2] Linux SCSI hotplug infrastructure
On Mon, Feb 07, 2005 at 12:27:53PM -0600, Matt Domsch wrote: In addition, two more infrastructure pieces are necessary: udev-050-scsi_topology.patch - adds the subsystem name scsi_topology to the list of devices *not* to wait for the creation of files in sysfs for - scsi_topology devices aren't to be registered in sysfs. Patch follows. Signed-off-by: Matt Domsch [EMAIL PROTECTED] -- Matt Domsch Software Architect Dell Linux Solutions linux.dell.com www.dell.com/linux Linux on Dell mailing lists @ http://lists.us.dell.com --- udev-050/udev_sysfs.c.~1~ 2004-12-17 23:53:07.0 -0600 +++ udev-050/udev_sysfs.c 2005-02-07 10:58:45.0 -0600 @@ -56,6 +56,7 @@ { .subsystem = fc_host, .file = port_id }, { .subsystem = spi_transport, .file = width }, { .subsystem = spi_host, .file = width }, + { .subsystem = scsi_topology, .file = NULL }, { NULL, NULL } }; - To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC][PATCH 2.6.11-rc2] Linux SCSI hotplug infrastructure
On Mon, Feb 07, 2005 at 12:27:53PM -0600, Matt Domsch wrote: /etc/hotplug/scsi_topology.agent handles the hotplug call, and invokes /sys/class/scsi_host/hostX/scan and /sys/class/scsi_device/H:C:T:L:/device/delete as appropriate. And here's scsi_topology.agent. Signed-off-by: Matt Domsch [EMAIL PROTECTED] -- Matt Domsch Software Architect Dell Linux Solutions linux.dell.com www.dell.com/linux Linux on Dell mailing lists @ http://lists.us.dell.com #!/bin/bash # # SCSI Topology hotplug agent. # Copyright (C) 2005 Dell, Inc. [EMAIL PROTECTED] # # This is invoked when a device, not currently known to the system, is # added or removed from a SCSI topology. This includes creation of a # logical drive on a RAID controller, or manually inserting a disk # into a SCSI disk enclosure. This script then invokes the scan # method of the scsi_host, or the delete method of the scsi_device, to # inform the kernel of the change made on the topology. # # SCSI_TOPOLOGY_EVENT_HCTL is used to know that the data to pass to # scan is a Host:Controller:Target ID:LUN tuple. This is to provide # for future SCSI implmentations that may use a native addressing # scheme rather than only HCTL. [ ${SCSI_TOPOLOGY_EVENT} != 1 ] exit [ ${SCSI_TOPOLOGY_EVENT_HCTL} != 1 ] exit if [ ${ACTION} = add ]; then MYPATH=/sys/class/scsi_host/host${SCSI_HOST}/scan [ -f ${MYPATH} ] echo ${SCSI_CHANNEL} ${SCSI_ID} ${SCSI_LUN} ${MYPATH} fi if [ ${ACTION} = remove ]; then MYPATH=/sys/class/scsi_device/${SCSI_HOST}:${SCSI_CHANNEL}:${SCSI_ID}:${SCSI_LUN}/device/delete [ -f ${MYPATH} ] echo 1 ${MYPATH} fi - To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html