inode01: Drop redundant 512MB dev_min_size requirement
PATCH 1/1 inode01: Drop redundant 512MB dev_min_size requirement
Commit ecf418722780 ("inode01: increase dev_min_size to fit the peak usage in parallel scenario") raised dev_min_size from the default 300MB to 512MB because mkfs.exfat defaulted to a 32KB cluster size on volumes larger than 256MB, providing only ~9,600 clusters on a 300MB device for the ~10,925 objects created across the 5 parallel workers.
Subsequently, commit 4bf4da8c6fda ("inode01: Configure 4KB cluster size on exfat to prevent ENOSPC") explicitly configured mkfs.exfat with a 4KB cluster size (-c 4K). With 4KB clusters, the 10,925 objects consume under 50MB at peak, and the default 300MB loop device provides ~76,800 clusters on exfat, which is more than sufficient for all supported filesystems.
Drop the redundant .dev_min_size = 512 setting so inode01 uses the default 300MB device size and avoids unnecessary ENOSPC failures when allocating the loop backing file on storage-constrained systems.
--- testcases/kernel/fs/inode/inode01.c | 1 - 1 file changed, 1 deletion(-)
testcases/kernel/fs/inode/inode01.c +0 -1
@@ -260,7 +260,6 @@ static struct tst_test test = { {} }, .needs_root = 1, - .dev_min_size = 512, .forks_child = 1, .needs_checkpoints = 1, .timeout = 300,
Signature · 5 lines
2.56.0.679.gc527c65306-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
Thanks,
Avinesh
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Pushed, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
Quoted 27 lines · Wake Liu via ltp
Commit
ecf418722780("inode01: increasedev_min_sizeto fit the peak usage in parallel scenario") raiseddev_min_sizefrom the default 300MB to 512MB because mkfs.exfat defaulted to a 32KB cluster size on volumes larger than 256MB, providing only ~9,600 clusters on a 300MB device for the ~10,925 objects created across the 5 parallel workers.Subsequently, commit
4bf4da8c6fda("inode01: Configure 4KB cluster size on exfat to prevent ENOSPC") explicitly configured mkfs.exfat with a 4KB cluster size (-c 4K). With 4KB clusters, the 10,925 objects consume under 50MB at peak, and the default 300MB loop device provides ~76,800 clusters on exfat, which is more than sufficient for all supported filesystems.Drop the redundant .dev_min_size = 512 setting so inode01 uses the default 300MB device size and avoids unnecessary ENOSPC failures when allocating the loop backing file on storage-constrained systems.
Signed-off-by Wake Liu <[email protected]>--- testcases/kernel/fs/inode/inode01.c | 1 - 1 file changed, 1 deletion(-)testcases/kernel/fs/inode/inode01.c +0
-0
testcases/kernel/fs/inode/inode01.c static struct tst_test test = { · line 265
Quoted 7 lines
testcases/kernel/fs/inode/inode01.c +0
-1@@ -260,7 +260,6 @@ static struct tst_test test = { {} }, .needs_root = 1, - .dev_min_size = 512, .forks_child = 1, .needs_checkpoints = 1, .timeout = 300,
Unfortunately this change breaks things on tmpfs on systems with 64k pagesize, as library sets
if (!tst_test->dev_min_size)
tmpfs_size = 32;tst_test.c:2005: TINFO: === Testing on tmpfs === tst_test.c:1305: TINFO: Skipping mkfs for TMPFS filesystem tst_test.c:1281: TINFO: Limiting tmpfs size to 32MB tst_test.c:1317: TINFO: Mounting ltp-tmpfs to /var/tmp/LTP_inourxWrA/mntpoint fstyp=tmpfs flags=0 inode01.c:241: TINFO: Testing single-process small tree (depth=3 fanout=4 repetitions=100 workers=1)
inode01.c:228: TPASS: Created and verified 28 objects in mntpoint/inode.5861 inode01.c:241: TINFO: Testing parallel larger trees (depth=6 fanout=6 repetitions=8 workers=5)
inode01.c:61: TBROK: write(3,0x7ffffd679118,73) failed: ENOSPC (28)
so either we need to revert this patch or we can do this lib change
(lib/tst_test.c)
- if (!tst_test->dev_min_size)
- tmpfs_size = 32;
- else
+ if (!tst_test->dev_min_size) {
+ /*
+ * tmpfs charges its size in whole pages, so 32MB is only 512
+ * pages with 64kB pages instead of 8192 with 4kB ones. Scale
+ * it to keep the same page budget on every architecture.
+ */
+ tmpfs_size = 32 * MAX(getpagesize() / 4096, 1);
+ } else {
tmpfs_size = tdev.size;+ }
--
Avinesh
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Wake Liu via ltp
Reviewed-by Wake LiuHi Avinesh,
Quoted 4 lines · Avinesh Kumar
Unfortunately this change breaks things on tmpfs on systems with 64k pagesize, as library sets
if (!tst_test->dev_min_size) tmpfs_size = 32;
...
Quoted 7 lines
so either we need to revert this patch or we can do this lib change
(
lib/tst_test.c)(quoted diff) +0
-3- if (!tst_test->dev_min_size) - tmpfs_size = 32; - else
Review
Quoted 10 lines
(quoted diff) +9
-0+ if (!tst_test->dev_min_size) { + /* + * tmpfs charges its size in whole pages, so 32MB is only 512 + * pages with 64kB pages instead of 8192 with 4kB ones. Scale + * it to keep the same page budget on every architecture. + */ + tmpfs_size = 32 * MAX(getpagesize() / 4096, 1); + } else { tmpfs_size = tdev.size; + }
Thanks for catching this!
I agree with updating limit_tmpfs_mount_size() in lib/tst_test.c rather than reverting. Reverting to .dev_min_size = 512 would bring back loop backing file ENOSPC failures on storage-constrained systems (and even .dev_min_size = 300 would only provide 4800 pages with 64kB pages, still short of the 5460 non-empty files created at peak in inode01).
Scaling the default 32MB tmpfs limit by getpagesize() / 4096 keeps a consistent 8192-page budget across 4kB (32MB), 16kB (128MB, which also matters for 16kB-page Android kernels), and 64kB (512MB) systems while preserving the 2x MemAvailable TCONF guard for low-memory machines.
Since the fix and comment are yours, will you be sending this as a formal patch? Feel free to add my:
(Or let me know if you prefer that I send it out with your Suggested-by.)
Thanks,
Wake
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/1 lib/tst_test.c: Scale default tmpfs size with filesystem block size
When .dev_min_size is not set, limit_tmpfs_mount_size() mounts tmpfs with a fixed 32MB size limit. Because tmpfs allocates space in whole filesystem blocks (kernel PAGE_SIZE), 32MB provides 8192 blocks with 4KB pages, but only 2048 blocks with 16KB pages and 512 blocks with 64KB pages.
After commit 3c212bef5d11 ("inode01: Drop redundant 512MB dev_min_size requirement"), inode01 creates 5460 non-empty files in parallel across 5 workers and fails with ENOSPC on tmpfs when the kernel uses 16KB or 64KB pages.
Query the actual tmpfs block size via memfd_create() and fstatvfs() (falling back to getpagesize() when unavailable) rather than deriving it from getpagesize(), as the kernel page size can also differ from the page size reported to userspace. Scale the default 32MB limit by MAX(block_size / 4096, 1) to keep a consistent 8192-block budget across all page configurations.
---
Context: https://lore.kernel.org/ltp/[email protected]/
lib/tst_test.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
lib/tst_test.c +26 -1
@@ -1257,6 +1257,31 @@ int tst_creat_unlinked(const char *path, int flags, mode_t mode)return fd; } +/* +* tmpfs allocates space in filesystem blocks (kernel PAGE_SIZE), which may +* exceed 4KB or differ from the page size reported to userspace. Query the +* actual tmpfs block size via memfd_create() + fstatvfs() so the default +* mount size keeps an 8192-block budget across all page configurations. +*/ +static unsigned long get_tmpfs_block_size (void ) +{ +struct statvfs st; +int fd =-1 ; + +if (__NR_memfd_create != __LTP__NR_INVALID_SYSCALL) + fd =syscall (__NR_memfd_create,"ltp_tmpfs" ,0 ); + +if (fd >=0 ) { +int ret =fstatvfs (fd, &st); + +SAFE_CLOSE (fd); +if (!ret && st.f_bsize >0 ) +return st.f_bsize; + } + +return getpagesize (); +} +static const char *limit_tmpfs_mount_size (const char *mnt_data,char *buf,size_t buf_size,const char *fs_type) {
@@ -1266,7 +1291,7 @@ static const char *limit_tmpfs_mount_size(const char *mnt_data,return mnt_data;if (!tst_test->dev_min_size) - tmpfs_size =32 ; + tmpfs_size =32 *MAX (get_tmpfs_block_size () /4096 ,1UL );else tmpfs_size = tdev.size;
Signature · 5 lines
2.56.1.750.gf70dc682cf-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] lib/tst_test.c: Scale default tmpfs size with filesystem block size
Hi Wake,
Quoted 1 line · Wake Liu
lib/tst_test.c: Scale default tmpfs size with filesystem block size
Verdict - Reviewed
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp