PATCH: Enhance queueing/scsi-midlayer to handle kiobufs. [Re: Request splits]
Subsystems (5)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
Quoted 2 lines · Chaitanya Tumuluri
I've had the same question in my mind. I've also wondered why raw I/O was restricted to only
KIO_MAX_SECTORSat a time.
Mainly for resource limiting --- you don't want to have too much user memory pinned permanently at once.
The real solution is probably not to increase the atomic I/O size, but rather to pipeline I/Os. That is planned for the future, and now there are other people interested in it, I'll bump that work up the queue a bit! The idea is to allow brw_kiovec to support fully async operation, and for the raw device driver to work with multiple kiobufs. That way we can keep 2 or 3 kiobufs streaming at all times, eliminating the stalls between raw I/O segments, without having to increase the max segment size.
In the future we'll also need to charge these I/Os against a per-user limit on pinned memory to control resources. We can't really offer O_DIRECT I/O to unprivileged user processes until we have eliminated that possible DOS attack. Right now raw devices can only be created by root and are protected by normal filesystem modes, so we don't have too much of a problem.
Quoted 3 lines
So, I enhanced Stephen Tweedie's
raw I/O and the queueing/scsi layers to handle kiobufs-based requests. This is in addition to the currentbuffer_headbased request processing.
The "current" kiobuf code is in ftp.uk.linux.org:/pub/linux/sct/fs/raw-io/. It includes a number of bug fixes (mainly rationalising the error returns), plus a few new significant bits of functionality. If you can get me a patch against those diffs, I'll include your new code in the main kiobuf patchset. (I'm still maintaining the different kiobuf patches as separate patches within that patchset tarball.)
Quoted 3 lines
Thus,
ll_rw_blk.chas two new functions:
oll_rw_kio()
o__make_kio_request()
Oh, *thankyou*. This has been needed for a while.
Quoted 5 lines
Here's the patch against a 2.3.99-pre2 kernel. To recap, two primary reasons for this patch:
1. To enhance the queueing and scsi-mid layers to handle kiobuf-based requests as well,
Quoted 7 lines
2. Remove request size limits on the upper layers (above
ll_rw_blk.c). TheKIO_MAX_SECTORSseems to have been inspired byMAX_SECTORS(128 per request) inll_rw_blk.c. The scsi mid-layer should handle `oversize' requests based on the HBAsg_tablesize.I'm not too sure about 2. above; so I'd love to hear from more knowledgeable people on that score.
It shouldn't be too much of a problem to retain this limit if the brw_kiovec code can stream properly.
Quoted 1 line
I'd highly appreciate any feedback before I submit this patch `officially'.
There needs to be some mechanism for dealing with drivers which do not have kiobuf request handling implemented.
I also think that the code is too dependent on request->buffer. We _really_ need to treat this as an opportunity to eliminate that field entirely for kiobuf-based I/Os. kiobufs refer to struct page *s, not individual data pointers, and so they can easily represent pages above the 4GB limit on large memory machines using PAE36. If we want to be able to add dual-address-cycle or PCI64 support to the individual scsi drivers at all, then we need to be able to preserve addresses above 4GB, and kiobufs would seem to be a sensible way to do this if we're going to have them in the struct request at all.
--Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Quoted 4 lines · Stephen C. Tweedie
Hi,
On Thu, May 18, 2000 at 12:55:04PM -0700, Chaitanya Tumuluri wrote:
Quoted 8 lines
Quoted 2 lines
I've had the same question in my mind. I've also wondered why raw I/O was restricted to only
KIO_MAX_SECTORSat a time.Mainly for resource limiting --- you don't want to have too much user memory pinned permanently at once.
The real solution is probably not to increase the atomic I/O size, but rather to pipeline I/Os. That is planned for the future, and now there
That really depends on the device characteristics. This Ciprico hardware I've been working with really only performs well if the atomic I/O size is >= 1MB. Once you introduce additional transactions across the bus, your performance drops significantly. I guess it is a tradeoff between latency and bandwidth. Unless you mean the low level device would be handed a vector of kiobufs and it would build a single SCSI request with that vector, then I suppose it would work well but the requests would have to make up a contiguous chunk of drive space.
BAPper
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Hi,
Quoted 10 lines · Brian Pomerantz
Quoted 2 lines
The real solution is probably not to increase the atomic I/O size, but rather to pipeline I/Os. That is planned for the future, and now there
That really depends on the device characteristics. This Ciprico hardware I've been working with really only performs well if the atomic I/O size is >= 1MB. Once you introduce additional transactions across the bus, your performance drops significantly. I guess it is a tradeoff between latency and bandwidth. Unless you mean the low level device would be handed a vector of kiobufs and it would build a single SCSI request with that vector,
ll_rw_block can already do that, but...
Quoted 2 lines
then I suppose it would work well but
the requests would have to make up a contiguous chunk of drive space.
... a single request _must_, by definition, be contiguous. There is simply no way for the kernel to deal with non-contiguous atomic I/Os. I'm not sure what you're talking about here --- how can an atomic I/O be anything else? We can do scatter-gather, but only from scattered memory, not to scattered disk blocks.
--Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Quoted 17 lines · Stephen C. Tweedie
Hi,
Quoted 10 lines · Brian Pomerantz
Quoted 2 lines
The real solution is probably not to increase the atomic I/O size, but rather to pipeline I/Os. That is planned for the future, and now there
That really depends on the device characteristics. This Ciprico hardware I've been working with really only performs well if the atomic I/O size is >= 1MB. Once you introduce additional transactions across the bus, your performance drops significantly. I guess it is a tradeoff between latency and bandwidth. Unless you mean the low level device would be handed a vector of kiobufs and it would build a single SCSI request with that vector,
ll_rw_blockcan already do that, but...
Quoted 9 lines
Quoted 2 lines
then I suppose it would work well but
the requests would have to make up a contiguous chunk of drive space.... a single request _must_, by definition, be contiguous. There is simply no way for the kernel to deal with non-contiguous atomic I/Os. I'm not sure what you're talking about here --- how can an atomic I/O be anything else? We can do scatter-gather, but only from scattered memory, not to scattered disk blocks.
I may just be confused about how this whole thing works still. I had to go change the number of SG segments the QLogic driver allocates and reports to the SCSI middle layer to a larger number otherwise the transaction gets split up and I no longer have a single 1MB transaction but four 256KB transactions. The number of segments it was set to was 32 (8KB * 32 = 256KB). So the question I have is in the end when you do this pipelining, if you don't increase the atomic I/O size, will the device attached to the SCSI bus (or FC) still receive a single request or will it quickly see a bunch of smaller requests? My point is, from my experiments with this RAID device, you will run across situations where it is good to be able to make a single SCSI request be quite large in order to achieve better performance.
BAPper
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Quoted 11 lines · Brian Pomerantz
< stuff snipped >
was set to was 32 (8KB * 32 = 256KB). So the question I have is in the end when you do this pipelining, if you don't increase the atomic I/O size, will the device attached to the SCSI bus (or FC) still receive a single request or will it quickly see a bunch of smaller requests? My point is, from my experiments with this RAID device, you will run across situations where it is good to be able to make a single SCSI request be quite large in order to achieve better performance.
Agreed. And the patch I've suggested to this list does exactly that. It allows you to issue large I/Os and the scsi midlayers will take care of the device sg_tablesize limitations and split/re-issue the large I/O into smaller sg_tablesize I/Os till the entire request is done.
So, the limitation (at least in the rawio path) would only be the HBA sg_tablesize. You wouldn't even have to endure the wait in the request queue, since these multiple sg_tablesize requests would be inserted at the head of the queue and the dispatch function for the queue called immediately (i.e. no _undue_ plugging/unplugging of the device queues).
Cheers,
-Chait.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Quoted 11 lines · Brian Pomerantz
Quoted 10 lines · Stephen C. Tweedie
Hi,
Quoted 6 lines · Brian Pomerantz
Quoted 2 lines
The real solution is probably not to increase the atomic I/O size, but rather to pipeline I/Os. That is planned for the future, and now there
That really depends on the device characteristics. This Ciprico hardware I've been working with really only performs well if the atomic I/O size is >= 1MB. Once you introduce additional transactions
Hmmm... SCSI allows up to 30,000 transactions per second and 15,000 T/s is observed with current technology. This allows to be comfortable with Ultra-320 even with using not too large transactions.
This let me claim that this 'Ciprico' should be damned shitty design or implementation of a SCSI device.
Using very large scatterlists may complexify a lot SCSI sub-system and drivers or let them oger memory for their memory pool. This Ciprico does not deserve that we add penalty and bloatage in our software, in my opinion. The only reasonnable approach could be to use some peripheral driver that can try to allocate a huge mostly contiguous chunk of memory for the Ciprico, but to leave quiet our software that does fit nicely the needs of reasonnably designed and implemented SCSI devices.
Quoted 17 lines
Quoted 7 lines
Quoted 4 lines
across the bus, your performance drops significantly. I guess it is a tradeoff between latency and bandwidth. Unless you mean the low level device would be handed a vector of kiobufs and it would build a single SCSI request with that vector,
ll_rw_blockcan already do that, but...Quoted 9 lines
Quoted 2 lines
then I suppose it would work well but
the requests would have to make up a contiguous chunk of drive space.... a single request _must_, by definition, be contiguous. There is simply no way for the kernel to deal with non-contiguous atomic I/Os. I'm not sure what you're talking about here --- how can an atomic I/O be anything else? We can do scatter-gather, but only from scattered memory, not to scattered disk blocks.
Quoted 13 lines
I may just be confused about how this whole thing works still. I had to go change the number of SG segments the QLogic driver allocates and reports to the SCSI middle layer to a larger number otherwise the transaction gets split up and I no longer have a single 1MB transaction but four 256KB transactions. The number of segments it was set to was 32 (8KB * 32 = 256KB). So the question I have is in the end when you do this pipelining, if you don't increase the atomic I/O size, will the device attached to the SCSI bus (or FC) still receive a single request or will it quickly see a bunch of smaller requests? My point is, from my experiments with this RAID device, you will run across situations where it is good to be able to make a single SCSI request be quite large in order to achieve better performance.
Low-level drivers have limits on number of scatter entries. They can do large transfers if scatter entries point to large data area. Rather than hacking low-level drivers that are very critical piece of code that require specific knowledge and documentation about the hardware, I recommend you to hack the peripheral driver used for the Ciprico and let it use large contiguous buffers (If obviously you want to spend your time for this device that should go to compost, IMO).
Wanting to provide best support for shitty designed hardware does not encourage hardware vendors to provide us with well designed hardware. In others words, the more we want to support crap, the more we will have to support crap.
Gerard.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Quoted 9 lines · Gerard Roudier
Low-level drivers have limits on number of scatter entries. They can do large transfers if scatter entries point to large data area. Rather than hacking low-level drivers that are very critical piece of code that require specific knowledge and documentation about the hardware, I recommend you to hack the peripheral driver used for the Ciprico and let it use large contiguous buffers (If obviously you want to spend your time for this device that should go to compost, IMO).
Quoted 5 lines
Wanting to provide best support for shitty designed hardware does not encourage hardware vendors to provide us with well designed hardware. In others words, the more we want to support crap, the more we will have to support crap.
I really don't want to get into a pissing match but it is obvious to me that you haven't had any experience with high performance external RAID solutions. You will see this sort of performance characteristic with a lot of these devices. They are used to put together very large storage systems (we are looking at building petabtye systems within two years).
There is no way I'm going to hack on the proprietary RAID controller in this system and even if I wanted to or could, I'm quite certain there is a reason for needing the large transaction size. When you take into account the maximum transaction unit on each drive (usually 64KB), the fact that there are 8 data drives, then you have parity calculation, latency of the transfer, and various points at which data is cached and queued up before there is a complete transaction, then you come up with the magic number. These things were designed for large streaming data and they do it VERY well.
If you have a hardware RAID 3 or RAID 5 solution that will give me this kind of performance for the price point and size that these Ciprico units have, then I would LOVE to hear it because I'm in the market for buying several of them. If you can find me a way of getting >= 150MB/s streaming I/O on a single I/O server for my cluster and fill an order for 2 I/O servers for under $100K, then I may consider something other than the Ciprico 7000. They deliver this performance for a very attractive price. And in a year, I'll come back and buy a fifty more.
BAPper
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Quoted 33 lines · Brian Pomerantz
Quoted 9 lines · Gerard Roudier
Low-level drivers have limits on number of scatter entries. They can do large transfers if scatter entries point to large data area. Rather than hacking low-level drivers that are very critical piece of code that require specific knowledge and documentation about the hardware, I recommend you to hack the peripheral driver used for the Ciprico and let it use large contiguous buffers (If obviously you want to spend your time for this device that should go to compost, IMO).
Quoted 5 lines
Wanting to provide best support for shitty designed hardware does not encourage hardware vendors to provide us with well designed hardware. In others words, the more we want to support crap, the more we will have to support crap.
I really don't want to get into a pissing match but it is obvious to me that you haven't had any experience with high performance external RAID solutions. You will see this sort of performance characteristic with a lot of these devices. They are used to put together very large storage systems (we are looking at building petabtye systems within two years).
There is no way I'm going to hack on the proprietary RAID controller in this system and even if I wanted to or could, I'm quite certain there is a reason for needing the large transaction size. When you take into account the maximum transaction unit on each drive (usually 64KB), the fact that there are 8 data drives, then you have parity calculation, latency of the transfer, and various points at which data is cached and queued up before there is a complete transaction, then you come up with the magic number. These things were designed for large streaming data and they do it VERY well.
Quoted 9 lines
If you have a hardware RAID 3 or RAID 5 solution that will give me this kind of performance for the price point and size that these Ciprico units have, then I would LOVE to hear it because I'm in the market for buying several of them. If you can find me a way of getting >= 150MB/s streaming I/O on a single I/O server for my cluster and fill an order for 2 I/O servers for under $100K, then I may consider something other than the Ciprico 7000. They deliver this performance for a very attractive price. And in a year, I'll come back and buy a fifty more.
The SCSI BUS is transaction based and shared. I donnot care of affordable stuff that moves needless burden to other parts. If they need specific support for their hardware they must pay for that, and in this situation these products would probably not really be so affordable.
Note that the same pathology happens to PCI technology. Some PCI devices, notably Video boards, IDE controllers, brigdes, Network boards, have abused a LOT of this BUS too. These hardware are/were also probably for an interesting price but made shit in that place too.
The 36 bit adress extension from Intel is of the same idiomania that costed a lot for a pathetic result, it seems. It adds complexity to VM handling on Intel 32 bit systems when 64 bit have been proven to be feasible 10 years ago and works fine.
I am only interested in technical issues but, in my opinion, it is the ones that induce costs that must pay for these costs and not others. A device that requires special handling because it abuses of technologies it uses should be discarded unless vendor want to pay for the additionnal effort that such offending stuff requires. But, if such vendors have interested customers that are ready to pay for the effort or to spend time implementing specific stuff for these products, I donnot see any problems.
A low-latency BUS does not require huge transactions in order to allow to use efficiently its bandwitch. If a device requires so, then it can only be badly designed. Given you description of the Capricio, it seems that it is based on some kind of stupid batch mode that looks extremally poor design to me.
Gerard.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Change direct I/O memory model? [Was Re: PATCH: Enhance queueing/scsi-midlayer to handle kiobufs]
One comment about direct I/O: Applications performing direct I/O usually know what they're doing...And if they don't, well, it's their problem: that's what direct I/O is all about. Therefore, perhaps the correct approach would be to allow these apps to manipulate the memory as they see fit (with the standard memory manipulation routines - mmap, mlock, whatever). I don't see a logical reason for the direct I/O stuff to be intricately tied in with memory management (i.e. limiting atomic I/O size, etc.). Direct I/O should receive a nicely aligned physical buffer (or a sg list of such buffers) which has already been locked in memory by the application, and perform the direct I/O. That's it - very simple. Note that in this case, the memory in question could be a user buffer, or it may even be a mapping to PCI memory sitting on another device, thus allowing adapter to adapter data transfers. Note that in NT, when performing unbuffered I/O, it is up to the user to lock the memory in question to sector-sized boundaries. This is the correct way to go...
Mark
Quoted 74 lines · Gerard Roudier
Quoted 33 lines · Brian Pomerantz
Quoted 9 lines · Gerard Roudier
Low-level drivers have limits on number of scatter entries. They can do large transfers if scatter entries point to large data area. Rather than hacking low-level drivers that are very critical piece of code that require specific knowledge and documentation about the hardware, I recommend you to hack the peripheral driver used for the Ciprico and let it use large contiguous buffers (If obviously you want to spend your time for this device that should go to compost, IMO).
Quoted 5 lines
Wanting to provide best support for shitty designed hardware does not encourage hardware vendors to provide us with well designed hardware. In others words, the more we want to support crap, the more we will have to support crap.
I really don't want to get into a pissing match but it is obvious to me that you haven't had any experience with high performance external RAID solutions. You will see this sort of performance characteristic with a lot of these devices. They are used to put together very large storage systems (we are looking at building petabtye systems within two years).
There is no way I'm going to hack on the proprietary RAID controller in this system and even if I wanted to or could, I'm quite certain there is a reason for needing the large transaction size. When you take into account the maximum transaction unit on each drive (usually 64KB), the fact that there are 8 data drives, then you have parity calculation, latency of the transfer, and various points at which data is cached and queued up before there is a complete transaction, then you come up with the magic number. These things were designed for large streaming data and they do it VERY well.
Quoted 9 lines
If you have a hardware RAID 3 or RAID 5 solution that will give me this kind of performance for the price point and size that these Ciprico units have, then I would LOVE to hear it because I'm in the market for buying several of them. If you can find me a way of getting >= 150MB/s streaming I/O on a single I/O server for my cluster and fill an order for 2 I/O servers for under $100K, then I may consider something other than the Ciprico 7000. They deliver this performance for a very attractive price. And in a year, I'll come back and buy a fifty more.
The SCSI BUS is transaction based and shared. I donnot care of affordable stuff that moves needless burden to other parts. If they need specific support for their hardware they must pay for that, and in this situation these products would probably not really be so affordable.
Note that the same pathology happens to PCI technology. Some PCI devices, notably Video boards, IDE controllers, brigdes, Network boards, have abused a LOT of this BUS too. These hardware are/were also probably for an interesting price but made shit in that place too.
The 36 bit adress extension from Intel is of the same idiomania that costed a lot for a pathetic result, it seems. It adds complexity to VM handling on Intel 32 bit systems when 64 bit have been proven to be feasible 10 years ago and works fine.
I am only interested in technical issues but, in my opinion, it is the ones that induce costs that must pay for these costs and not others. A device that requires special handling because it abuses of technologies it uses should be discarded unless vendor want to pay for the additionnal effort that such offending stuff requires. But, if such vendors have interested customers that are ready to pay for the effort or to spend time implementing specific stuff for these products, I donnot see any problems.
A low-latency BUS does not require huge transactions in order to allow to use efficiently its bandwitch. If a device requires so, then it can only be badly designed. Given you description of the Capricio, it seems that it is based on some kind of stupid batch mode that looks extremally poor design to me.
Quoted 5 lines
Gerard.
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Quoted 14 lines · Stephen C. Tweedie
Hi,
Quoted 10 lines · Brian Pomerantz
Quoted 2 lines
The real solution is probably not to increase the atomic I/O size, but rather to pipeline I/Os. That is planned for the future, and now there
That really depends on the device characteristics. This Ciprico hardware I've been working with really only performs well if the atomic I/O size is >= 1MB. Once you introduce additional transactions across the bus, your performance drops significantly. I guess it is a tradeoff between latency and bandwidth. Unless you mean the low level device would be handed a vector of kiobufs and it would build a single SCSI request with that vector,
Hmm...I was thinking more along the lines of kiobuf abstraction being limited to the scsi midlayer and the low-level device (HBA/disk driver) being handed a linked list of Scsi_Cmnds, each containing at most the HBA sg_tablesize of I/O. The chaining of such Scsi_Cmnd structs is not possible currently and might be the way to go. Each Scsi_Cmnd in the chain would represent one kiobuf-based I/O request at a time.
Quoted 10 lines
ll_rw_blockcan already do that, but...Quoted 2 lines
then I suppose it would work well but
the requests would have to make up a contiguous chunk of drive space.... a single request _must_, by definition, be contiguous. There is simply no way for the kernel to deal with non-contiguous atomic I/Os. I'm not sure what you're talking about here --- how can an atomic I/O be anything else? We can do scatter-gather, but only from scattered memory, not to scattered disk blocks.
And that could potentially be handled via the linked list of Scsi_Cmnd structs that I mention above. Each I/O within a Scsi_Cmnd would be restricted to contiguous disk blocks but that needn't apply across the linked list.
Cheers,
-Chait.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Quoted 9 lines · Stephen C. Tweedie
Hi,
Quoted 2 lines · Chaitanya Tumuluri
I've had the same question in my mind. I've also wondered why raw I/O was restricted to only
KIO_MAX_SECTORSat a time.Mainly for resource limiting --- you don't want to have too much user memory pinned permanently at once.
The flip side of this argument being that raw I/O is "raw" access to a device and such access is usually needed by systems (e.g. databases) that know what they are doing. I would like to think that in the raw I/O path at least, we shouldn't be posting such limits. Besides, things like databases have their "buffer caches" allocated during startup and pinned till the next reboot.
Quoted 8 lines
The real solution is probably not to increase the atomic I/O size, but rather to pipeline I/Os. That is planned for the future, and now there are other people interested in it, I'll bump that work up the queue a bit! The idea is to allow
brw_kiovecto support fully async operation, and for the raw device driver to work with multiple kiobufs. That way we can keep 2 or 3 kiobufs streaming at all times, eliminating the stalls between raw I/O segments, without having to increase the max segment size.
Sounds good; and its pretty much what I have in mind. And that is why I've added the following field to the kiobuf struct, to allow the issue of multiple kiobuf requests from the `parent' kiovec. This would be useful in the completion functions for the individual kiobufs:
+#if CONFIG_KIOBUF_IO
+ void *k_dev_id; /* Store kiovec (or pagebuf) here */
+#endif
However, I'd still like to draw the focus away from the limits imposed at the raw I/O (i.e raw.c / buffer.c) layers and say that we should work with the real h/w limits. The HBA scatter-gather memory size is the limiting factor here. There are two ways of dealing with I/O requests larger than this limit:
1. Repeatedly queue scsi-cmnds against the HBA/device till all the I/O is done. This requeuing is done at the scsi midlayer.
2. Provide for a "continuation" field in the Scsi_Cmnd struct that low-level HBA drivers understand and use to re-issue the I/Os in chunks of the sg_tablesize.
The advantage of 2. is obvious in that it doesn't pump the system with completion interrupts. However, the easiest solution at this point is
1. above (given the mechanism already exists in the scsi midlayers).
Quoted 6 lines
In the future we'll also need to charge these I/Os against a per-user limit on pinned memory to control resources. We can't really offer
O_DIRECTI/O to unprivileged user processes until we have eliminated that possible DOS attack. Right now raw devices can only be created by root and are protected by normal filesystem modes, so we don't have too much of a problem.
I hadn't thought that far; but I can see your point, yes.
Quoted 10 lines
Quoted 3 lines
So, I enhanced Stephen Tweedie's
raw I/O and the queueing/scsi layers to handle kiobufs-based requests. This is in addition to the currentbuffer_headbased request processing.The "current" kiobuf code is in ftp.uk.linux.org:/pub/linux/sct/fs/raw-io/. It includes a number of bug fixes (mainly rationalising the error returns), plus a few new significant bits of functionality. If you can get me a patch against those diffs, I'll include your new code in the main kiobuf patchset. (I'm still maintaining the different kiobuf patches as separate patches within that patchset tarball.)
Great...I'll work on it shortly.
Quoted 5 lines
Quoted 3 lines
Thus,
ll_rw_blk.chas two new functions:
oll_rw_kio()
o__make_kio_request()Oh, *thankyou*. This has been needed for a while.
Now there's a real gratifying response for you! Thank _you_! :^) Will you consider including these changes also (i.e. queueing/scsi midlayers) in your patchset as well?
Quoted 13 lines
Quoted 5 lines
Here's the patch against a 2.3.99-pre2 kernel. To recap, two primary reasons for this patch:
1. To enhance the queueing and scsi-mid layers to handle kiobuf-based requests as well,Quoted 7 lines
2. Remove request size limits on the upper layers (above
ll_rw_blk.c). TheKIO_MAX_SECTORSseems to have been inspired byMAX_SECTORS(128 per request) inll_rw_blk.c. The scsi mid-layer should handle `oversize' requests based on the HBAsg_tablesize.I'm not too sure about 2. above; so I'd love to hear from more knowledgeable people on that score.
Quoted 7 lines
It shouldn't be too much of a problem to retain this limit if the
brw_kioveccode can stream properly.Quoted 1 line
I'd highly appreciate any feedback before I submit this patch `officially'.
There needs to be some mechanism for dealing with drivers which do not have kiobuf request handling implemented.
They will continue working with the current buffer_head path. That is why as far as possible, I've separated the buffer_head and kiobuf request handling into separate functions in the code. This is also the reason I still have the #ifdefs in the code.....it enables easier surgery when the time comes (if and when!) to remove the buffer_head I/O paths completely.
<plug>
I've experimented with XFS performance using kiobuf-based requests and it has shown performance improvements ... data is still not stable yet. The main improvements (as expected) is in lowered CPU overheads and slightly improved disk thro'puts.
It'd be great if we could sit down and convert ext2 to use kiobufs/kiovecs and see the difference.
<\plug>
Quoted 9 lines
I also think that the code is too dependent on
request->buffer. We _really_ need to treat this as an opportunity to eliminate that field entirely for kiobuf-based I/Os. kiobufs refer to struct page *s, not individual data pointers, and so they can easily represent pages above the 4GB limit on large memory machines using PAE36. If we want to be able to add dual-address-cycle or PCI64 support to the individual scsi drivers at all, then we need to be able to preserve addresses above 4GB, and kiobufs would seem to be a sensible way to do this if we're going to have them in the struct request at all.
True and thats been the reasoning behind the "pagebuf" efforts currently being used in the XFS work.
I'll download your rawio source and merge my changes into that source.
Cheers,
-Chait.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
Quoted 10 lines · Stephen C. Tweedie
Hi,
On Thu, May 18, 2000 at 12:55:04PM -0700, Chaitanya Tumuluri wrote:
< stuff deleted >
Quoted 3 lines
So, I enhanced Stephen Tweedie's
raw I/O and the queueing/scsi layers to handle kiobufs-based requests. This is in addition to the currentbuffer_headbased request processing.
Quoted 7 lines
The "current" kiobuf code is in ftp.uk.linux.org:/pub/linux/sct/fs/raw-io/. It includes a number of bug fixes (mainly rationalising the error returns), plus a few new significant bits of functionality. If you can get me a patch against those diffs, I'll include your new code in the main kiobuf patchset. (I'm still maintaining the different kiobuf patches as separate patches within that patchset tarball.)
Stephen and others,
Here's my patch against the 2.3.99.pre9-2 patchset from your site. The main differences from my earlier post are:
- removed the #ifdefs around my code as Stephen Tweedie suggested,
- corrected indentation problems pointed out earlier (Eric/Alan).
Finally, I'd like to repeat that given the consensus about moving away from buffer-head based I/O in the future, it makes sense for me to retain the little bit of code duplication. This is in the interests of easy surgery when we do remove the buffer-head I/O paths.
While I see decent (upto 10%) improvement in b/w and turnaround time for I/O to a single disk, the biggest impact is the (almost 40%) reduction in CPU utilization with the new codepath. These are from simple `lmdd' tests timed with /usr/bin/time.
Based on further feedback from this audience, I would like to propose this change to Linus at some point as a general scsi mechanism to handle kiobuf-based requests.
Thanks much,
-Chait.
----------------------------CUT HERE---------------------------------------
drivers/block/ll_rw_blk.c +311 -1
@@ -4,6 +4,7 @@* Copyright (C) 1991, 1992 Linus Torvalds * Copyright (C) 1994, Karl Keyte: Added support for disk statistics * Elevator latency, (C) 2000 Andrea Arcangeli <[email protected]> SuSE +* Support for kiobuf-based I/O requests: Chaitanya Tumuluri [[email protected]] */ /*
@@ -639,7 +640,8 @@ starving =1 ;if (latency <0 )continue ; - +if (req->kiobuf) +continue ;if (req->sem)continue ;if (req->cmd != rw)
@@ -744,6 +746,7 @@ req->nr_hw_segments =1 ;/* Always 1 for a new request. */ req->buffer = bh->b_data; req->sem =NULL ; + req->kiobuf =NULL ; req->bh = bh; req->bhtail = bh; req->q = q;
@@ -886,6 +889,311 @@__ll_rw_block (rw, nr, bh,1 ); } +/* +* Function: __make_kio_request() +* +* Purpose: Construct a kiobuf-based request and insert into request queue. +* +* Arguments: q - request queue of device +* rw - read/write +* kiobuf - collection of pages +* dev - device against which I/O requested +* blocknr - dev block number at which to start I/O +* blksize - units (512B or other) of blocknr +* +* Lock status: No lock held upon entry. +* +* Returns: Nothing +* +* Notes: Requests generated by this function should _NOT_ be merged by +* the __make_request() (new check for `req->kiobuf') +* +* All (relevant) req->Y parameters are expressed in sector size +* of 512B for kiobuf based I/O. This is assumed in the scsi +* mid-layer as well. +*/ +static inline void __make_kio_request (request_queue_t * q, +int rw, +struct kiobuf * kiobuf, +kdev_t dev, +unsigned long blocknr, +size_t blksize) +{ +int major =MAJOR (dev); +unsigned int sector, count, nr_bytes, total_bytes, nr_seg; +struct request * req; +int rw_ahead, max_req; +unsigned long flags; +struct list_head * head = &q->queue_head; +size_t curr_offset; +int orig_latency; +elevator_t * elevator; +int correct_size, i, kioind; + +/* +* Sanity Tests: +* +* The input arg. `blocknr' is in units of the +* input arg. `blksize' (inode->i_sb->s_blocksize). +* Convert to 512B unit used in blk_size[] array. +*/ + count = kiobuf->length >>9 ; + sector = blocknr * (blksize >>9 ); + +if (blk_size[major]) { +unsigned long maxsector = (blk_size[major][MINOR (dev)] <<1 ) +1 ; + +if (maxsector < count || maxsector - count < sector) { +if (!blk_size[major][MINOR (dev)]) { + kiobuf->errno = -EINVAL ; + goto end_io; + } +/* This may well happen - the kernel calls bread() +without checking the size of the device, e.g., +when mounting a device. */ +printk (KERN_INFO +"attempt to access beyond end of device\n" ); +printk (KERN_INFO "%s: rw=%d, want=%d, limit=%d\n" , +kdevname (dev), rw, + (sector + count)>>1 , + blk_size[major][MINOR (dev)]); + kiobuf->errno = -ESPIPE ; + goto end_io; + } + } +/* +* Allow only basic block size multiples in the +* kiobuf->length. +*/ + correct_size =BLOCK_SIZE ; +if (blksize_size[major]) { + i = blksize_size[major][MINOR (dev)]; +if (i) + correct_size = i; + } +if ((kiobuf->length % correct_size) !=0 ) { +printk (KERN_NOTICE "ll_rw_kio: " +"request size [%d] not a multiple of device [%s] block-size [%d]\n" , + kiobuf->length, +kdevname (dev), + correct_size); + kiobuf->errno = -EINVAL ; + goto end_io; + } + rw_ahead =0 ;/* normal case; gets changed below for READA */ +switch (rw) { +case READA : + rw_ahead =1 ; + rw =READ ;/* drop into READ */ +case READ : + kstat.pgpgin++; + max_req =NR_REQUEST ;/* reads take precedence */ +break ; +case WRITERAW : + rw =WRITE ; + goto do_write;/* Skip the buffer refile */ +case WRITE : + do_write: +/* +* We don't allow the write-requests to fill up the +* queue completely: we want some room for reads, +* as they take precedence. The last third of the +* requests are only for reads. +*/ + kstat.pgpgout++; + max_req = (NR_REQUEST *2 ) /3 ; +break ; +default : +BUG (); + kiobuf->errno = -EINVAL ; + goto end_io; + } + +/* +* Creation of bounce buffers for data in high memory +* should (is) be handled lower in the food-chain. +* Ccurrently done in scsi_merge.c for scsi disks. +* +* Look for a free request with spinlock held. +* Apart from atomic queue access, it prevents +* another thread that has already queued a kiobuf-request +* into this queue from starting it, till we are done. +*/ + elevator = &q->elevator; + orig_latency =elevator_request_latency (elevator, rw); +spin_lock_irqsave (&io_request_lock,flags); + +if (list_empty (head)) + q->plug_device_fn (q, dev); +/* +* The scsi disk and cdrom drivers completely remove the request +* from the queue when they start processing an entry. For this +* reason it is safe to continue to add links to the top entry +* for those devices. +* +* All other drivers need to jump over the first entry, as that +* entry may be busy being processed and we thus can't change +* it. +*/ +if (q->head_active && !q->plugged) + head = head->next; + +/* find an unused request. */ + req =get_request (max_req, dev); + +/* +* if no request available: if rw_ahead, forget it, +* otherwise try again blocking.. +*/ +if (!req) { +spin_unlock_irqrestore (&io_request_lock,flags); +if (rw_ahead){ + kiobuf->errno = -EBUSY ; + goto end_io; + } + req =__get_request_wait (max_req, dev); +spin_lock_irqsave (&io_request_lock,flags); + +/* revalidate elevator */ + head = &q->queue_head; +if (q->head_active && !q->plugged) + head = head->next; + } + +/* fill up the request-info, and add it to the queue */ + req->cmd = rw; + req->errors =0 ; + req->sector = sector; + req->nr_hw_segments =1 ;/* Always 1 for a new request. */ + req->nr_sectors = count;/* Length of kiobuf */ + req->sem =NULL ; + req->kiobuf = kiobuf; + req->bh =NULL ; + req->bhtail =NULL ; + req->q = q; +/* Calculate req->buffer */ + curr_offset = kiobuf->offset; +for (kioind=0 ; kioind<kiobuf->nr_pages; kioind++) +if (curr_offset >=PAGE_SIZE ) + curr_offset -=PAGE_SIZE ; +else +break ; + req->buffer = (char *)page_address (kiobuf->maplist[kioind]) + + curr_offset; + +/* Calculate current_nr_sectors and # of scatter gather segments needed */ + total_bytes = kiobuf->length; + nr_bytes = (PAGE_SIZE - curr_offset) > total_bytes ? + total_bytes : (PAGE_SIZE - curr_offset); + req->current_nr_sectors = nr_bytes >>9 ; + +for (nr_seg =1 ; + kioind<kiobuf->nr_pages && nr_bytes != total_bytes; + kioind++) { + ++nr_seg; +if ((nr_bytes +PAGE_SIZE ) > total_bytes){ +break ; + }else { + nr_bytes +=PAGE_SIZE ; + } + } + req->nr_segments = nr_seg; + +add_request (q, req, head, orig_latency); +elevator_account_request (elevator, req); + +spin_unlock_irqrestore (&io_request_lock, flags); + +end_io: +return ; +} + + + +/* +* Function: ll_rw_kio() +* +* Purpose: Insert kiobuf-based request into request queue. +* +* Arguments: rw - read/write +* kiobuf - collection of pages +* dev - device against which I/O requested +* blocknr - dev block number at which to start I/O +* sector - units (512B or other) of blocknr +* error - return status +* +* Lock status: Assumed no lock held upon entry. +* Assumed that the pages in the kiobuf ___ARE LOCKED DOWN___. +* +* Returns: Nothing +* +* Notes: This function is called from any subsystem using kiovec[] +* collection of kiobufs for I/O (e.g. `pagebufs', raw-io). +* Relies on "kiobuf" field in the request structure. +*/ +void ll_rw_kio (int rw, +struct kiobuf *kiobuf, +kdev_t dev, +unsigned long blocknr, +size_t sector, +int *error) +{ +request_queue_t *q; +/* +* Only support SCSI disk for now. +* +* ENOSYS to indicate caller +* should try ll_rw_block() +* for non-SCSI (e.g. IDE) disks +* and for MD requests. +*/ +if (!SCSI_DISK_MAJOR (MAJOR (dev)) || + (MAJOR (dev) ==MD_MAJOR )) { + *error = -ENOSYS ; + goto end_io; + } +/* +* Sanity checks +*/ + q =blk_get_queue (dev); +if (!q) { +printk (KERN_ERR +"ll_rw_kio: Nnonexistent block-device %s\n" , +kdevname (dev)); + *error = -ENODEV ; + goto end_io; + } +if ((rw &WRITE ) &&is_read_only (dev)) { +printk (KERN_NOTICE "Can't write to read-only device %s\n" , +kdevname (dev)); + *error = -EPERM ; + goto end_io; + } +if (q->make_request_fn) { +printk (KERN_ERR +"ll_rw_kio: Unexpected device [%s] queueing function encountered\n" , +kdevname (dev)); + *error = -ENOSYS ; + goto end_io; + } + +__make_kio_request (q, rw, kiobuf, dev, blocknr, sector); +if (kiobuf->errno !=0 ) { + *error = kiobuf->errno; + goto end_io; + } + +return ; +end_io: +/* +* We come here only on an error so, just set +* kiobuf->errno and call the completion fn. +*/ +if (kiobuf->errno ==0 ) + kiobuf->errno = *error; +} + +#ifdef CONFIG_STRAM_SWAP extern int stram_device_init (void );#endif
@@ -1079,3 +1387,5 @@EXPORT_SYMBOL (blk_queue_pluggable);EXPORT_SYMBOL (blk_queue_make_request);EXPORT_SYMBOL (generic_make_request); +EXPORT_SYMBOL (__make_kio_request); +EXPORT_SYMBOL (ll_rw_kio);
drivers/char/raw.c +78 -13
119 lines not on this page · raw message
drivers/scsi/scsi_lib.c +169 -22
227 lines not on this page · raw message
drivers/scsi/scsi_merge.c +271 -60
420 lines not on this page · raw message
drivers/scsi/sd.c +9 -2
@@ -546,6 +546,7 @@static void rw_intr (Scsi_Cmnd * SCpnt) {int result = SCpnt->result; +#if CONFIG_SCSI_LOGGING char nbuff[6 ];#endif
@@ -575,8 +576,14 @@ (SCpnt->sense_buffer[4 ] <<16 ) | (SCpnt->sense_buffer[5 ] <<8 ) | SCpnt->sense_buffer[6 ]; -if (SCpnt->request.bh !=NULL ) - block_sectors = SCpnt->request.bh->b_size >>9 ; + +/* Tweak to support kiobuf-based I/O requests, [[email protected]] */ +if (SCpnt->request.kiobuf !=NULL ) + block_sectors = SCpnt->request.kiobuf->length >>9 ; +else if (SCpnt->request.bh !=NULL ) + block_sectors = SCpnt->request.bh->b_size >>9 ; +else +panic ("Both kiobuf and bh pointers are null!\n" );switch (SCpnt->device->sector_size) {case 1024 : error_sector <<=1 ;
include/linux/blkdev.h +2 -0
@@ -6,6 +6,7 @@#include <linux/genhd.h> #include <linux/tqueue.h> #include <linux/list.h> +#include <linux/iobuf.h> struct request_queue ;typedef struct request_queue request_queue_t ;
@@ -39,6 +40,7 @@void * special;char * buffer;struct semaphore * sem; +struct kiobuf * kiobuf;struct buffer_head * bh;struct buffer_head * bhtail;request_queue_t * q;
include/linux/elevator.h +6 -1
@@ -107,7 +107,12 @@ elevator->sequence++;if (req->cmd ==READ ) elevator->read_pendings++; - elevator->nr_segments++; + +if (req->kiobuf !=NULL ) { + elevator->nr_segments += req->nr_segments; + }else { + elevator->nr_segments++; + } }static inline int elevator_request_latency (elevator_t * elevator,int rw)
include/linux/fs.h +1 -0
@@ -1063,6 +1063,7 @@extern struct buffer_head *get_hash_table (kdev_t ,int ,int );extern struct buffer_head *getblk (kdev_t ,int ,int );extern void ll_rw_block (int ,int ,struct buffer_head * bh[]); +extern void ll_rw_kio (int ,struct kiobuf *,kdev_t ,unsigned long ,size_t ,int *);extern int is_read_only (kdev_t );extern void __brelse (struct buffer_head *);static inline void brelse (struct buffer_head *buf)
include/linux/iobuf.h +1 -0
@@ -56,6 +56,7 @@atomic_t io_count;/* IOs still in progress */ int errno;/* Status of completed IO */ void (*end_io) (struct kiobuf *);/* Completion callback */ +void *k_dev_id;/* Store kiovec (or pagebuf) here */ wait_queue_head_t wait_queue; };
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/