src/seek_sanity_test: fix test15 SEEK_HOLE expected results
PATCH 1/1 src/seek_sanity_test: fix test15 SEEK_HOLE expected results
Filesystesm with the "default behaviour" will always return the offset of the end of the file when lseek'ing with SEEK_HOLE. This test does the following:
- fallocate 4 << 20 bytes
- write PAGE_SIZE bytes at offset 0
- writes PAGE_SIZE bytes at offset 4 << 20
Thus, using lseek in an FS with the "default behaviour" will set the position at 4 << 20 + PAGE_SIZE.
--- src/seek_sanity_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/seek_sanity_test.c +2 -2
@@ -335,8 +335,8 @@ static int test15(int fd, int testnum) goto out;/* offset at the beginning */ - ret +=do_lseek (testnum,1 , fd, filsz,SEEK_HOLE ,0 , bufsz); - ret +=do_lseek (testnum,2 , fd, filsz,SEEK_HOLE ,1 , bufsz); + ret +=do_lseek (testnum,1 , fd, filsz + bufsz,SEEK_HOLE ,0 , bufsz); + ret +=do_lseek (testnum,2 , fd, filsz + bufsz,SEEK_HOLE ,1 , bufsz); ret +=do_lseek (testnum,3 , fd, filsz,SEEK_DATA ,0 ,0 ); ret +=do_lseek (testnum,4 , fd, filsz,SEEK_DATA ,1 ,1 ); ret +=do_lseek (testnum,5 , fd, filsz,SEEK_DATA , bufsz, filsz);
Quoted 8 lines · Luis Henriques
Filesystesm with the "default behaviour" will always return the offset of the end of the file when lseek'ing with
SEEK_HOLE. This test does the following:- fallocate 4 << 20 bytes
- writePAGE_SIZEbytes at offset 0
- writesPAGE_SIZEbytes at offset 4 << 20
Quoted 5 lines
Thus, using lseek in an FS with the "default behaviour" will set the position at 4 << 20 +
PAGE_SIZE.Cc Jan Kara <[email protected]>Signed-off-by Luis Henriques <[email protected]>
Thanks for fixing this. You can add:
Honza
Quoted 19 lines
--- src/seek_sanity_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/seek_sanity_test.c +2
-2@@ -335,8 +335,8 @@ static int test15(int fd, int testnum) goto out;/* offset at the beginning */ - ret +=do_lseek (testnum,1 , fd, filsz,SEEK_HOLE ,0 , bufsz); - ret +=do_lseek (testnum,2 , fd, filsz,SEEK_HOLE ,1 , bufsz); + ret +=do_lseek (testnum,1 , fd, filsz + bufsz,SEEK_HOLE ,0 , bufsz); + ret +=do_lseek (testnum,2 , fd, filsz + bufsz,SEEK_HOLE ,1 , bufsz); ret +=do_lseek (testnum,3 , fd, filsz,SEEK_DATA ,0 ,0 ); ret +=do_lseek (testnum,4 , fd, filsz,SEEK_DATA ,1 ,1 ); ret +=do_lseek (testnum,5 , fd, filsz,SEEK_DATA , bufsz, filsz);
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 10 lines · Luis Henriques
Filesystesm with the "default behaviour" will always return the offset of the end of the file when lseek'ing with
SEEK_HOLE. This test does the following:- fallocate 4 << 20 bytes
- writePAGE_SIZEbytes at offset 0
- writesPAGE_SIZEbytes at offset 4 << 20Thus, using lseek in an FS with the "default behaviour" will set the position at 4 << 20 +
PAGE_SIZE.
Thanks for fixing it! I've tested it on a "default behavior" filesystem (gfs2) this time, and test passed.
Quoted 12 lines
Cc Jan Kara <[email protected]>Signed-off-by Luis Henriques <[email protected]>--- src/seek_sanity_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/seek_sanity_test.c +0
-0
src/seek_sanity_test.c static int test15(int fd, int testnum) · line 339
Quoted 7 lines
src/seek_sanity_test.c +2
-2@@ -335,8 +335,8 @@ static int test15(int fd, int testnum) goto out;/* offset at the beginning */ - ret +=do_lseek (testnum,1 , fd, filsz,SEEK_HOLE ,0 , bufsz); - ret +=do_lseek (testnum,2 , fd, filsz,SEEK_HOLE ,1 , bufsz); + ret +=do_lseek (testnum,1 , fd, filsz + bufsz,SEEK_HOLE ,0 , bufsz); + ret +=do_lseek (testnum,2 , fd, filsz + bufsz,SEEK_HOLE ,1 , bufsz);
I think we should update filsz after the last write, before any do_lseek() test, because filsz was extended by bufsz and the 4th arg of do_lseek expects the actual file size.
src/seek_sanity_test.c static int test15(int fd, int testnum) · line 342
Quoted 3 lines
src/seek_sanity_test.c +0
-0ret +=do_lseek (testnum,3 , fd, filsz,SEEK_DATA ,0 ,0 ); ret +=do_lseek (testnum,4 , fd, filsz,SEEK_DATA ,1 ,1 ); ret +=do_lseek (testnum,5 , fd, filsz,SEEK_DATA , bufsz, filsz);
And the expected result of the 5th test should be 'filsz - bufsz' then.
Thanks,
Eryu
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 src/seek_sanity_test: fix test15 SEEK_HOLE expected results
Filesystesm with the "default behaviour" will always return the offset of the end of the file when lseek'ing with SEEK_HOLE. This test does the following:
- fallocate 4 << 20 bytes
- write PAGE_SIZE bytes at offset 0
- writes PAGE_SIZE bytes at offset 4 << 20
Thus, using lseek in an FS with the "default behaviour" will set the position at 4 << 20 + PAGE_SIZE.
---
- Changes since v1
Updated with Eryu suggestions (thanks for reviewing!): update filsz after the last write and set the expected result for the 5th test to 'filsz - bufsz'.
src/seek_sanity_test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
src/seek_sanity_test.c +4 -1
@@ -334,12 +334,15 @@ static int test15(int fd, int testnum)if (ret) goto out; +/* update file size */ + filsz += bufsz; +/* offset at the beginning */ ret +=do_lseek (testnum,1 , fd, filsz,SEEK_HOLE ,0 , bufsz); ret +=do_lseek (testnum,2 , fd, filsz,SEEK_HOLE ,1 , bufsz); ret +=do_lseek (testnum,3 , fd, filsz,SEEK_DATA ,0 ,0 ); ret +=do_lseek (testnum,4 , fd, filsz,SEEK_DATA ,1 ,1 ); - ret +=do_lseek (testnum,5 , fd, filsz,SEEK_DATA , bufsz, filsz); + ret +=do_lseek (testnum,5 , fd, filsz,SEEK_DATA , bufsz, filsz - bufsz); out:do_free (buf);