xfs_io: fix random pread/pwrite to honor offset
PATCH 1/1 xfs_io: fix random pread/pwrite to honor offset
xfs_io's pread & pwrite claim to support a random IO mode where it will do random IOs between offset & offset+len.
However, offset was ignored, and we did the IOs between 0 and len instead.
Clang caught this by pointing out that the calculated/normalized "offset" variable was never read.
(NB: If the range is larger than RAND_MAX, these functions don't work, but that's always been true, so I'll leave it for another day...)
---
I haven't tested this w/ xfstests but I don't see anyone who calls pread/pwrite with "-R" (and it's not documented in the manpage!)
io/pread.c +1 -1
@@ -246,7 +246,7 @@ read_random( *total =0 ;while (count >0 ) { - off = ((random () % range) / buffersize) * buffersize; + off = ((offset + (random () % range)) / buffersize) * buffersize; bytes =do_pread (fd, off, buffersize, buffersize);if (bytes ==0 )break ;
io/pwrite.c +1 -1
@@ -129,7 +129,7 @@ write_random( *total =0 ;while (count >0 ) { - off = ((random () % range) / buffersize) * buffersize; + off = ((offset + (random () % range)) / buffersize) * buffersize; bytes =do_pwrite (file->fd, off, buffersize, buffersize);if (bytes ==0 )break ;
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
io/pread.c read_random(
Quoted 24 lines · Eric Sandeen
xfs_io's pread & pwrite claim to support a random IO mode where it will do random IOs between offset & offset+len.
However, offset was ignored, and we did the IOs between 0 and len instead.
Clang caught this by pointing out that the calculated/normalized "offset" variable was never read.
(NB: If the range is larger than
RAND_MAX, these functions don't work, but that's always been true, so I'll leave it for another day...)Signed-off-by Eric Sandeen<[email protected]>---
I haven't tested this w/ xfstests but I don't see anyone who calls pread/pwrite with "-R" (and it's not documented in the manpage!)
io/pread.c +0
-0@@ -246,7 +246,7 @@ read_random(
offset can be the end of file offset. Do we care that the read (/write) could start or end past the end of file?
io/pread.c read_random( · line 252
Quoted 8 lines
io/pread.c +1
-1*total =0 ;while (count >0 ) { - off = ((random () % range) / buffersize) * buffersize; + off = ((offset + (random () % range)) / buffersize) * buffersize; bytes =do_pread (fd, off, buffersize, buffersize);if (bytes ==0 )break ;
Looks like this was introduced in:
commit 8fb2237e65555ff540e8b6108ffccfffefe239ac
Author: Nathan Scott <[email protected]> Date: Fri Nov 11 14:25:18 2005 +0000
Provide further debugging options and tweaks for analysing the read/write paths. Merge of master-melb:xfs-cmds:24372a by kenmcd.
---
If it was broken for 8.5 years, I think it could be removed.
--Mark.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 20 lines · Mark Tinguely
Quoted 19 lines · Eric Sandeen
xfs_io's pread & pwrite claim to support a random IO mode where it will do random IOs between offset & offset+len.
However, offset was ignored, and we did the IOs between 0 and len instead.
Clang caught this by pointing out that the calculated/normalized "offset" variable was never read.
(NB: If the range is larger than
RAND_MAX, these functions don't work, but that's always been true, so I'll leave it for another day...)Signed-off-by Eric Sandeen<[email protected]>---
I haven't tested this w/ xfstests but I don't see anyone who calls pread/pwrite with "-R" (and it's not documented in the manpage!)
Quoted 8 lines
io/pread.c read_random(
Quoted 5 lines
io/pread.c +0
-0@@ -246,7 +246,7 @@ read_random(offset can be the end of file offset. Do we care that the read (/write) could start or end past the end of file?
It now behaves the same as a normal forward read does if you tell it to go past EOF:
xfs_io> truncate 1gxfs_io> pread 1g 1m
read 0/1048576 bytes at offset 1073741824
0.000000 bytes, 0 ops; 0.0000 sec (0.000000 bytes/sec and 0.0000 ops/sec) xfs_io> pread -R 1g 1m
read 0/1048576 bytes at offset 1073741824
0.000000 bytes, 0 ops; 0.0000 sec (0.000000 bytes/sec and 0.0000 ops/sec)
so I think it's ok?
Quoted 14 lines
io/pread.c read_random( · line 252
Quoted 8 lines
io/pread.c +1
-1*total =0 ;while (count >0 ) { - off = ((random () % range) / buffersize) * buffersize; + off = ((offset + (random () % range)) / buffersize) * buffersize; bytes =do_pread (fd, off, buffersize, buffersize);if (bytes ==0 )break ;Looks like this was introduced in:
commit8fb2237e65555ff540e8b6108ffccfffefe239acAuthor: Nathan Scott <[email protected]> Date: Fri Nov 11 14:25:18 2005 +0000
Quoted 6 lines
Provide further debugging options and tweaks for analysing the read/write paths. Merge of master-melb:xfs-cmds:24372a by kenmcd.
---
If it was broken for 8.5 years, I think it could be removed.
Eh, could, or we could fix it. :) I suppose this means it needs a test... :/
-Eric
Quoted 2 lines
--Mark.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 17 lines · Eric Sandeen
Quoted 16 lines · Mark Tinguely
Quoted 15 lines · Eric Sandeen
xfs_io's pread & pwrite claim to support a random IO mode where it will do random IOs between offset & offset+len.
However, offset was ignored, and we did the IOs between 0 and len instead.
Clang caught this by pointing out that the calculated/normalized "offset" variable was never read.
(NB: If the range is larger than
RAND_MAX, these functions don't work, but that's always been true, so I'll leave it for another day...)Signed-off-by Eric Sandeen<[email protected]>---
....
Quoted 6 lines
Quoted 6 lines
Looks like this was introduced in:
commit8fb2237e65555ff540e8b6108ffccfffefe239acAuthor: Nathan Scott <[email protected]> Date: Fri Nov 11 14:25:18 2005 +0000
Quoted 8 lines
Quoted 6 lines
Provide further debugging options and tweaks for analysing the read/write paths. Merge of master-melb:xfs-cmds:24372a by kenmcd.
---
If it was broken for 8.5 years, I think it could be removed.
Eh, could, or we could fix it. :) I suppose this means it needs a test... :/
And document it ;)
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs