Re: [LTP] [PATCH v1 1/1] swap: Add exfat to filesystems requiring tst_fill_file

Namjae Jeon <[email protected]>
Newsgroups dev.linux.lists.regressions,it.linux.lists.ltp,org.kernel.vger.linux-kernel
Message-ID <CAKYAXd_3Za8Jzan9VV4WrK1ATB2WXTazLVuGJ5ViQ8RGp0xbLw@mail.gmail.com>
On Tue, Aug 25, 2026 at 10:46 PM Cyril Hrubis <[email protected]> wrote:
>
> Hi!
Hi Cyril, Petr,
> > > That does not make much sense, if swap_activate was added to kernel,
> > > pre-filling the fallocated file shouldn't be needed anymore.
> >
> > Good catch, you're right. I'm also confused, before v7.2 swap worked on exfat,
> > now even with 82a81a7352bc ("exfat: add iomap buffered I/O support") [2]
> > and your fix 03a43677ca91 ("exfat: add swap_activate support") [3] is not
> > working. Obviously the fix was not good enough.
>
> There were two bugs I suppose, one is that fallocate() support for exfat broke
> the swapon on fallocated file. The second bug was introduced later when
> exfat was rewritten to use iomap. The iomap case was fixed in the patch
> above, however it looks like the original bug caused by fallocate()
> implementation for exfat is still there.
Can you check if an attached patch improves this issue?
Thanks.
0001-exfat-map-allocated-extents-for-swap-activation.patch (text/x-patch, 2.1 KB)
From 5679a624816454c8e7683842eb0ab3f1adf0dcca Mon Sep 17 00:00:00 2001
From: Namjae Jeon <[email protected]>
Date: Wed, 26 Aug 2026 09:14:14 +0900
Subject: [PATCH] exfat: map allocated extents for swap activation

exFAT reports allocated ranges beyond valid_size as IOMAP_HOLE when
IOMAP_REPORT is set. iomap_swapfile_activate() also uses IOMAP_REPORT
while collecting physical extents for a swap file, so it treats the
preallocated tail as unallocated and rejects the file with -EINVAL.

Use swap-specific iomap operations that suppress IOMAP_REPORT before
mapping the file. This reports physically allocated ranges as
IOMAP_UNWRITTEN during swap activation without changing the
byte-accurate SEEK_HOLE and SEEK_DATA behavior of the regular iomap
operations.

Fixes: 03a43677ca91 ("exfat: add swap_activate support")
Signed-off-by: Namjae Jeon <[email protected]>
---
 fs/exfat/iomap.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c
index 0c805bf6676a..bf8baf78a9b8 100644
--- a/fs/exfat/iomap.c
+++ b/fs/exfat/iomap.c
@@ -155,6 +155,22 @@ const struct iomap_ops exfat_iomap_ops = {
 	.iomap_begin = exfat_iomap_begin,
 };
 
+static int exfat_swap_iomap_begin(struct inode *inode, loff_t offset,
+		loff_t length, unsigned int flags, struct iomap *iomap,
+		struct iomap *srcmap)
+{
+	/*
+	 * Swap activation needs the physical mappings of preallocated
+	 * ranges. Do not report the VDL tail as a hole.
+	 */
+	return __exfat_iomap_begin(inode, offset, length,
+			flags & ~IOMAP_REPORT, iomap, false);
+}
+
+static const struct iomap_ops exfat_swap_iomap_ops = {
+	.iomap_begin = exfat_swap_iomap_begin,
+};
+
 /*
  * exfat_write_iomap_end - Update the state after write
  *
@@ -274,5 +290,6 @@ const struct iomap_read_ops exfat_iomap_bio_read_ops = {
 int exfat_iomap_swap_activate(struct swap_info_struct *sis,
 			       struct file *file, sector_t *span)
 {
-	return iomap_swapfile_activate(sis, file, span, &exfat_iomap_ops);
+	return iomap_swapfile_activate(sis, file, span,
+				       &exfat_swap_iomap_ops);
 }
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.