]> www.infradead.org Git - users/jedix/linux-maple.git/commit
nfs: fix a deadlock in nfs client initialization
authorScott Mayhew <smayhew@redhat.com>
Tue, 5 Dec 2017 18:55:44 +0000 (13:55 -0500)
committerBrian Maly <brian.maly@oracle.com>
Mon, 15 Oct 2018 20:55:58 +0000 (16:55 -0400)
commitee06145bd8375dfeae0df768794318dc96ba2010
treefc99f47f0cdaae249e32ddf40f70f6a4a8042ae1
parent077770ba0c266b52bfba798fb39c47a5edec8322
nfs: fix a deadlock in nfs client initialization

The following deadlock can occur between a process waiting for a client
to initialize in while walking the client list during nfsv4 server trunking
detection and another process waiting for the nfs_clid_init_mutex so it
can initialize that client:

Process 1                               Process 2
---------                               ---------
spin_lock(&nn->nfs_client_lock);
list_add_tail(&CLIENTA->cl_share_link,
        &nn->nfs_client_list);
spin_unlock(&nn->nfs_client_lock);
                                        spin_lock(&nn->nfs_client_lock);
                                        list_add_tail(&CLIENTB->cl_share_link,
                                                &nn->nfs_client_list);
                                        spin_unlock(&nn->nfs_client_lock);
                                        mutex_lock(&nfs_clid_init_mutex);
                                        nfs41_walk_client_list(clp, result, cred);
                                        nfs_wait_client_init_complete(CLIENTA);
(waiting for nfs_clid_init_mutex)

Make sure nfs_match_client() only evaluates clients that have completed
initialization in order to prevent that deadlock.

This patch also fixes v4.0 trunking behavior by not marking the client
NFS_CS_READY until the clientid has been confirmed.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Orabug: 28486463

(cherry picked from commit c156618e15101a9cc8c815108fec0300a0ec6637)
Signed-off-by: Calum Mackay <calum.mackay@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
fs/nfs/client.c
fs/nfs/nfs4client.c