Persistent naming of scsi devices
Subsystems (5)
I have been working on a prototype to allow the persistent naming of scsi devices across boots. The prototype attempts to address the namespace slippage that occurs when names are assigned based on discovery order or topology, and a hardware configuration change occurs. It does this by assigning names based on the characteristics of the device.
The prototype and more detailed info can be found at:
http://oss.software.ibm.com/devreg/
The prototype utilizes 3 components:
1. driverfs to collect and publish the characteristics of the device
2. devfs to generate insertion and removal events
3. devfsd library to handle the events, parse driverfs, and apply the naming logic.
I am also currently working on a non devfs version that uses /sbin/hotplug as the event generation mechanism.
I would welcome any thoughts, comments, or suggestions.
Quoted 1 line · sullivan
I would welcome any thoughts, comments, or suggestions.
What is the rationale for doing this? I think we should rather get people to actually use the UUID= option to mount..
Quoted 5 lines · Christoph Hellwig
Quoted 1 line · sullivan
I would welcome any thoughts, comments, or suggestions.
What is the rationale for doing this? I think we should rather get people to actually use the UUID= option to mount..
right on!
Quoted 1 line · sullivan
I would welcome any thoughts, comments, or suggestions.
Quoted 2 lines · [email protected] said:
What is the rationale for doing this? I think we should rather get people to actually use the UUID= option to mount..
I think, actually, that this feature is aimed more generally. UUID really only works for filesystems that support it (and in Linux, I believe, this is currently only ext2/3 for 2.4 plus reiser in 2.5). A persistent device binding would be of use to people adopting Linux in their SAN enterprise who were not (at least initially) planning to convert all their filesystems over to Linux ones. It would also work for raw devices, which don't have an underlying filesystem to store the UUID.
I'm not sure we want to get into writing a UUID to a "safe" place on a device for such legacy filesystem types (especially as most administrators loathe this feature in NT).
The proposal for the device naming project says
"[...] Some of the characteristics examined include information returned from the SCSI Inquiry command, and the labels found on the disks partitions."
which implies to me that you can bind by UUID if desired.
One of the things I'm not so keen on in the proposed patch is that there is a large amount of code placed in the kernel for determining the vital product data IDs. For the scheme to be fully flexible, it would be much better to move this out to user land, using the /dev/sg pipe into the device, so that determining and using the device "characteristics" can be much more flexible. Hotplug is probably more useful to this type of user level based configuration than devfs et al.
James
Quoted 11 lines · James Bottomley
Quoted 1 line · sullivan
I would welcome any thoughts, comments, or suggestions.
One of the things I'm not so keen on in the proposed patch is that there is a large amount of code placed in the kernel for determining the vital product data IDs. For the scheme to be fully flexible, it would be much better to move this out to user land, using the
/dev/sgpipe into the device, so that determining and using the device "characteristics" can be much more flexible. Hotplug is probably more useful to this type of user level based configuration than devfs et al.
Quoted 1 line
James
James -
We could have a set of interfaces to get a SCSI UUID, and then have hotplug tell us which interface (or module?) to use. That way we don't require sg.
The device_list[] (black/white list) should also come from user land. Maybe hotplug could get the device_list[] characteristics, including the UUID method for the device.
I'd also like a uuid stored in Scsi_Device for multi-path support in the mid-layer (independent of how it's set). This uuid could not be stored in the partition or as part of the file system.
-- Patrick
Quoted 3 lines · [email protected] said:
We could have a set of interfaces to get a SCSI UUID, and then have hotplug tell us which interface (or module?) to use. That way we don't require sg.
I'm in two minds about this one. Deciding exactly what constitutes the UUID for a particular device can be non trivial. Usually you have to probe for the supported vital product pages, and if they have the WWN one use that otherwise fall back to the (less guaranteed to be unique) SCSI-2 serial number page or finally make something up dependent on what unique numbers you can get from the device.
It makes sense to me that this type of complex rule (of thumb almost) based lookup is best done from user level by doing the explicit SCSI commands if necessary.
However, I'm biased. From a philosophical point of view, I like the hotplug approach because it allows us to eject a lot of the use once initialisation code into user space from the kernel.
Quoted 7 lines
The device_list[] (black/white list) should also come from user land. Maybe hotplug could get the device_list[] characteristics, including the UUID method for the device.
I'd also like a uuid stored in
Scsi_Devicefor multi-path support in the mid-layer (independent of how it's set). This uuid could not be stored in the partition or as part of the file system.
If we can come up with a nice, general mechanism, there's no reason why it cannot apply outside the SCSI system, so I wouldn't necessarily tie it to Scsi_Devce. More likely (and actually what the persistent binding begins) is to tie it to the concept of the Mochel internal device tree.
James
Quoted 13 lines · James Bottomley
Quoted 3 lines · [email protected] said:
We could have a set of interfaces to get a SCSI UUID, and then have hotplug tell us which interface (or module?) to use. That way we don't require sg.
I'm in two minds about this one. Deciding exactly what constitutes the UUID for a particular device can be non trivial. Usually you have to probe for the supported vital product pages, and if they have the WWN one use that otherwise fall back to the (less guaranteed to be unique) SCSI-2 serial number page or finally make something up dependent on what unique numbers you can get from the device.
Quoted 7 lines
It makes sense to me that this type of complex rule (of thumb almost) based lookup is best done from user level by doing the explicit SCSI commands if necessary.
However, I'm biased. From a philosophical point of view, I like the hotplug approach because it allows us to eject a lot of the use once initialisation code into user space from the kernel.
Interesting discussion.
To see what the hotplug subsystem approach might look like, see http://www.torque.net/scsi/scsimon.html . This is a proposed scsi subsystem upper level driver (gathering dust). What sets it apart from the others is that it is not device based. It has a single (misc) device name and can be thought of as a window through to the scsi mid level. It supplies hotplug alerts whenever a scsi device is attached or detached. [Unfortunately scsi hosts being registered or unregistered does not cause hotplug alerts.] Attaches and detaches are given event numbers (ascending sequence) and a time_since_boot.
That said, I like the devfs/devfsd approach as well.
Quoted 4 lines
Quoted 3 lines
The device_list[] (black/white list) should also come from user land. Maybe hotplug could get the device_list[] characteristics, including the UUID method for the device.
Quoted 8 lines
Quoted 3 lines
I'd also like a uuid stored in
Scsi_Devicefor multi-path support in the mid-layer (independent of how it's set). This uuid could not be stored in the partition or as part of the file system.If we can come up with a nice, general mechanism, there's no reason why it cannot apply outside the SCSI system, so I wouldn't necessarily tie it to
Scsi_Devce. More likely (and actually what the persistent binding begins) is to tie it to the concept of the Mochel internal device tree.
In Patrick Mansfield's and my report_lun/twin_inquiry patch the full INQUIRY response (evpd=0 cmdtt=0) is placed in Scsi_Device. It could be useful to make that available (in ascii-hex) via driverfs/hot_plug to the user space.
Eric's point is a good one about dirty INQUIRY data. This is especially the case with what might be a large group of "scsi" devices that linux needs to cope with:
usb2 and ieee1394 talking to an external ATA disk. For the same Maxtor disk one INQUIRY (1394) tells me that it is a scsi 6 compliant device while the other INQUIRY (usb2) truncates the response at 28 bytes. I'm pretty sure they ignore the evpd bit as well.
I'm attempting to get this patch working against 2.5.7-dj3 (as it has captured most of the good patches from the list that haven't made it any further to date). There is a long way to go but here are some notes:
- driverfs is documented in:
Documentation/driver-model.txt Documentation/filesystems/driverfs.txt
- driverfs in built into 2.5 kernels but needs to be mounted. The documentation uses "/devices" as a mount point; driverfs seems more comfortable with me:
mkdir /driverfs ; mount -t driverfs none /driverfs
Doug Gilbert
Quoted 35 lines · Douglas Gilbert
Quoted 13 lines · James Bottomley
Quoted 3 lines · [email protected] said:
We could have a set of interfaces to get a SCSI UUID, and then have hotplug tell us which interface (or module?) to use. That way we don't require sg.
I'm in two minds about this one. Deciding exactly what constitutes the UUID for a particular device can be non trivial. Usually you have to probe for the supported vital product pages, and if they have the WWN one use that otherwise fall back to the (less guaranteed to be unique) SCSI-2 serial number page or finally make something up dependent on what unique numbers you can get from the device.
Quoted 7 lines
It makes sense to me that this type of complex rule (of thumb almost) based lookup is best done from user level by doing the explicit SCSI commands if necessary.
However, I'm biased. From a philosophical point of view, I like the hotplug approach because it allows us to eject a lot of the use once initialisation code into user space from the kernel.
Interesting discussion.
To see what the hotplug subsystem approach might look like, see http://www.torque.net/scsi/scsimon.html . This is a proposed scsi subsystem upper level driver (gathering dust). What sets it apart from the others is that it is not device based. It has a single (misc) device name and can be thought of as a window through to the scsi mid level. It supplies hotplug alerts whenever a scsi device is attached or detached. [Unfortunately scsi hosts being registered or unregistered does not cause hotplug alerts.] Attaches and detaches are given event numbers (ascending sequence) and a
time_since_boot.
Quoted 2 lines
That said, I like the devfs/devfsd approach as well.
Thanks Doug. I've taken a look at it looks like it would work very well in providing the event generation support in the non devfs case.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
The device_list[] (black/white list) should also come from user land. Maybe hotplug could get the device_list[] characteristics, including the UUID method for the device.
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
I'd also like a uuid stored in
Scsi_Devicefor multi-path support in the mid-layer (independent of how it's set). This uuid could not be stored in the partition or as part of the file system.If we can come up with a nice, general mechanism, there's no reason why it cannot apply outside the SCSI system, so I wouldn't necessarily tie it to
Scsi_Devce. More likely (and actually what the persistent binding begins) is to tie it to the concept of the Mochel internal device tree.
Patrick Mochel had mentioned before that he was looking at providing a unique identifier field as part of the common driverfs infrastructure. I'll check and see what his current thoughts are.
Quoted 4 lines
In Patrick Mansfield's and my report_lun/twin_inquiry patch the full INQUIRY response (evpd=0 cmdtt=0) is placed in
Scsi_Device. It could be useful to make that available (in ascii-hex) via driverfs/hot_plug to the user space.
Sounds good. I'll take a look at the patch and see about adding the driverfs implementation needed to support it.
Quoted 24 lines
Eric's point is a good one about dirty INQUIRY data. This is especially the case with what might be a large group of "scsi" devices that linux needs to cope with:
usb2 and ieee1394 talking to an external ATA disk. For the same Maxtor disk one INQUIRY (1394) tells me that it is a scsi 6 compliant device while the other INQUIRY (usb2) truncates the response at 28 bytes. I'm pretty sure they ignore the evpd bit as well.I'm attempting to get this patch working against 2.5.7-dj3 (as it has captured most of the good patches from the list that haven't made it any further to date). There is a long way to go but here are some notes:
- driverfs is documented in:
Documentation/driver-model.txtDocumentation/filesystems/driverfs.txt
- driverfs in built into 2.5 kernels but needs to be mounted. The documentation uses "/devices" as a mount point; driverfs seems more comfortable with me:
mkdir /driverfs ; mount -t driverfs none /driverfsDoug Gilbert
Quoted 24 lines · James Bottomley
Quoted 3 lines · [email protected] said:
We could have a set of interfaces to get a SCSI UUID, and then have hotplug tell us which interface (or module?) to use. That way we don't require sg.
I'm in two minds about this one. Deciding exactly what constitutes the UUID for a particular device can be non trivial. Usually you have to probe for the supported vital product pages, and if they have the WWN one use that otherwise fall back to the (less guaranteed to be unique) SCSI-2 serial number page or finally make something up dependent on what unique numbers you can get from the device.
It makes sense to me that this type of complex rule (of thumb almost) based lookup is best done from user level by doing the explicit SCSI commands if necessary.
However, I'm biased. From a philosophical point of view, I like the hotplug approach because it allows us to eject a lot of the use once initialisation code into user space from the kernel.
Quoted 3 lines
The device_list[] (black/white list) should also come from user land. Maybe hotplug could get the device_list[] characteristics, including the UUID method for the device.
Quoted 8 lines
Quoted 3 lines
I'd also like a uuid stored in
Scsi_Devicefor multi-path support in the mid-layer (independent of how it's set). This uuid could not be stored in the partition or as part of the file system.If we can come up with a nice, general mechanism, there's no reason why it cannot apply outside the SCSI system, so I wouldn't necessarily tie it to
Scsi_Devce. More likely (and actually what the persistent binding begins) is to tie it to the concept of the Mochel internal device tree.
I think this is the decision that is the most difficult. Setting up nodes on driverfs provides a consistent location and format (if we are careful) for surfacing information on devices. I find it much more difficult to keep up with where stuff is and what format it's in in /proc. Also, I must confess that keeping track of what userland utilites to use to collect various pieces of device information strains my limited memory cells. Of course this comes at the cost of extra code in the kernel.
Quoted 8 lines
James
-
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
Quoted 5 lines · Christoph Hellwig
Quoted 1 line · sullivan
I would welcome any thoughts, comments, or suggestions.
What is the rationale for doing this? I think we should rather get people to actually use the UUID= option to mount..
UUID cannot solve the problem. It identifies filesystems. There's a need to identify devices. Not everything is a hard drive with a filesystem on it.
Regards
Oliver
Quoted 8 lines · Oliver Neukum
Quoted 5 lines · Christoph Hellwig
Quoted 1 line · sullivan
I would welcome any thoughts, comments, or suggestions.
What is the rationale for doing this? I think we should rather get people to actually use the UUID= option to mount..
UUID cannot solve the problem. It identifies filesystems.
Or volumes..
Quoted 11 lines · Oliver Neukum
Quoted 5 lines · Christoph Hellwig
Quoted 1 line · sullivan
I would welcome any thoughts, comments, or suggestions.
What is the rationale for doing this? I think we should rather get people to actually use the UUID= option to mount..
UUID cannot solve the problem. It identifies filesystems. There's a need to identify devices. Not everything is a hard drive with a filesystem on it.
Then let's use WWPN/WWNS and/or drive serial #'s to do UUIDs for devices.
-amtt
Quoted 2 lines · [email protected] said:
Then let's use WWPN/WWNS and/or drive serial #'s to do UUIDs for devices.
That's what the persistent binding proposal that started all this uses. However, these strings are incredibly long at best and (in spite of what the SCSI spec says) sometimes include non-printing characters, so you don't necessarily want to be passing them on the command line.
James
A discussion about this kind of stuff went on at Sun in 1989. You want unambigious physical attribute names that are absolutely precise- this is what you get with, say, OpenBoot pathnames. But you don't want people to have to deal with them because they're unwieldy. Instead, you want 'friendly' names. For the OBP discussions back at Sun, this ended up as the 'devalias' command for the prom, so 'Fred' could be /iommu@foo/sbus@bar/disk@wank, etc.
For the current discussion, it seems to me that unlabelled/unimported disks/volumes (i.e., ones w/o a UUID) still can be named unambiguosly by the unwieldy names because you're likely to put a UUID on them very very quickly. Furthermore, a minor amount of effort in userland tools can make the manipulation of said names not as much of a problem.
Sorry if I came into the discussion late.
-matt
Quoted 18 lines · James Bottomley
Quoted 2 lines · [email protected] said:
Then let's use WWPN/WWNS and/or drive serial #'s to do UUIDs for devices.
That's what the persistent binding proposal that started all this uses. However, these strings are incredibly long at best and (in spite of what the SCSI spec says) sometimes include non-printing characters, so you don't necessarily want to be passing them on the command line.
James
-
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
Quoted 5 lines · [email protected] said:
For the current discussion, it seems to me that unlabelled/unimported disks/volumes (i.e., ones w/o a UUID) still can be named unambiguosly by the unwieldy names because you're likely to put a UUID on them very very quickly. Furthermore, a minor amount of effort in userland tools can make the manipulation of said names not as much of a problem.
I agree, but there are the edge cases where you can't put a UUID on them.
I think, however, that what the discussion is showing us is that there is no one universal way to get a unique name for a volume, so what we want is some type of pluggable infrastructure which allows us to construct a unique name.
As far as persistent binding goes, I think having the ability to persistently bind the unique name to a device is a useful feature for those of us who don't want to know what the actual unique name is (or who want a nicer name).
However, nothing should prevent you from passing the name as a string to mount instead of using persistent binding (even if the string turns out to have to be a set of hex digits). Perhaps we could even have a user level table of nice UUID to unwieldy unique name mapping, and you can use a user specified UUID without having to put anything on the device or partition.
The summary so far, as I see it, is
1) persistent binding might be a user friendly way of uniquely identifying devices
2) UUID doesn't solve the problem because not everything has one
3) ditto for WWN or EVPID
Another wrinkle is that UUID is partition specific, but WWN etc. are device specific.
James
Quoted 7 lines
Quoted 5 lines · [email protected] said:
For the current discussion, it seems to me that unlabelled/unimported disks/volumes (i.e., ones w/o a UUID) still can be named unambiguosly by the unwieldy names because you're likely to put a UUID on them very very quickly. Furthermore, a minor amount of effort in userland tools can make the manipulation of said names not as much of a problem.
Quoted 5 lines
I agree, but there are the edge cases where you can't put a UUID on them.
I think, however, that what the discussion is showing us is that there is no one universal way to get a unique name for a volume, so what we want is some type of pluggable infrastructure which allows us to construct a unique name.
Fair enough!
I would resist constructing names with addresses that can change easily (e.g., PortIDs or SCSI Targets, or device instance numbers based on probe order).
-matt
Quoted 5 lines · Christoph Hellwig
Quoted 1 line · sullivan
I would welcome any thoughts, comments, or suggestions.
What is the rationale for doing this? I think we should rather get people to actually use the UUID= option to mount..
Imagine an appliance serving out data from filesystems but also directly connected to a tape library (or, even better, many such libraries), obviously for direct backups. After reshuffling devices in the library (e.g. by breaking some of them :) Linux will reorder the tape devices in the way it finds them which will completely screw up the windows client software that is controlling the actual backup. So persistent naming of such devices is a good idea but to implement it is far from trivial. I am assuming the folks at IBM did this "non-trivial bit".
Regards,
Tigran
Quoted 8 lines · sullivan
I have been working on a prototype to allow the persistent naming of scsi devices across boots. The prototype attempts to address the namespace slippage that occurs when names are assigned based on discovery order or topology, and a hardware configuration change occurs. It does this by assigning names based on the characteristics of the device.
The prototype and more detailed info can be found at:
http://oss.software.ibm.com/devreg/
Looks good. As your README acknowledges one problem is that not all devices support the pages 0x80 and 0x83.
A quick scan of the code looks like you will work well with the "good" devices. :-)
Several cases you might want to consider for "bad" devices:
- devices that don't support 0x00 and return standard inquiry data instead!
- devices that don't support 0x00 but do support 0x80
For the first case you can snoop the return data from 0x00 to see if it looks "good" versus looks like standard inquiry.
For the second case if 0x00 fails go ahead and try 0x80 anyway.
Eddie
Hi,
just reading this discussion, I hope you all are aware of scsidev, which provides some of the functionality needed.
Apart from allowing you to specify devces according to the bus topology (just as devfs does), it also allows for aliases, based on various things, such as names, device types, model or serial numbers (got from INQUIRY with page code 0x80).
It may miss some mechanisms to deal with devices without this serial no, e.g., but in general I do not really see why it would not be useable.
http://www.garloff.de/kurt/linux/scsidev/
Regards,
Signature · 3 lines
Kurt Garloff <[email protected]> Eindhoven, NL GPG key: See mail header, key servers Linux kernel development SuSE Linux AG, Nuernberg, DE SCSI, Security
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: When must the io_request_lock be held?
Quoted 10 lines · [email protected] said:
Maybe I am mis-reading something.
Why would we want to go back to a model of having LL drivers using locks outside there domain (
queue_lock). Should we not be moving toward having drivers use there own locks.I would think a future model might be to have
queue_locksfor queue operations and possible shared as a scsi device lock, ahost_lockfor host data, and LL driver locks used where the driver needs them.
We're not really moving back: Drivers that do their own locking today should continue to work under the new model (it just breaks the granularity of the io_request_lock, which was used for queueing previously). Obviously, if those drivers move to individual queue locks instead of using the host lock for all queues, they get greater throughput but have nastier deadlock potential.
The drivers that don't have their own locks should now rely on either the host_lock or the queue_lock depending on what their hardware allows. The re-entrancy of queuecommand is goverened by the programming model of the device. For simple register and single mailbox cards, it doesn't really make too much sense to introduce a separate card lock just so they can drop the queue locks---It complicates the programming model and has no corresponding performance gain.
The bottom line is that there's no reason to require all drivers to develop their own locking scheme, but the barriers to this should be decreasing for those drivers that can profitably do this.
James
Re: [PATCH] 2.5.31 scsi_error.c cleanup
In reply to a message not in the archiveQuoted 9 lines · [email protected] said:
Thanks for the feedback my intent was not to panic on failed recovery. I will re-verify an offline case.
All sdev's that fail to recover in
scsi_eh_bus_host_resetthrough a bus and/or host reset should be offlined at the bottom of the channel for loop before we go on to the next channel. TheBUG_ON(shost-> host_failed)inscsi_unjamhost is a carryover from the oldscsi_errorpanic that I believe was trying to catch race conditions / code problems. I left the check in for now.
Ah, OK. I missed that in the logic flow. Does it perhaps make sense to move the offline into its own nicely named function? It might add to the initial readability of scsi_unjam_host. I see it was problematic because the offline loop is bound up inside the host loop.
James
Re: [PATCH] 2.5.31 scsi_error.c cleanup
Quoted 6 lines · James Bottomley [[email protected]] wrote:
Ah, OK. I missed that in the logic flow. Does it perhaps make sense to move the offline into its own nicely named function? It might add to the initial readability of
scsi_unjam_host. I see it was problematic because the offline loop is bound up inside the host loop.James
On early versions of the patch I had off-lining in its own function, but moved it into scsi_eh_bus_host_reset for some forgotten reason. I will re-roll the patch with a offline function as I agree it will improve the readability of scsi_unjam_host.
-Mike
Signature · 2 lines
Michael Anderson [email protected]
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
In reply to a message not in the archiveQuoted 2 lines · [email protected] said:
James I do not follow the usage of LUNs linked by pointers, can you explain further?
Yes: the mid-layer could function only with Scsi_Devices and Scsi_Hosts. LUNs are currently only used explicitly for scanning. However, I'd like to make the error handler handle the consequences of its action, thus it will need to know LUN relationships to handle a BDR correctly. However, the mid layer doesn't need an arbitrary number associated with LUN or PUN. Since the number, string or whatever is only really useful to the lld. So, simply put, we'd probably have an entry in the Scsi_Device for lun_list. This would be the usual doubly linked list so starting with any Scsi_Device we could always find the associated LUNs.
James
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
Quoted 4 lines · James Bottomley [[email protected]] wrote:
Quoted 2 lines · [email protected] said:
James I do not follow the usage of LUNs linked by pointers, can you explain further?
Quoted 10 lines
Yes: the mid-layer could function only with
Scsi_DevicesandScsi_Hosts. LUNs are currently only used explicitly for scanning. However, I'd like to make the error handler handle the consequences of its action, thus it will need to know LUN relationships to handle a BDR correctly. However, the mid layer doesn't need an arbitrary number associated with LUN or PUN. Since the number, string or whatever is only really useful to the lld. So, simply put, we'd probably have an entry in theScsi_Deviceforlun_list. This would be the usual doubly linked list so starting with anyScsi_Devicewe could always find the associated LUNs.
Ok, so we are looking for a sibling check. We should alter our driverfs registration so that we pick this up for free by comparing the de->parent of our scsi_device. Example tree shown below. Our scsi_device devfs_entry would be pointing the lun leaf node. TBD on where all the devfs_entrys get stored an who creates / destroys them.
Example tree
devices/root/pci0/00:09.0/name "PCI device 1014:002e" devices/root/pci0/00:09.0/0/name "scsi0" devices/root/pci0/00:09.0/0/0/name "chan0" devices/root/pci0/00:09.0/0/0/1/name "tgt1" devices/root/pci0/00:09.0/0/0/1/1/name "lun1" devices/root/pci0/00:09.0/0/0/1/0/name "lun0" devices/root/pci0/00:09.0/0/0/0/name "tgt0" devices/root/pci0/00:09.0/0/0/0/1/name "lun1" devices/root/pci0/00:09.0/0/0/0/0/name "lun0"
-Mike
Signature · 2 lines
Michael Anderson [email protected]
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
Sorry for replying to myself, but a mistake on the previous mail in that I meant to reference the scsi_device sdev_driverfs_dev member and associated sdev_driverfs_dev.parent pointer.
-Mike
Quoted 43 lines · Mike Anderson [[email protected]] wrote:
Quoted 4 lines · James Bottomley [[email protected]] wrote:
Quoted 2 lines · [email protected] said:
James I do not follow the usage of LUNs linked by pointers, can you explain further?
Quoted 10 lines
Yes: the mid-layer could function only with
Scsi_DevicesandScsi_Hosts. LUNs are currently only used explicitly for scanning. However, I'd like to make the error handler handle the consequences of its action, thus it will need to know LUN relationships to handle a BDR correctly. However, the mid layer doesn't need an arbitrary number associated with LUN or PUN. Since the number, string or whatever is only really useful to the lld. So, simply put, we'd probably have an entry in theScsi_Deviceforlun_list. This would be the usual doubly linked list so starting with anyScsi_Devicewe could always find the associated LUNs.Ok, so we are looking for a sibling check. We should alter our driverfs registration so that we pick this up for free by comparing the
de->parentof ourscsi_device. Example tree shown below. Ourscsi_devicedevfs_entrywould be pointing the lun leaf node. TBD on where all thedevfs_entrysget stored an who creates / destroys them.Example tree
devices/root/pci0/00:09.0/name "PCI device 1014:002e" devices/root/pci0/00:09.0/0/name "scsi0" devices/root/pci0/00:09.0/0/0/name "chan0" devices/root/pci0/00:09.0/0/0/1/name "tgt1" devices/root/pci0/00:09.0/0/0/1/1/name "lun1" devices/root/pci0/00:09.0/0/0/1/0/name "lun0" devices/root/pci0/00:09.0/0/0/0/name "tgt0" devices/root/pci0/00:09.0/0/0/0/1/name "lun1" devices/root/pci0/00:09.0/0/0/0/0/name "lun0"-Mike
Signature · 7 lines
Michael Anderson [email protected] - 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
Signature · 2 lines
Michael Anderson [email protected]
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
In reply to a message not in the archiveQuoted 1 line · [email protected] said:
Ok, so we are looking for a sibling check
Exactly.
Quoted 10 lines
Example tree
devices/root/pci0/00:09.0/name "PCI device 1014:002e" devices/root/pci0/00:09.0/0/name "scsi0" devices/root/pci0/00:09.0/0/0/name "chan0" devices/root/pci0/00:09.0/0/0/1/name "tgt1" devices/root/pci0/00:09.0/0/0/1/1/name "lun1" devices/root/pci0/00:09.0/0/0/1/0/name "lun0" devices/root/pci0/00:09.0/0/0/0/name "tgt0" devices/root/pci0/00:09.0/0/0/0/1/name "lun1" devices/root/pci0/00:09.0/0/0/0/0/name "lun0"
I'm not too happy with this tree. The unique string devices/root/pci0/00:09.0/name "PCI device 1014:002e" is enough to enumerate the scsi card (as long as it's not multi-function). If I follow my PUN/LUN position to its logical conclusion, we no longer need scsi host numbers, either. tgt1 is really a fiction: For a device that has luns there's usually no such thing as the target address (traditionally, it's LUN 0). However, fundamentally, the point is that moving all this entirely into driverfs means that scsi doesn't need to care what the tree looks like, it just has mappings into parts of it.
James
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
Quoted 11 lines · James Bottomley [[email protected]] wrote:
Quoted 10 lines
Example tree
devices/root/pci0/00:09.0/name "PCI device 1014:002e" devices/root/pci0/00:09.0/0/name "scsi0" devices/root/pci0/00:09.0/0/0/name "chan0" devices/root/pci0/00:09.0/0/0/1/name "tgt1" devices/root/pci0/00:09.0/0/0/1/1/name "lun1" devices/root/pci0/00:09.0/0/0/1/0/name "lun0" devices/root/pci0/00:09.0/0/0/0/name "tgt0" devices/root/pci0/00:09.0/0/0/0/1/name "lun1" devices/root/pci0/00:09.0/0/0/0/0/name "lun0"
Quoted 5 lines
I'm not too happy with this tree. The unique string devices/root/pci0/00:09.0/name "PCI device 1014:002e" is enough to enumerate the scsi card (as long as it's not multi-function). If I follow my PUN/LUN position to its logical conclusion, we no longer need scsi host numbers, either.
Agreed, this most likely can be collapsed. In looking at hosts.[ch] list addition/cleanup and talking with Greg k-h in the future (once driverfs ref count is in) we should not being doing our own host lists and ref counting.
Quoted 2 lines
tgt1 is really a fiction: For a device that has luns there's usually no such thing as the target address (traditionally, it's LUN 0).
Is there no need to represent a I_T nexus and a I_T_L nexus? It would seem to be a lost of information if we dump everything into to large of a bucket and then need to make extra links to regain this information.
The tgts where just examples, these could be port names, etc. My point was to say if luns (which can have any name you want) where contained under a port node than it would be easy to determine siblings. The only drawback would be an extra lun0 node.
Quoted 3 lines
However, fundamentally, the point is that moving all this entirely into driverfs means that scsi doesn't need to care what the tree looks like, it just has mappings into parts of it.
I am confused as the scsi subsystem is creating parts of this tree by deciding when and what to register with driverfs. Driverfs is only providing the interface and some default nodes. While driverfs is doing a lot, how we register can make future code easier or hard.
-Mike
Signature · 2 lines
Michael Anderson [email protected]
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
Quoted 25 lines · Mike Anderson
Quoted 11 lines · James Bottomley [[email protected]] wrote:
Quoted 10 lines
Example tree
devices/root/pci0/00:09.0/name "PCI device 1014:002e" devices/root/pci0/00:09.0/0/name "scsi0" devices/root/pci0/00:09.0/0/0/name "chan0" devices/root/pci0/00:09.0/0/0/1/name "tgt1" devices/root/pci0/00:09.0/0/0/1/1/name "lun1" devices/root/pci0/00:09.0/0/0/1/0/name "lun0" devices/root/pci0/00:09.0/0/0/0/name "tgt0" devices/root/pci0/00:09.0/0/0/0/1/name "lun1" devices/root/pci0/00:09.0/0/0/0/0/name "lun0"Quoted 5 lines
I'm not too happy with this tree. The unique string devices/root/pci0/00:09.0/name "PCI device 1014:002e" is enough to enumerate the scsi card (as long as it's not multi-function). If I follow my PUN/LUN position to its logical conclusion, we no longer need scsi host numbers, either.
Agreed, this most likely can be collapsed. In looking at hosts.[ch] list addition/cleanup and talking with Greg k-h in the future (once driverfs ref count is in) we should not being doing our own host lists and ref counting.
Quoted 2 lines
tgt1 is really a fiction: For a device that has luns there's usually no such thing as the target address (traditionally, it's LUN 0).
Quoted 8 lines
Is there no need to represent a
I_Tnexus and aI_T_Lnexus? It would seem to be a lost of information if we dump everything into to large of a bucket and then need to make extra links to regain this information.The tgts where just examples, these could be port names, etc. My point was to say if luns (which can have any name you want) where contained under a port node than it would be easy to determine siblings. The only drawback would be an extra lun0 node.
James/Mike -
For hotplug user level probe/scanning, you want a target identified: having the device model (aka driverfs) expose a target would (should) eventually lead to a hotplug callout that can then be used to trigger a probe (sequential lun or report lun scans) of the target from user land.
A target representation is also nice for device (i.e. target) removal/replacment, where we want to shutdown and perhaps remove everything on one target with multiple LUNs. Even if we have to manually remove each LUN, having a target in the tree lets a user figure out which LUNs have to be shutdown/removed.
The notion of a target could be useful for multi-path path selection, when we want to round-robin across the target ports, rather than a LUN port, or pick the least-busy target port. The notion of a bus (like a SCSI bus, FCP fabric, or an FCP loop) could be usefull for similiar reasons.
Also - according to Pat Mochel the struct device "name" field is supposed to be a description of the device, not an id or unique identifier. I don't know if he has plans to add a id/uuid field.
-- Patrick Mansfield
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
In reply to Mike AndersonQuoted 17 lines · Mike Anderson
Quoted 11 lines · James Bottomley [[email protected]] wrote:
Quoted 10 lines
Example tree
devices/root/pci0/00:09.0/name "PCI device 1014:002e" devices/root/pci0/00:09.0/0/name "scsi0" devices/root/pci0/00:09.0/0/0/name "chan0" devices/root/pci0/00:09.0/0/0/1/name "tgt1" devices/root/pci0/00:09.0/0/0/1/1/name "lun1" devices/root/pci0/00:09.0/0/0/1/0/name "lun0" devices/root/pci0/00:09.0/0/0/0/name "tgt0" devices/root/pci0/00:09.0/0/0/0/1/name "lun1" devices/root/pci0/00:09.0/0/0/0/0/name "lun0"Quoted 5 lines
I'm not too happy with this tree. The unique string devices/root/pci0/00:09.0/name "PCI device 1014:002e" is enough to enumerate the scsi card (as long as it's not multi-function). If I follow my PUN/LUN position to its logical conclusion, we no longer need scsi host numbers, either.
Quoted 4 lines
Agreed, this most likely can be collapsed. In looking at hosts.[ch] list addition/cleanup and talking with Greg k-h in the future (once driverfs ref count is in) we should not being doing our own host lists and ref counting.
The scsi host can be collapsed, the other stuff should really remain. After all, the scsi host number was nothing more than the previous way of expressing "PCI device 1014:002e", they both map to a controller somewhere.
Quoted 4 lines
Quoted 2 lines
tgt1 is really a fiction: For a device that has luns there's usually no such thing as the target address (traditionally, it's LUN 0).
Is there no need to represent a
I_Tnexus and aI_T_Lnexus?
There is. Not really for device needs, but for management needs. It's connection specific and likely is just an implementation detail, but it would make like simpler for LLDDs if this was expressed. What I'm thinking is that both the target level struct and the lun level struct need to have driver_private pointers for driver defined memory structs as well as a back pointer from the lun struct to the parent target struct. This is so drivers can easily do things like implement tagged queues properly, which are per lun, and also implement speed negotiations, which are per target.
Quoted 3 lines
It would
seem to be a lost of information if we dump everything into to large of a bucket and then need to make extra links to regain this information.
Having links to get the information isn't bad (it's currently better than the crap we do now which is search the linear list until we've found all the needed devices, very ugly). Having the right links is actually quite nice ;-)
Quoted 4 lines
The tgts where just examples, these could be port names, etc. My point was to say if luns (which can have any name you want) where contained under a port node than it would be easy to determine siblings. The only drawback would be an extra lun0 node.
It doesn't have to be that way. It's entirely possible to make the target struct not require this extra lun0 node you refer to. However, the target struct should actually be a fairly thin struct, only containing enough info to represent those items that are in fact target wide vs. lun specific. Essentially, anything that the SAM spec calls out as using an I_T nexus should be here, and anything that goes on an I_T_L nexus should be in the lun struct. It seems to me that the specs are likely to keep this level of heirarchy going forward and so it should be safe to model after it, but I could be wrong (and I have read the latest draft specs so I could already be wrong). Feel free to correct me here if I am wrong.
Quoted 4 lines
I am confused as the scsi subsystem is creating parts of this tree by deciding when and what to register with driverfs. Driverfs is only providing the interface and some default nodes. While driverfs is doing a lot, how we register can make future code easier or hard.
Hmmm...I'm not going to comment on this yet because I want to go look a few things up first....
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
In reply to a message not in the archiveQuoted 4 lines · [email protected] said:
Is there no need to represent a
I_Tnexus and aI_T_Lnexus? It would seem to be a lost of information if we dump everything into to large of a bucket and then need to make extra links to regain this information.
As far as the mid-layer is concerned, no. I_T vs I_T_L is really somewhat of a fiction even in SAM-2 since the M_IDENTIFY for I_T just looks like a M_IDENTIFY for I_T_L with LUN set to 0.
Quoted 4 lines
The tgts where just examples, these could be port names, etc. My point was to say if luns (which can have any name you want) where contained under a port node than it would be easy to determine siblings. The only drawback would be an extra lun0 node.
Oh, yes, I agree with that. The mid-layer just uses a Scsi_Device with a
driverfs pointer attached. If the driverfs representation happens to be a simple tgt1 or tgt1/lun0, the mid-layer won't care.
Quoted 4 lines
I am confused as the scsi subsystem is creating parts of this tree by deciding when and what to register with driverfs. Driverfs is only providing the interface and some default nodes. While driverfs is doing a lot, how we register can make future code easier or hard.
OK, I see, conceptually what I'm aiming at is that the bulk of the mid-layer doesn't know or care about the name: it thinks in terms of Scsi_Host or Scsi_Device. When the mid-layer needs to print a name, it fishes it out of driverfs.
Currently, the code that generates these names lives in the mid-layer, but it is possible that the day may come when we need standardisation amongst all disc like devices (or tape like devices, etc.), and it may not live there any longer (or at least, parts of it may not).
The ideal now is that we separate these as cleanly as possible inside the mid-layer. I'd like us to be to the point where if we don't like the current host/chan/pun/lun/... naming scheme, a few formatting characters get altered in one routine and the new naming scheme is implemented. In the long run, I think we probably turn over one piece (the host/chan/pun) to the Host driver so that it can be used for naming an mapping (with library routines in the mid layer for the usual pun numbering) and the LUN part probably always belongs in the mid layer since that's fairly universal.
James
Re: SCSI woes (followup)
In reply to a message not in the archiveQuoted 3 lines · [email protected] said:
If you want me to I can add it to a patch bundle I already have that includes ports of Russell's previous changes that apply on top of my 2.5
scsi_errorcleanup patch.
Sounds good. Do you have a copy of the error handler clean up that applies cleanly to 2.5.38 (after the removal of scsi_queue.c)?
James
Re: SCSI woes (followup)
Quoted 8 lines · James Bottomley [[email protected]] wrote:
Quoted 3 lines · [email protected] said:
If you want me to I can add it to a patch bundle I already have that includes ports of Russell's previous changes that apply on top of my 2.5
scsi_errorcleanup patch.Sounds good. Do you have a copy of the error handler clean up that applies cleanly to 2.5.38 (after the removal of
scsi_queue.c)?
Yes,
I am sending out mail now on new thread.
-andmike
--
Michael Anderson
[email protected]
Re: [PATCH] first cut at fixing unable to requeue with no outstanding commands
In reply to a message not in the archiveQuoted 2 lines · [email protected] said:
Are we guaranteed that
blk_run_queueswill be called for all types of I/O?
Pretty much, it looks like. It's mainly triggered by I/O stuff in fs, including the buffer functions, so I think the assumption that we will be called eventually is good.
James
Re: [PATCH] first cut at fixing unable to requeue with no outstanding commands
Quoted 9 lines · James Bottomley
Quoted 2 lines · [email protected] said:
Are we guaranteed that
blk_run_queueswill be called for all types of I/O?Pretty much, it looks like. It's mainly triggered by I/O stuff in fs, including the buffer functions, so I think the assumption that we will be called eventually is good.
James
What about applications and devices that only send one IO at a time? They could still hang.
We have: tape (st or osst), sg usage, partitioning, scanning, direct use of the block device (i.e. dd if=/dev/sda), and probably others.
-- Patrick Mansfield
Re: [PATCH] first cut at fixing unable to requeue with no outstanding commands
In reply to a message not in the archiveQuoted 5 lines · [email protected] said:
- Is the call to
scsi_delete_timerreally necessary. All callers have already deleted the timer. Thedel_timerfunction takes a lock which would be nice to avoid if we do not need to call it. If we want to protect the code we could do a quick check onSCset->eh_timeout.functionprior to calling.
That's a belt and braces thing. I suppose we could change it to BUG_ON timer active and see what pops out of the woodwork.
Quoted 7 lines · [email protected] said:
- Patrick pointed out a while ago that the "if (
host->host_busy== 0)" check and the similar one for the device will never be called because to be in this function the values of these variables need to be at least 1. I believe this direct call toscsi_retry_commandshould be removed instead of adjusting the check to "== 1" as this seems counter to how you are trying to handle busy.
Yes, I plan on slowly removing all automatic reissues of commands. I've already removed the checks in my local tree (and the corresponding reissues).
James
Re: [PATCH] scsi host cleanup 3/3 (driver changes)
In reply to a message not in the archiveI (finally) got around to looking at the patches. There were only a few minor quibbles, really boiling down to the fact that you export some functions beginning shost_ instead of scsi_ (shost_tp_for_each_host, shost_chk_and_release). I can't see any reason why this might cause a naming clash, but I think it is safer to stick to exports beginning with scsi_.
Also, why do we now have some functions beginning scsi_host and some beginning scsi_shost? Could we just use one or the other (I'd vote for scsi_host, since it's shorter).
James
Re: [PATCH] scsi host cleanup 3/3 (driver changes)
Quoted 5 lines · James Bottomley [[email protected]] wrote:
I (finally) got around to looking at the patches. There were only a few minor quibbles, really boiling down to the fact that you export some functions beginning
shost_instead ofscsi_(shost_tp_for_each_host,shost_chk_and_release). I can't see any reason why this might cause a naming clash, but I think it is safer to stick to exports beginning withscsi_.
Ok will change to scsi_.
Quoted 5 lines
Also, why do we now have some functions beginning
scsi_hostand some beginningscsi_shost? Could we just use one or the other (I'd vote forscsi_host, since it's shorter).
Ok. will change to scsi_host.
Currently I waiting on a re-roll because of an issue currently with the patch relating to driverfs registration. Since I moved a lot of functionality to scsi_register (which I wanted to do because of past issues / comments) I am registering the host with driverfs prior to scsi_set_pci_device being called by the host driver. This result in scsi(n) showing up under root. I could move registration into the scsi_set_pci_device function, but was wanting to wait until we get some driverfs layout issues understood.
-andmike
--
Michael Anderson
[email protected]
Re: [patch 2.5] ips queue depths
In reply to a message not in the archiveQuoted 9 lines · [email protected] said:
I never seen the mid layer handle device starvation correctly. It might be because in
scsi_queue_next_requestwe do this:/*
* Just hit the requeue function for the queue.
*/
q->request_fn(q);before we check for starved.
This starvation code has nothing to do with fairness. It's job is purely to restart the device queue if we got a host blocked condition and we had to reject commands with zero depth. When the host blocked abates then we loop over all the starved devices and call their request functions. Without this, we could get a hang in the block layer queueing.
This could do with being converted over to the blk_stop/start_queue api.
The SCSI code seems to have been written with the idea that device queue_depth << can_queue and thus doesn't concern itself with resource fairness issues when the two are closer in size to each other.
James
Re: [patch 2.5] ips queue depths
Quoted 9 lines · James Bottomley [[email protected]] wrote:
Quoted 7 lines · [email protected] said:
I never seen the mid layer handle device starvation correctly. It might be because in
scsi_queue_next_requestwe do this:/*
* Just hit the requeue function for the queue.
*/
q->request_fn(q);
Quoted 7 lines
Quoted 1 line
before we check for starved.
This starvation code has nothing to do with fairness. It's job is purely to restart the device queue if we got a host blocked condition and we had to reject commands with zero depth. When the host blocked abates then we loop over all the starved devices and call their request functions. Without this, we could get a hang in the block layer queueing.
I am mis-reading what your saying.
Ok it will not handle fairness, but it will trigger a starved and some_device_starved case when SHpnt->can_queue > 0 and SHpnt->host_busy >= SHpnt->can_queue. Which is the case we where discussing and is not a host blocked condition. The reverse ordering of the request_fn call could cause a device to stayed starved if the device queue depth is near or equal to the host can_queue.
-andmike
--
Michael Anderson
[email protected]
Re: [patch 2.5] ips queue depths
In reply to a message not in the archiveQuoted 4 lines · [email protected] said:
Ok it will not handle fairness, but it will trigger a starved and
some_device_starvedcase whenSHpnt->can_queue> 0 and SHpnt->host_busy>=SHpnt->can_queue. Which is the case we where discussing and is not a host blocked condition.
Yes, but this still only activates if the device trying to queue has no currently outstanding commands. Usually under heavy load to multiple LUNs, you probably won't run into this too often.
The way the mid-layer expects to operate under load is that a returning command for a given device triggers the request queue for that device to queue up the next waiting command.
Quoted 3 lines
The reverse ordering of the
request_fncall could cause a device to stayed starved if the device queue depth is near or equal to the hostcan_queue.
True, I suppose, but only in the limited case where there are no queued commands for a particular device. The most likely case is that one device has stolen a huge number of slots and everyone else gets a tiny number, which won't activate this code at all.
James
Re: [RFC][PATCH] move dma_mask into struct device
In reply to a message not in the archiveQuoted 2 lines · [email protected] said:
I got a compile error here. This should be.
dev->dev.dma_mask = &dev->dma_mask;
Oops, yes, that's what comes of making changes in code you don't compile.
Quoted 2 lines
The machine is a 2x pci systems with the following drivers loaded:
aic7xxx, ips, qlogicisp.
Thanks for testing it.
James
PATCH 1/1 2.5.31 scsi_error.c cleanup
I have created a scsi_error cleanup patch.
I would appreciate any feedback and testing.
The patch simplifies scsi_unjam_host and associated functions.
I did not change any of the current error policy. I would like to do that in the future.
I have tested the patch on the following configurations with successful recovery:
UML:
Driver: scsi_debug Version: 1.59
Error Hdlr Policy:
- Request sense if no auto sense.
- Abort on timed out command
2.5.31:
Driver: aic7xxx 6.2.4
Error Hdlr Policy:
- Abort on timed out command
- Attempt BDR
- Send Bus Reset.
I also ran against qlogicisp, ips, and qla drivers but error injection did not generate any meaningful results.
Complete patch against 2.5.31 is at:
http://www-124.ibm.com/storageio/gen-io/patch-scsi_error-2.5.31-1.gz
-Mike
Signature · 2 lines
Michael Anderson [email protected]
Re: [PATCH] 2.5.31 scsi_error.c cleanup
Quoted 2 lines · [email protected] said:
I did not change any of the current error policy. I would like to do that in the future.
Looking through the patch, it seems you've changed the offline behaviour. Now if all error recovery fails, the machine will panic instead of just offlining the failed device. I know offlining has never worked correctly, because it always seems to leave the system hanging, but it is a useful feature for large machines with many SCSI attachements, could you look at trying to get it to work corectly?
Thanks,
James
Re: [PATCH] 2.5.31 scsi_error.c cleanup
Quoted 11 lines · James Bottomley [[email protected]] wrote:
Quoted 2 lines · [email protected] said:
I did not change any of the current error policy. I would like to do that in the future.
Looking through the patch, it seems you've changed the offline behavior. Now if all error recovery fails, the machine will panic instead of just offlining the failed device. I know offlining has never worked correctly, because it always seems to leave the system hanging, but it is a useful feature for large machines with many SCSI attachments, could you look at trying to get it to work corectly?
Quoted 3 lines
Thanks,
James
Thanks for the feedback my intent was not to panic on failed recovery. I will re-verify an offline case.
All sdev's that fail to recover in scsi_eh_bus_host_reset through a bus and/or host reset should be offlined at the bottom of the channel for loop before we go on to the next channel. The BUG_ON(shost->host_failed) in scsi_unjam host is a carryover from the old scsi_error panic that I believe was trying to catch race conditions / code problems. I left the check in for now.
-Mike
Signature · 2 lines
Michael Anderson [email protected]
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
Quoted 8 lines
Quoted 5 lines · [email protected] said:
To me all of the proposed changes look good. The one above I'd be interested in particularly. It would help sorting out a lot of woes we had with writing a fibre-channel HBA driver. For fibre-channel LUNs and port IDs (WWPN) are 64-bit and depending on configuration, high values can be (and in our case are) common.
Quoted 4 lines
Actually, I'd like to see us moving towards adopting the capabilities of driverfs for this.
PUN is to all intents and purposes now an abstraction in the FC realm.
LUNs
Quoted 1 line
too, as long as they retain the grouping abstraction with PUNs. The mid
layer
Quoted 1 line
really doesn't need to know what these are (there are a few pieces of
code
Quoted 1 line
that populate the LUN field for SCSI-1 devices that would need rework).
All
Quoted 3 lines
the mid layer really needs is the
Scsi_Devicestructure that describes anindividual LUN (and some knowledge of LUN and PUN grouping for reset
action
Quoted 1 line
prediction). It doesn't need to know or care about the current PUN and
LUN
Quoted 3 lines
numbers.
If FC drivers move straight to using driverfs, you can populate the
driverfs
Quoted 1 line
names with whatever is meaningful to you for PUN (WWN, portid etch) and
LUN
Quoted 1 line
and thus avoid this problem (and also the mapping code most have to take
these
Quoted 2 lines
to and from the PUN/LUN numbers). Since driverfs is a tree, the PUN/LUN division is done in a directory (and could, theoretically be done on more
than
Quoted 3 lines
just a two level split).
James
James, there are some things that I don't fully understand, yet.
Does the use of driverfs-names mean that the HBA driver somehow comes into the discovery-loop for devices (e.g. scan_scsis somehow interacts with the HBA driver to determine which driverfs entry to create.)? Shouldn't there be some sort of rule for LUN (or unit) naming within at least the same hardware class? That is for: parallel, iSCSI, FC, etc. Will the SCSI stack automatically try to discover all devices behind the HBA (e.g, on the FC SAN)? Or will there be an interface to restrict the range, etc?
Lastly, how will you keep track of LUNs in the SCSI stack? Will the current LUN field disappear in favour of a generic character string?
Cheers,
Aron
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
Quoted 3 lines · [email protected] said:
Does the use of driverfs-names mean that the HBA driver somehow comes into the discovery-loop for devices (e.g.
scan_scsissomehow interacts with the HBA driver to determine which driverfs entry to create.)?
Well, scanning is really only for legacy. Way into the future, I'd like to see hotplug notification for device attach events, so no fibre controller ever need be troubled by the scan. All they'd do is send a device attach notification into SCSI when they detect one. (SCSI would probably then turn around and ask for a REPORT_LUNS).
Quoted 5 lines
Shouldn't there be some sort of rule for LUN (or unit) naming within at least the same hardware class? That is for: parallel, iSCSI, FC, etc. Will the SCSI stack automatically try to discover all devices behind the HBA (e.g, on the FC SAN)? Or will there be an interface to restrict the range, etc?
Yes, there should. But such a rule would only be for maintaining consistency within driverfs, and therefore could happily become Patric Mochel's problem. If we go the whole hotplug route, discovery would be up to the scsi hotplug scripts.
Quoted 2 lines
Lastly, how will you keep track of LUNs in the SCSI stack? Will the current LUN field disappear in favour of a generic character string?
Internally to Scsi_Device, LUNs will be linked by pointers. How we know whether such a linkage needs to occur, I'm not yet sure about. In the worst case we could use driverfs matching to see if a newly discovered device's PUN matches an existing device, or there might be a way for the HBA driver to supply the information.
James
Re: [RFC]: 64 bit LUN/Tags, dummy device in host_queue, host_lock <-> LLDD reentrancy
Quoted 11 lines · James Bottomley [[email protected]] wrote:
Quoted 3 lines · [email protected] said:
Does the use of driverfs-names mean that the HBA driver somehow comes into the discovery-loop for devices (e.g.
scan_scsissomehow interacts with the HBA driver to determine which driverfs entry to create.)?Well, scanning is really only for legacy. Way into the future, I'd like to see hotplug notification for device attach events, so no fibre controller ever need be troubled by the scan. All they'd do is send a device attach notification into SCSI when they detect one. (SCSI would probably then turn around and ask for a
REPORT_LUNS).
There will probably still need to be some form of scan through the hotplug scripts based on a HAs capability (parallel SCSI, FC loop). A CAM-3 like indication that the HA is capable of auto discovery or needs a probe from min-max.
Quoted 11 lines
Quoted 5 lines
Shouldn't there be some sort of rule for LUN (or unit) naming within at least the same hardware class? That is for: parallel, iSCSI, FC, etc. Will the SCSI stack automatically try to discover all devices behind the HBA (e.g, on the FC SAN)? Or will there be an interface to restrict the range, etc?
Yes, there should. But such a rule would only be for maintaining consistency within driverfs, and therefore could happily become Patric Mochel's problem. If we go the whole hotplug route, discovery would be up to the scsi hotplug scripts.
Quoted 9 lines
Quoted 2 lines
Lastly, how will you keep track of LUNs in the SCSI stack? Will the current LUN field disappear in favour of a generic character string?
Internally to
Scsi_Device, LUNs will be linked by pointers. How we know whether such a linkage needs to occur, I'm not yet sure about. In the worst case we could use driverfs matching to see if a newly discovered device's PUN matches an existing device, or there might be a way for the HBA driver to supply the information.
James I do not follow the usage of LUNs linked by pointers, can you explain further?
-Mike
Signature · 2 lines
Michael Anderson [email protected]
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 2 lines · Lars Marowsky-Bree
So, what is the take on "multi-path IO" (in particular, storage) in 2.5/2.6?
I've already made my views on this fairly clear (at least from the SCSI stack standpoint):
- multi-path inside the low level drivers (like qla2x00) is wrong
- multi-path inside the SCSI mid-layer is probably wrong
- from the generic block layer on up, I hold no specific preferences
That being said, I'm not particularly happy to have the multi-path solution tied to a specific raid driver; I'd much rather it were in something generic that could be made use of by all raid drivers (and yes, I do see the LVM2 device mapper as more hopeful than md in this regard).
Quoted 3 lines
I am looking at what to do for 2.5. I have considered porting the small changes from 2.4 to md 2.5. The LVM1 changes are probably and out gone, as LVM1 doesn't work still.
Well, neither of the people most involved in the development (that's Neil Brown for md in general and Ingo Molnar for the multi-path enhancements) made any comments---see if you can elicit some feedback from either of them.
James
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 8 lines · James Bottomley
Quoted 2 lines · Lars Marowsky-Bree
So, what is the take on "multi-path IO" (in particular, storage) in 2.5/2.6?
I've already made my views on this fairly clear (at least from the SCSI stack standpoint):
- multi-path inside the low level drivers (like qla2x00) is wrong
Agreed.
Quoted 1 line
- multi-path inside the SCSI mid-layer is probably wrong
Disagree
Quoted 1 line
- from the generic block layer on up, I hold no specific preferences
Using md or volume manager is wrong for non-failover usage, and somewhat bad for failover models; generic block layer is OK but it is wasted code for any lower layers that do not or cannot have multi-path IO (such as IDE).
Quoted 2 lines
James
I have a newer version of SCSI multi-path in the mid layer that I hope to post this week, the last version patched against 2.5.14 is here:
http://www-124.ibm.com/storageio/multipath/scsi-multipath
Some documentation is located here:
http://www-124.ibm.com/storageio/multipath/scsi-multipath/docs/index.html
I have a current patch against 2.5.33 that includes NUMA support (it requires discontigmem support that I believe is in the current linus bk tree, plus NUMA topology patches).
A major problem with multi-path in md or other volume manager is that we use multiple (block layer) queues for a single device, when we should be using a single queue. If we want to use all paths to a device (i.e. round robin across paths or such, not a failover model) this means the elevator code becomes inefficient, mabye even counterproductive. For disk arrays, this might not be bad, but for actual drives or even plugging single ported drives into a switch or bus with multiple initiators, this could lead to slower disk performance.
If the volume manager implements only a failover model (use only a single path until that path fails), besides performance issues in balancing IO loads, we waste space allocating an extra Scsi_Device for each path.
In the current code, each path is allocated a Scsi_Device, including a request_queue_t, and a set of Scsi_Cmnd structures. Not only do we end up with a Scsi_Device for each path, we also have an upper level (sd, sg, st, or sr) driver attached to each Scsi_Device.
For sd, this means if you have n paths to each SCSI device, you are limited to whatever limit sd has divided by n, right now 128 / n. Having four paths to a device is very reasonable, limiting us to 32 devices, but with the overhead of 128 devices.
Using a volume manager to implement multiple paths (again non-failover model) means that the queue_depth might be too large if the queue_depth (i.e. number of outstanding commands sent to the drive) is set as a per-device value - we can end sending n * queue_depth commands to a device.
multi-path in the scsi layer enables multi-path use for all upper level scsi drivers, not just disks.
We could implement multi-path IO in the block layer, but if the only user is SCSI, this gains nothing compared to putting multi-path in the scsi layers. Creating block level interfaces that will work for future devices and/or future code is hard without already having the devices or code in place. Any block level interface still requires support in the the underlying layers.
I'm not against a block level interface, but I don't have ideas or code for such an implementation.
Generic device naming consistency is a problem if multiple devices show up with the same id.
With the scsi layer multi-path, ide-scsi or usb-scsi could also do multi-path IO.
-- Patrick Mansfield
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 4 lines · [email protected] said:
Using md or volume manager is wrong for non-failover usage, and somewhat bad for failover models; generic block layer is OK but it is wasted code for any lower layers that do not or cannot have multi-path IO (such as IDE).
What about block devices that could usefully use multi-path to achieve network redundancy, like nbd? If it's in the block layer or above, they can be made to work with minimal effort.
My basic point is that the utility of the feature transcends SCSI, so SCSI is too low a layer for it.
I wouldn't be too sure even of the IDE case: IDE has a habit of copying SCSI features when they become more main-stream (and thus cheaper). It wouldn't suprise me to see multi-path as an adjunct to the IDE serial stuff.
Quoted 9 lines
A major problem with multi-path in md or other volume manager is that we use multiple (block layer) queues for a single device, when we should be using a single queue. If we want to use all paths to a device (i.e. round robin across paths or such, not a failover model) this means the elevator code becomes inefficient, mabye even counterproductive. For disk arrays, this might not be bad, but for actual drives or even plugging single ported drives into a switch or bus with multiple initiators, this could lead to slower disk performance.
That's true today, but may not be true in 2.6. Suparna's bio splitting code is aimed precisely at this and other software RAID cases.
Quoted 4 lines
In the current code, each path is allocated a
Scsi_Device, including arequest_queue_t, and a set ofScsi_Cmndstructures. Not only do we end up with aScsi_Devicefor each path, we also have an upper level (sd, sg, st, or sr) driver attached to eachScsi_Device.
You can't really get away from this. Transfer parameters are negotiated at the Scsi_Device level (i.e. per device path from HBA to controller), and LLDs accept I/O's for Scsi_Devices. Whatever you do, you still need an entity that performs most of the same functions as the Scsi_Device, so you might as well keep Scsi_Device itself, since it works.
Quoted 4 lines
For sd, this means if you have n paths to each SCSI device, you are limited to whatever limit sd has divided by n, right now 128 / n. Having four paths to a device is very reasonable, limiting us to 32 devices, but with the overhead of 128 devices.
I really don't expect this to be true in 2.6.
Quoted 5 lines
Using a volume manager to implement multiple paths (again non-failover model) means that the
queue_depthmight be too large if thequeue_depth(i.e. number of outstanding commands sent to the drive) is set as a per-device value - we can end sending n *queue_depthcommands to a device.
The queues tend to be in the controllers, not in the RAID devices, thus for a dual path RAID device you usually have two caching controllers and thus twice the queue depth (I know this isn't always the case, but it certainly is enough of the time for me to argue that you should have the flexibility to queue per path).
Quoted 9 lines
We could implement multi-path IO in the block layer, but if the only user is SCSI, this gains nothing compared to putting multi-path in the scsi layers. Creating block level interfaces that will work for future devices and/or future code is hard without already having the devices or code in place. Any block level interface still requires support in the the underlying layers.
I'm not against a block level interface, but I don't have ideas or code for such an implementation.
SCSI got into a lot of trouble by going down the "kernel doesn't have X feature I need, so I'll just code it into the SCSI mid-layer instead", I'm loth to accept something into SCSI that I don't think belongs there in the long term.
Answer me this question:
- In the forseeable future does multi-path have uses other than SCSI?
I've got to say, I can't see a "no" to that one, so it fails the high level bar to getting into the scsi subsystem. However, the kernel, as has been said before, isn't a theoretical excercise in design, so is there a good expediency argument (like "it will take one year to get all the features of the block layer to arrive and I have a customer now"). Also, to go in under expediency, the code must be readily removable against the day it can be redone correctly.
Quoted 2 lines
Generic device naming consistency is a problem if multiple devices show up with the same id.
Patrick Mochel has an open task to come up with a solution to this.
Quoted 2 lines
With the scsi layer multi-path, ide-scsi or usb-scsi could also do multi-path IO.
The "scsi is everything" approach got its wings shot off at the kernel summit, and subsequently confirmed its death in a protracted wrangle on lkml (I can't remember the reference off the top of my head, but I'm sure others can).
James
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 9 lines · James Bottomley [[email protected]] wrote:
Quoted 4 lines · [email protected] said:
Using md or volume manager is wrong for non-failover usage, and somewhat bad for failover models; generic block layer is OK but it is wasted code for any lower layers that do not or cannot have multi-path IO (such as IDE).
What about block devices that could usefully use multi-path to achieve network redundancy, like nbd? If it's in the block layer or above, they can be made to work with minimal effort.
When you get into networking I believe we may get into path failover capability that is already implemented by the network stack. So the paths may not be visible to the block layer.
Quoted 8 lines
My basic point is that the utility of the feature transcends SCSI, so SCSI is too low a layer for it.
I wouldn't be too sure even of the IDE case: IDE has a habit of copying SCSI features when they become more main-stream (and thus cheaper). It wouldn't suprise me to see multi-path as an adjunct to the IDE serial stuff.
The utility does transcend SCSI, but transport / device specific characteristics may make "true" generic implementations difficult.
To add functionality beyond failover multi-path you will need to get into transport and device specific data gathering.
Quoted 10 lines
Quoted 9 lines
A major problem with multi-path in md or other volume manager is that we use multiple (block layer) queues for a single device, when we should be using a single queue. If we want to use all paths to a device (i.e. round robin across paths or such, not a failover model) this means the elevator code becomes inefficient, mabye even counterproductive. For disk arrays, this might not be bad, but for actual drives or even plugging single ported drives into a switch or bus with multiple initiators, this could lead to slower disk performance.
Quoted 2 lines
That's true today, but may not be true in 2.6. Suparna's bio splitting code is aimed precisely at this and other software RAID cases.
I have not looked at Suparna's patch but it would seem that device knowledge would be helpful for knowing when to split.
Quoted 10 lines
Quoted 4 lines
In the current code, each path is allocated a
Scsi_Device, including arequest_queue_t, and a set ofScsi_Cmndstructures. Not only do we end up with aScsi_Devicefor each path, we also have an upper level (sd, sg, st, or sr) driver attached to eachScsi_Device.You can't really get away from this. Transfer parameters are negotiated at the
Scsi_Devicelevel (i.e. per device path from HBA to controller), and LLDs accept I/O's forScsi_Devices. Whatever you do, you still need an entity that performs most of the same functions as theScsi_Device, so you might as well keepScsi_Deviceitself, since it works.
James have you looked at the documentation / patch previously pointed to by Patrick? There is still a Scsi_device.
Quoted 8 lines
Quoted 5 lines
For sd, this means if you have n paths to each SCSI device, you are limited to whatever limit sd has divided by n, right now 128 / n. Having four paths to a device is very reasonable, limiting us to 32 devices, but with the overhead of 128 devices.
I really don't expect this to be true in 2.6.
While the device space may be increased in 2.6 you are still consuming extra resources, but we do this in other places also.
Quoted 10 lines
Quoted 9 lines
We could implement multi-path IO in the block layer, but if the only user is SCSI, this gains nothing compared to putting multi-path in the scsi layers. Creating block level interfaces that will work for future devices and/or future code is hard without already having the devices or code in place. Any block level interface still requires support in the the underlying layers.
I'm not against a block level interface, but I don't have ideas or code for such an implementation.
Quoted 9 lines
SCSI got into a lot of trouble by going down the "kernel doesn't have X feature I need, so I'll just code it into the SCSI mid-layer instead", I'm loth to accept something into SCSI that I don't think belongs there in the long term.
Answer me this question:
- In the forseeable future does multi-path have uses other than SCSI?
See top comment.
Quoted 3 lines
The "scsi is everything" approach got its wings shot off at the kernel summit, and subsequently confirmed its death in a protracted wrangle on lkml (I can't remember the reference off the top of my head, but I'm sure others can).
Could you point this out so I can understand the context.
-Mike
Signature · 2 lines
Michael Anderson [email protected]
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 3 lines · Mike Anderson
When you get into networking I believe we may get into path failover capability that is already implemented by the network stack. So the paths may not be visible to the block layer.
It depends. The block layer might need knowledge of the different paths for load balancing.
Quoted 2 lines
The utility does transcend SCSI, but transport / device specific characteristics may make "true" generic implementations difficult.
I disagree. What makes "generic" implementations difficult is the absolutely mediocre error reporting and handling from the lower layers.
With multipathing, you want the lower level to hand you the error _immediately_ if there is some way it could be related to a path failure and no automatic retries should take place - so you can immediately mark the path as faulty and go to another.
However, on a "access beyond end of device" or a clear read error, failing a path is a rather stupid idea, but instead the error should go up immediately.
This will need to be sorted regardless of the layer it is implemented in.
How far has this been already addressed in 2.5 ?
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
For sd, this means if you have n paths to each SCSI device, you are limited to whatever limit sd has divided by n, right now 128 / n. Having four paths to a device is very reasonable, limiting us to 32 devices, but with the overhead of 128 devices.
I really don't expect this to be true in 2.6.
While the device space may be increased in 2.6 you are still consuming extra resources, but we do this in other places also.
For user-space reprobing of failed paths, it may be vital to expose the physical paths too. Then "reprobing" could be as simple as
dd if=/dev/physical/path of=/dev/null count=1 && enable_path_again
I dislike reprobing in kernel space, in particular using live requests as the LVM1 patch by IBM does it.
Sincerely,
Lars Marowsky-Brée <[email protected]>
Signature · 2 lines
Immortality is an adequate definition of high availability for me. --- Gregory F. Pfister
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 7 lines · Lars Marowsky-Bree
On 2002-09-09T11:40:26,
With multipathing, you want the lower level to hand you the error _immediately_ if there is some way it could be related to a path failure and no automatic retries should take place - so you can immediately mark the path as faulty and go to another.
Quoted 7 lines
However, on a "access beyond end of device" or a clear read error, failing a path is a rather stupid idea, but instead the error should go up immediately.
This will need to be sorted regardless of the layer it is implemented in.
How far has this been already addressed in 2.5 ?
The current scsi multi-path code handles the above cases. There is a scsi_path_decide_disposition() that fails paths independent of the result of the IO. It is similiar to the current scsi_decide_disposition, except it also fails the path. So for a check condition of media error, the IO might be marked as SUCCESS (meaning completed with an error), but the path would not be modified (there are more details than this).
Quoted 5 lines
For user-space reprobing of failed paths, it may be vital to expose the physical paths too. Then "reprobing" could be as simple as
dd if=/dev/physical/path of=/dev/null count=1 && enable_path_again
Yes, that is a good idea, I was thinking that this should be done via sg, and modify sg to allow path selection - so no matter what, sg could be used to probe a path. I have no plans to expose a user level device for each path, but a device model "file" could be exposed for the state of each path, and its state controlled via driverfs.
Quoted 6 lines
I dislike reprobing in kernel space, in particular using live requests as the LVM1 patch by IBM does it.
Sincerely,
Lars Marowsky-Brée <[email protected]>
-- Patrick Mansfield
Re: [RFC] Multi-path IO in 2.5/2.6 ?
In reply to Lars Marowsky-BreeQuoted 7 lines · Lars Marowsky-Bree [[email protected]] wrote:
Quoted 3 lines · Mike Anderson
When you get into networking I believe we may get into path failover capability that is already implemented by the network stack. So the paths may not be visible to the block layer.
Quoted 9 lines
It depends. The block layer might need knowledge of the different paths for load balancing.
Quoted 2 lines
The utility does transcend SCSI, but transport / device specific characteristics may make "true" generic implementations difficult.
I disagree. What makes "generic" implementations difficult is the absolutely mediocre error reporting and handling from the lower layers.
Where working on it. I have done a mid scsi_error cleanup patch for 2.5 so that we can better view where we are at currently. Hopefully soon we can do some actual useful improvements.
My main point on the previous comment though was that some transports may decide not to expose there paths (i.e. the may manage them at the transport layer) and the block layer would be unable to attach to individual paths.
The second point I was trying to make is that if you look at most multi-path solutions across different operating systems once they have failover capability and move to support more performant / advanced multi-path solutions they need specific attributes of the device or path. These attributes have sometimes been called personalities.
Examples of these personalities are path usage models (failover, transparent failover, active load balancing), ports per controller config, platform memory latency (NUMA), cache characteristics, special error decoding for device events, etc.
I mention a few in these in this document.
http://www-124.ibm.com/storageio/multipath/scsi-multipath/docs/index.html
These personalities could be acquired at any level of the IO stack, but involve some API if we want to try and get as close as possible to "generic".
Quoted 5 lines
With multipathing, you want the lower level to hand you the error _immediately_ if there is some way it could be related to a path failure and no automatic retries should take place - so you can immediately mark the path as faulty and go to another.
Agreed, In a past O/S we worked hard to have our error policy structure so that transports worried about transport errors and devices worried about device errors. If a transport received a completion of an IO its job was done (we did have some edge case and heuristics to stop paths from cycling from disabled to enabled)
Quoted 3 lines
However, on a "access beyond end of device" or a clear read error, failing a path is a rather stupid idea, but instead the error should go up immediately.
Agreed, each layer should only deal with error in there domain.
Quoted 3 lines
This will need to be sorted regardless of the layer it is implemented in.
How far has this been already addressed in 2.5 ?
See previous comment.
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
For sd, this means if you have n paths to each SCSI device, you are limited to whatever limit sd has divided by n, right now 128 / n. Having four paths to a device is very reasonable, limiting us to 32 devices, but with the overhead of 128 devices.
I really don't expect this to be true in 2.6.
While the device space may be increased in 2.6 you are still consuming extra resources, but we do this in other places also.
Quoted 8 lines
For user-space reprobing of failed paths, it may be vital to expose the physical paths too. Then "reprobing" could be as simple as
dd if=/dev/physical/path of=/dev/null count=1 && enable_path_againI dislike reprobing in kernel space, in particular using live requests as the LVM1 patch by IBM does it.
In the current mid-mp patch the paths are exposed through the proc interface and can be activated / state changed through a echo command.
While live requests are sometimes viewed as a bad things to activate a path very small IO sizes in optical networks a unreliable in determining anything but completely dead paths. The size of the payload is important.
I believe the difference in views here is what to expose and what size/type of structure represents each piece of the nexus (b:c:t:l).
-Mike
Signature · 2 lines
Michael Anderson [email protected]
Re: [RFC] Multi-path IO in 2.5/2.6 ?
In reply to James BottomleyJames -
Quoted 6 lines · James Bottomley
What about block devices that could usefully use multi-path to achieve network redundancy, like nbd? If it's in the block layer or above, they can be made to work with minimal effort.
My basic point is that the utility of the feature transcends SCSI, so SCSI is too low a layer for it.
I agree it has potential uses outside of SCSI, this does not directly imply that we need to create a generic implementation. I have found no code to reference in other block drivers or in the block layer. I've looked some at the dasd code but can't figure out if or where there is any multi-path code.
Putting multi-path into the block layer means it would have to acquire and maintain a handle (i.e. path) for each device it knows about, and then eventually pass this handle down to the lower level. I don't see this happening in 2.5/2.6, unless someone is coding it right now.
It makes sense to at least expose the topology of the IO storage, whether or not the block or other layers can figure out what to do with the information. That is, ideally for SCSI we should have a representation of the target - like struct scsi_target - and then the target is multi-pathed, not the devices (LUNs, block or character devices) attached to the target. We should also have a bus or fabric representation, showing multi-path from the adapters view (multiple initiators on the fabric or bus).
Whether or not the fabric or target information is used to route IO, they are useful for hardware removal/replacement. Imagine replacing a fibre switch, or replacing a failed controller on a raid array.
If all this information was in the device model (driver?), with some sort of function or data pointers, perhaps (in 2.7.x timeframe) we could route IO and call appropriate drivers based on that information.
Quoted 10 lines
Quoted 9 lines
A major problem with multi-path in md or other volume manager is that we use multiple (block layer) queues for a single device, when we should be using a single queue. If we want to use all paths to a device (i.e. round robin across paths or such, not a failover model) this means the elevator code becomes inefficient, mabye even counterproductive. For disk arrays, this might not be bad, but for actual drives or even plugging single ported drives into a switch or bus with multiple initiators, this could lead to slower disk performance.
Quoted 2 lines
That's true today, but may not be true in 2.6. Suparna's bio splitting code is aimed precisely at this and other software RAID cases.
Yes, but then we need some sort of md/RAID/volume manager aware eleavator code + bio splitting, and perhaps avoid calling elevator code normally called for a Scsi_Device. Though I can imagine splitting the bio in md and then still merging and sorting requests for SCSI.
Quoted 10 lines
Quoted 4 lines
In the current code, each path is allocated a
Scsi_Device, including arequest_queue_t, and a set ofScsi_Cmndstructures. Not only do we end up with aScsi_Devicefor each path, we also have an upper level (sd, sg, st, or sr) driver attached to eachScsi_Device.You can't really get away from this. Transfer parameters are negotiated at the
Scsi_Devicelevel (i.e. per device path from HBA to controller), and LLDs accept I/O's forScsi_Devices. Whatever you do, you still need an entity that performs most of the same functions as theScsi_Device, so you might as well keepScsi_Deviceitself, since it works.
Yes negotiation is at the adapter level, but that does not have to be tied to a Scsi_Device. I need to search for Scsi_Device::hostdata usage to figure out details, and to figure out if anything is broken in the current scsi multi-path code - right now it requires the same adapter drivers be used and that certain Scsi_Host parameters are equal if multiple paths to a Scsi_Device are found.
Quoted 6 lines
Quoted 4 lines
For sd, this means if you have n paths to each SCSI device, you are limited to whatever limit sd has divided by n, right now 128 / n. Having four paths to a device is very reasonable, limiting us to 32 devices, but with the overhead of 128 devices.
I really don't expect this to be true in 2.6.
If we use a Scsi_Device for each path, we always have the overhead of the number of paths times the number of devices - upping the limits of sd certainly helps, but we are then increasing the possibly large amount of memory that we can waste. And, other devices besides disks can be multi-pathed.
Quoted 11 lines
Quoted 5 lines
Using a volume manager to implement multiple paths (again non-failover model) means that the
queue_depthmight be too large if thequeue_depth(i.e. number of outstanding commands sent to the drive) is set as a per-device value - we can end sending n *queue_depthcommands to a device.The queues tend to be in the controllers, not in the RAID devices, thus for a dual path RAID device you usually have two caching controllers and thus twice the queue depth (I know this isn't always the case, but it certainly is enough of the time for me to argue that you should have the flexibility to queue per path).
You can have multiple initiators on FCP or SPI, without dual controllers involved at all. Most of my multi-path testing has been with dual ported FCP disk drives, with multiple FCP adapters connected to a switch, not with disk arrays (I don't have any non-failover multi-ported disk arrays available, I'm using a fastt 200 disk array); I don't know the details of the drive controllers for my disks, but putting multiple controllers in a disk drive certainly would increase the cost.
Yes, per path queues and per device queues are reasonable; per path queues requires knowledge of actual device ports not in the current scsi multi-path patch. The code I have now uses the Scsi_Host::can_queue to limit the number of commands sent to a host. I really need slave_attach() support in the host adapter (like Doug L's patch a while back), plus maybe a slave_attach_path(), and/or queue limit per path.
Per path queues are not required, as long as any queue limits do not hinder the performance.
Quoted 7 lines
SCSI got into a lot of trouble by going down the "kernel doesn't have X feature I need, so I'll just code it into the SCSI mid-layer instead", I'm loth to accept something into SCSI that I don't think belongs there in the long term.
Answer me this question:
Quoted 8 lines
- In the forseeable future does multi-path have uses other than SCSI?
I've got to say, I can't see a "no" to that one, so it fails the high level bar to getting into the scsi subsystem. However, the kernel, as has been said before, isn't a theoretical excercise in design, so is there a good expediency argument (like "it will take one year to get all the features of the block layer to arrive and I have a customer now"). Also, to go in under expediency, the code must be readily removable against the day it can be redone correctly.
Yes, there could be future multi-path users, or maybe with DASD. If we take SCSI and DASD as existing usage, they could be a basis for a block layer (or generic) set of multi-path interfaces.
There is code available for scsi multi-path, this is not a design in theory. Anyone can take the code and fold it into a block layer implementation or other approach. I would be willing to work on scsi usage or such for any new block level or other such code for generic multi-path use. At this time I wouldn't feel comfortable adding to or modifying block layer interfaces and code, nor do I think it is possible to come up with the best interface given only one block driver implementation, nor do I think there is enough time to get this into 2.5.x.
IMO, there is demand for scsi multi-path support now, as users move to large databases requiring higher availabitity. md or volume manager for failover is adequate in some of these cases.
I see other issues as being more important to scsi - like cleaning it up or rewriting portions of the code, but we still need to add new features as we move forward.
Even with generic block layer multi-path support, we still need block driver (scsi, ide, etc.) code for multi-path.
Quoted 4 lines
Quoted 2 lines
Generic device naming consistency is a problem if multiple devices show up with the same id.
Patrick Mochel has an open task to come up with a solution to this.
I don't think this can be solved if multiple devices show up with the same id. If I have five disks that all say I'm disk X, how can there be one name or handle for it from user level?
Quoted 6 lines
Quoted 2 lines
With the scsi layer multi-path, ide-scsi or usb-scsi could also do multi-path IO.
The "scsi is everything" approach got its wings shot off at the kernel summit, and subsequently confirmed its death in a protracted wrangle on lkml (I can't remember the reference off the top of my head, but I'm sure others can).
Agreed, but having the block layer be everything is also wrong.
My view is that md/volume manager multi-pathing is useful with 2.4.x, scsi layer multi-path for 2.5.x, and this (perhaps with DASD) could then evolve into generic block level (or perhaps integrated with the device model) multi-pathing support for use in 2.7.x. Do you agree or disagree with this approach?
-- Patrick Mansfield
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 8 lines · Patrick Mansfield
You can have multiple initiators on FCP or SPI, without dual controllers involved at all. Most of my multi-path testing has been with dual ported FCP disk drives, with multiple FCP adapters connected to a switch, not with disk arrays (I don't have any non-failover multi-ported disk arrays available, I'm using a fastt 200 disk array); I don't know the details of the drive controllers for my disks, but putting multiple controllers in a disk drive certainly would increase the cost.
Is there any plan to do something for hardware RAIDs in which two different RAID controllers can get to the same logical unit, but you pay a performance penalty when you access the lun via both controllers? It seems to me that all RAIDs that don't require a command to switch a lun from one to the other controller (i.e. where both ctlrs can access a lun simultaneously) pay a performance penalty when you access a lun from both.
Working around this in a generic way (i.e. without designation by the system admin) seems difficult, so I'm wondering what may have been done with this (my reading of this discussion is that it has not been tackled yet).
thanks
jeremy
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 3 lines · Jeremy Higdon
Is there any plan to do something for hardware RAIDs in which two different RAID controllers can get to the same logical unit, but you pay a performance penalty when you access the lun via both controllers?
This is implemented in the md multipath patch in 2.4; it distinguishes between "active" and "spare" paths.
The LVM1 patch also does this by having priorities for each path and only going to the next priority group if all paths in the current one have failed, which IMHO is slightly over the top but there is always someone who might need it ;-)
This functionality is a generic requirement IMHO.
Sincerely,
Lars Marowsky-Brée <[email protected]>
Signature · 2 lines
Immortality is an adequate definition of high availability for me. --- Gregory F. Pfister
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 15 lines · Lars Marowsky-Bree
Quoted 3 lines · Jeremy Higdon
Is there any plan to do something for hardware RAIDs in which two different RAID controllers can get to the same logical unit, but you pay a performance penalty when you access the lun via both controllers?
This is implemented in the md multipath patch in 2.4; it distinguishes between "active" and "spare" paths.
The LVM1 patch also does this by having priorities for each path and only going to the next priority group if all paths in the current one have failed, which IMHO is slightly over the top but there is always someone who might need it ;-)
Quoted 5 lines
This functionality is a generic requirement IMHO.
Sincerely,
Lars Marowsky-Brée <[email protected]>
The current scsi multi-path has a default setting of "last path used", so that it will always work with such controllers (I refer to such controllers as fail-over devices). You have to modify the config, or boot with a flag to get round-robin path selection. Right now, all paths will start out on the same adapter (initiator), this is bad if you have more than a few arrays attached to and adapter.
I was planning on implementing something similiar to what you describe for LVM1, with path weighting. Yes, it seems a bit heavy, but if there are only two weights or priorities, it looks just like your active/spare code, and is a bit more flexible.
Figuring out what ports are active or spare is not easy, and varies from array to array. This is a (another) good canidate for user level probing/configuration. I will likely probably hard-code device personallity information into the kernel for now, and hopefully in 2.7 we could move SCSI to user level probe/scan/configure.
I have heard that some arrays at one time had a small penalty for switching controllers, and it was best to use the last path used, but it was still OK to use both at the same time (cache warmth). I was trying to think of a way to allow good load balancing in such cases, but didn't come up with a good solution. Like use last path used selection, and once a path is too "busy" move to another path
- but then all devices might switch at the same time; some hearistics or timing could probably be added to avoid such problems. The code allows for path selection in a single function, so it should not be difficult to add more complex path selection.
I have also put NUMA path selection into the latest code. I've tested it with 2.5.32, and a bunch of NUMA + NUMAQ patches on IBM/Sequent NUMAQ systems.
-- Patrick Mansfield
Re: [RFC] Multi-path IO in 2.5/2.6 ?
In reply to Patrick MansfieldOn 2002-09-09T17:08:47,
Patrick Mansfield <[email protected]> said:
Patrick, I am only replying to what I understand. Some of your comments on the internals of the SCSI layer are beyond me ;-)
Quoted 6 lines
Yes negotiation is at the adapter level, but that does not have to be tied to a
Scsi_Device. I need to search forScsi_Device::hostdatausage to figure out details, and to figure out if anything is broken in the current scsi multi-path code - right now it requires the same adapter drivers be used and that certainScsi_Hostparameters are equal if multiple paths to aScsi_Deviceare found.
This seems to be a serious limitation. There are good reasons for wanting to use different HBAs for the different paths.
And the Scsi_Device might be quite different. Imagine something like two storage boxes which do internal replication among them; yes, you'd only want to use one of them normal (because the Cache-coherency traffic is going to kill performance otherwise), but you can failover from one to the other even if they have different SCSI serials etc.
Quoted 2 lines
of memory that we can waste. And, other devices besides disks can be multi-pathed.
That is a good point.
But it would also be true for a generic block device implementation.
Quoted 3 lines
Yes, there could be future multi-path users, or maybe with DASD. If we take SCSI and DASD as existing usage, they could be a basis for a block layer (or generic) set of multi-path interfaces.
SATA will also support multipathing if the birds were right, so it might make sense to keep this in mind, at least for 2.7.
Quoted 1 line
There is code available for scsi multi-path, this is not a design in theory.
Well, there is code available for all the others too ;-)
Quoted 3 lines
IMO, there is demand for scsi multi-path support now, as users move to large databases requiring higher availabitity. md or volume manager for failover is adequate in some of these cases.
The volume manager multi-pathing, at least as done via the LVM1 patch, has a major drawback. It can't easily be stacked with software RAID. It is very awkward to do that right now.
And software RAID on top of multi-pathing is a typical example for a truely fault tolerant configuration.
Thats obviously easier with md, and I assume your SCSI code can also do that nicely.
Quoted 2 lines
Even with generic block layer multi-path support, we still need block driver (scsi, ide, etc.) code for multi-path.
Yes. Error handling in particular ;-)
The topology information you mention is also a good candidate for exposure.
Quoted 1 line
Agreed, but having the block layer be everything is also wrong.
Having the block device handling all block devices seems fairly reasonable to me.
Quoted 5 lines
My view is that md/volume manager multi-pathing is useful with 2.4.x, scsi layer multi-path for 2.5.x, and this (perhaps with DASD) could then evolve into generic block level (or perhaps integrated with the device model) multi-pathing support for use in 2.7.x. Do you agree or disagree with this approach?
Well, I guess 2.5/2.6 will have all the different multi-path implementations mentioned so far (EVMS, LVM2, md, scsi, proprietary) - they all have code and a userbase... All of them and future implementations can benefit from better error handling and general cleanup, so that might be the best to do for now.
I think it is too soon to clean that up and consolidate the m-p approaches, but I think it really ought to be consolidated in 2.7, and this seems like a good time to start planning for that one.
Sincerely,
Lars Marowsky-Brée <[email protected]>
Signature · 2 lines
Immortality is an adequate definition of high availability for me. --- Gregory F. Pfister
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 10 lines · Lars Marowsky-Bree
Quoted 6 lines · Patrick Mansfield
Yes negotiation is at the adapter level, but that does not have to be tied to a
Scsi_Device. I need to search forScsi_Device::hostdatausage to figure out details, and to figure out if anything is broken in the current scsi multi-path code - right now it requires the same adapter drivers be used and that certainScsi_Hostparameters are equal if multiple paths to aScsi_Deviceare found.
Quoted 2 lines
This seems to be a serious limitation. There are good reasons for wanting to use different HBAs for the different paths.
What reasons? Adapter upgrades/replacement on a live system? I can imagine someone using different HBAs so that they won't hit the same bug in both HBAs, but that is a weak argument; I would think such systems would want some type of cluster failover.
If the HBAs had the same memory and other limitations, it should function OK, but it is hard to figure out exactly what might happen (if the HBAs had different error handling characteristics, handled timeouts differently, etc.). It would be easy to get rid of the checking for the same drivers, (the code actually checks for the same drivers via Scsi_Host::hostt, not the same hardware) - so it would allow multiple paths if the same driver is used for different HBA's.
Quoted 11 lines
And the
Scsi_Devicemight be quite different. Imagine something like two storage boxes which do internal replication among them; yes, you'd only want to use one of them normal (because the Cache-coherency traffic is going to kill performance otherwise), but you can failover from one to the other even if they have different SCSI serials etc.And software RAID on top of multi-pathing is a typical example for a truely fault tolerant configuration.
Thats obviously easier with md, and I assume your SCSI code can also do that nicely.
I haven't tried it, but I see no reason why it would not work.
Quoted 4 lines
Quoted 1 line
Agreed, but having the block layer be everything is also wrong.
Having the block device handling all block devices seems fairly reasonable to me.
Note that scsi uses the block device layer (the request_queue_t) for character devices - look at st.c, sg.c, and sr*.c, calls to scsi_do_req() or scsi_wait_req() queue to the request_queue_t. Weird but it works - you can open a CD via sr and sg at the same time.
Quoted 11 lines
Quoted 5 lines
My view is that md/volume manager multi-pathing is useful with 2.4.x, scsi layer multi-path for 2.5.x, and this (perhaps with DASD) could then evolve into generic block level (or perhaps integrated with the device model) multi-pathing support for use in 2.7.x. Do you agree or disagree with this approach?
Well, I guess 2.5/2.6 will have all the different multi-path implementations mentioned so far (EVMS, LVM2, md, scsi, proprietary) - they all have code and a userbase... All of them and future implementations can benefit from better error handling and general cleanup, so that might be the best to do for now.
Quoted 7 lines
I think it is too soon to clean that up and consolidate the m-p approaches, but I think it really ought to be consolidated in 2.7, and this seems like a good time to start planning for that one.
Sincerely,
Lars Marowsky-Brée <[email protected]>
The scsi multi-path code is not in 2.5.x, and I doubt it will be accepted without the support of James and others.
-- Patrick Mansfield
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 2 lines · [email protected] said:
The scsi multi-path code is not in 2.5.x, and I doubt it will be accepted without the support of James and others.
I haven't said "no" yet (and Doug and Jens haven't said anything). I did say when the patches first surfaced that I didn't like the idea of replacing Scsi_Device with Scsi_Path at the bottom and the concomitant changes to all the Low Level Drivers which want to support multi-pathing. If this is to go in the SCSI subsystem it has to be self contained, transparent and easily isolated. That means the LLDs shouldn't have to be multipath aware.
I think we all agree:
1) that multi-path in SCSI isn't the way to go in the long term because other devices may have a use for the infrastructure.
2) that the scsi-error handler is the big problem
3) that errors (both medium and transport) may need to be propagated immediately up the block layer in order for multi-path to be handled efficiently.
Although I outlined my ideas for a rework of the error handler, they got lost in the noise of the abort vs reset debate. These are some of the salient features that will help in this case
- no retries from the tasklet.
- Quiesce from above, not below (commands return while eh processes, so we begin with the first error and don't have to wait for all commands to return or error out)
- It's the object of the error handler to return all commands to the block layer for requeue and reorder as quickly as possible. They have to be returned with an indication from the error handler that it would like them retried. This indication can be propagated up (although I haven't given thought how to do that). Any commands that are sent down to probe the device are generated from within the error handler thread (no device probing with live commands).
What other features do you need on the eh wishlist?
James
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 4 lines · James Bottomley
Quoted 2 lines · [email protected] said:
The scsi multi-path code is not in 2.5.x, and I doubt it will be accepted without the support of James and others.
I haven't said "no" yet (and Doug and Jens haven't said anything).
Except for dasds, all devices I care for with regard to multipathing _are_ SCSI, so that would solve at least 90% of my worries in the mid-term. And also do multipathing for !block devices, in theory.
It does have the advantage of knowing the topology better than the block layer; the chance that a path failure only affects one of the LUNs on a device is pretty much nil, so it would speed up error recovery.
However, I could also live with this being handled in the volume manager / device mapper. This would transcend all potential devices - if the character devices were really mapped through the block layer (didn't someone have this weird idea once? ;-), it would too work for !block devs.
Exposing a better error reporting upwards is also definetely a good idea, and if the device mapper could have the notion of "to what topology group does this device belong to", or even "distance metric (without going into further detail on what this is, as long as it is consistent to the physical layer) to the current CPU" (so that the shortest path in NUMA could be selected), that would be kinda cool ;-) And doesn't seem too intrusive.
Now, what I definetely dislike is the vaste amount of duplicated code. I'm not sure whether we can get rid of this in 2.5 timeframe though.
<rant>
If EVMS was cleaned up some, maybe used the neat LVM2 device mapper internally, and in fact is a superset of everything we've had before and can support everything from our past as well as give us what we really want (multi-pathing, journaled RAID etc), and we do the above, I vote for a legacy free kernel. Unify the damn block device management and throw out the old code.
I hate cruft. Customers want to and will use it. Someone has to support it. It breaks stuff. It cuts a 9 of my availability figure. ;-)
</rant>
Quoted 1 line
I think we all agree:
I agree here.
Quoted 3 lines
3) that errors (both medium and transport) may need to be propagated immediately up the block layer in order for multi-path to be handled efficiently.
Right. All the points you outline about the error handling are perfectly valid.
But one of the issues with the md layer right now for example is the fact that an error on a backup path will only be noticed as soon as it actually tries to use it, even if the cpqfc (to name the culprit, worst code I've seen in a while) notices a link-down event. It isn't communicated anywhere, and how should it be?
This may be for later, but is something to keep in mind.
Quoted 3 lines
thought how to do that). Any commands that are sent down to probe the device are generated from within the error handler thread (no device probing with live commands).
If the path was somehow exposed to user-space (as it is with md right now), the reprobing could even be done outside the kernel. This seems to make sense, because a potential extensive device-specific diagnostic doesn't have to be folded into it then.
Quoted 1 line
What other features do you need on the eh wishlist?
The other features on my list - prioritizing paths, a useful, consistent user interface via driverfs/devfs/procfs - are more or less policy I guess.
Sincerely,
Lars Marowsky-Brée <[email protected]>
Signature · 2 lines
Immortality is an adequate definition of high availability for me. --- Gregory F. Pfister
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 6 lines · [email protected] said:
and if the device mapper could have the notion of "to what topology
group does this device belong to", or even "distance metric (without going into further detail on what this is, as long as it is consistent to the physical layer) to the current CPU" (so that the shortest path in NUMA could be selected), that would be kinda cool ;-) And doesn't seem too intrusive.
I think I see driverfs as the solution here. Topology is deduced by examining certain device and HBA parameters. As long as these parameters can be exposed as nodes in the device directory for driverfs, a user level daemon map the topology and connect the paths at the top. It should even be possible to weight the constructed multi-paths.
This solution appeals because the kernel doesn't have to dictate policy, all it needs to be told is what information it should be exposing and lets user level get on with policy determination (this is a mini version of why we shouldn't have network routing policy deduced and implemented by the kernel).
Quoted 5 lines
But one of the issues with the md layer right now for example is the fact that an error on a backup path will only be noticed as soon as it actually tries to use it, even if the cpqfc (to name the culprit, worst code I've seen in a while) notices a link-down event. It isn't communicated anywhere, and how should it be?
I've been think about this separately. FC in particular needs some type of event notification API (something like "I've just seen this disk" or "my loop just went down"). I'd like to leverage a mid-layer api into hot plug for some of this, but I don't have the details worked out.
Quoted 4 lines
If the path was somehow exposed to user-space (as it is with md right now), the reprobing could even be done outside the kernel. This seems to make sense, because a potential extensive device-specific diagnostic doesn't have to be folded into it then.
The probing issue is an interesting one. At least SCSI has the ability to probe with no IO (something like a TEST UNIT READY) and I assume other block devices have something similar. Would it make sense to tie this to a single well known ioctl so that you can probe any device that supports it without having to send real I/O?
Quoted 2 lines
The other features on my list - prioritizing paths, a useful, consistent user interface via driverfs/devfs/procfs - are more or less policy I guess.
Mike Sullivan (of IBM) is working with Patrick Mochel on this.
James
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 5 lines · James Bottomley
I think I see driverfs as the solution here. Topology is deduced by examining certain device and HBA parameters. As long as these parameters can be exposed as nodes in the device directory for driverfs, a user level daemon map the topology and connect the paths at the top. It should even be possible to weight the constructed multi-paths.
Perfect, I agree, should've thought of it. As long as this is simple enough that it can be done in initrd (if / is on a multipath device...).
The required weighting has already been implemented in the LVM1 patch by IBM. While it appeared overkill to me for "simple" cases, I think it is suited to expressing proximity.
Quoted 1 line
This solution appeals because the kernel doesn't have to dictate policy,
Right.
Quoted 4 lines
I've been think about this separately. FC in particular needs some type of event notification API (something like "I've just seen this disk" or "my loop just went down"). I'd like to leverage a mid-layer api into hot plug for some of this, but I don't have the details worked out.
This isn't just FC, but also dasd on S/390. Potentially also network block devices, which can notice a link down.
Quoted 5 lines
The probing issue is an interesting one. At least SCSI has the ability to probe with no IO (something like a TEST UNIT READY) and I assume other block devices have something similar. Would it make sense to tie this to a single well known ioctl so that you can probe any device that supports it without having to send real I/O?
Not sufficient. The test is policy, so the above applies here too ;-)
In the case of talking to a dual headed RAID box for example, TEST UNIT READY might return OK, but the controller might refuse actual IO, or the path may be somehow damaged in a way which is only detected by doing some "large" IO. Now, this might be total overkill for other scenarios.
I vote for exposing the path via driverfs (which, I think, is already concensus so the multipath group, topology etc can be used) and allowing user-space to reenable them after doing whatever probing deemed necessary.
What are your ideas on the potential timeframe?
Sincerely,
Lars Marowsky-Brée <[email protected]>
Signature · 2 lines
Immortality is an adequate definition of high availability for me. --- Gregory F. Pfister
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 7 lines · In article <[email protected]> you wrote:
Quoted 4 lines
I've been think about this separately. FC in particular needs some type of event notification API (something like "I've just seen this disk" or "my loop just went down"). I'd like to leverage a mid-layer api into hot plug for some of this, but I don't have the details worked out.
This isn't just FC, but also dasd on S/390. Potentially also network block devices, which can notice a link down.
It is true for every device. Starting from a IDE Disk which can fail to a SCSI DEvice, to a network link, even hot Plug-PCI Cards and CPUs, RAM Modules and so on can use this API.
Recovering from an ahardware failure is a major weakness of non-host operating systems. Linux Filesystems used to panic much too often. It is getting better, but it is still a long way to allow multipath IO, especially in environemnts where it is more complicated than a faild FC loop. For example 2 FC adapters on 2 different PCI bus should be able to deactivate themself if IO with the adapter locks.
Quoted 3 lines
I vote for exposing the path via driverfs (which, I think, is already concensus so the multipath group, topology etc can be used) and allowing user-space to reenable them after doing whatever probing deemed necessary.
There are situations where a path is reenabled by the kernel, for example network interfaces. But it makes sence in a HA environemnt to move this to a user mode daemon, simply because the additional stability is worth the extra daemon. On the other hand, kernel might need to detect congestion/jam anyway, especially if load balancing is used.
Personally I like the simple md approach for IO Multipath, as long as not the whole kernel is able to operate sanely with changing hardware topology.
This is especially less intrusiver to all the drivers out there. And allows funny combinations like SAN with NAS Backups.
Greetings
Bernd
Re: [RFC] Multi-path IO in 2.5/2.6 ?
In reply to James BottomleyQuoted 14 lines · James Bottomley
Quoted 6 lines · [email protected] said:
and if the device mapper could have the notion of "to what topology
group does this device belong to", or even "distance metric (without going into further detail on what this is, as long as it is consistent to the physical layer) to the current CPU" (so that the shortest path in NUMA could be selected), that would be kinda cool ;-) And doesn't seem too intrusive.I think I see driverfs as the solution here. Topology is deduced by examining certain device and HBA parameters. As long as these parameters can be exposed as nodes in the device directory for driverfs, a user level daemon map the topology and connect the paths at the top. It should even be possible to weight the constructed multi-paths.
Quoted 4 lines
This solution appeals because the kernel doesn't have to dictate policy, all it needs to be told is what information it should be exposing and lets user level get on with policy determination (this is a mini version of why we shouldn't have network routing policy deduced and implemented by the kernel).
Not coincidentally, network routing policy _is_ multipath config in the iSCSI or nbd case.
Signature · 1 line
"Love the dolphins," she advised him. "Write by W.A.S.T.E.."
Re: [RFC] Multi-path IO in 2.5/2.6 ?
In reply to James BottomleyQuoted 5 lines · James Bottomley
Quoted 2 lines · [email protected] said:
The scsi multi-path code is not in 2.5.x, and I doubt it will be accepted without the support of James and others.
I haven't said "no" yet (and Doug and Jens haven't said anything).
Well, I for one was gone on vacation, and I'm allowed to ignore linux-scsi in such times, so, as Bill de Cat would say, thptptptppt! :-)
Quoted 6 lines
I did say
when the patches first surfaced that I didn't like the idea of replacingScsi_DevicewithScsi_Pathat the bottom and the concomitant changes to all the Low Level Drivers which want to support multi-pathing. If this is to go in the SCSI subsystem it has to be self contained, transparent and easily isolated. That means the LLDs shouldn't have to be multipath aware.
I agree with this.
Quoted 4 lines
I think we all agree:
1) that multi-path in SCSI isn't the way to go in the long term because other devices may have a use for the infrastructure.
I'm not so sure about this. I think in the long run this is going to end up blurring the line between SCSI layer and block layer IMHO.
Quoted 1 line
2) that the scsi-error handler is the big problem
Aye, it is, and for more than just this issue.
Quoted 3 lines
3) that errors (both medium and transport) may need to be propagated immediately up the block layer in order for multi-path to be handled efficiently.
This is why I'm not sure I agree with 1. If we are doing this, then we are sending up SCSI errors at which point the block layer now needs to know SCSI specifics in order to properly decide what to do with the error. That, or we are building specific "is this error multipath relevant" logic into the SCSI layer and then passing the result up to the block layer. I'm the kind of person that my preference would be that either A) the SCSI layer doesn't know jack about multipath and the block layer handles it all or B) the block layer doesn't know about our multipath and the SCSI layer handles it all. I don't like the idea of mixing them at this current point in time (there really isn't much of a reason to mix them yet, and people can only speculate that there might be reason to do so later).
Quoted 3 lines
Although I outlined my ideas for a rework of the error handler, they got lost in the noise of the abort vs reset debate. These are some of the salient features that will help in this case
[ snipped eh features ]
I'll have to respond to these items separately. They cross over some with these issues, but really they aren't tired directly together and deserve separate consideration.
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 11 lines · Doug Ledford [[email protected]] wrote:
Quoted 7 lines · James Bottomley
[email protected] said:
I did say
when the patches first surfaced that I didn't like the idea of replacingScsi_DevicewithScsi_Pathat the bottom and the concomitant changes to all the Low Level Drivers which want to support multi-pathing. If this is to go in the SCSI subsystem it has to be self contained, transparent and easily isolated. That means the LLDs shouldn't have to be multipath aware.I agree with this.
In the mid-level mp patch the adapters are not aware of multi-path. The changes to adapters carried in the patch have to do with a driver not allowing aborts during link down cases or iterating over the host_queue for ioctl, /proc reasons. The hiding of some of the lists behind APIs is something I had to do in the host list cleanup. We might even do some of this same list cleanup outside of mp.
Also add "my me to" on the scsi error handling is lacking statement. I am currently trying to do something about not using the failed command for error recovery (post abort).
-Mike
Signature · 2 lines
Michael Anderson [email protected]
Re: [RFC] Multi-path IO in 2.5/2.6 ?
In reply to Patrick MansfieldQuoted 9 lines
Quoted 5 lines
Quoted 3 lines
Generic device naming consistency is a problem if multiple devices show up with the same id.
Patrick Mochel has an open task to come up with a solution to this.
I don't think this can be solved if multiple devices show up with the same id. If I have five disks that all say I'm disk X, how can there be one name or handle for it from user level?
Easy: you map the unique identifier of the device to a name in userspace. In our utopian future, /sbin/hotplug is called with that unique ID as one of its parameters. It searches for, and finds names based on the ID is. If the name(s) already exist, then it doesn't continue.
-pat
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 10 lines · Patrick Mochel
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Generic device naming consistency is a problem if multiple devices show up with the same id.
Patrick Mochel has an open task to come up with a solution to this.
I don't think this can be solved if multiple devices show up with the same id. If I have five disks that all say I'm disk X, how can there be one name or handle for it from user level?
Quoted 7 lines
Easy: you map the unique identifier of the device to a name in userspace. In our utopian future,
/sbin/hotplugis called with that unique ID as one of its parameters. It searches for, and finds names based on the ID is. If the name(s) already exist, then it doesn't continue.-pat
But then if the md or volume manager wants to do multi-path IO it will not be able to find all of the names in userspace since the extra ones (second path and on) have been dropped.
-- Patrick Mansfield
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 17 lines · Patrick Mansfield
Quoted 16 lines · Patrick Mochel
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Generic device naming consistency is a problem if multiple devices show up with the same id.
Patrick Mochel has an open task to come up with a solution to this.
I don't think this can be solved if multiple devices show up with the same id. If I have five disks that all say I'm disk X, how can there be one name or handle for it from user level?
Easy: you map the unique identifier of the device to a name in userspace. In our utopian future,
/sbin/hotplugis called with that unique ID as one of its parameters. It searches for, and finds names based on the ID is. If the name(s) already exist, then it doesn't continue.
Quoted 5 lines
Quoted 1 line
-pat
But then if the md or volume manager wants to do multi-path IO it will not be able to find all of the names in userspace since the extra ones (second path and on) have been dropped.
Which is it that you want? One canonical name or all the paths? I supplied a solution for the former in my repsonse. The latter is solved via the exposure of the paths in driverfs, which has been discussed previously.
-pat
Re: [RFC] Multi-path IO in 2.5/2.6 ?
Quoted 16 lines · Patrick Mochel
Quoted 7 lines · Patrick Mansfield
Quoted 6 lines · Patrick Mochel
Easy: you map the unique identifier of the device to a name in userspace. In our utopian future,
/sbin/hotplugis called with that unique ID as one of its parameters. It searches for, and finds names based on the ID is. If the name(s) already exist, then it doesn't continue.Quoted 5 lines
Quoted 1 line
-pat
But then if the md or volume manager wants to do multi-path IO it will not be able to find all of the names in userspace since the extra ones (second path and on) have been dropped.
Quoted 6 lines
Which is it that you want? One canonical name or all the paths? I supplied a solution for the former in my repsonse. The latter is solved via the exposure of the paths in driverfs, which has been discussed previously.
-pat
For scsi multi-path, one name; without scsi multi-path (or for individual paths that are not exposed in driverfs) each path probably needs to show up in user space with a different name so md or other volume managers can use them.
-- Patrick Mansfield
Re: [RFC] Multi-path IO in 2.5/2.6 ?
In reply to James BottomleyQuoted 4 lines · On Monday September 9, [email protected] wrote:
Well, neither of the people most involved in the development (that's Neil Brown for md in general and Ingo Molnar for the multi-path enhancements) made any comments---see if you can elicit some feedback from either of them.
I'm fairly un-interested in multipath. I try not to break it while tidying up the generic md code, but apart from that I leave it alone.
For failover, I suspect that md is an appropriate place for multipath, though it would be nice to get more detail error information from the lower levels.
For load balancing you really need something lower down, just below the elevator would seem right: at the request_fn level rather than make_request_fn.
But all that has pretty much been said.
NeilBrown
SCSI woes (followup)
In my previous mail, I said I thought scsi_allocate_device() was the cause of the lockup while trying to attach devices to drivers. This doesn't seem to be the case.
Instead, we have something interesting going on:
1. We submit a test unit ready command for the disk device. This command is at the head, and we call scsi_request_fn()
2. the scsi_request_fn() realises that the device was reset, and performs a scsi_ioctl to lock the door.
3. the ioctl queues up another request on the tail of the request queue to lock the door, and calls scsi_request_fn()
4. scsi_request_fn() processes the test unit ready command at the head of the queue, and hands this off to the driver. The driver is now busy.
5. scsi_request_fn() returns, and waits for our door lock request to complete.
6. the test unit ready command completes. We pass completion notification through scsi_done, the bottom half handler, scsi_finish_command, the scsi command's done function (which is the scsi requests sr_done function.) At no point to we kick the queue to go and execute that door lock request.
So, we are left with one invocation of scsi_request_fn() spinning in the scsi ioctl code waiting for a command that can never ever complete.
I'm getting the impression that the door lock handling code is misplaced, and is probably the cause of these problems. I'm going to try disabling that code, and reverting my previous change to scsi_restart_operations().
Help!
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
Quoted 4 lines · [email protected] said:
I'm getting the impression that the door lock handling code is misplaced, and is probably the cause of these problems. I'm going to try disabling that code, and reverting my previous change to
scsi_restart_operations().
Unfortunately, if we want to ensure the medium is locked in place, the lock has to occur that low down (since error recovery can unlock the door and a retry doesn't currently trouble the upper layers).
I think it's method of operation is misplaced. What it should probably be doing is simply adding a doorlock to the head of the queue and then go back around. Since we know the doorlock now preceeds the command that instigated the issue the door should be locked before anything else happens. It should simply loop around and process the door lock request so it doesn't have to wait for anything else to occur (any commands which come down in the interim should go on the queue tail).
However, for your case does simply moving the queue empty check to the top cause the problems to go away? (That would be hiding the problem not fixing it, but still...)
James
===== scsi_lib.c 1.15 vs edited =====
scsi_lib.c renamed from drivers/scsi/scsi_lib.c +9 -7
@@ -868,6 +868,15 @@if (SDpnt->device_blocked) {break ; } + +/* +* If we couldn't find a request that could be queued, then we +* can also quit. +*/ + +if (list_empty (&q->queue_head)) +break ; +if ((SHpnt->can_queue >0 && (SHpnt->host_busy >= SHpnt->can_queue)) || (SHpnt->host_blocked) || (SHpnt->host_self_blocked)) {
@@ -914,13 +923,6 @@continue ; } } - -/* -* If we couldn't find a request that could be queued, then we -* can also quit. -*/ -if (list_empty (&q->queue_head)) -break ;/* * Loop through all of the requests in this queue, and find
Re: SCSI woes (followup)
Quoted 1 line · James Bottomley
I think it's method of operation is misplaced.
I think it is misplaced. It locks the doors of devices that aren't even in use, which is just plain stupid.
Quoted 3 lines
However, for your case does simply moving the queue empty check to the top cause the problems to go away? (That would be hiding the problem not fixing it, but still...)
I #if 0'd it out, and it makes the problem go away.
One thing to note is the comment that Eric left in the code about it - it seems to indicate that he believes it to be misplaced, but its there because we have host drivers using the old error handling code.
I'm wondering if this behaviour only happens with host drivers that use the new error handling. If so, one possibility would be to follow Eric's suggestion there, and lock the door in the error handler "as Eric intended" and leave that door locking behind for the old error handling.
Incidentally, I've found another weirdness in the code. We decide that we need to lock the door based on the "was_reset" flag, which we clear. However, st.c uses "was_reset" to decide whether to suspend operations (due to a bus reset). The two uses of this flag seem to conflict each other. How can we guarantee that st.c will see was_reset set if the request function clears it? st.c appears to use scsi_request_fn, so I guess there's a conflict of use there.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
Quoted 2 lines · [email protected] said:
I think it is misplaced. It locks the doors of devices that aren't even in use, which is just plain stupid.
A better fix is probably to implement a flag to say whether the door should be locked or not.
The whole lock door before a command goes down philosophy looks slightly wrong to me. I can see we want to lock the door for a mounted device and other conditions, but locking the door just to send down a test unit ready or inquiry doesn't seem correct.
Door locking is very similar to reservation maintenance. Perhaps adding kernel code to maintain certain persistent but fragile states of the device might be in order.
Quoted 7 lines
Incidentally, I've found another weirdness in the code. We decide that we need to lock the door based on the "
was_reset" flag, which we clear. However,st.cuses "was_reset" to decide whether to suspend operations (due to a bus reset). The two uses of this flag seem to conflict each other. How can we guarantee thatst.cwill seewas_resetset if the request function clears it?st.cappears to usescsi_request_fn, so I guess there's a conflict of use there.
The code is riddled with these. Reset handling was really just bolted on to the code as an afterthought.
James
Re: SCSI woes (followup)
Quoted 4 lines · James Bottomley
A better fix is probably to implement a flag to say whether the door should be locked or not.
This would really depend on the command to be executed. I.e. does the command need access to the media, or not.
Quoted 4 lines
The whole lock door before a command goes down philosophy looks slightly wrong to me. I can see we want to lock the door for a mounted device and other conditions, but locking the door just to send down a test unit ready or inquiry doesn't seem correct.
Well, SAM-3 is the place to check this out. For TUR (7.27) it would seem that one does indeed need to lock the door/media into place in order to be ``able to accept an appropriate medium-access command without returning CHECK CONDITION status''.
Quoted 3 lines
Door locking is very similar to reservation maintenance. Perhaps adding kernel code to maintain certain persistent but fragile states of the device might be in order.
This is the job of the task manager for the LU, and if not implemented by the LU, it should be implemented by the LLDD, which would complicate things considerably for the LLDD.
As to your suggestion, there may be generic code, which LLDD may want to use, but nevetheless, has to be no higher than the LLDD, and ideally in the LU itself.
The idea is that SCSI core should be quite minimal as I've been suggesting for some time now.
Signature · 1 line
Luben
Re: SCSI woes (followup)
In reply to Russell KingQuoted 11 lines · Russell King
Quoted 1 line · James Bottomley
I think it's method of operation is misplaced.
I think it is misplaced. It locks the doors of devices that aren't even in use, which is just plain stupid.
Quoted 3 lines
However, for your case does simply moving the queue empty check to the top cause the problems to go away? (That would be hiding the problem not fixing it, but still...)
I #if 0'd it out, and it makes the problem go away.
The scan will only send INQUIRY commands, and after all scanning is done, the upper level drivers might send a TUR.
After a new Scsi_Device is added in scsi_scan.c it calls scsi_release_commandblocks() and sets queue_depth = 0.
Any call to scsi_request_fn() for the device at this point will just return (break statements) after scsi_allocate_device() returns NULL, and if scsi_ioctl() was called from scsi_request_fn() it will hang forever.
The problem is that we try to send a command via scsi_request_fn() to a device that has no command blocks allocated - it's initializatin is incomplete.
Moving the empty check up sounds like good and simple fix for 2.4, or check if queue_depth == 0. Anything else would be difficult to get right.
Moving the the SCSI_IOCTL_DOORLOCK doesn't fix the problem if it is still called on a incompletely initialized device.
And, perhaps do not allow the error handler to run during scanning, let later IO (to any discovered device) kick off the error handler. It's hard to say if this is good or not - for example, if this is your root device, you want it online. But if it some other device, and we try hard to scan and use it, it can cause more problems (if it keeps getting errors, and we keeping running the error handler/reset cycle, blocking other IO).
The problem happens via:
1) device A is found that has removable media during scan
2) INQUIRY to another device B kicks off error handling before the scan has completed, so device A has no command blocks.
3) Error handler completion calls scsi_request_fn() for A.
4) scsi_request_fn() for A sees the reset happened, and calls scsi_ioctl().
5) scsi_ioctl() calls scsi_request_fn(), it cannot get a Scsi_Cmnd, so it just returns, incorrectly assuming that another request must be outstanding.
6) The scsi_ioctl() never completes. The error handling thread should be hung.
-- Patrick Mansfield
Re: SCSI woes (followup)
Quoted 2 lines · Patrick Mansfield
Moving the empty check up sounds like good and simple fix for 2.4, or check if
queue_depth== 0. Anything else would be difficult to get right.
I disagree here. Moving the empty check up means that we won't relock any in-use but idle check.
As I said to James earlier today, Eric Young's comments in the code say that it is in the wrong place. Thinking about it for a while, I'd agree with that statement for the reason above; any device that is in use by user space (ie, mounted on a filesystem) could well be idle for many hours before a request comes through for it.
This means that the door would be unlocked on an in-use device, and the media can be (accidentally) unloaded.
Quoted 2 lines
Moving the the
SCSI_IOCTL_DOORLOCKdoesn't fix the problem if it is still called on a incompletely initialized device.
There are _many_ problems here. Let me sort out a patch later tonight and put together the gory details of each problem. Its basically layer upon layer of crap and fixme's.
I have a set of fixes piling up, some trivial, that address many of these problems. Hell, I almost have a completely stable SCSI system here which I almost can't bring down. And I'm giving it all sorts of hellish conditions to deal with.
Quoted 6 lines
And, perhaps do not allow the error handler to run during scanning, let later IO (to any discovered device) kick off the error handler. It's hard to say if this is good or not - for example, if this is your root device, you want it online. But if it some other device, and we try hard to scan and use it, it can cause more problems (if it keeps getting errors, and we keeping running the error handler/reset cycle, blocking other IO).
No. You need the error handler to produce bus resets. Without bus resets, if your SCSI bus hangs (eg, in my case due to a permanent parity error to one device brought on by test code) you don't want to continue queueing IDENTIFY messages to other targets. They have no hope what so ever to get onto the bus.
You need the error handler to time out the connection to the bad device and perform a bus reset. A bus reset is the only way that an initiator can clear down a stuck bus.
Quoted 7 lines
The problem happens via:
1) device A is found that has removable media during scan
2) INQUIRY to another device B kicks off error handling before the scan has completed, so device A has no command blocks.
Quoted 7 lines
3) Error handler completion calls
scsi_request_fn()for A.4)
scsi_request_fn()for A sees the reset happened, and callsscsi_ioctl().5)
scsi_ioctl()callsscsi_request_fn(), it cannot get aScsi_Cmnd, so it just returns, incorrectly assuming that another request must be outstanding.
Not quite. Its even more disgusting. That code is fundamentally wrong, as proven by my later hangs when the devices have been initialised, and passed to the device drivers.
1) We queue up a command for device A _or_ step 3 above.
2) scsi_request_fn() gets called to start this device
3) scsi_request_fn() for A sees that a reset happened, and calls scsi_ioctl()
4) scsi_ioctl() calls scsi_request_fn().
5) the head of the request queue is _not_ the door lock, but the original request.
6) we kick off the original request and return from scsi_request_fn()
7) scsi_ioctl() waits for its door lock command to complete.
Ahem, well, it has _never_ been submitted to the host driver. The done paths for the original request don't kick the request function. We deadlock.
Trying to lock the door in scsi_request_fn() in the way we do is _fundamentally_ flawed. Even Eric Young's comments agree!
Now, as I said above, I do have a whole raft of fixes accumulating here, and if I can solve the last few problems, I'll get some patches out for you guys to look at.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
In reply to Patrick MansfieldQuoted 6 lines · Patrick Mansfield [[email protected]] wrote:
The problem is that we try to send a command via
scsi_request_fn()to a device that has no command blocks allocated - it's initializatin is incomplete.Moving the empty check up sounds like good and simple fix for 2.4, or check if
queue_depth== 0. Anything else would be difficult to get right.
Since error handling running during scan is kinda casuing the problem a a patch like the one below to scsi_restart_operations sould also work.
-andmike
--
Michael Anderson
[email protected]
drivers/scsi/scsi_error.c +4 -2
@@ -1264,8 +1264,10 @@ || (SDpnt->device_blocked)) {break ; } - q = &SDpnt->request_queue; - q->request_fn (q); +if (SDpnt->has_cmdblocks) { + q = &SDpnt->request_queue; + q->request_fn (q); + } }spin_unlock_irqrestore (&io_request_lock, flags); }
Re: SCSI woes (followup)
Quoted 10 lines · Mike Anderson
Quoted 6 lines · Patrick Mansfield [[email protected]] wrote:
The problem is that we try to send a command via
scsi_request_fn()to a device that has no command blocks allocated - it's initializatin is incomplete.Moving the empty check up sounds like good and simple fix for 2.4, or check if
queue_depth== 0. Anything else would be difficult to get right.Since error handling running during scan is kinda casuing the problem a a patch like the one below to
scsi_restart_operationssould also work.
No. There are still deadlock cases. This is the _wrong_ fix.
Been there. Tried it. It failed.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
In reply to Patrick MansfieldQuoted 6 lines · Russell King
Quoted 2 lines · Patrick Mansfield
Moving the empty check up sounds like good and simple fix for 2.4, or check if
queue_depth== 0. Anything else would be difficult to get right.I disagree here. Moving the empty check up means that we won't relock any in-use but idle check.
But, if we check for queue_depth == 0, it will still relock in-use but idle devices. No, it won't relock immediately if the error handler does not run, but this does not involve finding another place to send the ioctl.
Quoted 9 lines
As I said to James earlier today, Eric Young's comments in the code say that it is in the wrong place. Thinking about it for a while, I'd agree with that statement for the reason above; any device that is in use by user space (ie, mounted on a filesystem) could well be idle for many hours before a request comes through for it.
This means that the door would be unlocked on an in-use device, and the media can be (accidentally) unloaded.
Quoted 6 lines
Quoted 2 lines
Moving the the
SCSI_IOCTL_DOORLOCKdoesn't fix the problem if it is still called on a incompletely initialized device.There are _many_ problems here. Let me sort out a patch later tonight and put together the gory details of each problem. Its basically layer upon layer of crap and fixme's.
Yeh :(
I totally agree the re-locking _should_ be moved, and should be conditional (if it was locked, lock it again, but don't lock an unlocked device, like your tape door example).
Quoted 4 lines
I have a set of fixes piling up, some trivial, that address many of these problems. Hell, I almost have a completely stable SCSI system here which I almost can't bring down. And I'm giving it all sorts of hellish conditions to deal with.
Maybe you can try 2.5 first? Not that it makes thing easier for you, but it is probably very easy to break something, and we should break 2.5 rather than 2.4. Mike's cleaned up scsi_error.c would probably help a lot, it should be pushed into 2.5.
Backporting to 2.4 would be ummm fun :(
Quoted 13 lines
Quoted 6 lines
And, perhaps do not allow the error handler to run during scanning, let later IO (to any discovered device) kick off the error handler. It's hard to say if this is good or not - for example, if this is your root device, you want it online. But if it some other device, and we try hard to scan and use it, it can cause more problems (if it keeps getting errors, and we keeping running the error handler/reset cycle, blocking other IO).
No. You need the error handler to produce bus resets. Without bus resets, if your SCSI bus hangs (eg, in my case due to a permanent parity error to one device brought on by test code) you don't want to continue queueing IDENTIFY messages to other targets. They have no hope what so ever to get onto the bus.
Quoted 3 lines
You need the error handler to time out the connection to the bad device and perform a bus reset. A bus reset is the only way that an initiator can clear down a stuck bus.
OK - but you also do not want eternal bus resets because of a marginal device. Maybe the error handler can kick off, but if it is a scan INQUIRY, do not retry the command, do the resets etc and complete the command as a failure. The device being scanned is likely causing the problem (since no one else should be using the adapter at this point, unless this is a "hardcoded" scan via /proc), this would prevent a new Scsi_Device from being created, but would allow scanning to continue.
Quoted 19 lines
Quoted 7 lines
The problem happens via:
1) device A is found that has removable media during scan
2) INQUIRY to another device B kicks off error handling before the scan has completed, so device A has no command blocks.
Quoted 7 lines
3) Error handler completion calls
scsi_request_fn()for A.4)
scsi_request_fn()for A sees the reset happened, and callsscsi_ioctl().5)
scsi_ioctl()callsscsi_request_fn(), it cannot get aScsi_Cmnd, so it just returns, incorrectly assuming that another request must be outstanding.Not quite. Its even more disgusting. That code is fundamentally wrong, as proven by my later hangs when the devices have been initialised, and passed to the device drivers.
Quoted 8 lines
1) We queue up a command for device A _or_ step 3 above.
2)
scsi_request_fn()gets called to start this device3)
scsi_request_fn()for A sees that a reset happened, and callsscsi_ioctl()4)
scsi_ioctl()callsscsi_request_fn().
Agree with all the above.
Quoted 2 lines
5) the head of the request queue is _not_ the door lock, but the original request.
I still don't see how this can be the original request. The TUR is sent via the error handler, the INQUIRY resent during error handling does not call scsi_request_fn().
So, where is the request requeued?
Is this is in modified error handler code or something?
Quoted 1 line
6) we kick off the original request and return from
scsi_request_fn()
And, I don't see how this can happen since I don't see how step 5 happens.
Quoted 15 lines
7)
scsi_ioctl()waits for its door lock command to complete.Ahem, well, it has _never_ been submitted to the host driver. The done paths for the original request don't kick the request function. We deadlock.
Trying to lock the door in
scsi_request_fn()in the way we do is _fundamentally_ flawed. Even Eric Young's comments agree!Now, as I said above, I do have a whole raft of fixes accumulating here, and if I can solve the last few problems, I'll get some patches out for you guys to look at.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
Quoted 2 lines · Patrick Mansfield
OK - but you also do not want eternal bus resets because of a marginal device.
I agree. I'm actually running against the "rmk" error handler, which has a fair number of the problems with the existing error handler fixed. For instance, it won't leave the HBA driver with a currently executing command and a stuck bus after attempting a retry.
It also knows about channels, and knows that if it a command fails on a bus that has needed a reset, then the right thing to do is to reset it _once_ again and only once, because the bus is probably stuck.
Oh, yes, I've put a lot of thought into this. 8)
Quoted 15 lines
Quoted 4 lines
Not quite. Its even more disgusting. That code is fundamentally wrong, as proven by my later hangs when the devices have been initialised, and passed to the device drivers.
Quoted 8 lines
1) We queue up a command for device A _or_ step 3 above.
2)
scsi_request_fn()gets called to start this device3)
scsi_request_fn()for A sees that a reset happened, and callsscsi_ioctl()4)
scsi_ioctl()callsscsi_request_fn().Agree with all the above.
Quoted 8 lines
Quoted 2 lines
5) the head of the request queue is _not_ the door lock, but the original request.
I still don't see how this can be the original request. The TUR is sent via the error handler, the INQUIRY resent during error handling does not call
scsi_request_fn().So, where is the request requeued?
A request received via ioctl is queued at the tail of the request queue, not the head. I can give you a reference if you'd like. 8)
Quoted 1 line
Is this is in modified error handler code or something?
Yes, and it is definitely more correct than the previous. It certainly isn't the cause of the problems. I can say this because I'm now back in my driver trying to debug a problem there, and the rest of the SCSI subsystem is admirably coping with the crap I'm throwing at it.
My error handler doesn't go around chunking stuff into request queues btw. Neither does the existing one.
Basically, all its doing is knowing about channels properly, and knowing that it needs to do a bus reset if its going to take a device off line.
If you can stand the suspense a while longer, I'll generate the patches, and then you can read all the gory details yourself. Until that time, I think its rather academic trying to discuss stuff that I've had more than 12 hours to hammer away at and successfully solve.
Give me two hours, and I'll have patches.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
Quoted 10 lines · Russell King
I agree. I'm actually running against the "rmk" error handler, which has a fair number of the problems with the existing error handler fixed. For instance, it won't leave the HBA driver with a currently executing command and a stuck bus after attempting a retry.
It also knows about channels, and knows that if it a command fails on a bus that has needed a reset, then the right thing to do is to reset it _once_ again and only once, because the bus is probably stuck.
Oh, yes, I've put a lot of thought into this. 8)
Have you seen Mike Anderon's 2.5 cleanup patch?
Patch:
http://www-124.ibm.com/storageio/gen-io/patch-scsi_error-2.5.34-1.gz
Posting:
http://marc.theaimsgroup.com/?l=linux-scsi&m=103187417110244&w=2
I've been focusing on 2.5.x scsi (i.e. scsi multi-path), and would prefer work be done there first.
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines
5) the head of the request queue is _not_ the door lock, but the original request.
I still don't see how this can be the original request. The TUR is sent via the error handler, the INQUIRY resent during error handling does not call
scsi_request_fn().So, where is the request requeued?
A request received via ioctl is queued at the tail of the request queue, not the head. I can give you a reference if you'd like. 8)
Yes, I understand that, but where is the original, non-door lock request coming from?
My point is that I think there is none, and there can't be any on a partially initialized device, since there are no command blocks for the device - put a printk in the scsi_ioctl or such to dump Scsi_Device::queue_depth and/or Scsi_Device::has_cmdblocks.
-- Patrick Mansfield
Re: SCSI woes (followup)
Quoted 4 lines · Patrick Mansfield
Have you seen Mike Anderon's 2.5 cleanup patch?
Patch:
Quoted 8 lines
http://www-124.ibm.com/storageio/gen-io/patch-scsi_error-2.5.34-1.gz
Posting:
http://marc.theaimsgroup.com/?l=linux-scsi&m=103187417110244&w=2
I've been focusing on 2.5.x scsi (i.e. scsi multi-path), and would prefer work be done there first.
I'd rather not. 2.5.x is a little unstable for this box. It holds the master ARM kernel trees for 2.2, 2.4 and 2.5, and given the recent "issues" with 2.5 IDE, I'd rather not have to reinstall the box from scratch.
I will look at the patch though.
Quoted 5 lines
Quoted 2 lines
A request received via ioctl is queued at the tail of the request queue, not the head. I can give you a reference if you'd like. 8)
Yes, I understand that, but where is the original, non-door lock request coming from?
You must have missed something I mentioned in a previous mail. Let me restate with hard evidence.
There are two, almost identical conditions where this goes pear shaped.
1. when restarting operations after error handling.
2. when trying to attach devices to drivers.
In the second case you end up with the precise case; you have a command that is queued on the request list, and we try to lock the door.
Case 1: yes, there is no pending request. However, we do drop the request on the floor because there are no Scsi_Cmnd structures available. Here are the debugging messages:
!! scsi: device set offline - not ready or command retry failed after bus reset: host 0 channel 0 id 3 lun 0 !! unjam_host: returning success
!! host_busy = 1 host_blocked = 0
!! Adding timer for command c4489c00 at 100 (c00e1050)
!! Clearing timer for command c4489c00 1
!! host_busy = 1 host_blocked = 0
!! scsi_error.c: Waking up host to restart
!! scsi_error.c: device offline - report as SUCCESS
!! Command finished 1 0 0x6
!! Notifying upper driver of completion for device 3 6
!! restarting target 1
!! Request for device 1: queue empty
!! device 1 re-locking door
!! Open returning 1
!! Trying ioctl with scsi command 30
!! scsi_do_req (host = 0, channel = 0 target = 1, buffer =00000000, bufflen = 0, done = c00db780, timeout = 1000, retries = 5) !! command : 1e 00 00 00 01 00
!! Request for device 1: req c0471ab4 cmd 4 special 1 completion c45d1e98 command=Prevent/Allow Medium Removal 00 00 00 01 00 !!
!! Leaving scsi_do_req()
Here, we have dropped the command on the floor because there weren't any Scsi_Cmnd structures available. We are still waiting for it though, and we are using the error handlers context, and thus blocking the error handler.
!! Deactivating command for device 3 (active=0, failed=0)
!! Request for device 3: queue empty
!! device 3 re-locking door
!! device 3 no request
!! scsi: INQUIRY failed with code 0x6
!! scsi: performing INQUIRY
!! scsi_do_req (host = 0, channel = 0 target = 4, buffer =c459fd44, bufflen = 256, done = c00db780, timeout = 600, retries = 3) !! command : 12 00 00 00 ff 00
!! Request for device 4: req c0471db4 cmd 4 special 1 completion c459fc3c command=Inquiry 00 00 00 ff 00 !!
!! Activating command for device 4 (1)
!! Leaving scsi_init_cmd_from_req()
!! Adding timer for command c4489e00 at 600 (c00e0de8)
!! scsi_dispatch_cmnd (host = 0, channel = 0, target = 4, command = c4489e58, buffer = c459fd44,
!! bufflen = 256, done = c00db780)
!! queuecommand : routine at cc81d784
!! scsi0.H: received command for id 4 (c4489e00) Inquiry 00 00 00 ff 00
!! scsi0.4: starting Inquiry 00 00 00 ff 00
!! scsi0.4: select: data pointers [c459fd44, 100]
!! scsi0.H: queue success
!! leaving scsi_dispatch_cmnd()
!! host blocked: host_busy=1 host_blocked=0 host_self_blocked=0
!! Leaving scsi_do_req()
!! Command timed out active=1 busy=1 failed=1
<< deadlock >>
Note the nice race condition here. Above, you'll notice that the command timed out, and requires error handler work. Oh, but the error handler is blocked waiting for a command to complete that never will. Below, the command disconnected with DID_NO_CONNECT status.
For some reason, this host controller chip seems to be slow to report this.
!! scsi0.4: disconnect phase=01
!! scsi0.4: command complete result=0x00010000 CDB: Inquiry 00 00 00 ff 00 !! Clearing timer for command c4489e00 0
Case 2: I'll let you read through this.
!! Host status for host c0c7e000:
!! Device 1 c0c2d400:
!! Device 2 c0c2d800:
!! sg_init
!! sg_attach: dev=0
!! sg_attach: dev=1
!! Attached scsi removable disk sda at scsi0, channel 0, id 2, lun 0
!! scsi_do_req (host = 0, channel = 0 target = 2, buffer =c0bea000, bufflen = 0, done = c00db780, timeout = 3000, retries = 5) !! command : 00 00 00 00 00 00
!! Request for device 2: req cc3fe0d4 cmd 4 special 1 completion c0d47d74 command=Test Unit Ready 00 00 00 00 00
!! device 2 re-locking door
!! Open returning 1
!! Trying ioctl with scsi command 30
!! scsi_do_req (host = 0, channel = 0 target = 2, buffer =00000000, bufflen = 0, done = c00db780, timeout = 1000, retries = 5) !! command : 1e 00 00 00 01 00
!! Request for device 2: req cc3fe0d4 cmd 4 special 1 completion c0d47d74 command=Test Unit Ready 00 00 00 00 00
!! Activating command for device 2 (1)
!! Leaving scsi_init_cmd_from_req()
!! Adding timer for command c0c0e200 at 3000 (c00e0de8)
!! scsi_dispatch_cmnd (host = 0, channel = 0, target = 2, command = c0c0e258, buffer = c0bea000,
!! bufflen = 0, done = c00db780)
!! queuecommand : routine at cc81d784
!! scsi0.H: received command for id 2 (c0c0e200) Test Unit Ready 00 00 00 00 00
!! scsi0.2: starting Test Unit Ready 00 00 00 00 00
!! scsi0.2: select: data pointers [00000000, 0]
!! scsi0.H: queue success
!! leaving scsi_dispatch_cmnd()
!! scsi0.2: disconnect phase=0d
!! scsi0.2: command complete result=0x00000002 CDB: Test Unit Ready 00 00 00 00 00
!! scsi0.2: starting Request Sense 00 00 00 40 00
!! scsi0.2: select: data pointers [c0c0e30c, 40]
!! host blocked: host_busy=1 host_blocked=0 host_self_blocked=0
!! Leaving scsi_do_req()
!! scsi0.2: disconnect phase=0d
!! scsi0.H: request sense complete, result=0x00000000
!! scsi0.2: sense buffer: 70 00 06 00 00 00 00 0e 00 00 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 !! Clearing timer for command c0c0e200 1
!! Command needs retry 1 0 0x2
!! Adding timer for command c0c0e200 at 3000 (c00e0de8)
!! scsi_dispatch_cmnd (host = 0, channel = 0, target = 2, command = c0c0e258, buffer = c0bea000,
!! bufflen = 0, done = c00db780)
!! queuecommand : routine at cc81d784
!! scsi0.H: received command for id 2 (c0c0e200) Test Unit Ready 00 00 00 00 00
!! scsi0.2: starting Test Unit Ready 00 00 00 00 00
!! scsi0.2: select: data pointers [00000000, 0]
!! scsi0.H: queue success
!! leaving scsi_dispatch_cmnd()
!! scsi0.2: disconnect phase=0d
!! scsi0.2: command complete result=0x00000002 CDB: Test Unit Ready 00 00 00 00 00
!! scsi0.2: starting Request Sense 00 00 00 40 00
!! scsi0.2: select: data pointers [c0c0e30c, 40]
!! scsi0.2: disconnect phase=0d
!! scsi0.H: request sense complete, result=0x00000000
!! scsi0.2: sense buffer: 70 00 02 00 00 00 00 0e 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 !! Clearing timer for command c0c0e200 1
!! Command finished 1 0 0x2
!! Notifying upper driver of completion for device 2 8000002
<< deadlock >>
Both of the above are nicely reproducable, and are from my logs from earlier today, where I've plenty of such examples.
So, lets review.
1. We deadlock the error handler when we issue a door lock request while trying to restart operations and there is are no requests pending, nor command structures available.
2. We deadlock if we issue a door lock request with a pending request.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
In reply to Patrick MansfieldOk, as promised here's the first patch.
This completely solves the door locking issues for host drivers that use the new error handling code, and preserves the old behaviour for drivers that use the old error handler. If I decide to resurect my old WD33C93 card, I'll look at the old error handler issues.
The patch is arranged so that you can read the notes in order, and the patch in order, and the two tie up. Please take the time to read the whole thing.
I don't recommend incorporating this into mainline currently; there are a few minor build issues with it that I'd like to get cleaned up first (for example, a missing function prototype.) At this point, I think it is more important to get this looked over, and to provide a basis for ideas.
Please note that this patch is against vanilla 2.4.19.
The ideas and method behind this came out of discussion with James Bottomley. James should therefore take some credit for this.
1. We introduce a new per-device flag - "locked". When this flag is set, it means that user space wanted the door locked, and we have successfully locked it. When clear, it means something user space wanted the door unlocked, and we have successfully unlocked it.
2. Introduce "scsi_set_medium_removal". This handles all door locking and unlocking requests that essentially originate from user space. ie, when a device is opened or closed, or an ioctl is received. This function takes care of issuing the ALLOW_MEDIUM_REMOVAL command via the ioctl layers.
This function ins't really anything new; its existing code moved into a function. It also removes code duplication.
The new bit is what it does after the command has completed. If the command was successful, we update the device "locked" flag to indicate the new state.
3. Rather than indirecting via scsi_ioctl() from the various drivers, we now call scsi_set_medium_removal directly.
So far so good; the above changes are all about tracking the current door lock state. Now for its use. We use it in two places. Ideally, this should become one place in the long run.
4. The "new" error handling code. Just before we attempt to restart operations on a host in scsi_restart_operations(), we loop through all devices on the host. At this point, we don't have much idea which devices received a reset.
Any device that is online (something the old code never checked for) and was locked, we try to re-lock the door. Note how we handle this. We create a request structure, and fill in all the relevant values, and insert this request at the _head_ of the queue.
The requests done function merely frees the command. If the command fails, we can't really do much to recover from it. We could retry, but the generic SCSI command handling will have done that for us already.
5. The "old" code. Yes, suggestion: read the comment. Since we have the "new" error handling code in place, we must not to lock the door while processing requests. If we do, we'll certainly deadlock.
However, we do take note of the currently requested lock state, and only ask for the door to be locked if it was previously locked.
Now, as I say, this is only _half_ of my fixes. This fixes the SCSI door locking problem. It doesn't fix the complete bus hangs when the new error handing kicks in, fails, and takes devices off line. We'll deal with that can of worms when we've got this one out of the way.
drivers/scsi/scsi.h +1 -0
@@ -597,6 +597,7 @@ unsigned changed:1; /* Data invalid due to media change */ unsigned busy:1; /* Used to prevent races */ unsigned lockable:1; /* Able to prevent media removal */ + unsigned locked:1; /* Media removal disabled */ unsigned borken:1; /* Tell the Seagate driver to be* painfully slow on this device */ unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */
drivers/scsi/scsi_ioctl.c +25 -17
55 lines not on this page · raw message
drivers/scsi/sd.c +2 -2
@@ -524,7 +524,7 @@if (SDev->removable)if (SDev->access_count==1 )if (scsi_block_when_processing_errors (SDev)) -scsi_ioctl (SDev,SCSI_IOCTL_DOORLOCK ,NULL ); +scsi_set_medium_removal (SDev,SCSI_REMOVAL_PREVENT );return 0 ;
@@ -553,7 +553,7 @@if (SDev->removable) {if (!SDev->access_count)if (scsi_block_when_processing_errors (SDev)) -scsi_ioctl (SDev,SCSI_IOCTL_DOORUNLOCK ,NULL ); +scsi_set_medium_removal (SDev,SCSI_REMOVAL_ALLOW ); }if (SDev->host->hostt->module)__MOD_DEC_USE_COUNT (SDev->host->hostt->module);
drivers/scsi/sr_ioctl.c +2 -3
@@ -216,9 +216,8 @@int sr_lock_door (struct cdrom_device_info *cdi,int lock) { -return scsi_ioctl (scsi_CDs[MINOR (cdi->dev)].device, - lock ?SCSI_IOCTL_DOORLOCK :SCSI_IOCTL_DOORUNLOCK , -0 ); +return scsi_set_medium_removal (scsi_CDs[MINOR (cdi->dev)].device, + lock ?SCSI_REMOVAL_PREVENT :SCSI_REMOVAL_ALLOW ); }int sr_drive_status (struct cdrom_device_info *cdi,int slot)
drivers/scsi/scsi_error.c +51 -0
69 lines not on this page · raw message
drivers/scsi/scsi_lib.c +11 -2
@@ -901,8 +926,17 @@* space. Technically the error handling thread should be * doing this crap, but the error handler isn't used by * most hosts. +* +* (rmk) +* Trying to lock the door can cause deadlocks. We therefore +* only use this for old hosts; our door locking is now done +* by the error handler in scsi_restart_operations for new +* eh hosts. +* +* Note that we don't clear was_reset here; this is used by +* st.c, and either one or other has to die. */ -if (SDpnt->was_reset) { +if (SHpnt->hostt->use_new_eh_code ==0 && SDpnt->was_reset) {/* * We need to relock the door, but we might * be in an interrupt handler. Only do this
@@ -913,7 +947,7 @@* this work. */ SDpnt->was_reset =0 ; -if (SDpnt->removable && !in_interrupt ()) { +if (SDpnt->removable && SDpnt->locked && !in_interrupt ()) {spin_unlock_irq (&io_request_lock);scsi_ioctl (SDpnt,SCSI_IOCTL_DOORLOCK ,0 );spin_lock_irq (&io_request_lock);
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
Quoted 4 lines · [email protected] said:
Now, as I say, this is only _half_ of my fixes. This fixes the SCSI door locking problem. It doesn't fix the complete bus hangs when the new error handing kicks in, fails, and takes devices off line. We'll deal with that can of worms when we've got this one out of the way.
This looks fine to me, except the bit where you free the command and request from inside the done function. I can't find anywhere we might touch the request again after this, so I suppose it's safe for now.
send it off to Marcelo and I'll try to up-port to 2.5
James
Re: SCSI woes (followup)
Quoted 1 line · James Bottomley [[email protected]] wrote:
send it off to Marcelo and I'll try to up-port to 2.5
If you want me to I can add it to a patch bundle I already have that includes ports of Russell's previous changes that apply on top of my 2.5 scsi_error cleanup patch.
-andmike
--
Michael Anderson
[email protected]
Re: SCSI woes (followup)
Quoted 6 lines · Mike Anderson
Quoted 1 line · James Bottomley [[email protected]] wrote:
send it off to Marcelo and I'll try to up-port to 2.5
If you want me to I can add it to a patch bundle I already have that includes ports of Russell's previous changes that apply on top of my 2.5
scsi_errorcleanup patch.
Thanks Mike; I should really be looking at 2.5 kernel stuff for the ARM CPU at the moment (like getting a new release out.)
There is a trivial but required fix that I should backport from 2.5 to 2.4; that's the one that limits the number of command retries in scsi_error.c. I'm not sure if Doug Ledford picked that one up though. Doug?
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
Quoted 4 lines · Russell King [[email protected]] wrote:
There is a trivial but required fix that I should backport from 2.5 to 2.4; that's the one that limits the number of command retries in
scsi_error.c. I'm not sure if Doug Ledford picked that one up though. Doug?
After I forward ported your restore code prior to retry I noticed that the retry code did look correct.
The 2.5 code copies the scsi_decide_disposition maybe_retry code block into scsi_eh_completed_normally. While this function is similar to decide_disposition it is called by scsi_send_eh_cmnd which is used both for error_recovery cmds (TURs, etc) and retrying the command. The down side here is that you get inconsistent and unexpected behavior in your error_recovery commands depending on the retry allowed value of the failed cmd and you also alter the retry count for the failed command. The failed commands are also retried even if the user has said not to (not a very nice thing to do a sequential device).
I moved this check up higher. I also altered the retry code to not exceed retries allowed.
I will try to post my update tomorrow, but it will not mean much to 2.4 as it is on top of the 2.5 cleanup which is very different from 2.4.
-andmike
--
Michael Anderson
[email protected]
Re: SCSI woes (followup)
Quoted 2 lines · Mike Anderson
I will try to post my update tomorrow, but it will not mean much to 2.4 as it is on top of the 2.5 cleanup which is very different from 2.4.
Nevertheless, bounding those retries in 2.4 is a must for stability. Loops that could become infinite one day almost certainly will at some point. I think the SCSI subsystem has proven this point in the past. 8/
I've also spotted a few other places that could do with my "restore Scsi_Cmnd to pristine state after error handling commands have completed" cleanup in scsi_error.c to ensure that we restore everything necessary.
I'm putting that at low priority at the moment though.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
In reply to Russell KingQuoted 4 lines · Russell King
There is a trivial but required fix that I should backport from 2.5 to 2.4; that's the one that limits the number of command retries in
scsi_error.c. I'm not sure if Doug Ledford picked that one up though. Doug?
I haven't even caught up entirely yet from being gone so much the last two weeks, so I seriously doubt it (and I don't remember it).
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
Re: SCSI woes (followup)
In reply to Mike AndersonQuoted 6 lines · Mike Anderson
Quoted 1 line · James Bottomley [[email protected]] wrote:
send it off to Marcelo and I'll try to up-port to 2.5
If you want me to I can add it to a patch bundle I already have that includes ports of Russell's previous changes that apply on top of my 2.5
scsi_errorcleanup patch.
It'll probably be better to wait for me to say "ok, I'm happy, and sending the stuff" before doing that.
I've just re-diffed and cleaned up all my scsi patches to date, and split them up into logical blocks:
01-scsi-cmd-retry-1.diff
01-scsi-cmd-retry-2.diff
01-scsi-cmd-retry-3.diff
02-scsi-cmd-report.diff
03-scsi-restart-ops.diff
04-scsi-door-lock-1.diff
04-scsi-door-lock-2.diff
I've updated the command retry patches to catch a couple of re-setup places I'd missed in scsi_error.c.
I've also incorporated Patricks concern about breaking out of the restart loop when we hit a device with the "device_blocked" flag set. In this case, I think we should still call the request function; the request function performs its own "device blocked" check, so putting such a check here would just be a needless duplicate.
I'll put the patches up on ftp.linux.org.uk later today.
I'll also be asking Alan Cox at some point in the future if he'd mind dropping them into his tree for further testing, before sending them to Marcelo.
(Oh, and in case anyone hasn't realised yet, I'm not on linux-scsi.)
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
In reply to Russell KingRussell King [[email protected]] wrote:
looks good.
One nit is that scsi_report_bus_reset sets was_reset which is only called by two drivers I currently see. The new code does not catch this case, but the trade of is probably worth it.
-andmike
--
Michael Anderson
[email protected]
Re: SCSI woes (followup)
Quoted 7 lines · Mike Anderson
Russell King [[email protected]] wrote:
looks good.
One nit is that
scsi_report_bus_resetsetswas_resetwhich is only called by two drivers I currently see. The new code does not catch this case, but the trade of is probably worth it.
I opted for the safe method here for two reasons (why am I making lists of stuff all the time 8)):
a) There seems to exist a hole with the device reset handling, where we want to reset one device. We make no attempt to mark this device has having been reset.
The other (bus and host) reset functions in scsi_error.c set was_reset and the unit attention flag.
b) st.c certainly uses was_reset for its own purposes. We could introduce a new flag "needs_locking" or something like that, but to be honest I didn't see the point. If we entered the error handler, commands have gone horribly wrong, and the host is quiet, so we aren't going to eat bus bandwidth sending these commands.
(a) I'm going to think about tomorrow; IMHO it should be plugged anyway, but I want to make sure we get the right approach there, and end up with something sane. I also want to review your work; I'm sure there's ideas that will be mutually beneficial to each other in both of our the error handler efforts.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
In reply to Russell KingQuoted 1 line · Russell King
Ok, as promised here's the first patch.
Looks nice. I have the same comment as before about no commands.
Quoted 3 lines
The new bit is what it does after the command has completed. If the command was successful, we update the device "locked" flag to indicate the new state.
(The sd.c and sr code are a bit odd since lock failures are ignored; sr won't unlock later in such cases, but sd unlocks even if the lock failed on sd_open.)
drivers/scsi/scsi_error.c line 1233
Quoted 10 lines
drivers/scsi/scsi_error.c +10
-0+static void scsi_eh_lock_done (struct scsi_cmnd *SCpnt) +{ +struct scsi_request *SRpnt = SCpnt->sc_request; + + SCpnt->sc_request =NULL ; + SRpnt->sr_command =NULL ; + +scsi_release_command (SCpnt); +scsi_release_request (SRpnt); +}
This is back to my orginal point (i.e. case 1 in your other response about "restarting operations after error handling", I haven't figured out case 2 yet) - the above will not be called if there are no commands.
Can you add some debug printks or what not above and below so we know for certain the result?
It would be nice if we could call scsi_set_medium_removal(SCSI_REMOVAL_PREVENT) and use a single code path for all door lock requests, then we need a special force-to-queue-head argument passed on down the chain. (We should really have some common setup-a-scsi-command functions to remove all the duplicate cmd[] setup code.)
Quoted 34 lines
drivers/scsi/scsi_error.c +27
-0+STATIC void scsi_eh_lock_door(struct scsi_device *dev) +{ +struct scsi_request *SRpnt =scsi_allocate_request (dev); + +if (SRpnt ==NULL ) { +/* what now? */ +return ; + } + + SRpnt->sr_cmnd[0 ] =ALLOW_MEDIUM_REMOVAL ; + SRpnt->sr_cmnd[1 ] = (dev->scsi_level <=SCSI_2 ) ? (dev->lun <<5 ) :0 ; + SRpnt->sr_cmnd[2 ] =0 ; + SRpnt->sr_cmnd[3 ] =0 ; + SRpnt->sr_cmnd[4 ] =SCSI_REMOVAL_PREVENT ; + SRpnt->sr_cmnd[5 ] =0 ; + SRpnt->sr_data_direction =SCSI_DATA_NONE ; + SRpnt->sr_bufflen =0 ; + SRpnt->sr_buffer =NULL ; + SRpnt->sr_allowed =5 ; + SRpnt->sr_done = scsi_eh_lock_done; + SRpnt->sr_timeout_per_command =10 *HZ ; + SRpnt->sr_cmd_len =COMMAND_SIZE (SRpnt->sr_cmnd[0 ]); + +scsi_insert_special_req (SRpnt,1 ); +} +/* * Function: scsi_restart_operations * @@ -1241,6 +1280,18 @@ASSERT_LOCK (&io_request_lock,0 );/* +* If the door was locked, we need to insert a door lock request
drivers/scsi/scsi_error.c line 1293
Quoted 10 lines
drivers/scsi/scsi_error.c +9
-0+* onto the head of the SCSI request queue for the device. There +* is no point trying to lock the door of an off-line device. +*/ +for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) { +if (!SDpnt->online || !SDpnt->locked) +continue ; + +scsi_eh_lock_door (SDpnt); + }
Why is the above in a separate loop from the loop with the request_fn call? To avoid holding the lock during the call or what?
Above is where we also need a "SDpnt->has_cmdblock" check, simplify the above to be:
for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) if (SDpnt->online && SDpnt->locked && SDpnt->has_cmdblock) scsi_eh_lock_door(SDpnt);
(And why does the SDpnt->device_blocked cause the later loop to break rather than continue! I can understand the host->xxx checks breaking out.)
-- Patrick Mansfield
Re: SCSI woes (followup)
Quoted 4 lines · Patrick Mansfield
Quoted 1 line · Russell King
Ok, as promised here's the first patch.
Looks nice. I have the same comment as before about no commands.
I fail to see what the problem here is. I've repeatedly explained this. I'm not going to explain it again; maybe it would be wise to read the 2.4.19 code? Please re-read all my mails since Sunday.
Quoted 6 lines
Quoted 6 lines
drivers/scsi/scsi_error.c +6
-0+static void scsi_eh_lock_done (struct scsi_cmnd *SCpnt) +{ +struct scsi_request *SRpnt = SCpnt->sc_request; + + SCpnt->sc_request =NULL ; + SRpnt->sr_command =NULL ;
Quoted 8 lines
drivers/scsi/scsi_error.c line 1233
Quoted 4 lines
drivers/scsi/scsi_error.c +4
-0+ +scsi_release_command (SCpnt); +scsi_release_request (SRpnt); +}This is back to my orginal point (i.e. case 1 in your other response about "restarting operations after error handling", I haven't figured out case 2 yet) - the above will not be called if there are no commands.
It seems that you've misunderstood what this code is doing.
We queue up a set of door lock requests onto the head of the queue for each device. Each of these requests needs a "done" function (read some of the other subsystem code to find out why, I'm not going to explain the basics of the subsystem here) and the above code that you quoted is it. Since we are the last user of the request and command structures for this door lock request, we must free them to avoid leaking memory. So we do exactly that.
The above code has _nothing_ to do with any other request what so ever nor the state of the queues.
I fail to see what is soo difficult to grasp here.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
Russel -
Quoted 8 lines · Russell King
Quoted 3 lines · Patrick Mansfield
On Tue, Sep 24, 2002 at 11:39:42PM +0100, Russell King wrote:
Looks nice. I have the same comment as before about no commands.
I fail to see what the problem here is. I've repeatedly explained this. I'm not going to explain it again; maybe it would be wise to read the 2.4.19 code? Please re-read all my mails since Sunday.
OK, I understand those and the IO completion code.
I see now in your patch that if Scsi_Device::locked is set, we must have Scsi_Device::cmd_blocks != 0, since we only set locked in upper layers or via an ioctl to an upper layer device. So, checking for cmd_blocks is redundant.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/scsi/scsi_error.c +6
-0+static void scsi_eh_lock_done (struct scsi_cmnd *SCpnt) +{ +struct scsi_request *SRpnt = SCpnt->sc_request; + + SCpnt->sc_request =NULL ; + SRpnt->sr_command =NULL ;
Quoted 8 lines
Quoted 8 lines
drivers/scsi/scsi_error.c line 1233
Quoted 4 lines
drivers/scsi/scsi_error.c +4
-0+ +scsi_release_command (SCpnt); +scsi_release_request (SRpnt); +}This is back to my orginal point (i.e. case 1 in your other response about "restarting operations after error handling", I haven't figured out case 2 yet) - the above will not be called if there are no commands.
So, the above can never happen, since locked can't be set until after cmd_blocks == 1.
-- Patrick Mansfield
Re: SCSI woes (followup)
In reply to Patrick MansfieldSome more thoughts about this...
Quoted 4 lines · Patrick Mansfield
It would be nice if we could call
scsi_set_medium_removal(SCSI_REMOVAL_PREVENT)and use a single code path for all door lock requests, then we need a special force-to-queue-head argument passed on down the chain.
I don't think so. In the general case, we need to wait for the command to complete, pick up the result of that command, and report that back to the caller.
In the error handing case, we must not wait for the command to complete. Firstly, any result it reveals isn't useful. The completion of the command isn't interesting.
Secondly, blocking the error handler is one of the problems that the original code had, which is why the rest of the error handler goes to great efforts to submit retried commands to the host adapter in a carefully controlled manner. We must not block the error handler, and then get into a situation that we need the error handler to recover itself from.
So we have two situations. First, the common case where we add requests to the tail of the request queue. This is the one you optimise for, and make as fast as possible.
Second, we have the slow path, which is the error recovery. Yes, it is less important to optimise it, but it shouldn't be at the expense of the fast, common path.
Quoted 2 lines
(We should really have some common setup-a-scsi-command functions to remove all the duplicate cmd[] setup code.)
I have some thoughts on this. However, I don't believe them to be appropriate for 2.4 kernels. For 2.4, I'm working to fix the problems by introducing the minimum of new features.
Quoted 10 lines
drivers/scsi/scsi_error.c line 1292
Quoted 7 lines
drivers/scsi/scsi_error.c +6
-0+for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) { +if (!SDpnt->online || !SDpnt->locked) +continue ; + +scsi_eh_lock_door (SDpnt); + }Why is the above in a separate loop from the loop with the
request_fncall? To avoid holding the lock during the call or what?
Yes. scsi_eh_lock_door() may sleep when trying to obtain a request. I'm not convinced that this is the best thing to do yet. However, if we do have the possibility of sleeping, we must not hold any spinlocks.
Quoted 2 lines
Above is where we also need a "
SDpnt->has_cmdblock" check, simplify the above to be:
No. The request allocation code should be doing that for us.
Quoted 7 lines
for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) if (SDpnt->online && SDpnt->locked && SDpnt->has_cmdblock) scsi_eh_lock_door(SDpnt);(And why does the
SDpnt->device_blockedcause the later loop to break rather than continue! I can understand thehost->xxxchecks breaking out.)
Probably another bug.
I'm trying to make things more correct than they currently are. Each change on its own may not fix every single bug in one go. Neither should it.
Locate one problem, address it, solve it, prove that it is solved, create a patch, submit, and get it reviewed. Move to the next problem.
This is the only way that we're going to get reasonable improvement. SCSI error handling has sucked for many many years. If it was trivial to fix, it would've been fixed long ago.
It's going to take time, but I believe that this method will have a better success rate than one huge patch that claims to address all issues, changes lots of code and therefore can't be reviewed.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Re: SCSI woes (followup)
In reply to James BottomleyQuoted 9 lines · James Bottomley
I think it's method of operation is misplaced. What it should probably be doing is simply adding a doorlock to the head of the queue and then go back around. Since we know the doorlock now preceeds the command that instigated the issue the door should be locked before anything else happens. It should simply loop around and process the door lock request so it doesn't have to wait for anything else to occur (any commands which come down in the interim should go on the queue tail).
Similar mechanism exists in some current SCSI transport/interconnect protocols.
The notion of _an_immediate_command_ does exactly that.
Add a flag, say unsigned I:1; to scsi_cmnd, which if set to 1, will make add it to the head of the queue, irrespective of its serial number, else the command is added according to its serial number in the pending commands queue.
Signature · 1 line
Luben
Re: SCSI woes (followup)
Quoted 4 lines · Luben Tuikov [[email protected]] wrote:
Add a flag, say unsigned I:1; to
scsi_cmnd, which if set to 1, will make add it to the head of the queue, irrespective of its serial number, else the command is added according to its serial number in the pending commands queue.
The code path currently being discussed is a request path and we do not have a scsi_cmnd until it is processed by the scsi_request_fn. There is already an interface to insert the request at the head of the queue scsi_insert_special_req, but we always set it to 0. We also do not expose this interface high enough to let requests set this. We do expose it through the older scsi_insert_special_cmd interface used by scsi_mlqueue_insert.
-andmike
--
Michael Anderson
[email protected]
Re: SCSI woes (followup)
Quoted 8 lines · Mike Anderson
Quoted 4 lines · Luben Tuikov [[email protected]] wrote:
Add a flag, say unsigned I:1; to
scsi_cmnd, which if set to 1, will make add it to the head of the queue, irrespective of its serial number, else the command is added according to its serial number in the pending commands queue.The code path currently being discussed is a request path and we do not
Sorry Mike,
I didn't really bother to look this up -- I just wanted to send along an idea -- whether it be a request or cmnd, the important thing is that you get the idea.
Quoted 3 lines
have a
scsi_cmnduntil it is processed by thescsi_request_fn. There is already an interface to insert the request at the head of the queuescsi_insert_special_req, but we always set it to 0. We also do not
Should be a flag. ``Make'' it private to SCSI core, e.g. by setting it to 0 when entering from ULP, etc.
Thus, the queue insertion code would be quite generic; also using list_head as Doug has suggested, would do wonders (again I'm _not_ looking this up).
Quoted 3 lines
expose this interface high enough to let requests set this. We do expose it through the older
scsi_insert_special_cmdinterface used byscsi_mlqueue_insert.
Signature · 1 line
Luben
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH] first cut at fixing unable to requeue with no outstanding commands
Quoted 5 lines · [email protected] said:
What about applications and devices that only send one IO at a time? They could still hang.
We have: tape (st or osst), sg usage, partitioning, scanning, direct use of the block device (i.e. dd if=/dev/sda), and probably others.
I don't believe so.
Unplugging is a global thing. The request function for a plugged queue will always be run, that's a guarantee, so using this approach, the queue will stall but never hang forever.
I think for a rejection of a command with none outstanding, a stall is what you want (give the host/device time to recover from whatever the problem is). The length of the stall will be dependent on I/O pressure in the system, which is also roughly what you want: we can afford to give a device quite a while to recover if we're not desparate to get I/O to it. We can also handle BUSY returns this way too...
James
Re: [PATCH] first cut at fixing unable to requeue with no outstanding commands
Quoted 13 lines · James Bottomley [[email protected]] wrote:
Quoted 5 lines · [email protected] said:
What about applications and devices that only send one IO at a time? They could still hang.
We have: tape (st or osst), sg usage, partitioning, scanning, direct use of the block device (i.e. dd if=/dev/sda), and probably others.
I don't believe so.
Unplugging is a global thing. The request function for a plugged queue will always be run, that's a guarantee, so using this approach, the queue will stall but never hang forever.
Quoted 8 lines
I think for a rejection of a command with none outstanding, a stall is what you want (give the host/device time to recover from whatever the problem is). The length of the stall will be dependent on I/O pressure in the system, which is also roughly what you want: we can afford to give a device quite a while to recover if we're not desparate to get I/O to it. We can also handle BUSY returns this way too...
James
ok I see the call path now. I was unsure that blk_run_queues would be called for non-fs IO.
I traced a dd (dd if=/dev/sda of=/dev/null count=2 bs=512) command under uml with a modified scsi_debug to return 1 on a queuecommand call and your patch. The trace showed blk_run_queues being called through wb_kupdate.
#0 scsi_request_fn (...) at scsi_lib.c:738 #1 0xa00beda2 in blk_run_queues () at ll_rw_blk.c:1045 #2 0xa004fb0d in wb_kupdate (...) at page-writeback.c:270 #3 0xa004f6c9 in __pdflush (...) at pdflush.c:130 #4 0xa004f76e in pdflush (...) at pdflush.c:178 #5 0xa001aba4 in run_kernel_thread (...) at process.c:232
Since you are modifying scsi_mlqueue_insert what about a couple of these cleanups.
- Is the call to scsi_delete_timer really necessary. All callers have already deleted the timer. The del_timer function takes a lock which would be nice to avoid if we do not need to call it. If we want to protect the code we could do a quick check on SCset->eh_timeout.function prior to calling.
- Patrick pointed out a while ago that the "if (host->host_busy == 0)" check and the similar one for the device will never be called because to be in this function the values of these variables need to be at least 1. I believe this direct call to scsi_retry_command should be removed instead of adjusting the check to "== 1" as this seems counter to how you are trying to handle busy.
-andmike
--
Michael Anderson
[email protected]
Inhibit auto-attach of scsi disks ?
In reply to James BottomleyQuoted 3 lines
[email protected] said:
use of the block device (i.e. dd if=/dev/sda), and probably others.
I've noticed (at least in LK 2.4.19) that the scsi system will automatically "attach" any scsi disk-type device that it finds while scanning the scsi bus for new devices. This includes issuing read capacity commands and attempting to read and parse that device's partition table.
I was wondering if there has been any discussion of a method/option by which a user could inhibit the automatic attachment of disk units ? This might be desired if the users intent was to reformat, repartition, or perform other low-level activities.
Thanks, Scott.
Re: Inhibit auto-attach of scsi disks ?
You can do all those things while it is attached as a disk device.
Alan
Re: Inhibit auto-attach of scsi disks ?
Quoted 1 line · Alan Cox
You can do all those things while it is attached as a disk device.
Yes - my concerns are perhaps more "artistic" (and possibly misguided). If I am mounting a disk for low level maintenance, it may not have a valid partition table and I may not appreciate the Syslog warnings related to the partition table. Furthermore, all though I haven't investigated, it seems like it might be tricky to determine that I have altered the partition table and that /dev/sdb6 is no longer a valid partition. To me, it just seemed that giving the user/administrator some way to control/inhibit the auto-attachment would be a "cleaner" solution to the problem - but that's just one man's opinion ... :)
Regards, Scott.
Re: Inhibit auto-attach of scsi disks ?
Quoted 5 lines · Scott Merritt
Quoted 1 line · Alan Cox
You can do all those things while it is attached as a disk device.
Yes - my concerns are perhaps more "artistic" (and possibly misguided). If I am mounting a disk for low level maintenance, it may not have a valid partition table and I may not appreciate the Syslog warnings related to the partition table. Furthermore, all though I haven't investigated, it seems like it might be tricky to determine that I have altered the partition table and that
/dev/sdb6is no longer a valid partition. To me, it just seemed that giving the user/administrator some way to control/inhibit the auto-attachment would be a "cleaner" solution to the problem - but that's just one man's opinion ... :)
You are confusing auto attachment with auto mounting. When you do the low level things you suggest, the disk should not be *mounted* but it *must* be attached (or else there won't be a scsi device for you to open and tell to format itself for instance). Same goes for fdisk partition operations, the disk shouldn't be mounted, but it must be attached for fdisk to be able to write to it. Then, when the partition tables are rewritten, fdisk tells the kernel to reread the tables from disk, which the kernel happily does as long as no one currently has any of the previous partitions still mounted.
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
Re: Inhibit auto-attach of scsi disks ?
Quoted 4 lines · On Tue, 1 Oct 2002 21:58:38 -0400 Doug Ledford <[email protected]> wrote:
You are confusing auto attachment with auto mounting. When you do the low level things you suggest, the disk should not be *mounted* but it *must* be attached (or else there won't be a scsi device for you to open and tell to format itself for instance).
Yes, I would certainly agree that the scsi disk must first be "attached". However, I'm not entirely clear on the need to *always* read/parse the partition table as an integral part of "attaching" the scsi disk.
Assuming that I understand you correctly, I think this is simply a slightly different "artistic" view. Under the assumption that an "early" read of the partition table does no "damage", there is clearly no compelling reason to change. About the best argument I could come up with is some type of hypothetical disk device that would appreciate a firmware/parameter download from the "main" filesystem before being forced to perform it's first data operation. An admittedly tenuous example ... :)
Best regards, Scott.
Re: Inhibit auto-attach of scsi disks ?
In reply to Scott MerrittYou need it attached to write the partition table.
Re: [RFC PATCH] consolidate SCSI-2 command lun setting
In reply to a message not in the archiveThis all looks OK, except here:
+++ b/drivers/scsi/scsi_lib.c Tue Oct 15 09:46:06 2002
@@ -972,6 +972,14 @@
continue;
}
}
+ /*
+ * If SCSI-2 or lower, store the LUN value in cmnd.
+ */
+ if (SDpnt->scsi_level <= SCSI_2)
+ SCpnt->cmnd[1] = (SCpnt->cmnd[1] & 0x1f) |
+ (SCpnt->lun << 5 & 0xe0);
+
+
/*
* Finally, initialize any error handling parameters, and set up
* the timers for timeouts.
Shouldn't this code go early in scsi_dispatch_io instead? (with something similar in scsi_send_eh_cmnd)
James
Re: [RFC PATCH] consolidate SCSI-2 command lun setting
Quoted 19 lines · James Bottomley
This all looks OK, except here:
+++
b/drivers/scsi/scsi_lib.cTue Oct 15 09:46:06 2002(quoted diff) +8
-0@@ -972,6 +972,14 @@ continue; } } + /* + * If SCSI-2 or lower, store the LUN value in cmnd. + */ + if (SDpnt->scsi_level <= SCSI_2) + SCpnt->cmnd[1] = (SCpnt->cmnd[1] & 0x1f) | + (SCpnt->lun << 5 & 0xe0); + + /* * Finally, initialize any error handling parameters, and set up * the timers for timeouts.
Quoted 4 lines
Shouldn't this code go early in
scsi_dispatch_ioinstead? (with something similar inscsi_send_eh_cmnd)James
James -
Thanks, yes, (I assume you meant scsi_dispatch_cmnd), that makes more sense and I added common code for scsi_send_eh_cmnd.
New patch:
drivers/scsi/osst.c | 2 -- drivers/scsi/scsi.c | 6 ++++++ drivers/scsi/scsi_error.c | 12 +++++------- drivers/scsi/scsi_ioctl.c | 16 ++++------------ drivers/scsi/sd.c | 22 +++++----------------- drivers/scsi/sg.c | 4 ---- drivers/scsi/sr.c | 17 ++--------------- drivers/scsi/sr_ioctl.c | 20 +------------------- drivers/scsi/sr_vendor.c | 18 +++--------------- drivers/scsi/st.c | 2 -- include/scsi/sg.h | 2 +- 11 files changed, 27 insertions(+), 94 deletions(-)
drivers/scsi/osst.c +0 -2
@@ -322,8 +322,6 @@ } } -if (SRpnt->sr_device->scsi_level <=SCSI_2 ) - cmd[1 ] |= (SRpnt->sr_device->lun <<5 ) &0xe0 ;init_completion (&STp->wait); SRpnt->sr_use_sg = (bytes > (STp->buffer)->sg[0 ].length) ? (STp->buffer)->use_sg :0 ;
drivers/scsi/scsi.c +6 -0
@@ -798,6 +798,12 @@ serial_number =1 ; SCpnt->serial_number = serial_number; SCpnt->pid = scsi_pid++; +/* +* If SCSI-2 or lower, store the LUN value in cmnd. +*/ +if (SCpnt->device->scsi_level <=SCSI_2 ) + SCpnt->cmnd[1 ] = (SCpnt->cmnd[1 ] &0x1f ) | + (SCpnt->lun <<5 &0xe0 );/* * We will wait MIN_RESET_DELAY clock ticks after the last reset so
drivers/scsi/scsi_error.c +5 -7
@@ -502,6 +502,10 @@*/ scmd->owner =SCSI_OWNER_LOWLEVEL ; +if (scmd->device->scsi_level <=SCSI_2 ) + scmd->cmnd[1 ] = (scmd->cmnd[1 ] &0x1f ) | + (scmd->lun <<5 &0xe0 ); +if (host->can_queue) {DECLARE_MUTEX_LOCKED (sem);
@@ -610,9 +614,6 @@memcpy ((void *) scmd->cmnd, (void *) generic_sense,sizeof (generic_sense)); -if (scmd->device->scsi_level <=SCSI_2 ) - scmd->cmnd[1 ] = scmd->lun <<5 ; - scsi_result = (!scmd->host->hostt->unchecked_isa_dma) ? &scsi_result0[0 ] :kmalloc (512 ,GFP_ATOMIC |GFP_DMA );
@@ -839,9 +840,6 @@memcpy ((void *) scmd->cmnd, (void *) tur_command,sizeof (tur_command)); -if (scmd->device->scsi_level <=SCSI_2 ) - scmd->cmnd[1 ] = scmd->lun <<5 ; -/* * zero the sense buffer. the scsi spec mandates that any * untransferred sense data should be interpreted as being zero.
@@ -1419,7 +1417,7 @@ } sreq->sr_cmnd[0 ] =ALLOW_MEDIUM_REMOVAL ; - sreq->sr_cmnd[1 ] = (sdev->scsi_level <=SCSI_2 ) ? (sdev->lun <<5 ) :0 ; + sreq->sr_cmnd[1 ] =0 ; sreq->sr_cmnd[2 ] =0 ; sreq->sr_cmnd[3 ] =0 ; sreq->sr_cmnd[4 ] =SCSI_REMOVAL_PREVENT ;
drivers/scsi/scsi_ioctl.c +4 -12
@@ -160,7 +160,7 @@return 0 ; scsi_cmd[0 ] =ALLOW_MEDIUM_REMOVAL ; - scsi_cmd[1 ] = (dev->scsi_level <=SCSI_2 ) ? (dev->lun <<5 ) :0 ; + scsi_cmd[1 ] =0 ; scsi_cmd[2 ] =0 ; scsi_cmd[3 ] =0 ; scsi_cmd[4 ] = state;
@@ -297,12 +297,6 @@if (copy_from_user (buf, cmd_in + cmdlen, inlen)) goto error; -/* -* Set the lun field to the correct value. -*/ -if (dev->scsi_level <=SCSI_2 ) - cmd[1 ] = (cmd[1 ] &0x1f ) | (dev->lun <<5 ); -switch (opcode) {case FORMAT_UNIT : timeout =FORMAT_UNIT_TIMEOUT ;
@@ -416,7 +410,6 @@int scsi_ioctl (Scsi_Device * dev,int cmd,void *arg) {char scsi_cmd[MAX_COMMAND_SIZE ]; -char cmd_byte1;/* No idea how this happens.... */ if (!dev)
@@ -431,7 +424,6 @@if (!scsi_block_when_processing_errors (dev)) {return -ENODEV ; } - cmd_byte1 = (dev->scsi_level <=SCSI_2 ) ? (dev->lun <<5 ) :0 ;switch (cmd) {case SCSI_IOCTL_GET_IDLUN :
@@ -484,7 +476,7 @@return scsi_set_medium_removal (dev,SCSI_REMOVAL_ALLOW );case SCSI_IOCTL_TEST_UNIT_READY : scsi_cmd[0 ] =TEST_UNIT_READY ; - scsi_cmd[1 ] = cmd_byte1; + scsi_cmd[1 ] =0 ; scsi_cmd[2 ] = scsi_cmd[3 ] = scsi_cmd[5 ] =0 ; scsi_cmd[4 ] =0 ; return ioctl_internal_command((Scsi_Device *) dev, scsi_cmd,
@@ -492,7 +484,7 @@break ;case SCSI_IOCTL_START_UNIT : scsi_cmd[0 ] =START_STOP ; - scsi_cmd[1 ] = cmd_byte1; + scsi_cmd[1 ] =0 ; scsi_cmd[2 ] = scsi_cmd[3 ] = scsi_cmd[5 ] =0 ; scsi_cmd[4 ] =1 ; return ioctl_internal_command((Scsi_Device *) dev, scsi_cmd,
@@ -500,7 +492,7 @@break ;case SCSI_IOCTL_STOP_UNIT : scsi_cmd[0 ] =START_STOP ; - scsi_cmd[1 ] = cmd_byte1; + scsi_cmd[1 ] =0 ; scsi_cmd[2 ] = scsi_cmd[3 ] = scsi_cmd[5 ] =0 ; scsi_cmd[4 ] =0 ; return ioctl_internal_command((Scsi_Device *) dev, scsi_cmd,
drivers/scsi/sd.c +5 -17
@@ -402,8 +402,7 @@ nbuff, (rq_data_dir (SCpnt->request) ==WRITE ) ? "writing" : "reading", this_count, SCpnt->request->nr_sectors)); - SCpnt->cmnd[1 ] = (SCpnt->device->scsi_level <=SCSI_2 ) ? - ((SCpnt->lun <<5 ) &0xe0 ) :0 ; + SCpnt->cmnd[1 ] =0 ;if (((this_count >0xff ) || (block >0x1fffff )) || SCpnt->device->ten) {if (this_count >0xffff )
@@ -815,9 +814,7 @@while (retries <3 ) { cmd[0 ] =TEST_UNIT_READY ; - cmd[1 ] = (sdp->scsi_level <=SCSI_2 ) ? - ((sdp->lun <<5 ) &0xe0 ) :0 ; -memset ((void *) &cmd[2 ],0 ,8 ); +memset ((void *) &cmd[1 ],0 ,9 ); SRpnt->sr_cmd_len =0 ; SRpnt->sr_sense_buffer[0 ] =0 ;
@@ -851,9 +848,7 @@printk (KERN_NOTICE "%s: Spinning up disk..." , diskname); cmd[0 ] =START_STOP ; - cmd[1 ] = (sdp->scsi_level <=SCSI_2 ) ? - ((sdp->lun <<5 ) &0xe0 ) :0 ; - cmd[1 ] |=1 ;/* Return immediately */ + cmd[1 ] =1 ;/* Return immediately */ memset ((void *) &cmd[2 ],0 ,8 ); cmd[4 ] =1 ;/* Start spin cycle */ SRpnt->sr_cmd_len =0 ;
@@ -894,7 +889,6 @@ Scsi_Request *SRpnt, unsigned char *buffer) { unsigned char cmd[10]; -Scsi_Device *sdp = sdkp->device;int the_result, retries; retries =3 ;
@@ -902,9 +896,7 @@memset ((void *) &cmd[0 ],0 ,10 ); cmd[0 ] =MODE_SENSE ; - cmd[1 ] = (sdp->scsi_level <=SCSI_2 ) ? - ((sdp->lun <<5 ) &0xe0 ) :0 ; - cmd[1 ] |=0x08 ;/* DBD */ + cmd[1 ] =0x08 ;/* DBD */ cmd[2 ] =0x08 ;/* current values, cache page */ cmd[4 ] =128 ;/* allocation length */
@@ -968,9 +960,7 @@ retries =3 ; do { cmd[0] = READ_CAPACITY; - cmd[1] = (sdp->scsi_level <= SCSI_2) ? - ((sdp->lun << 5) & 0xe0) : 0; - memset((void *) &cmd[2], 0, 8); + memset((void *) &cmd[1], 0, 9); memset((void *) buffer, 0, 8); SRpnt->sr_cmd_len = 0;
@@ -1090,7 +1080,6 @@memset ((void *) &cmd[0 ],0 ,8 ); cmd[0 ] =MODE_SENSE ; - cmd[1 ] = (sdp->scsi_level <=SCSI_2 ) ? ((sdp->lun <<5 ) &0xe0 ) :0 ; cmd[2 ] = modepage; cmd[4 ] = len;
@@ -1612,7 +1601,6 @@unsigned char cmd[10 ] = {0 }; cmd[0 ] =SYNCHRONIZE_CACHE ; - cmd[1 ] = SDpnt->scsi_level <=SCSI_2 ? (SDpnt->lun <<5 ) &0xe0 :0 ;/* leave the rest of the command zero to indicate * flush everything */ scsi_wait_req(SRpnt, (void *)cmd, NULL, 0,
drivers/scsi/sg.c +0 -4
@@ -705,10 +705,6 @@ SRpnt->sr_request->rq_dev = sdp->i_rdev; SRpnt->sr_sense_buffer[0 ] =0 ; SRpnt->sr_cmd_len = hp->cmd_len; -if (!(hp->flags &SG_FLAG_LUN_INHIBIT )) { -if (sdp->device->scsi_level <=SCSI_2 ) - cmnd[1 ] = (cmnd[1 ] &0x1f ) | (sdp->device->lun <<5 ); - } SRpnt->sr_use_sg = srp->data.k_use_sg; SRpnt->sr_sglist_len = srp->data.sglist_len; SRpnt->sr_bufflen = srp->data.bufflen;
drivers/scsi/sr.c +2 -15
@@ -336,9 +336,7 @@ (rq_data_dir (SCpnt->request) ==WRITE ) ?"writing" :"reading" , this_count, SCpnt->request->nr_sectors)); - SCpnt->cmnd[1 ] = (SCpnt->device->scsi_level <=SCSI_2 ) ? - ((SCpnt->lun <<5 ) &0xe0 ) :0 ; - + SCpnt->cmnd[1 ] =0 ; block = (unsigned int )SCpnt->request->sector / (s_size >>9 );if (this_count >0xffff )
@@ -486,9 +484,7 @@ do { cmd[0] = READ_CAPACITY; - cmd[1] = (cd->device->scsi_level <= SCSI_2) ? - ((cd->device->lun << 5) & 0xe0) : 0; - memset((void *) &cmd[2], 0, 8); + memset((void *) &cmd[1], 0, 9); SRpnt->sr_request->rq_status = RQ_SCSI_BUSY; /* Mark as really busy */ SRpnt->sr_cmd_len = 0;
@@ -599,8 +595,6 @@ }memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); cgc.cmd[0 ] =MODE_SENSE ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - ((cd->device->lun <<5 ) &0xe0 ) :0 ; cgc.cmd[2 ] =0x2a ; cgc.cmd[4 ] =128 ; cgc.buffer = buffer;
@@ -678,13 +672,6 @@*/ static int sr_packet (struct cdrom_device_info *cdi,struct cdrom_generic_command *cgc) { -Scsi_CD *cd = cdi->handle; -Scsi_Device *device = cd->device; - -/* set the LUN */ -if (device->scsi_level <=SCSI_2 ) - cgc->cmd[1 ] |= device->lun <<5 ; -if (cgc->timeout <=0 ) cgc->timeout =IOCTL_TIMEOUT ;
drivers/scsi/sr_ioctl.c +1 -19
@@ -200,8 +200,6 @@memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); cgc.cmd[0 ] =GPCMD_TEST_UNIT_READY ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - ((cd->device->lun) <<5 ) :0 ; cgc.quiet =1 ; cgc.data_direction =SCSI_DATA_NONE ; cgc.timeout =IOCTL_TIMEOUT ;
@@ -215,8 +213,6 @@memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); cgc.cmd[0 ] =GPCMD_START_STOP_UNIT ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - ((cd->device->lun) <<5 ) :0 ; cgc.cmd[4 ] = (pos ==0 ) ?0x03 /* close */ :0x02 /* eject */ ; cgc.data_direction =SCSI_DATA_NONE ; cgc.timeout =IOCTL_TIMEOUT ;
@@ -293,8 +289,6 @@memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); cgc.cmd[0 ] =GPCMD_READ_SUBCHANNEL ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - ((cd->device->lun) <<5 ) :0 ; cgc.cmd[2 ] =0x40 ;/* I do want the subchannel info */ cgc.cmd[3 ] =0x02 ;/* Give me medium catalog number info */ cgc.cmd[8 ] =24 ;
@@ -327,8 +321,6 @@memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); cgc.cmd[0 ] =GPCMD_SET_SPEED ;/* SET CD SPEED */ - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - ((cd->device->lun) <<5 ) :0 ; cgc.cmd[2 ] = (speed >>8 ) &0xff ;/* MSB for speed (in kbytes/sec) */ cgc.cmd[3 ] = speed &0xff ;/* LSB */ cgc.data_direction =SCSI_DATA_NONE ;
@@ -361,8 +353,6 @@struct cdrom_tochdr *tochdr = (struct cdrom_tochdr *) arg; cgc.cmd[0 ] =GPCMD_READ_TOC_PMA_ATIP ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - ((cd->device->lun) <<5 ) :0 ; cgc.cmd[8 ] =12 ;/* LSB of length */ cgc.buffer = buffer; cgc.buflen =12 ;
@@ -382,8 +372,6 @@struct cdrom_tocentry *tocentry = (struct cdrom_tocentry *) arg; cgc.cmd[0 ] =GPCMD_READ_TOC_PMA_ATIP ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - ((cd->device->lun) <<5 ) :0 ; cgc.cmd[1 ] |= (tocentry->cdte_format ==CDROM_MSF ) ?0x02 :0 ; cgc.cmd[6 ] = tocentry->cdte_track; cgc.cmd[8 ] =12 ;/* LSB of length */
@@ -411,8 +399,6 @@struct cdrom_ti * ti = (struct cdrom_ti *)arg; cgc.cmd[0 ] =GPCMD_PLAYAUDIO_TI ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - (cd->device->lun <<5 ) :0 ; cgc.cmd[4 ] = ti->cdti_trk0; cgc.cmd[5 ] = ti->cdti_ind0; cgc.cmd[7 ] = ti->cdti_trk1;
@@ -463,9 +449,7 @@memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); cgc.cmd[0 ] =GPCMD_READ_CD ;/* READ_CD */ - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - (cd->device->lun <<5 ) :0 ; - cgc.cmd[1 ] |= ((format &7 ) <<2 ); + cgc.cmd[1 ] = ((format &7 ) <<2 ); cgc.cmd[2 ] = (unsigned char ) (lba >>24 ) &0xff ; cgc.cmd[3 ] = (unsigned char ) (lba >>16 ) &0xff ; cgc.cmd[4 ] = (unsigned char ) (lba >>8 ) &0xff ;
@@ -521,8 +505,6 @@memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); cgc.cmd[0 ] =GPCMD_READ_10 ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - (cd->device->lun <<5 ) :0 ; cgc.cmd[2 ] = (unsigned char ) (lba >>24 ) &0xff ; cgc.cmd[3 ] = (unsigned char ) (lba >>16 ) &0xff ; cgc.cmd[4 ] = (unsigned char ) (lba >>8 ) &0xff ;
drivers/scsi/sr_vendor.c +3 -15
@@ -124,9 +124,7 @@#endif memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); cgc.cmd[0 ] =MODE_SELECT ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - (cd->device->lun <<5 ) :0 ; - cgc.cmd[1 ] |= (1 <<4 ); + cgc.cmd[1 ] = (1 <<4 ); cgc.cmd[4 ] =12 ; modesel = (struct ccs_modesel_head *) buffer;memset (modesel,0 ,sizeof (*modesel));
@@ -180,8 +178,6 @@case VENDOR_SCSI3 : cgc.cmd[0 ] =READ_TOC ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - (cd->device->lun <<5 ) :0 ; cgc.cmd[8 ] =12 ; cgc.cmd[9 ] =0x40 ; cgc.buffer = buffer;
@@ -210,9 +206,7 @@case VENDOR_NEC :{unsigned long min, sec, frame; cgc.cmd[0 ] =0xde ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - (cd->device->lun <<5 ) :0 ; - cgc.cmd[1 ] |=0x03 ; + cgc.cmd[1 ] =0x03 ; cgc.cmd[2 ] =0xb0 ; cgc.buffer = buffer; cgc.buflen =0x16 ;
@@ -242,9 +236,7 @@/* we request some disc information (is it a XA-CD ?, * where starts the last session ?) */ cgc.cmd[0 ] =0xc7 ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - (cd->device->lun <<5 ) :0 ; - cgc.cmd[1 ] |=0x03 ; + cgc.cmd[1 ] =0x03 ; cgc.buffer = buffer; cgc.buflen =4 ; cgc.quiet =1 ;
@@ -272,8 +264,6 @@case VENDOR_WRITER : cgc.cmd[0 ] =READ_TOC ; - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - (cd->device->lun <<5 ) :0 ; cgc.cmd[8 ] =0x04 ; cgc.cmd[9 ] =0x40 ; cgc.buffer = buffer;
@@ -291,8 +281,6 @@break ; } cgc.cmd[0 ] =READ_TOC ;/* Read TOC */ - cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - (cd->device->lun <<5 ) :0 ; cgc.cmd[6 ] = rc &0x7f ;/* number of last session */ cgc.cmd[8 ] =0x0c ; cgc.cmd[9 ] =0x40 ;
drivers/scsi/st.c +0 -2
@@ -379,8 +379,6 @@ } } -if (SRpnt->sr_device->scsi_level <=SCSI_2 ) - cmd[1 ] |= (SRpnt->sr_device->lun <<5 ) &0xe0 ;init_completion (&STp->wait); SRpnt->sr_use_sg = STp->buffer->do_dio || (bytes > (STp->buffer)->frp[0 ].length);if (SRpnt->sr_use_sg) {
include/scsi/sg.h +1 -1
@@ -130,7 +130,7 @@/* following flag values can be "or"-ed together */ #define SG_FLAG_DIRECT_IO 1/* default is indirect IO */ -#define SG_FLAG_LUN_INHIBIT 2/* default is overwrite lun in SCSI */ +#define SG_FLAG_UNUSED_LUN_INHIBIT 2/* default is overwrite lun in SCSI */ /* command block (when <= SCSI_2) */ #define SG_FLAG_MMAP_IO 4/* request memory mapped IO */ #define SG_FLAG_NO_DXFER 0x10000/* no transfer of kernel buffers to/from */
Re: [PATCH] 2.5 current bk fix setting scsi queue depths
In reply to a message not in the archiveQuoted 2 lines · [email protected] said:
This patch fixes a problem with the current linus bk tree setting scsi queue depths to 1. Please apply.
This patch causes the depth specification to be retained when we release commandblocks. Since releasing command blocks is supposed only to be done when we give up the device (and therefore, is supposed to clear everything), your fix looks like it's merely masking a problem, not fixing it.
Is the real problem that this controller is getting a release command blocks and then a reallocate of them after slave_attach is called? If so, that's probably what needs to be fixed.
James
Re: [PATCH] 2.5 current bk fix setting scsi queue depths
Quoted 9 lines · James Bottomley
Quoted 2 lines · [email protected] said:
This patch fixes a problem with the current linus bk tree setting scsi queue depths to 1. Please apply.
This patch causes the depth specification to be retained when we release commandblocks. Since releasing command blocks is supposed only to be done when we give up the device (and therefore, is supposed to clear everything), your fix looks like it's merely masking a problem, not fixing it.
Quoted 5 lines
Is the real problem that this controller is getting a release command blocks and then a reallocate of them after
slave_attachis called? If so, that's probably what needs to be fixed.James
Yes, the problem is that in scsi_register_host() if there are no upper level drivers - the standard case if building no modules - we call scsi_release_commandblocks even though we are NOT getting rid of the scsi_device. So, with current code, new_queue_depth and current_queue_depth are zero.
When we register upper level drivers in scsi_register_device(), we call scsi_build_commandblocks (again), and get a queue depth of 1, since we've cleared new_queue_depth.
(In many cases, for one device we call build command blocks twice, call release command blocks, and then build command blocks again. Yuck)
Removing the scsi_release_commandblocks() in scsi_register_host() would also fix the problem, and in most cases, would not waste any space. In the worst case AFAICT it would waste one scsi_cmnd (about 300 or so bytes?).
I see no good reason to zero new_queue_depth in scsi_release_commandblocks, as new_queue_depth is the desired queue depth, and should remain so until scsi_adjust_queue_depth is called. Setting new_queue_depth to zero means we have to call slave_attach again to set it right, and depending on what else an adapter slave_attach does could be very wrong.
-- Patrick Mansfield
Re: [PATCH] 2.5 current bk fix setting scsi queue depths
In reply to a message not in the archiveQuoted 5 lines
Yes, the problem is that in
scsi_register_host()if there are no upper level drivers - the standard case if building no modules - we callscsi_release_commandblockseven though we are NOT getting rid of thescsi_device. So, with current code,new_queue_depthandcurrent_queue_depthare zero.
But slave_attach isn't called here (even though it should be for attached devices). I assume it's getting added by the scan between register_host & register_device.
Quoted 3 lines
When we register upper level drivers in
scsi_register_device(), we callscsi_build_commandblocks(again), and get a queue depth of 1, since we've clearednew_queue_depth.
OK, we have a slight mess up here. Perhaps the rule for slave_attach should be that we only call it if we actually have an upper level device attached (if we haven't, there's little point asking the HBA to allocate space for queueing for a device we're not currently using). Then, we should do slave_attach when something actually decides to attach to the device.
if we follow this approach, slave_attach wouldn't be called until register_device in your problem scenario, and then everything would work as expected.
Quoted 4 lines
Removing the
scsi_release_commandblocks()inscsi_register_host()would also fix the problem, and in most cases, would not waste any space. In the worst case AFAICT it would waste onescsi_cmnd(about 300 or so bytes?).
Well, if there's no device attached, there's no need for a queue. This would waste 1 SCSI command per unattached device (and SCSI commands are DMA'able memory which is precious on some systems). Right now, that's OK for small systems. When we move to a lazy attachment model because we have an array with 65535 LUNs and we're only interested in one of them, it won't be.
Quoted 6 lines
I see no good reason to zero
new_queue_depthinscsi_release_commandblocks, asnew_queue_depthis the desired queue depth, and should remain so untilscsi_adjust_queue_depthis called. Settingnew_queue_depthto zero means we have to callslave_attachagain to set it right, and depending on what else an adapterslave_attachdoes could be very wrong.
Well, to my way of thinking, build and release commandblocks are like constructor and destructor for the device queue. On general design principles, I don't like the idea of queue specific information persisting past its destruction.
James
Re: [PATCH] scsi host cleanup 3/3 (driver changes)
Quoted 6 lines · Mike Anderson
If you read my previous post on this patch I indicated that few of the driver changes I was only able to compile test (
block/cciss_scsi.c,scsi/53c700.c, scsi/pcmcia/*,scsi/wd33c93.c). The changes to the drivers are to remove the old interfaces and possibly extra NULL inits of struct members. These changes will need to be ok'd by there respective maintainers.
I tried out these patches with 2.5.40 and the cciss driver. Looks ok to me.
When I did "echo engage scsi > /proc/driver/cciss/cciss0" to make the cciss driver register with the scsi subsystem, I got what you see below. However, I also got the same thing when trying 2.5.40 without the patches, so I don't think the patches are the problem.
When I tried 2.5.41 without the patches, the problem below was gone.
And, despite all this, it always appeared to work anyway. My tape drive appeared, and I could always do i/o to it.
-- steve
dmesg output follows:
cciss0: No device changes detected.
scsi0 : cciss0
Vendor: COMPAQ Model: SDT-10000 Rev: 1.14
Type: Sequential-Access ANSI SCSI revision: 02
Debug: sleeping function called from illegal context at slab.c:1374 ce275de0 c01195e6 c0320bc0 c0326282 0000055e c1287080 c013c15f c0326282
0000055e c1336324 c1330c00 00000000 ce275e4c 00000286 00000286 cfc32974
cf37e000 00000000 cfffb080 d0800000 00001000 ce274000 00001000 c013a199
Call Trace:
[<c01195e6>]__might_sleep+0x56/0x5d
[<c013c15f>]kmalloc+0x4f/0x330
[<c013a199>]get_vm_area+0x29/0x140
[<c013a4fb>]__vmalloc+0x3b/0x120
[<c013a5f6>]vmalloc+0x16/0x20
[<c029837e>]sg_init+0xbe/0x160
[<c0288280>]scsi_register_host+0x130/0x200
[<c025a5b6>]cciss_engage_scsi+0x136/0x150
[<c025a8da>]cciss_proc_write+0x8a/0xb0
[<c015ca9f>]open_namei+0x37f/0x4e0
[<c013bcf2>]free_block+0x192/0x2c0
[<c017bf21>]proc_file_write+0x31/0x40
[<c014d316>]vfs_write+0xb6/0x180
[<c014c94f>]filp_close+0x10f/0x120
[<c014c94f>]filp_close+0x10f/0x120
[<c014d44a>]sys_write+0x2a/0x40
[<c01078af>]syscall_call+0x7/0xbbad: scheduling while atomic!ce275ce8 c0116b9d c0320a20 c03c0590 ce275d0c c01170a1 c12b5800 00000000
ce274000 ce275dd4 ce275dd8 ce275d68 c011749a 00000000 cfcb1080 c0117080
00000000 00000000 c0117196 c03c0588 00000003 00000001 cfcb1080 c0117080
Call Trace:
[<c0116b9d>]schedule+0x3d/0x4c0
[<c01170a1>]default_wake_function+0x21/0x40
[<c011749a>]wait_for_completion+0x12a/0x1e0
[<c0117080>]default_wake_function+0x0/0x40
[<c0117196>]__wake_up+0x66/0xb0
[<c0117080>]default_wake_function+0x0/0x40
[<c012d5a1>]call_usermodehelper+0x101/0x110
[<c012d470>]__call_usermodehelper+0x0/0x30
[<c013bcf2>]free_block+0x192/0x2c0
[<c012d470>]__call_usermodehelper+0x0/0x30
[<c021ed84>]dev_hotplug+0x1a4/0x230
[<c021edd7>]dev_hotplug+0x1f7/0x230
[<c021babd>]device_attach+0x2d/0x40
[<c021be84>]device_register+0x194/0x270
[<c029874f>]sg_attach+0x2cf/0x380
[<c02882ca>]scsi_register_host+0x17a/0x200
[<c025a5b6>]cciss_engage_scsi+0x136/0x150
[<c025a8da>]cciss_proc_write+0x8a/0xb0
[<c015ca9f>]open_namei+0x37f/0x4e0
[<c013bcf2>]free_block+0x192/0x2c0
[<c017bf21>]proc_file_write+0x31/0x40
[<c014d316>]vfs_write+0xb6/0x180
[<c014c94f>]filp_close+0x10f/0x120
[<c014c94f>]filp_close+0x10f/0x120
[<c014d44a>]sys_write+0x2a/0x40
[<c01078af>]syscall_call+0x7/0xbAttached scsi tape st0 at scsi0, channel 0, id 0, lun 0
st0: try direct i/o: yes, max page reachable by HBA 65532
Re: [PATCH] scsi host cleanup 3/3 (driver changes)
Stephen,
You where most likely hitting the sg might sleep problem. I posted a patch to this list and I believe that the workaround is in 2.5.41.
Quoted 46 lines · Stephen Cameron [[email protected]] wrote:
Quoted 6 lines · Mike Anderson
If you read my previous post on this patch I indicated that few of the driver changes I was only able to compile test (
block/cciss_scsi.c,scsi/53c700.c, scsi/pcmcia/*,scsi/wd33c93.c). The changes to the drivers are to remove the old interfaces and possibly extra NULL inits of struct members. These changes will need to be ok'd by there respective maintainers.I tried out these patches with 2.5.40 and the cciss driver. Looks ok to me.
When I did "echo engage scsi >
/proc/driver/cciss/cciss0" to make the cciss driver register with the scsi subsystem, I got what you see below. However, I also got the same thing when trying 2.5.40 without the patches, so I don't think the patches are the problem.When I tried 2.5.41 without the patches, the problem below was gone.
And, despite all this, it always appeared to work anyway. My tape drive appeared, and I could always do i/o to it.
-- steve
dmesg output follows:
cciss0: No device changes detected.
scsi0 : cciss0
Vendor: COMPAQ Model: SDT-10000 Rev: 1.14
Type: Sequential-Access ANSI SCSI revision: 02
Debug: sleeping function called from illegal context at slab.c:1374ce275de0c01195e6c0320bc0c03262820000055ec1287080c013c15fc03262820000055e c1336324 c1330c00 00000000 ce275e4c 00000286 00000286 cfc32974 cf37e000 00000000 cfffb080 d0800000 00001000 ce274000 00001000 c013a199 Call Trace: [<c01195e6>]__might_sleep+0x56/0x5d [<c013c15f>]kmalloc+0x4f/0x330 [<c013a199>]get_vm_area+0x29/0x140 [<c013a4fb>]__vmalloc+0x3b/0x120 [<c013a5f6>]vmalloc+0x16/0x20 [<c029837e>]sg_init+0xbe/0x160 [<c0288280>]scsi_register_host+0x130/0x200 [<c025a5b6>]cciss_engage_scsi+0x136/0x150 [<c025a8da>]cciss_proc_write+0x8a/0xb0
Quoted 8 lines
[<c015ca9f>]open_namei+0x37f/0x4e0 [<c013bcf2>]free_block+0x192/0x2c0 [<c017bf21>]proc_file_write+0x31/0x40 [<c014d316>]vfs_write+0xb6/0x180 [<c014c94f>]filp_close+0x10f/0x120 [<c014c94f>]filp_close+0x10f/0x120 [<c014d44a>]sys_write+0x2a/0x40 [<c01078af>]syscall_call+0x7/0xb
.. snip ..
-andmike
--
Michael Anderson
[email protected]
PATCH 1/1 ips queue depths
Dave,
Here's a patch that should restore the queue depths to what they were before the
queue depths change was merged in. Hopefully this well restore your lost performance. If I don't hear or find anything bad about it, it will be going
to Linus shortly.
And thanks goes to Mike Anderson for his initial version. That made writing this patch all the easier.
David Jeffery
drivers/scsi/ips.c +7 -3
@@ -1877,12 +1877,16 @@ {ips_ha_t *ha;int min; +int depth; ha =IPS_HA (SDptr->host); min = ha->max_cmds /4 ; -if (min <8 ) - min = ha->max_cmds -1 ; -scsi_adjust_queue_depth (SDptr,MSG_ORDERED_TAG , min); +if ((SDptr->type ==TYPE_DISK ) && ha->enq->ucLogDriveCount){ + depth = (ha->max_cmds -1 ) / ha->enq->ucLogDriveCount; + depth =max (min, depth); + }else + depth =2 ; +scsi_adjust_queue_depth (SDptr,MSG_SIMPLE_TAG , depth);return 0 ; }
Re: [patch 2.5] ips queue depths
Quoted 11 lines · David
Dave,
Here's a patch that should restore the queue depths to what they were before the
queue depths change was merged in. Hopefully this well restore your lost performance. If I don't hear or find anything bad about it, it will be going
to Linus shortly.And thanks goes to Mike Anderson for his initial version. That made writing this patch all the easier.
Thank you for taking care of that so quickly. I've tested it and it shows that I'm within 0.5% of where I was before. this is well within the margin of error for my test.
On another (completely cosmetic) note, ips.c is spitting out warnings because of the IPS_*LOCK_RESTORE macros which don't use the flags argument in 2.5. If you're sending an update to Linus, could you include something like what I've attached to get rid of them?
Signature · 2 lines
Dave Hansen [email protected]
ips.c renamed from ips.c.orig +2 -2
@@ -248,8 +248,8 @@#else #define IPS_SG_ADDRESS (sg) (page_address((sg)->page) ? \ page_address((sg)->page)+(sg)->offset : 0) -#define IPS_LOCK_SAVE (lock,flags) spin_lock(lock) -#define IPS_UNLOCK_RESTORE (lock,flags) spin_unlock(lock) +#define IPS_LOCK_SAVE (lock,flags) do { spin_lock(lock); (void)flags } while (0) +#define IPS_UNLOCK_RESTORE (lock,flags) { spin_unlock(lock); (void)flags } while (0)#endif #define IPS_DMA_DIR (scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \
Re: [patch 2.5] ips queue depths
In reply to Jeffery, DavidQuoted 11 lines · David
Dave,
Here's a patch that should restore the queue depths to what they were before the
queue depths change was merged in. Hopefully this well restore your lost performance. If I don't hear or find anything bad about it, it will be going
to Linus shortly.And thanks goes to Mike Anderson for his initial version. That made writing this patch all the easier.
I actually sent a patch to linus already to do this but it hasn't come through yet. However, my patch and yours differ in one key point that I don't understand.
The scsi mid layer will never send you more than host->can_queue commands at one time, so why do all the scsi driver authors feel it is necessary to split their queue depth up amongst devices? Justin Gibbs is the only one that gets it right IMHO. Set the depth on each device as deep as that device can take (if that happens to be host->can_queue - 1 or such, then so be it). Then, let the mid layer and the request function worry about fairness across devices. That's its job after all. If everyone is going to moderate their queue depths like that, then we might as well yank can_queue out of the host struct entirely because *it serves no purpose*.
Now, simple scsi controllers like the aic7xxx and intelligent raid controllers are two different beasts. On simple controllers, the max queue depth on a target is typically whatever that target can handle. On raid controllers, it's all up to what the firmware can handle (for all I know, the ServeRAID firmware may have one queue depth limit for total commands and a separate queue depth limit on each logical device). So, I can't say for sure what the ips driver can and can't do, but I'm relatively sure that you are artificially limiting your own performance by handling queue depths the way you are.
Oh, also, host->cmd_per_lun is suppossed to be the automatic queue depth on untagged devices. 16 is typically way excessive for an untagged device (and I'm not even sure you support untagged pass-through devices on ips, and if you do I have no clue if the firmware will properly queue up untagged commands on a pass through device), so I changed that as well. So, attached are the 3 different patches I sent to linus on this driver. I would be interested to know what happens to performance on this driver if you follow my suggestion of letting the mid layer take care of watching the card's maximum queue depth and start letting the drives have queues as deep as they can handle.
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.754 -> 1.755 # drivers/scsi/ips.c 1.26 -> 1.27 # drivers/scsi/ips.h 1.9 -> 1.10
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/10/11 [email protected] 1.755
# Make the rest of the world happy with ips again
# --------------------------------------------
#
drivers/scsi/ips.c +29 -4
@@ -433,6 +433,7 @@int ips_eh_reset (Scsi_Cmnd *);int ips_queue (Scsi_Cmnd *,void (*) (Scsi_Cmnd *));int ips_biosparam (Disk *,struct block_device *,int *); +int ips_slave_attach (Scsi_Device *);const char *ips_info (struct Scsi_Host *);void do_ipsintr (int ,void *,struct pt_regs *);static int ips_hainit (ips_ha_t *);
@@ -481,7 +482,7 @@static void ips_free_flash_copperhead (ips_ha_t *ha);static void ips_get_bios_version (ips_ha_t *,int );static void ips_identify_controller (ips_ha_t *); -static void ips_select_queue_depth (struct Scsi_Host *,Scsi_Device *); +//static void ips_select_queue_depth(struct Scsi_Host *, Scsi_Device *); static void ips_chkstatus (ips_ha_t *,IPS_STATUS *);static void ips_enable_int_copperhead (ips_ha_t *);static void ips_enable_int_copperhead_memio (ips_ha_t *);
@@ -1087,7 +1088,7 @@ sh->n_io_port = io_addr ?255 :0 ; sh->unique_id = (io_addr) ? io_addr : mem_addr; sh->irq = irq; - sh->select_queue_depths = ips_select_queue_depth; +//sh->select_queue_depths = ips_select_queue_depth; sh->sg_tablesize = sh->hostt->sg_tablesize; sh->can_queue = sh->hostt->can_queue; sh->cmd_per_lun = sh->hostt->cmd_per_lun;
@@ -1827,7 +1828,7 @@/* Select queue depths for the devices on the contoller */ /* */ /****************************************************************************/ -static void +/*static void ips_select_queue_depth(struct Scsi_Host *host, Scsi_Device *scsi_devs) { Scsi_Device *device; ips_ha_t *ha;
@@ -1860,6 +1861,30 @@} } } +*/ + +/****************************************************************************/ +/* */ +/* Routine Name: ips_slave_attach */ +/* */ +/* Routine Description: */ +/* */ +/* Set queue depths on devices once scan is complete */ +/* */ +/****************************************************************************/ +int +ips_slave_attach (Scsi_Device *SDptr) +{ +ips_ha_t *ha; +int min; + + ha =IPS_HA (SDptr->host); + min = ha->max_cmds /4 ; +if (min <8 ) + min = ha->max_cmds -1 ; +scsi_adjust_queue_depth (SDptr,MSG_ORDERED_TAG , min); +return 0 ; +}/****************************************************************************/ /* */
@@ -7407,7 +7432,7 @@ sh->n_io_port = io_addr ?255 :0 ; sh->unique_id = (io_addr) ? io_addr : mem_addr; sh->irq = irq; - sh->select_queue_depths = ips_select_queue_depth; +//sh->select_queue_depths = ips_select_queue_depth; sh->sg_tablesize = sh->hostt->sg_tablesize; sh->can_queue = sh->hostt->can_queue; sh->cmd_per_lun = sh->hostt->cmd_per_lun;
drivers/scsi/ips.h +3 -1
@@ -60,6 +60,7 @@extern int ips_eh_reset (Scsi_Cmnd *);extern int ips_queue (Scsi_Cmnd *,void (*) (Scsi_Cmnd *));extern int ips_biosparam (Disk *,struct block_device *,int *); +extern int ips_slave_attach (Scsi_Device *);extern const char *ips_info (struct Scsi_Host *);extern void do_ips (int ,void *,struct pt_regs *);
@@ -481,7 +482,8 @@ eh_host_reset_handler : ips_eh_reset, \ abort : NULL, \ reset : NULL, \ - slave_attach : NULL, \ + slave_attach : ips_slave_attach, \ + slave_detach : NULL, \ bios_param : ips_biosparam, \ can_queue : 0, \ this_id: -1, \
drivers/scsi/ips.c +6 -4
@@ -1879,10 +1879,12 @@int min; ha =IPS_HA (SDptr->host); - min = ha->max_cmds /4 ; -if (min <8 ) - min = ha->max_cmds -1 ; -scsi_adjust_queue_depth (SDptr,MSG_ORDERED_TAG , min); +if (SDptr->tagged_supported) { + min = ha->max_cmds /2 ; +if (min <=16 ) + min = ha->max_cmds -1 ; +scsi_adjust_queue_depth (SDptr,MSG_ORDERED_TAG , min); + }return 0 ; }
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.782.2.2 -> 1.782.2.3
# drivers/scsi/ips.h 1.11 -> 1.12
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/10/12 [email protected] 1.782.2.3
# ips.h:
# Since we now have proper tagged depth setting, make # the cmd_per_lun value reasonable for untagged devices # like it is suppossed to be.
# --------------------------------------------
#
drivers/scsi/ips.h +3 -3
@@ -429,7 +429,7 @@ can_queue : 0, \ this_id: -1, \ sg_tablesize : IPS_MAX_SG, \ - cmd_per_lun: 16, \ + cmd_per_lun: 3, \ present : 0, \ unchecked_isa_dma : 0, \ use_clustering : ENABLE_CLUSTERING, \
@@ -458,7 +458,7 @@ can_queue : 0, \ this_id: -1, \ sg_tablesize : IPS_MAX_SG, \ - cmd_per_lun: 16, \ + cmd_per_lun: 3, \ present : 0, \ unchecked_isa_dma : 0, \ use_clustering : ENABLE_CLUSTERING, \
@@ -488,7 +488,7 @@ can_queue : 0, \ this_id: -1, \ sg_tablesize : IPS_MAX_SG, \ - cmd_per_lun: 16, \ + cmd_per_lun: 3, \ present : 0, \ unchecked_isa_dma : 0, \ use_clustering : ENABLE_CLUSTERING, \
Re: [patch 2.5] ips queue depths
Quoted 10 lines · Doug Ledford
The scsi mid layer will never send you more than
host->can_queuecommands at one time, so why do all the scsi driver authors feel it is necessary to split their queue depth up amongst devices? Justin Gibbs is the only one that gets it right IMHO. Set the depth on each device as deep as that device can take (if that happens to behost->can_queue- 1 or such, then so be it). Then, let the mid layer and the request function worry about fairness across devices. That's its job after all. If everyone is going to moderate their queue depths like that, then we might as well yankcan_queueout of the host struct entirely because *it serves no purpose*.
Quoted 9 lines
Now, simple scsi controllers like the aic7xxx and intelligent raid controllers are two different beasts. On simple controllers, the max queue depth on a target is typically whatever that target can handle. On raid controllers, it's all up to what the firmware can handle (for all I know, the ServeRAID firmware may have one queue depth limit for total commands and a separate queue depth limit on each logical device). So, I can't say for sure what the ips driver can and can't do, but I'm relatively sure that you are artificially limiting your own performance by handling queue depths the way you are.
I totally agree the queue depth should not be limited based on the number of devices, but there should be a maximum limit - as Justin noted with the aic driver, using a large default queue depth (he had 253 or so) is not good with linux.
The queue depth should be as small as possible without limiting the performance.
-- Patrick Mansfield
Re: [patch 2.5] ips queue depths
Quoted 5 lines · Patrick Mansfield
I totally agree the queue depth should not be limited based on the number of devices, but there should be a maximum limit - as Justin noted with the aic driver, using a large default queue depth (he had 253 or so) is not good with linux.
That's largely due to the scsi_request_fn() in its current form.
Quoted 2 lines
The queue depth should be as small as possible without limiting the performance.
Which happens to be a magic number that no one really knows I think ;-) Current goals of the work I'm doing include making this adjustable so you aren't wasting queue depth on devices that have a hard limit less than your initial queue depth value and changing the scsi_request_fn() to be more fair with command allocation on a controller in the presence of starvation (and of course, starvation is only possible when the queue depth of all devices is greater than the depth of the controller, so obviously the starvation code in scsi_request_fn() is something controllers have been avoiding by limiting queue depths on individual devices).
The adjustable queue depth work has been mostly done and sent to linus. I'm trying to finish up the last few controllers that haven't been modified to the new scheme yet. The request_fn work is on hold until this is done (because the breakage made everyone moan so loadly that I dropped everything else until this is taken care of).
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
Re: [patch 2.5] ips queue depths
Quoted 8 lines · Doug Ledford
Quoted 5 lines · Patrick Mansfield
I totally agree the queue depth should not be limited based on the number of devices, but there should be a maximum limit - as Justin noted with the aic driver, using a large default queue depth (he had 253 or so) is not good with linux.
That's largely due to the
scsi_request_fn()in its current form.
I don't understand that.
Quoted 5 lines
Quoted 3 lines
The queue depth should be as small as possible without limiting the performance.
Which happens to be a magic number that no one really knows I think ;-)
Yes, but that implies that adapters should not be relied upon to set the queue depth. If the adapter is setting queue depth based upon what the adapter knows, that is completely wrong - a regular disk and disk array can end up with the same queue depth (this is not ture for raid cards like ips, where the adapter is the device).
Quoted 2 lines
Current goals of the work I'm doing include making this adjustable so you aren't wasting queue depth on devices that have a hard limit less than
But, this won't lower it to some optimal magic number.
Quoted 7 lines
your initial queue depth value and changing the
scsi_request_fn()to be more fair with command allocation on a controller in the presence of starvation (and of course, starvation is only possible when the queue depth of all devices is greater than the depth of the controller, so obviously the starvation code inscsi_request_fn()is something controllers have been avoiding by limiting queue depths on individual devices).
It would nice to have more device model/kernfs device attributes.
With your new queueing code, if we expose and allow setting new_queue_depth, user code can easily modify the queue depth.
I wanted to write some code in this area but don't have enoough time. It would not be hard to have a scsi_sdev_attrs.c file, that using macros could automagically create device attr files and functions for any selection of Scsi_Device fields. Locking might be an issue - since we don't have a Scsi_Device lock for queue depth, just one big lock, this is true for some of the other Scsi_Device fields.
A single function could be called in scsi_scan.c to setup all Scsi_Device device attribute files (i.e. calls device_create_file for multiple xxx_attr_types).
-- Patrick Mansfield
Re: [patch 2.5] ips queue depths
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
The queue depth should be as small as possible without limiting the performance.
Which happens to be a magic number that no one really knows I think ;-)
Yes, but that implies that adapters should not be relied upon to set the queue depth. If the adapter is setting queue depth based upon what the adapter knows, that is completely wrong - a regular disk and disk array can end up with the same queue depth (this is not ture for raid cards like ips, where the adapter is the device).
If I'm reading this correctly, does this bash the ability to set the queue depth by the LLDD?
This ability is ESSENTIAL, especially in the light of newer devices coming into play. E.g. just imagine what kind of storage magic you can do with an iSCSI Initiator(*) connected to fiber using LUN masking... and setting the queue depth to 50 would be just <your fav. methaphor>.
* This of course uses 64 bit LUN transparently (as an interconnect)...
Quoted 4 lines
Quoted 2 lines
Current goals of the work I'm doing include making this adjustable so you aren't wasting queue depth on devices that have a hard limit less than
But, this won't lower it to some optimal magic number.
No, it won't. But that is NOT the point.
All he is saying is that it will allow for the MECHANISM, and leave the policy to some other entity/entities to decide...
As far as I remember THIS is the whole beauty of the UNIX/Linux paradigm.
Quoted 4 lines
It would nice to have more device model/kernfs device attributes.
With your new queueing code, if we expose and allow setting
new_queue_depth, user code can easily modify the queue depth.
Not bloody likely. To use the language of the other LT, this would be ``braindead''.
Linux is not a research project for someone to write a shell script and expriment with different device tag queue depths from user space.
This will KILL the whole point of the matter. This should be a kernel issue.
This is the whole point of having and Operating System, (pause) and having Device Drivers.
User space should NOT be concerned about this at all.
This is a kernel issue and the more you give userspace to play with kernel issues the more the OS will degrade. That is, the user/kernel space border should be clearly marked, so that both sides are happy.
If you don't believe me, ask Linus.
Quoted 6 lines
I wanted to write some code in this area but don't have enoough time. It would not be hard to have a
scsi_sdev_attrs.cfile, that using macros could automagically create device attr files and functions for any selection ofScsi_Devicefields. Locking might be an issue - since we don't have aScsi_Devicelock for queue depth, just one big lock, this is true for some of the otherScsi_Devicefields.
Overengineering would not lead to good things, definitely not. On the long run, and given the fact that so many subsystems come into play.
Let's keep the SCSI subsystem lean and clean, else the other block subsystem's path awaits us...
Signature · 1 line
Luben
Re: [patch 2.5] ips queue depths
In reply to Patrick MansfieldQuoted 11 lines · Patrick Mansfield
Quoted 8 lines · Doug Ledford
Quoted 5 lines · Patrick Mansfield
I totally agree the queue depth should not be limited based on the number of devices, but there should be a maximum limit - as Justin noted with the aic driver, using a large default queue depth (he had 253 or so) is not good with linux.
That's largely due to the
scsi_request_fn()in its current form.I don't understand that.
The current scsi_request_fn() sucks rocks when it comes to any sort of fair load balancing in a host queue starvation scenario.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The queue depth should be as small as possible without limiting the performance.
Which happens to be a magic number that no one really knows I think ;-)
Yes, but that implies that adapters should not be relied upon to set the queue depth.
I draw exactly the opposite conclusion (look at the email from Lubon Tuikov for several valid reasons why).
Quoted 2 lines
If the adapter is setting queue depth based upon what the adapter knows, that is completely wrong
I strongly disagree here. Only the adapter driver knows if the card itself has a hard limit of X commands at a time (so that deeper queues are wasted). Only the adapter driver knows if the particular interconnect has any inherent queue limitations or speed limitations. There are a thousand things only the adapter driver knows that should be factored into a sane queue depth.
Quoted 3 lines
- a regular disk and disk
array can end up with the same queue depth (this is not ture for raid cards like ips, where the adapter is the device).
I don't see a problem here. I have yet to meet a reasonable SCSI disk that doesn't do well with deep queues. Raid devices I'm not so sure of, but I'll give them the benefit of the doubt and let them have a deep queue as well. I would say the maximum speed of the interconnect combined with the maximum size of each command is a better guage upon which to determine queue depth than whether it's a real disk or logical disk.
Quoted 4 lines
Quoted 2 lines
Current goals of the work I'm doing include making this adjustable so you aren't wasting queue depth on devices that have a hard limit less than
But, this won't lower it to some optimal magic number.
No, the controller driver in question should already have it's "optimum" number in mind, set the drive to that, then if it's too high it can come down. There is no magical "Hey, send me more commands" status code, so you have to start high and go low, not the other way around. That, of course, is why an adjustable depth is important. The controller should set this "optimum" number based upon it's own capabilities and assume the drive is just as capable.
Quoted 8 lines
Quoted 7 lines
your initial queue depth value and changing the
scsi_request_fn()to be more fair with command allocation on a controller in the presence of starvation (and of course, starvation is only possible when the queue depth of all devices is greater than the depth of the controller, so obviously the starvation code inscsi_request_fn()is something controllers have been avoiding by limiting queue depths on individual devices).
Quoted 4 lines
It would nice to have more device model/kernfs device attributes.
With your new queueing code, if we expose and allow setting
new_queue_depth, user code can easily modify the queue depth.
No. For the reasons that the driver knows what it's capable of, there really is *very* little tunability here. But, should you really need it, the drivers should provide it (both mine and Justin's aic7xxx drivers do so run time via module options or boot command options). Make the default a good common default, let users override if necessary. But I wouldn't make it a fiddle knob that people can tweak without thinking. Regardless of where you make it adjustable though, it has to be passed through the low level drivers so that they can adjust their internal data structs as needed (some won't have to do anything, some will have to do allocations or frees on every adjustment, so you *have* to pass all adjustments through them).
Quoted 16 lines
I wanted to write some code in this area but don't have enoough time. It would not be hard to have a
scsi_sdev_attrs.cfile, that using macros could automagically create device attr files and functions for any selection ofScsi_Devicefields. Locking might be an issue - since we don't have aScsi_Devicelock for queue depth, just one big lock, this is true for some of the otherScsi_Devicefields.A single function could be called in
scsi_scan.cto setup allScsi_Devicedevice attribute files (i.e. callsdevice_create_filefor multiplexxx_attr_types).-- Patrick Mansfield
-
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
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
Re: [patch 2.5] ips queue depths
Quoted 11 lines · Doug Ledford
Quoted 2 lines · Patrick Mansfield
If the adapter is setting queue depth based upon what the adapter knows, that is completely wrong
I strongly disagree here. Only the adapter driver knows if the card itself has a hard limit of X commands at a time (so that deeper queues are wasted). Only the adapter driver knows if the particular interconnect has any inherent queue limitations or speed limitations. There are a thousand things only the adapter driver knows that should be factored into a sane queue depth.
OK, the adapter does not get it completely wrong, but it does not know about special scsi device limitations, block layer limits, usage patterns, or total number of scsi devices on the system.
Your changes (set high, adjust lower as we hit queue fulls) should work fine in most cases, and is much better than the previous state.
Some example cases where we might want to lower queue depth:
System with small amounts of memory compared to the number of devices.
With many disks on a system, some with a very light load, it could be give the lightly loaded disks a lower queue depth so they use less memory, or so they can do less IO.
In a 2 node cluster with shared devices, the queue depth could be set to half of some hard limit on each node of the cluster, and avoid hitting any hard queue fulls.
(It would really nice if we could modify the number of struct request's allocated for little used or unused devices, or on character devices like tape that don't even use the requests. Current block code allocates 2*128 of these on systems with lots of memory, this could save way more space than lowering the queue depth.)
Quoted 5 lines
Quoted 4 lines
It would nice to have more device model/kernfs device attributes.
With your new queueing code, if we expose and allow setting
new_queue_depth, user code can easily modify the queue depth.
Quoted 11 lines
No. For the reasons that the driver knows what it's capable of, there really is *very* little tunability here. But, should you really need it, the drivers should provide it (both mine and Justin's aic7xxx drivers do so run time via module options or boot command options). Make the default a good common default, let users override if necessary. But I wouldn't make it a fiddle knob that people can tweak without thinking. Regardless of where you make it adjustable though, it has to be passed through the low level drivers so that they can adjust their internal data structs as needed (some won't have to do anything, some will have to do allocations or frees on every adjustment, so you *have* to pass all adjustments through them).
I was suggesting a common interface via a Scsi_Device device attribute so the default depth can be modified as needed, rather than a fixed boot or module load option that is fixed (once the driver is loaded) and might be a different option for every adapter driver.
It's too bad we can't modify new_queue_depth and have all the layers (well mid and lower) adjust accordingly.
-- Patrick Mansfield
Re: [patch 2.5] ips queue depths
Quoted 13 lines · Patrick Mansfield
Quoted 11 lines · Doug Ledford
Quoted 2 lines · Patrick Mansfield
If the adapter is setting queue depth based upon what the adapter knows, that is completely wrong
I strongly disagree here. Only the adapter driver knows if the card itself has a hard limit of X commands at a time (so that deeper queues are wasted). Only the adapter driver knows if the particular interconnect has any inherent queue limitations or speed limitations. There are a thousand things only the adapter driver knows that should be factored into a sane queue depth.
Quoted 3 lines
OK, the adapter does not get it completely wrong, but it does not know about special scsi device limitations, block layer limits, usage patterns, or total number of scsi devices on the system.
All of these are special cases. Scsi device limitations it will learn (that's the go lower part ;-), block layer limits need to be addressed (by changing the block layer to know about our queue depth requirements is my preferred way of doing things, I would like to see the block layer adjust the request queue depth whenever we adjust our queue depth, but I'm not sure what this would take at this point in time), usage patterns are something only an admin could reasonably tell us ("Hey, this disk is only used for temporary storage when streaming to tape, so it only needs miniscule resources" is valid, but special, and trying to write a default for this scenario isn't feasible), and total number of scsi devices on the system is learnable, but I don't think we should change our defaults over it (especially since hot plug devices makes this a dubious distinction at best, I think the better default is to assume that any machine with some huge number of drives attached via SCSI is likely a huge machine and that the relatively small X kilobytes of data we allocate statically per drive is OK, the aic7xxx_old driver allocates 1k +- for each command, with a maximum of 255 commands per controller regardless of total device queue depth on that controller, so a maximum of 256K per controller right now, so 100 drives on 10 controllers would be a maximum of 2.5MB of RAM, and any machine with 100 disks shouldn't balk at 2.5MB of aic7xxx_old data structs, how much data is allocated in the block layer and mid layer is not a figure I have at hand though).
Quoted 2 lines
Your changes (set high, adjust lower as we hit queue fulls) should work fine in most cases, and is much better than the previous state.
Good, then we agree ;-)
Quoted 7 lines
Some example cases where we might want to lower queue depth:
System with small amounts of memory compared to the number of devices.
With many disks on a system, some with a very light load, it could be give the lightly loaded disks a lower queue depth so they use less memory, or so they can do less IO.
Both of these are strong candidates for proper admin setup IMHO.
Quoted 3 lines
In a 2 node cluster with shared devices, the queue depth could be set to half of some hard limit on each node of the cluster, and avoid hitting any hard queue fulls.
Maybe, but what if you want each node to be able to reach maximum performance under peak conditions and then fall back during more relaxed times? This is the same sort of thing that all of our controllers have been doing in the past by limiting the queue depth of all devices on a controller to the controllers maximum depth and I contend it's a false optimization. It permanently lowers the peak performance of each machine for fear that you might have contention for the device's queue instead of simply acting reasonable in the presence of QUEUE_FULL return codes.
Quoted 5 lines
(It would really nice if we could modify the number of struct request's allocated for little used or unused devices, or on character devices like tape that don't even use the requests. Current block code allocates 2*128 of these on systems with lots of memory, this could save way more space than lowering the queue depth.)
This I agree with 1000% and is on my list of things to investigate.
Quoted 7 lines
I was suggesting a common interface via a
Scsi_Devicedevice attribute so the default depth can be modified as needed, rather than a fixed boot or module load option that is fixed (once the driver is loaded) and might be a different option for every adapter driver.It's too bad we can't modify
new_queue_depthand have all the layers (well mid and lower) adjust accordingly.
Well, I don't have any objection to being able to modify queue depths. However, the current problem is that none of the device drivers have the ability to accept events that tell them to change their queue depth on a device. Instead, they all want to tell the mid layer what queue depth to use. Now, because we can't just blindly shove more commands into a driver than it's expecting, you can't up the queue depth without telling the driver (lowering it is probably safe, although it is wasteful of allocated structs in memory). As it stands, the mid layer *would* honor changing new_queue_depth.
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
Re: [patch 2.5] ips queue depths
In reply to Patrick MansfieldQuoted 5 lines · Patrick Mansfield
OK, the adapter does not get it completely wrong, but it does not know about special scsi device limitations, block layer limits, usage patterns, or total number of scsi devices on the system.
This is the dependency graph:
block layer <-- SCSI core <-- SCSI LLDD.
where ``A <-- B'', means ``A depends on B''.
That is, the block layer (as an UPPER LAYER) should change its parameters as suggested by the lower layers, since they operate closer to the real devices, and NOT the other way around, as has been suggested so many times here. (The whole point of an OS.)
That is, should should NOT force the device and you should NOT restrain the device.
Also involving the elevator algorithm, merging, etc, is not appropriate when we talk about such things as TCQ depths, just because those notions belong to a different layer (upper at that).
Quoted 12 lines
Some example cases where we might want to lower queue depth:
System with small amounts of memory compared to the number of devices.
With many disks on a system, some with a very light load, it could be give the lightly loaded disks a lower queue depth so they use less memory, or so they can do less IO.
In a 2 node cluster with shared devices, the queue depth could be set to half of some hard limit on each node of the cluster, and avoid hitting any hard queue fulls.
Quoted 6 lines
(It would really nice if we could modify the number of struct request's allocated for little used or unused devices, or on character devices like tape that don't even use the requests. Current block code allocates 2*128 of these on systems with lots of memory, this could save way more space than lowering the queue depth.)
Valid point, but what kind of memory allocator are you thinking of?
I'm thinking more of the lines of, what was once suggested by Doug, a pool of the objects and if we need one, just unhook it from its struct list_head (great solution), and use it... (search linux-scsi for the exact message)
That is, the queue becomes just a NUMBER, an int if you like, and the resource management is centralized, thus wasting LESS resources, as resource users increases (OS 101).
Now let's take this step further, and _delegate_. Let's give resource management to the lookaside cache (kmem_cache_create() and friends) and let that (the) resource manager worry about whether it uses struct list_head, or what not and how many pages it has preallocated and what not, and if we have a problem with how fast or what not, we can get in touch with its maintainers. (Though I've used that solution in my drivers and I get _excellent_ performance.)
So you see, the tagged device queue itself would be a number rather than wasted resources.
Quoted 4 lines
I was suggesting a common interface via a
Scsi_Devicedevice attribute so the default depth can be modified as needed, rather than a fixed boot or module load option that is fixed (once the driver is loaded) and might be a different option for every adapter driver.
This discussion should be dropped already.
Just imagine what would happen if a SCSI LLDD suddently finds out that its tagged device queue depth has been changed, what is it supposed to do?
Furthermore, you say ``so the default depth can be modified as needed'', which contradicts the meaning of ``default''.
In fact the default setting wouldn't play much, and would be quickly forgotten as soon as the driver is run and disk/devices are connected to it. So in this respect it has little significance.
Even if you have little memory (thin client) it makes sense to have a TCQ depth of 200 if you're connected to a monster storage system, since if you send 200 tagged commands to /dev/sda they may NOT necessarily go to one ``device''. Imagine that!
Signature · 1 line
Luben
Re: [patch 2.5] ips queue depths
Quoted 19 lines · Luben Tuikov [[email protected]] wrote:
Valid point, but what kind of memory allocator are you thinking of?
I'm thinking more of the lines of, what was once suggested by Doug, a pool of the objects and if we need one, just unhook it from its struct
list_head(great solution), and use it... (search linux-scsi for the exact message)That is, the queue becomes just a NUMBER, an int if you like, and the resource management is centralized, thus wasting LESS resources, as resource users increases (OS 101).
Now let's take this step further, and _delegate_. Let's give resource management to the lookaside cache (
kmem_cache_create()and friends) and let that (the) resource manager worry about whether it uses structlist_head, or what not and how many pages it has preallocated and what not, and if we have a problem with how fast or what not, we can get in touch with its maintainers. (Though I've used that solution in my drivers and I get _excellent_ performance.)
Quoted 3 lines
So you see, the tagged device queue itself would be a number rather than wasted resources.
I assume all devices will be guaranteed a min of the poll otherwise under memory pressure we could be unable to do IO on swap devices.
Quoted 8 lines
This discussion should be dropped already.
Just imagine what would happen if a SCSI LLDD suddently finds out that its tagged device queue depth has been changed, what is it supposed to do?
Furthermore, you say ``so the default depth can be modified as needed'', which contradicts the meaning of ``default''.
Quoted 8 lines
In fact the default setting wouldn't play much, and would be quickly forgotten as soon as the driver is run and disk/devices are connected to it. So in this respect it has little significance.
Even if you have little memory (thin client) it makes sense to have a TCQ depth of 200 if you're connected to a monster storage system, since if you send 200 tagged commands to
/dev/sdathey may NOT necessarily go to one ``device''. Imagine that!
Just because a device can accept a command and not return busy does not mean it is always a good thing to give it 200 commands. Most larger arrays will have dynamic queue depths and accept a lot of IO without really working on it. If the delta of time is increasing on your IO than at some point you are inefficient. We have already seen on some adapters that reducing the queue depths achieved the same amount of IO rate with reduced CPU overhead. Which is a good thing as users usally want to do something else besides IO.
If you are using shared resources (i.e. sg_table pool mem, the above suggested scsi command poll, timers, etc) to avoid resource starvation you might need to set limits outside of what a single LLDD believes is best. More efficient implementations would also reduce some of the overhead.
A administrator may want to adjust the overall policy for a specific work load. Maybe proper values can be set and feedback information can allow self adjustment, but there are probably workloads that the values are incorrect. What that policy is would depend on the resources. Something similar to vm adjustments.
-andmike
--
Michael Anderson
[email protected]
Re: [patch 2.5] ips queue depths
Quoted 7 lines · Mike Anderson
Quoted 4 lines · Luben Tuikov [[email protected]] wrote:
Even if you have little memory (thin client) it makes sense to have a TCQ depth of 200 if you're connected to a monster storage system, since if you send 200 tagged commands to
/dev/sdathey may NOT necessarily go to one ``device''. Imagine that!
Quoted 8 lines
Just because a device can accept a command and not return busy does not mean it is always a good thing to give it 200 commands. Most larger arrays will have dynamic queue depths and accept a lot of IO without really working on it. If the delta of time is increasing on your IO than at some point you are inefficient. We have already seen on some adapters that reducing the queue depths achieved the same amount of IO rate with reduced CPU overhead. Which is a good thing as users usally want to do something else besides IO.
I repeat again: those commands will NOT go to the same device, but after tier one, they'll be sent out to different devices and probably execute concurrently, and come back out of order, at which point the interconnect will (may) order them, before returning status.
Quoted 11 lines
If you are using shared resources (i.e.
sg_tablepool mem, the above suggested scsi command poll, timers, etc) to avoid resource starvation you might need to set limits outside of what a single LLDD believes is best. More efficient implementations would also reduce some of the overhead.A administrator may want to adjust the overall policy for a specific work load. Maybe proper values can be set and feedback information can allow self adjustment, but there are probably workloads that the values are incorrect. What that policy is would depend on the resources. Something similar to vm adjustments.
Cannot comment on general statements like this.
A more concrete example would be needed.
Signature · 1 line
Luben
Re: [patch 2.5] ips queue depths
In reply to Doug LedfordQuoted 4 lines · Doug Ledford [[email protected]] wrote:
I actually sent a patch to linus already to do this but it hasn't come through yet. However, my patch and yours differ in one key point that I don't understand.
Quoted 13 lines
The scsi mid layer will never send you more than
host->can_queuecommands at one time, so why do all the scsi driver authors feel it is necessary to split their queue depth up amongst devices? Justin Gibbs is the only one that gets it right IMHO. Set the depth on each device as deep as that device can take (if that happens to behost->can_queue- 1 or such, then so be it). Then, let the mid layer and the request function worry about fairness across devices. That's its job after all. If everyone is going to moderate their queue depths like that, then we might as well yankcan_queueout of the host struct entirely because *it serves no purpose*. commands and a separate queue depth limit on each logical device). So, I can't say for sure what the ips driver can and can't do, but I'm relatively sure that you are artificially limiting your own performance by handling queue depths the way you are.
I never seen the mid layer handle device starvation correctly. It might be because in scsi_queue_next_request we do this:
/*
* Just hit the requeue function for the queue.
*/
q->request_fn(q);
before we check for starved.
-andmike
--
Michael Anderson
[email protected]
Re: [patch 2.5] ips queue depths
Quoted 9 lines · Mike Anderson
I never seen the mid layer handle device starvation correctly. It might be because in
scsi_queue_next_requestwe do this:/*
* Just hit the requeue function for the queue.
*/
q->request_fn(q);before we check for starved.
Don't pay too much attention to the junk that's there now...
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
Re: [patch 2.5] ips queue depths
In reply to Doug LedfordStyle question below.
drivers/scsi/ips.h line 489
Quoted 10 lines · Doug Ledford [[email protected]] wrote:
drivers/scsi/ips.h +2
-1@@ -481,7 +482,8 @@ eh_host_reset_handler : ips_eh_reset, \ abort : NULL, \ reset : NULL, \ - slave_attach : NULL, \ + slave_attach : ips_slave_attach, \ + slave_detach : NULL, \ bios_param : ips_biosparam, \ can_queue : 0, \ this_id: -1, \
Can we stop setting struct members to NULL. If we later change the interface it makes the patch just that much larger.
-andmike
--
Michael Anderson
[email protected]
Re: [patch 2.5] ips queue depths
Quoted 16 lines · Mike Anderson
Style question below.
drivers/scsi/ips.h line 489
Quoted 10 lines · Doug Ledford [[email protected]] wrote:
drivers/scsi/ips.h +2
-1@@ -481,7 +482,8 @@ eh_host_reset_handler : ips_eh_reset, \ abort : NULL, \ reset : NULL, \ - slave_attach : NULL, \ + slave_attach : ips_slave_attach, \ + slave_detach : NULL, \ bios_param : ips_biosparam, \ can_queue : 0, \ this_id: -1, \Can we stop setting struct members to NULL. If we later change the interface it makes the patch just that much larger.
Sure, I don't care.
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606
Re: [patch 2.5] ips queue depths
In reply to Doug LedfordQuoted 11 lines · Doug Ledford
The scsi mid layer will never send you more than
host->can_queuecommands at one time, so why do all the scsi driver authors feel it is necessary to split their queue depth up amongst devices? Justin Gibbs is the only one that gets it right IMHO. Set the depth on each device as deep as that device can take (if that happens to behost->can_queue- 1 or such, then so be it). Then, let the mid layer and the request function worry about fairness across devices. That's its job after all. If everyone is going to moderate their queue depths like that, then we might as well yankcan_queueout of the host struct entirely because *it serves no purpose*. [...]
I agree with Doug on the functionality splitting. Regarding bashing SCSI core that it doesn't handle the device q's (starvation) properly: nevertheless it is _its_ function to do so and this should be observed. Soon enough it will get it right.
There should be a functionality split and LLDD should abide by it -- in the worst case, LLDD can play with the max tagged cmnds number.
Re. bashing the too large a number of tags allowed -- this actually makes sense sometimes -- e.g. an iSCSI Initiator wants to have as many tagged commands under its control rather than they be waiting in SCSI core. If the mid layer has a problem with a scsi tagged command, then it can notify the LLDD and it will resolve this (*** please see my next Q. posting ***).
Statements like this: ``The queue depth should be as small as possible without limiting the performance.'' cannot be generalized to all devices, be it hardware or software emulations (YKWIM).
Signature · 1 line
Luben
Re: [patch 2.5] ips queue depths
Quoted 11 lines · Luben Tuikov
Re. bashing the too large a number of tags allowed -- this actually makes sense sometimes -- e.g. an iSCSI Initiator wants to have as many tagged commands under its control rather than they be waiting in SCSI core. If the mid layer has a problem with a scsi tagged command, then it can notify the LLDD and it will resolve this (*** please see my next Q. posting ***).
Statements like this: ``The queue depth should be as small as possible without limiting the performance.'' cannot be generalized to all devices, be it hardware or software emulations (YKWIM).
I'm saying don't set the queue depth really high when it gives no or very little performance gain. If an adapter driver finds that a large queue depth helps more than it hurts for all IO loads (for sequential as well as random IO), go ahead, but I would guess that queue depths over 100 give zero or very little performance gain compared to a queue depth of say 50 for most devices. I was trying to run some tests on this in the past but never had time to get it working well, plus it would have been for only two different devices (disk and disk array), and the drives I have are not really fast (20 mb/sec for disk, about 50mb/sec for the disk array).
What is really needed are IO performance numbers for varying queue depths.
With 2.5, the number of commands outstanding to the device is not subtracted from the blk request queue size (we don't release a blk request until the IO is completed, there is no call to blkdev_release_request in scsi_request_fn) - this means large queue depths will cause the blk request queue to fill up and even be full without any available blk request queue commands to merge or sort with.
There are also issues like Andrew had with the read latency - although his benchmark is aritificial, and has more to do with too many dirty pages, it still showed that higher queue depths can have an impact on interactive performance (i.e. read latencies).
-- Patrick Mansfield
Re: [patch 2.5] ips queue depths
Quoted 11 lines · Patrick Mansfield
I'm saying don't set the queue depth really high when it gives no or very little performance gain. If an adapter driver finds that a large queue depth helps more than it hurts for all IO loads (for sequential as well as random IO), go ahead, but I would guess that queue depths over 100 give zero or very little performance gain compared to a queue depth of say 50 for most devices. I was trying to run some tests on this in the past but never had time to get it working well, plus it would have been for only two different devices (disk and disk array), and the drives I have are not really fast (20 mb/sec for disk, about 50mb/sec for the disk array).
Ok, this may work, now and here, but then and there it doesn't have to.
Predicting on a number, say 100, is speculation at best. What if the initiator is connected to fiber which is connected to another, etc. And what if /dev/sda is an iSCSI initiator, connected to a bunch of targets, which are arrays on another fiber...
You see, 100 means nothing anymore. That is sending 200 tagged commands will NOT go to the same ``device''... (your imagination here)
The SCSI LLDD, being the gate to the interconnect/transport, knows best, and has at its disposal features/abilities not easily exportable to ULP/userland. Thus, it has the ability to at least hint at some number, being the device queue depth.
Quoted 1 line
What is really needed are IO performance numbers for varying queue depths.
Yep, this is what you give your boss... (Essay topic for next Thursday :-))
But tomorrow, someone has decided to just change one little iota in the code and those same numbers are out the window (just as has recently happened). That is, this wouldn't work here.
Those numbers would of course depend on each subsystem getting it ``right'', and the dependent variables become too many.
Thus, in my experience (and it is my opinion) it is best to approach matters like this from an academic/reasearch point of view -- that is, we are speaking of a _general_ architecture, and not of a few empirical tests, hinting at 10 five line patches.
Quoted 6 lines
With 2.5, the number of commands outstanding to the device is not subtracted from the blk request queue size (we don't release a blk request until the IO is completed, there is no call to
blkdev_release_requestinscsi_request_fn) - this means large queue depths will cause the blk request queue to fill up and even be full without any available blk request queue commands to merge or sort with.
Yes, ok, so we are involving the block layer, which can/should/may change tomorrow BUT the SCSI core should/may not have to -- this would mean that it's doing a great job. (cont'd below)
Quoted 4 lines
There are also issues like Andrew had with the read latency - although his benchmark is aritificial, and has more to do with too many dirty pages, it still showed that higher queue depths can have an impact on interactive performance (i.e. read latencies).
Right! Meaning that the issue is/was elsewhere all along.
So if we involve the block layer too much, and tomorrow someone finds out something was broken there, we SHOULD NOT HAVE TO change the SCSI core. This would mean a fairly independent implementation (being a subsystem), which implies general structrure, which implies research.
While it is good to look at who's below us and above us (SCSI core), depending too much on their particulars is not generally a good investment.
((All this of course implies that SCSI Core would be quite minimal.))
Signature · 1 line
Luben
Re: [patch 2.5] ips queue depths
In reply to Doug LedfordQuoted 4 lines · Doug Ledford [[email protected]] wrote:
ha = IPS_HA(SDptr->host);drivers/scsi/ips.c +0
-2- min = ha->max_cmds /4 ; -if (min <8 )
drivers/scsi/ips.c line 1889
Quoted 10 lines
drivers/scsi/ips.c +6
-2- min = ha->max_cmds -1 ; -scsi_adjust_queue_depth (SDptr,MSG_ORDERED_TAG , min); +if (SDptr->tagged_supported) { + min = ha->max_cmds /2 ; +if (min <=16 ) + min = ha->max_cmds -1 ; +scsi_adjust_queue_depth (SDptr,MSG_ORDERED_TAG , min); + }return 0 ; }
Doug,
Sorry I did not get on to checking your version of this patch sooner.
I did check 2.5.44 which includes your patched version of ips.c. I am seeing only a queue depth of 1.
The reason is that the SERVERAID disks are virutal and the inquiry data they send back does is generated in the driver. The inq data does not have the CmdQue bit set which results in tagged_supported not being set.
Either the slave_attached code will need to change or the driver will need to start setting CmdQue.
Output for ServeRAID:
PQual=0, Device type=0, RMB=0, ANSI version=2, [full version=0x02] AERC=0, TrmTsk=0, NormACA=0, HiSUP=0, Resp data format=2, SCCS=0 BQue=0, EncServ=0, MultiP=0, MChngr=0, ACKREQQ=0, Addr16=1 RelAdr=0, WBus16=1, Sync=1, Linked=0, TranDis=0, CmdQue=0 length=36 (0x24)
Vendor identification: IBM
Product identification: SERVERAID
Product revision level: 1.00
-andmike
--
Michael Anderson
[email protected]
Re: [patch 2.5] ips queue depths
Quoted 20 lines · Mike Anderson
Quoted 4 lines · Doug Ledford [[email protected]] wrote:
ha = IPS_HA(SDptr->host);drivers/scsi/ips.c +0
-2- min = ha->max_cmds /4 ; -if (min <8 )drivers/scsi/ips.c line 1889
Quoted 10 lines
drivers/scsi/ips.c +6
-2- min = ha->max_cmds -1 ; -scsi_adjust_queue_depth (SDptr,MSG_ORDERED_TAG , min); +if (SDptr->tagged_supported) { + min = ha->max_cmds /2 ; +if (min <=16 ) + min = ha->max_cmds -1 ; +scsi_adjust_queue_depth (SDptr,MSG_ORDERED_TAG , min); + }return 0 ; }Doug,
Sorry I did not get on to checking your version of this patch sooner.
Quoted 6 lines
I did check 2.5.44 which includes your patched version of
ips.c. I am seeing only a queue depth of 1.The reason is that the SERVERAID disks are virutal and the inquiry data they send back does is generated in the driver. The inq data does not have the CmdQue bit set which results in
tagged_supportednot being set.
Yeah, David Jeffery of Adaptec (the current maintainer of the ips driver) already sent a fix for this to Linus, so it should be in 2.5.44 I think. If not, let me know and I'll add it to my queue I'm preparing for when Linus comes back.
Signature · 4 lines
Doug Ledford <[email protected]> 919-754-3700 x44233 Red Hat, Inc. 1801 Varsity Dr. Raleigh, NC 27606