Skip to content

Commit 5676680

Browse files
riteshharjanigregkh
authored andcommitted
ext4: implement swap_activate aops using iomap
commit 0e6895b upstream. After moving ext4's bmap to iomap interface, swapon functionality on files created using fallocate (which creates unwritten extents) are failing. This is since iomap_bmap interface returns 0 for unwritten extents and thus generic_swapfile_activate considers this as holes and hence bail out with below kernel msg :- [340.915835] swapon: swapfile has holes To fix this we need to implement ->swap_activate aops in ext4 which will use ext4_iomap_report_ops. Since we only need to return the list of extents so ext4_iomap_report_ops should be enough. Cc: [email protected] Reported-by: Yuxuan Shui <[email protected]> Fixes: ac58e4f ("ext4: move ext4 bmap to use iomap infrastructure") Signed-off-by: Ritesh Harjani <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9129151 commit 5676680

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

fs/ext4/inode.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,6 +3601,13 @@ static int ext4_set_page_dirty(struct page *page)
36013601
return __set_page_dirty_buffers(page);
36023602
}
36033603

3604+
static int ext4_iomap_swap_activate(struct swap_info_struct *sis,
3605+
struct file *file, sector_t *span)
3606+
{
3607+
return iomap_swapfile_activate(sis, file, span,
3608+
&ext4_iomap_report_ops);
3609+
}
3610+
36043611
static const struct address_space_operations ext4_aops = {
36053612
.readpage = ext4_readpage,
36063613
.readahead = ext4_readahead,
@@ -3616,6 +3623,7 @@ static const struct address_space_operations ext4_aops = {
36163623
.migratepage = buffer_migrate_page,
36173624
.is_partially_uptodate = block_is_partially_uptodate,
36183625
.error_remove_page = generic_error_remove_page,
3626+
.swap_activate = ext4_iomap_swap_activate,
36193627
};
36203628

36213629
static const struct address_space_operations ext4_journalled_aops = {
@@ -3632,6 +3640,7 @@ static const struct address_space_operations ext4_journalled_aops = {
36323640
.direct_IO = noop_direct_IO,
36333641
.is_partially_uptodate = block_is_partially_uptodate,
36343642
.error_remove_page = generic_error_remove_page,
3643+
.swap_activate = ext4_iomap_swap_activate,
36353644
};
36363645

36373646
static const struct address_space_operations ext4_da_aops = {
@@ -3649,6 +3658,7 @@ static const struct address_space_operations ext4_da_aops = {
36493658
.migratepage = buffer_migrate_page,
36503659
.is_partially_uptodate = block_is_partially_uptodate,
36513660
.error_remove_page = generic_error_remove_page,
3661+
.swap_activate = ext4_iomap_swap_activate,
36523662
};
36533663

36543664
static const struct address_space_operations ext4_dax_aops = {
@@ -3657,6 +3667,7 @@ static const struct address_space_operations ext4_dax_aops = {
36573667
.set_page_dirty = noop_set_page_dirty,
36583668
.bmap = ext4_bmap,
36593669
.invalidatepage = noop_invalidatepage,
3670+
.swap_activate = ext4_iomap_swap_activate,
36603671
};
36613672

36623673
void ext4_set_aops(struct inode *inode)

0 commit comments

Comments
 (0)