has an inherent weakness: If a client is off the network for too long its locks on files on NFS4 shares will expire. In this case another client can theoretically lock one of these files, make changes to it and unlock it again. If the client is back on the network it will get the lock back but the file has changed without the client realising it. This could lead to data corruption.
The Linux kernel provides the
parameter to deal with locked files for which the lock was lost as described above:
- If set to
0 (the default) attempting to read from or write to an open file with a lost lock will fail with
- If set to
1 the kernel NFS4 client will attempt to reclaim the lock and assume the file was not changed in the meantime.
The default behaviour causes applications to crash with NFS4 home directories, for instance web browsers or mail clients, if the server is not reachable for a few minutes.
Configuration for All Recent Linux Distributions
To immediately activate the change without rebooting execute the following command:
echo Y > /sys/module/nfs/parameters/recover_lost_locks
To persistently set the parameter create a file
with the following content:
options nfs recover_lost_locks=1