* [LTP] [PATCH v2] syscalls/stat04&lstat03: remove fs block size related code
@ 2025-11-13 16:22 Zorro Lang via ltp
2025-12-18 13:36 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 2+ messages in thread
From: Zorro Lang via ltp @ 2025-11-13 16:22 UTC (permalink / raw)
To: ltp
The st_blksize isn't equivalent to the filesystem block size. The
stat(3) manual describe st_blksize as:
"This field gives the "preferred" block size for efficient filesystem I/O."
So the st_blksize is the "preferred" block size for "efficient" fs
I/O, extN might think the "preferred" block size is fs block size.
But not all filesystems think same with extN. For example, xfs thinks
the "preferred" block size is:
max_t(uint32_t, PAGE_SIZE, mp->m_sb.sb_blocksize)
So you might get st_blksize=4096, no matter on 1k blocksize xfs or 4k
blocksize xfs. We shouldn't expect to use a different blocksize mkfs
option to get a different st_blksize. This part of code is useless,
except causing unexpected test failures on other filesystems (e.g.
xfs, btrfs and so on).
Signed-off-by: Zorro Lang <zlang@kernel.org>
---
Hi,
I tried to fix the mkfs problem last year:
https://lists.linux.it/pipermail/ltp/2024-December/041038.html
Now I got a chance to look back this test failure, I think it's not a mkfs
option problem, but the test case misunderstood the st_blksize.
Except we limit this test only run on extN, or we don't need to make
fs with a different block size, especially shouldn't expect to get
a different st_blksize from that.
Thanks,
Zorro
testcases/kernel/syscalls/lstat/lstat03.c | 12 +-----------
testcases/kernel/syscalls/stat/stat04.c | 11 +----------
2 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/testcases/kernel/syscalls/lstat/lstat03.c b/testcases/kernel/syscalls/lstat/lstat03.c
index 9438e2920..7d9d01ad1 100644
--- a/testcases/kernel/syscalls/lstat/lstat03.c
+++ b/testcases/kernel/syscalls/lstat/lstat03.c
@@ -34,7 +34,6 @@ static void run(void)
TST_EXP_EXPR(file_stat->st_gid != symb_stat->st_gid);
TST_EXP_EXPR(file_stat->st_size != symb_stat->st_size);
TST_EXP_EXPR(file_stat->st_blocks != symb_stat->st_blocks);
- TST_EXP_EXPR(file_stat->st_blksize != symb_stat->st_blksize);
TST_EXP_EXPR(file_stat->st_atime != symb_stat->st_atime);
TST_EXP_EXPR(file_stat->st_mtime != symb_stat->st_mtime);
TST_EXP_EXPR(file_stat->st_ctime != symb_stat->st_ctime);
@@ -42,18 +41,9 @@ static void run(void)
static void setup(void)
{
- char opt_bsize[32];
- const char *const fs_opts[] = {opt_bsize, NULL};
- struct stat sb;
- int pagesize;
int fd;
- /* change st_blksize / st_dev */
- SAFE_STAT(".", &sb);
- pagesize = sb.st_blksize == 4096 ? 1024 : 4096;
-
- snprintf(opt_bsize, sizeof(opt_bsize), "-b %i", pagesize);
- SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
+ SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL);
SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, 0);
SAFE_TOUCH(FILENAME, 0777, NULL);
diff --git a/testcases/kernel/syscalls/stat/stat04.c b/testcases/kernel/syscalls/stat/stat04.c
index 09a9a6823..3c233df51 100644
--- a/testcases/kernel/syscalls/stat/stat04.c
+++ b/testcases/kernel/syscalls/stat/stat04.c
@@ -41,21 +41,12 @@ static void run(void)
static void setup(void)
{
- char opt_bsize[32];
- const char *const fs_opts[] = {opt_bsize, NULL};
- struct stat sb;
- int pagesize;
int fd;
file_path = tst_tmpdir_genpath(FILENAME);
symb_path = tst_tmpdir_genpath(SYMBNAME);
- /* change st_blksize / st_dev */
- SAFE_STAT(".", &sb);
- pagesize = sb.st_blksize == 4096 ? 1024 : 4096;
-
- snprintf(opt_bsize, sizeof(opt_bsize), "-b %i", pagesize);
- SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
+ SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL);
SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, 0);
SAFE_TOUCH(FILENAME, 0777, NULL);
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [LTP] [PATCH v2] syscalls/stat04&lstat03: remove fs block size related code
2025-11-13 16:22 [LTP] [PATCH v2] syscalls/stat04&lstat03: remove fs block size related code Zorro Lang via ltp
@ 2025-12-18 13:36 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 2+ messages in thread
From: Andrea Cervesato via ltp @ 2025-12-18 13:36 UTC (permalink / raw)
To: Zorro Lang, ltp
Hi!
Sorry for the delay to this review.
On Thu Nov 13, 2025 at 5:22 PM CET, Zorro Lang via ltp wrote:
> The st_blksize isn't equivalent to the filesystem block size. The
> stat(3) manual describe st_blksize as:
>
> "This field gives the "preferred" block size for efficient filesystem I/O."
>
> So the st_blksize is the "preferred" block size for "efficient" fs
> I/O, extN might think the "preferred" block size is fs block size.
> But not all filesystems think same with extN. For example, xfs thinks
> the "preferred" block size is:
>
> max_t(uint32_t, PAGE_SIZE, mp->m_sb.sb_blocksize)
>
> So you might get st_blksize=4096, no matter on 1k blocksize xfs or 4k
> blocksize xfs. We shouldn't expect to use a different blocksize mkfs
> option to get a different st_blksize. This part of code is useless,
> except causing unexpected test failures on other filesystems (e.g.
> xfs, btrfs and so on).
>
> Signed-off-by: Zorro Lang <zlang@kernel.org>
> ---
>
> Hi,
>
> I tried to fix the mkfs problem last year:
> https://lists.linux.it/pipermail/ltp/2024-December/041038.html
>
> Now I got a chance to look back this test failure, I think it's not a mkfs
> option problem, but the test case misunderstood the st_blksize.
>
> Except we limit this test only run on extN, or we don't need to make
> fs with a different block size, especially shouldn't expect to get
> a different st_blksize from that.
If testing `st_blksize` is an issue only under certain filesystems, we
should probably test it only when the right ones are in use.
For instance, this can be done as following :
if (!strcmp(tst_device->fs_type, "ext2")) {
/* test `st_blocks` attribute */
}
In this way we avoid to disable `st_blksize` testing for all existing
filesystems.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-18 13:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-13 16:22 [LTP] [PATCH v2] syscalls/stat04&lstat03: remove fs block size related code Zorro Lang via ltp
2025-12-18 13:36 ` Andrea Cervesato via ltp
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.