exfat: swapon(2) fails with EINVAL after iomap conversion
Subsystems (3)
Hi,
we are seeing a regression on linux-next after commit
614f71ca1bdfaa2f25a6f147fe22f3ad031f8e2b
("exfat: add iomap buffered I/O support")
With this change, swapon(2) on an exfat swapfile fails with EINVAL.
Observed fallout in LTP:
swapoff01
swapoff02
swapon01
swapon02
swapon03
Example failure:
tst_test.c:1980: TINFO: === Testing on exfat ===
tst_test.c:1291: TINFO: Formatting /dev/loop0 with exfat opts='' extra opts='' tst_test.c:1303: TINFO: Mounting /dev/loop0 to /tmp/LTP_swaKmkGVo/mntpoint fstyp=exfat flags=0 tse_swap.c:196: TINFO: create a swapfile size of 1 megabytes (MB) tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
tse_swap.c:228: TFAIL: swapon() on exfat failed: EINVAL (22)
and from swapon02:
swapon02.c:56: TWARN: swapon(alreadyused) failed: EINVAL (22) swapon02.c:73: TFAIL: swapon(2) fail with File already used expected EBUSY: EINVAL (22)
The iomap conversion changes exfat_aops to iomap based callbacks, but does not add a .swap_activate handler. The VFS documentation says that ->swap_activate() should call add_swap_extent(), or the helper iomap_swapfile_activate().
So this looks like an exfat swap activation regression triggered by the iomap buffered I/O conversion.
#regzbot introduced: 614f71ca1bdfaa2f25a6f147fe22f3ad031f8e2b
#regzbot monitor: https://lore.kernel.org/all/PUZPR04MB63168E8C2FB92B80F9F6476581002@PUZPR04MB6316.apcprd04.prod.outlook.com/
Thanks
Jan
Namjae Jeon
maintainerQuoted 28 lines · Jan Polensky
Hi,
we are seeing a regression on linux-next after commit
614f71ca1bdfaa2f25a6f147fe22f3ad031f8e2b
("exfat: add iomap buffered I/O support")With this change, swapon(2) on an exfat swapfile fails with EINVAL.
Observed fallout in LTP:
swapoff01
swapoff02
swapon01
swapon02
swapon03Example failure:
tst_test.c:1980: TINFO: === Testing on exfat ===
tst_test.c:1291: TINFO: Formatting/dev/loop0with exfat opts='' extra opts='' tst_test.c:1303: TINFO: Mounting/dev/loop0to/tmp/LTP_swaKmkGVo/mntpointfstyp=exfat flags=0 tse_swap.c:196: TINFO: create a swapfile size of 1 megabytes (MB) tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
tse_swap.c:228: TFAIL:swapon()on exfat failed: EINVAL (22)and from swapon02:
Quoted 8 lines
swapon02.c:56: TWARN: swapon(alreadyused) failed: EINVAL (22) swapon02.c:73: TFAIL: swapon(2) fail with File already used expected EBUSY: EINVAL (22)
The iomap conversion changes
exfat_aopsto iomap based callbacks, but does not add a .swap_activate handler. The VFS documentation says that ->swap_activate() should calladd_swap_extent(), or the helperiomap_swapfile_activate().So this looks like an exfat swap activation regression triggered by the iomap buffered I/O conversion.
You have already suggested a solution. Could you please provide a patch for this ?
Thanks for the report.
PATCH 1/1 exfat: add swap_activate support
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.
--- fs/exfat/inode.c | 1 + fs/exfat/iomap.c | 6 ++++++ fs/exfat/iomap.h | 3 +++ 3 files changed, 10 insertions(+)
fs/exfat/inode.c +1 -0
@@ -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)
fs/exfat/iomap.c +6 -0
@@ -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); +}
fs/exfat/iomap.h +3 -0
@@ -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
Quoted 8 lines · Jan Polensky
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 theaddress_space_operations.swapon(2) on an exfat swapfile then fails with EINVAL, which causes LTP swap tests to fail.
Quoted 6 lines
Add
exfat_iomap_swap_activate()and hook it intoexfat_aopsso exfat usesiomap_swapfile_activate()for swapfile activation.Fixes 614f71ca1bdf ("exfat: add iomap buffered I/O support")Signed-off-by Jan Polensky <[email protected]>
Applied it to #dev.
Thanks!
Re: [PATCH] exfat: add swap_activate support
Quoted 9 lines · Namjae Jeon
Quoted 8 lines · Jan Polensky
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 theaddress_space_operations.swapon(2) on an exfat swapfile then fails with EINVAL, which causes LTP swap tests to fail.
Quoted 8 lines
Quoted 6 lines
Add
exfat_iomap_swap_activate()and hook it intoexfat_aopsso exfat usesiomap_swapfile_activate()for swapfile activation.Fixes 614f71ca1bdf ("exfat: add iomap buffered I/O support")Signed-off-by Jan Polensky <[email protected]>Applied it to #dev.
Thanks!
Hi Namjae,
I think one line might have been missed when applying my patch:
.swap_activate = exfat_iomap_swap_activate,
I checked linux-next (master and next-20260604 / next-20260605), and the issue is still present there.
Link:
https://lore.kernel.org/all/[email protected]/
Could you please take a look?
Thanks,
Jan
Namjae Jeon
maintainerRe: [PATCH] exfat: add swap_activate support
Quoted 26 lines · Jan Polensky
Quoted 9 lines · Namjae Jeon
Quoted 8 lines · Jan Polensky
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 theaddress_space_operations.swapon(2) on an exfat swapfile then fails with EINVAL, which causes LTP swap tests to fail.
Quoted 8 lines
Quoted 6 lines
Add
exfat_iomap_swap_activate()and hook it intoexfat_aopsso exfat usesiomap_swapfile_activate()for swapfile activation.Fixes 614f71ca1bdf ("exfat: add iomap buffered I/O support")Signed-off-by Jan Polensky <[email protected]>Applied it to #dev.
Thanks!Hi Namjae,
I think one line might have been missed when applying my patch:
.swap_activate =
exfat_iomap_swap_activate,
Quoted 7 lines
I checked linux-next (master and next-20260604 / next-20260605), and the issue is still present there.
Link:
https://lore.kernel.org/all/[email protected]/Could you please take a look?
Sorry about that, my bad. Your patch wasn't being applied properly, so I tried to update it manually and made a mistake. Anyway, I have just fixed it. Thank you very much for pointing it out!