syscalls/statx01: Update the stx_blocks check
PATCH 1/1 syscalls/statx01: Update the stx_blocks check
After talking with Jan Kara we decided that the previous check wasn't 100% right.
* In some cases the data for small files can be stored along with the file metadata and in such case the number of allocated blocks would be zero.
* I've been assured that the filesystem blocks size is <= than the optimal transfer block size and while the definition for stx_blksize is quite vague it should be good enough for the test.
Note that we also rely on the fact that we write 256 bytes to the file, which is smaller than any known block size, so@most one block would be allocated.
--- testcases/kernel/syscalls/statx/statx01.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/statx/statx01.c +1 -1
@@ -90,7 +90,7 @@ static void test_normal_file(void) buff.stx_mode, MODE); -if (buff.stx_blocks >0 && buff.stx_blocks <=128 ) +if (buff.stx_blocks <= buff.stx_blksize/512 )tst_res (TPASS ,"stx_blocks(%" PRIu64") is valid" , buff.stx_blocks);else
Signature · 1 line
2.16.4
PATCH 1/1 syscalls/statx01: Update the stx_blocks check
Quoted 7 lines · Cyril Hrubis
After talking with Jan Kara we decided that the previous check wasn't 100% right.
* In some cases the data for small files can be stored along with the file metadata and in such case the number of allocated blocks would be zero.
Quoted 7 lines
* I've been assured that the filesystem blocks size is <= than the optimal transfer block size and while the definition for
stx_blksizeis quite vague it should be good enough for the test.Note that we also rely on the fact that we write 256 bytes to the file, which is smaller than any known block size, so at most one block would be allocated.
This is not 100% correct as filesystem is in principle free to allocate arbitrary amount of metadata for the file and account it in stx_blocks. Just no sane filesystem does it... So I think the test is worth a try. We can always relax it if it proves to be too big hassle.
Quoted 2 lines
Signed-off-by Cyril Hrubis <[email protected]>CC Jan Kara <[email protected]>
You can add:
Honza
Quoted 20 lines
--- testcases/kernel/syscalls/statx/statx01.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)testcases/kernel/syscalls/statx/statx01.c +1
-1@@ -90,7 +90,7 @@ static void test_normal_file(void) buff.stx_mode, MODE); -if (buff.stx_blocks >0 && buff.stx_blocks <=128 ) +if (buff.stx_blocks <= buff.stx_blksize/512 )tst_res (TPASS ,"stx_blocks(%" PRIu64") is valid" , buff.stx_blocks);else Signature · 1 line
2.16.4
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 1/1 syscalls/statx01: Update the stx_blocks check
Hi!
Quoted 1 line
Acked-by Jan Kara <[email protected]>
Added and pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]