[Devel] [PATCH VZ9] nfs: don't allow file lock and exception stacks be freezable

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue May 20 06:26:19 MSK 2025


This should prevent freezer semi-deadlock when nfs stack freezes while
holding inode or other file related lock, and there is a task waiting
for this same lock which thus now can never be frozen (unless thawed and
retried).

Now we explicitly wait for any nfs related code to finish before
considering it frozen, so it should not hold any file related locks and
thus should not induce this semi-deadlock.

Note: There is a drawback of this approach if nfs hangs on something
that can lead to totally non freezable setup, where previously if we
were lucky and no one was blocked by auxiliary locks held by nfs freeze
was possible.

https://virtuozzo.atlassian.net/browse/VSTOR-97985
Fixes: 20ac17f50d30 ("ms/NFS/CIFS/SUNRPC: don't allow to freeze execution")
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 fs/nfs/nfs4proc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 405f73e80ab5..10760a237660 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -53,7 +53,6 @@
 #include <linux/module.h>
 #include <linux/xattr.h>
 #include <linux/utsname.h>
-#include <linux/freezer.h>
 #include <linux/iversion.h>
 
 #include "nfs4_fs.h"
@@ -432,7 +431,7 @@ static int nfs4_delay_interruptible(long *timeout)
 {
 	might_sleep();
 
-	freezable_schedule_timeout_interruptible_unsafe(nfs4_update_delay(timeout));
+	schedule_timeout_interruptible(nfs4_update_delay(timeout));
 	if (!signal_pending(current))
 		return 0;
 	return __fatal_signal_pending(current) ? -EINTR :-ERESTARTSYS;
@@ -7498,10 +7497,8 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
 			break;
 
 		status = -ERESTARTSYS;
-		freezer_do_not_count();
 		wait_woken(&waiter.wait, TASK_INTERRUPTIBLE,
 			   NFS4_LOCK_MAXTIMEOUT);
-		freezer_count();
 	} while (!signalled());
 
 	remove_wait_queue(q, &waiter.wait);
-- 
2.49.0



More information about the Devel mailing list