* [PATCH] src/seek_sanity_test: fix test15 SEEK_HOLE expected results
@ 2017-05-23 14:06 Luis Henriques
2017-05-23 14:21 ` Jan Kara
2017-05-23 15:56 ` Eryu Guan
0 siblings, 2 replies; 4+ messages in thread
From: Luis Henriques @ 2017-05-23 14:06 UTC (permalink / raw)
To: fstests; +Cc: Luis Henriques, Jan Kara
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.
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
src/seek_sanity_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index d52e2b6dab79..b35a324c749c 100644
--- a/src/seek_sanity_test.c
+++ b/src/seek_sanity_test.c
@@ -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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] src/seek_sanity_test: fix test15 SEEK_HOLE expected results
2017-05-23 14:06 [PATCH] src/seek_sanity_test: fix test15 SEEK_HOLE expected results Luis Henriques
@ 2017-05-23 14:21 ` Jan Kara
2017-05-23 15:56 ` Eryu Guan
1 sibling, 0 replies; 4+ messages in thread
From: Jan Kara @ 2017-05-23 14:21 UTC (permalink / raw)
To: Luis Henriques; +Cc: fstests, Jan Kara
On Tue 23-05-17 15:06:18, Luis Henriques wrote:
> 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.
>
> Cc: Jan Kara <jack@suse.cz>
> Signed-off-by: Luis Henriques <lhenriques@suse.com>
Thanks for fixing this. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> src/seek_sanity_test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
> index d52e2b6dab79..b35a324c749c 100644
> --- a/src/seek_sanity_test.c
> +++ b/src/seek_sanity_test.c
> @@ -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);
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] src/seek_sanity_test: fix test15 SEEK_HOLE expected results
2017-05-23 14:06 [PATCH] src/seek_sanity_test: fix test15 SEEK_HOLE expected results Luis Henriques
2017-05-23 14:21 ` Jan Kara
@ 2017-05-23 15:56 ` Eryu Guan
2017-05-23 16:19 ` [PATCH v2] " Luis Henriques
1 sibling, 1 reply; 4+ messages in thread
From: Eryu Guan @ 2017-05-23 15:56 UTC (permalink / raw)
To: Luis Henriques; +Cc: fstests, Jan Kara
On Tue, May 23, 2017 at 03:06:18PM +0100, Luis Henriques wrote:
> 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.
Thanks for fixing it! I've tested it on a "default behavior" filesystem
(gfs2) this time, and test passed.
>
> Cc: Jan Kara <jack@suse.cz>
> Signed-off-by: Luis Henriques <lhenriques@suse.com>
> ---
> src/seek_sanity_test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
> index d52e2b6dab79..b35a324c749c 100644
> --- a/src/seek_sanity_test.c
> +++ b/src/seek_sanity_test.c
> @@ -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.
> 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);
And the expected result of the 5th test should be 'filsz - bufsz' then.
Thanks,
Eryu
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] src/seek_sanity_test: fix test15 SEEK_HOLE expected results
2017-05-23 15:56 ` Eryu Guan
@ 2017-05-23 16:19 ` Luis Henriques
0 siblings, 0 replies; 4+ messages in thread
From: Luis Henriques @ 2017-05-23 16:19 UTC (permalink / raw)
To: fstests; +Cc: Eryu Guan, Jan Kara, 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
- 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.
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
- 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(-)
diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index d52e2b6dab79..064a8fa5822f 100644
--- a/src/seek_sanity_test.c
+++ b/src/seek_sanity_test.c
@@ -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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-23 16:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 14:06 [PATCH] src/seek_sanity_test: fix test15 SEEK_HOLE expected results Luis Henriques
2017-05-23 14:21 ` Jan Kara
2017-05-23 15:56 ` Eryu Guan
2017-05-23 16:19 ` [PATCH v2] " Luis Henriques
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.