* [LTP] [PATCH] tse_swap: Fill swapfile with zeroes on exFAT
@ 2026-11-10 11:21 Wake Liu via ltp
2026-11-10 13:05 ` [LTP] " linuxtestproject.agent
2026-11-11 6:18 ` [LTP] [PATCH] " Wake Liu via ltp
0 siblings, 2 replies; 3+ messages in thread
From: Wake Liu via ltp @ 2026-11-10 11:21 UTC (permalink / raw)
To: ltp; +Cc: Wake Liu
Since commit bf1797960c20 ("exfat: add fallocate
FALLOC_FL_ALLOCATE_RANGE support") in v7.1, fallocate() succeeds on
exFAT. It only allocates clusters and leaves the valid data length
(VDL) unchanged, so tst_prealloc_size_fd() no longer falls back to
writing zeroes and the swapfile is left unwritten beyond the header
written by mkswap.
Since exFAT was converted to iomap in v7.2, swapon() maps the file via
iomap_swapfile_activate(), which queries the mapping with IOMAP_REPORT.
exFAT reports the range beyond the VDL as IOMAP_HOLE, so swapon()
rejects the file as having unallocated extents, and swapon01-03 and
swapoff01-02 fail on exFAT with:
tse_swap.c:228: TFAIL: swapon() on exfat failed: EINVAL (22)
This matches swapon(8), which notes that files preallocated with
fallocate(1) may be interpreted as files with holes depending on the
filesystem, and that writing the file with zeroes is the most portable
way to create a swap file.
Fill the swapfile with zeroes on exFAT, as is already done for old
XFS, so that the whole file is written before mkswap and swapon().
Signed-off-by: Wake Liu <wakel@google.com>
---
libs/swap/tse_swap.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libs/swap/tse_swap.c b/libs/swap/tse_swap.c
index ae3c19313..1e40d0d62 100644
--- a/libs/swap/tse_swap.c
+++ b/libs/swap/tse_swap.c
@@ -145,6 +145,7 @@ int make_swapfile(const char *file, const int lineno,
unsigned int blocks = 0;
size_t pg_size = sysconf(_SC_PAGESIZE);
char mnt_path[PATH_MAX];
+ long fs_type;
safe_statvfs(file, lineno, ".", &fs_info);
@@ -177,8 +178,12 @@ int make_swapfile(const char *file, const int lineno,
if (prealloc_contiguous_file(swapfile, blk_size, blocks) != 0)
tst_brk_(file, lineno, TBROK, "Failed to create swapfile");
- /* Fill the file if needed (specific to old xfs filesystems) */
- if (tst_fs_type(swapfile) == TST_XFS_MAGIC) {
+ /*
+ * Fill the file if needed: swapon() rejects preallocated but
+ * unwritten blocks on old XFS and on exFAT.
+ */
+ fs_type = tst_fs_type(swapfile);
+ if (fs_type == TST_XFS_MAGIC || fs_type == TST_EXFAT_MAGIC) {
if (tst_fill_file(swapfile, 0, blk_size, blocks) != 0)
tst_brk_(file, lineno, TBROK, "Failed to fill swapfile");
}
--
2.56.0.506.g506a7eabc5-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [LTP] tse_swap: Fill swapfile with zeroes on exFAT
2026-11-10 11:21 [LTP] [PATCH] tse_swap: Fill swapfile with zeroes on exFAT Wake Liu via ltp
@ 2026-11-10 13:05 ` linuxtestproject.agent
2026-11-11 6:18 ` [LTP] [PATCH] " Wake Liu via ltp
1 sibling, 0 replies; 3+ messages in thread
From: linuxtestproject.agent @ 2026-11-10 13:05 UTC (permalink / raw)
To: Wake Liu; +Cc: ltp
Hi Wake,
On Tue Nov 10, 2026, Wake Liu wrote:
> tse_swap: Fill swapfile with zeroes on exFAT
> - /* Fill the file if needed (specific to old xfs filesystems) */
> - if (tst_fs_type(swapfile) == TST_XFS_MAGIC) {
> + /*
> + * Fill the file if needed: swapon() rejects preallocated but
> + * unwritten blocks on old XFS and on exFAT.
> + */
> + fs_type = tst_fs_type(swapfile);
> + if (fs_type == TST_XFS_MAGIC || fs_type == TST_EXFAT_MAGIC) {
> if (tst_fill_file(swapfile, 0, blk_size, blocks) != 0)
> tst_brk_(file, lineno, TBROK, "Failed to fill swapfile");
> }
The swapon() failure on fallocate()-preallocated exFAT swapfiles in v7.2 is a
kernel regression that was fixed in v7.4 by kernel commit 4483ab85d1e0
("exfat: map allocated extents for swap activation"), which suppresses
IOMAP_REPORT during swap activation so preallocated blocks beyond valid_size
are mapped as IOMAP_UNWRITTEN instead of IOMAP_HOLE. Filling the swapfile with
zeroes on exFAT works around this kernel bug in LTP and masks the failure on
kernels missing that fix, so this change should be dropped.
Verdict - Needs revision
---
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [LTP] [PATCH] tse_swap: Fill swapfile with zeroes on exFAT
2026-11-10 11:21 [LTP] [PATCH] tse_swap: Fill swapfile with zeroes on exFAT Wake Liu via ltp
2026-11-10 13:05 ` [LTP] " linuxtestproject.agent
@ 2026-11-11 6:18 ` Wake Liu via ltp
1 sibling, 0 replies; 3+ messages in thread
From: Wake Liu via ltp @ 2026-11-11 6:18 UTC (permalink / raw)
To: ltp
Hi,
Please drop this patch. As the review pointed out, the swapon() failure
on preallocated exFAT swapfiles is a kernel regression fixed in
v7.4-rc1 by commit 4483ab85d1e0 ("exfat: map allocated extents for
swap activation"), so LTP should keep reporting it on kernels without
that fix.
Sorry for the noise.
Thanks,
Wake
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-11 6:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10 11:21 [LTP] [PATCH] tse_swap: Fill swapfile with zeroes on exFAT Wake Liu via ltp
2026-11-10 13:05 ` [LTP] " linuxtestproject.agent
2026-11-11 6:18 ` [LTP] [PATCH] " Wake Liu 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.