SUNRPC: Set memalloc_nofs_save() for sync tasks
authorBenjamin Coddington <bcodding@redhat.com>
Wed, 3 Mar 2021 13:47:16 +0000 (08:47 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Mon, 8 Mar 2021 20:32:16 +0000 (15:32 -0500)
We could recurse into NFS doing memory reclaim while sending a sync task,
which might result in a deadlock.  Set memalloc_nofs_save for sync task
execution.

Fixes: a1231fda7e94 ("SUNRPC: Set memalloc_nofs_save() on all rpciod/xprtiod jobs")
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/sched.c

index cf702a5..39ed0e0 100644 (file)
@@ -963,8 +963,11 @@ void rpc_execute(struct rpc_task *task)
 
        rpc_set_active(task);
        rpc_make_runnable(rpciod_workqueue, task);
-       if (!is_async)
+       if (!is_async) {
+               unsigned int pflags = memalloc_nofs_save();
                __rpc_execute(task);
+               memalloc_nofs_restore(pflags);
+       }
 }
 
 static void rpc_async_schedule(struct work_struct *work)