diff options
| author | Jeff Moyer <[email protected]> | 2006-02-03 03:04:27 -0800 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2006-02-03 08:32:07 -0800 |
| commit | 35dc8161d0a6fa5e654bcb3d6240acc9ecb0a259 (patch) | |
| tree | 0c688ffc3adc127f5cf9f35ff93e6072e1f42438 /scripts/basic | |
| parent | 835417967c10b6dfaffdffddba59196196e5d431 (diff) | |
[PATCH] fix O_DIRECT read of last block in a sparse file
Currently, if you open a file O_DIRECT, truncate it to a size that is not a
multiple of the disk block size, and then try to read the last block in the
file, the read will return 0. The problem is in do_direct_IO, here:
/* Handle holes */
if (!buffer_mapped(map_bh)) {
char *kaddr;
...
if (dio->block_in_file >=
i_size_read(dio->inode)>>blkbits) {
/* We hit eof */
page_cache_release(page);
goto out;
}
We shift off any remaining bytes in the final block of the I/O, resulting
in a 0-sized read. I've attached a patch that fixes this. I'm not happy
about how ugly the math is getting, so suggestions are more than welcome.
I've tested this with a simple program that performs the steps outlined for
reproducing the problem above. Without the patch, we get a 0-sized result
from read. With the patch, we get the correct return value from the short
read.
Signed-off-by: Jeff Moyer <[email protected]>
Cc: Badari Pulavarty <[email protected]>
Cc: Suparna Bhattacharya <[email protected]>
Cc: Mingming Cao <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: "Chen, Kenneth W" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'scripts/basic')
0 files changed, 0 insertions, 0 deletions