direct-io: remove address alignment check
A message that is not in the archive (sent off-list or not yet received): 1121298112.6025.21.camel@ibm-c.pdx.osdl.net.suse.lists.linux.kernel
Quoted 2 lines · Daniel McNeil
This patch relaxes the direct i/o alignment check so that user addresses do not have to be a multiple of the device block size.
The original reason for this limit was that lots of drivers (not only IDE) explode when you give them odd sizes. Sometimes it is even worse.
I doubt all of them have been fixed.
Very risky change.
-Andi
Quoted 5 lines · Andi Kleen
Quoted 2 lines · Daniel McNeil
This patch relaxes the direct i/o alignment check so that user addresses do not have to be a multiple of the device block size.
Quoted 8 lines
The original reason for this limit was that lots of drivers (not only IDE) explode when you give them odd sizes. Sometimes it is even worse.
I doubt all of them have been fixed.
Very risky change.
That is exactly why I made this a separate patch, so that we can test and find out where the problems are and work to fix them.
Are there problems only with odd sizes, or do drivers have problems with non-512 sizes?
Allowing 4-byte aligned user addresses would be a good step forward, since it looks like malloc() returns 4-byte aligned addresses.
Daniel
Quoted 3 lines
That is exactly why I made this a separate patch, so that we can test and find out where the problems are and work to fix them.
That's pretty hard because there are a lot of block drivers.
And might not very nice for people's data.
Quoted 3 lines
Are there problems only with odd sizes, or do drivers have problems with non-512 sizes?
I believe they have problems with non 512 sizes (and probably alignments) too.
-Andi
Quoted 6 lines · Andi Kleen
Quoted 3 lines
That is exactly why I made this a separate patch, so that we can test and find out where the problems are and work to fix them.
That's pretty hard because there are a lot of block drivers.
Quoted 8 lines
And might not very nice for people's data.
Quoted 3 lines
Are there problems only with odd sizes, or do drivers have problems with non-512 sizes?
I believe they have problems with non 512 sizes (and probably alignments) too.
The check still only allows i/o that is multiple of the device block size. That will always be a requirement.
I was trying to ask:
Do drivers have problems with odd addresses or with non-512 addresses?
In my limited testing, I saw problems with odd user space addresses on IDE (using DMA). When testing 2-byte aligned addresses, I did not see any problems, and so far, the data looks correct.
I am continuing to test and this patch allows other to try it out as well. For the most part, it should be safe because nobody has application code that uses O_DIRECT with non-aligned addresses. Obviously, it will only be ready for mainline if/when we fix all the drivers.
Thanks,
Daniel
Quoted 3 lines · Daniel McNeil
Do drivers have problems with odd addresses or with
non-512 addresses?
I do recall hearing rumours that some bus-masters have fairly strict memory alignment requirements. A cacheline size, perhaps - that would be 32 bytes given the age of the hardware.
But yeah, it's v. risky to assume that all bus masters can cope with memory alignments down to two bytes.
It would be sane to put the minimum alignment into ->backing_dev_info, default to 512, get the device drivers to override that as they are tested.
But this introduces a very very bad problem: people will write applications which work on their hardware, ship the things and then find that the apps break on other people's hardware. So we can't do that.
Instead, we need to work out the minimum alignment requirement for all disk controllers and DMA controllers and motherboards in the world. And that includes catering for weird ones which appear to work but which occasionally fail in mysterious ways with finer alignments. That's hard. It's easier to continue to make application developers jump through hoops.
Quoted 19 lines · Andrew Morton
Quoted 3 lines · Daniel McNeil
Do drivers have problems with odd addresses or with
non-512 addresses?I do recall hearing rumours that some bus-masters have fairly strict memory alignment requirements. A cacheline size, perhaps - that would be 32 bytes given the age of the hardware.
But yeah, it's v. risky to assume that all bus masters can cope with memory alignments down to two bytes.
It would be sane to put the minimum alignment into ->backing_dev_info, default to 512, get the device drivers to override that as they are tested.
But this introduces a very very bad problem: people will write applications which work on their hardware, ship the things and then find that the apps break on other people's hardware. So we can't do that.
Quoted 5 lines
Instead, we need to work out the minimum alignment requirement for all disk controllers and DMA controllers and motherboards in the world. And that includes catering for weird ones which appear to work but which occasionally fail in mysterious ways with finer alignments. That's hard. It's easier to continue to make application developers jump through hoops.
I was hoping this patch would help turn rumors into real data :)
If we did put min alignment into backing_dev_info, we could implement the equivalent of bounce buffers for direct-io -- or just fall back to buffer i/o like it does sometimes anyway. That way application would not break, just get worse performance on some hardware.
Right now I just wanted to get the issues on table, get some test results, and see how to proceed from there. Since this patch only affects direct i/o, getting test results shouldn't cause too many problems.
Thanks,
Daniel