[PATCH] exfat: add swap_activate support

Jan Polensky posted 1 patch 4 days, 17 hours ago
fs/exfat/inode.c | 1 +
fs/exfat/iomap.c | 6 ++++++
fs/exfat/iomap.h | 3 +++
3 files changed, 10 insertions(+)
[PATCH] exfat: add swap_activate support
Posted by Jan Polensky 4 days, 17 hours ago
Commit 614f71ca1bdf ("exfat: add iomap buffered I/O support")
converted exfat buffered I/O to iomap, but did not add a
.swap_activate handler to the address_space_operations.

swapon(2) on an exfat swapfile then fails with EINVAL, which causes
LTP swap tests to fail.

Add exfat_iomap_swap_activate() and hook it into exfat_aops so exfat
uses iomap_swapfile_activate() for swapfile activation.

Fixes: 614f71ca1bdf ("exfat: add iomap buffered I/O support")
Closes: https://lore.kernel.org/all/20260603110212.3020276-1-japo@linux.ibm.com/
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
---
 fs/exfat/inode.c | 1 +
 fs/exfat/iomap.c | 6 ++++++
 fs/exfat/iomap.h | 3 +++
 3 files changed, 10 insertions(+)

diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 96ea243c67db..3b3ac722cf07 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -496,6 +496,7 @@ static const struct address_space_operations exfat_aops = {
 	.release_folio		= iomap_release_folio,
 	.invalidate_folio	= iomap_invalidate_folio,
 	.direct_IO		= exfat_direct_IO,
+	.swap_activate		= exfat_iomap_swap_activate,
 };

 static inline unsigned long exfat_hash(loff_t i_pos)
diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c
index 188df8cfac9a..54c724cea1d0 100644
--- a/fs/exfat/iomap.c
+++ b/fs/exfat/iomap.c
@@ -213,3 +213,9 @@ const struct iomap_read_ops exfat_iomap_bio_read_ops = {
 	.read_folio_range	= iomap_bio_read_folio_range,
 	.submit_read		= exfat_iomap_bio_submit_read,
 };
+
+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);
+}
diff --git a/fs/exfat/iomap.h b/fs/exfat/iomap.h
index 7f8dcbe20a17..295e36312baf 100644
--- a/fs/exfat/iomap.h
+++ b/fs/exfat/iomap.h
@@ -11,4 +11,7 @@ extern const struct iomap_ops exfat_write_iomap_ops;
 extern const struct iomap_writeback_ops exfat_writeback_ops;
 extern 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);
+
 #endif /* _LINUX_EXFAT_IOMAP_H */
--
2.53.0
Re: [PATCH] exfat: add swap_activate support
Posted by Namjae Jeon 4 days, 16 hours ago
On Wed, Jun 3, 2026 at 10:20 PM Jan Polensky <japo@linux.ibm.com> wrote:
>
> Commit 614f71ca1bdf ("exfat: add iomap buffered I/O support")
> converted exfat buffered I/O to iomap, but did not add a
> .swap_activate handler to the address_space_operations.
>
> swapon(2) on an exfat swapfile then fails with EINVAL, which causes
> LTP swap tests to fail.
>
> Add exfat_iomap_swap_activate() and hook it into exfat_aops so exfat
> uses iomap_swapfile_activate() for swapfile activation.
>
> Fixes: 614f71ca1bdf ("exfat: add iomap buffered I/O support")
> Closes: https://lore.kernel.org/all/20260603110212.3020276-1-japo@linux.ibm.com/
> Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Applied it to #dev.
Thanks!