Skip to content

Commit 6ba0982

Browse files
mcgrofbrauner
authored andcommitted
swapfile: disable swapon for bs > ps devices
Devices which have a requirement for bs > ps cannot be supported for swap as swap still needs work. Now that the block device cache sets the min order for block devices we need this stop gap otherwise all swap operations are rejected. Without this you'll end up with errors on these devices as the swap code still needs much love to support min order. With this we at least now put a stop gap of its use, until the swap subsystem completes its major overhaul: mkswap: /dev/nvme3n1: warning: wiping old swap signature. Setting up swapspace version 1, size = 100 GiB (107374178304 bytes) no label, UUID=6af76b5c-7e7b-4902-b7f7-4c24dde6fa36 swapon: /dev/nvme3n1: swapon failed: Invalid argument Reviewed-by: Davidlohr Bueso <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent d9ec733 commit 6ba0982

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mm/swapfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3322,6 +3322,15 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
33223322
goto bad_swap_unlock_inode;
33233323
}
33243324

3325+
/*
3326+
* The swap subsystem needs a major overhaul to support this.
3327+
* It doesn't work yet so just disable it for now.
3328+
*/
3329+
if (mapping_min_folio_order(mapping) > 0) {
3330+
error = -EINVAL;
3331+
goto bad_swap_unlock_inode;
3332+
}
3333+
33253334
/*
33263335
* Read the swap header.
33273336
*/

0 commit comments

Comments
 (0)