[PATCH/RFC] nfs: NFS_SWAP should depend on SWAP

From: Geert Uytterhoeven
Date: Mon Dec 30 2019 - 10:32:44 EST


If CONFIG_SWAP=n, it does not make much sense to offer the user the
option to enable support for swapping over NFS, as that will still fail
at run time:

# swapon /swap
swapon: /swap: swapon failed: Function not implemented

Fix this by adding a dependency on CONFIG_SWAP.

Fixes: a564b8f0398636ba ("nfs: enable swap on NFS")
Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
---
Marked RFC, as this still doesn't seem to work.
When enabled, the kernel log is spammed with:

[ 449.371536] __swap_writepage: 413288 callbacks suppressed
[ 449.371577] Write error on dio swapfile (10047488)
[ 449.382435] Write error on dio swapfile (14147584)
[ 449.387320] Write error on dio swapfile (10919936)
[ 449.392474] Write error on dio swapfile (8945664)
[ 449.397263] Write error on dio swapfile (24256512)
[ 449.402330] Write error on dio swapfile (14307328)
[ 449.407195] Write error on dio swapfile (229376)
[ 449.412031] Write error on dio swapfile (10293248)
[ 449.416891] Write error on dio swapfile (2007040)

Platform is 32-bit Cortex A9 with 32 MiB of RAM (hence the need for
swap).
---
fs/nfs/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index 295a7a21b7744014..e7dd07f47825939e 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -90,7 +90,7 @@ config NFS_V4
config NFS_SWAP
bool "Provide swap over NFS support"
default n
- depends on NFS_FS
+ depends on NFS_FS && SWAP
select SUNRPC_SWAP
help
This option enables swapon to work on files located on NFS mounts.
--
2.17.1