]> git.karo-electronics.de Git - linux-beck.git/commitdiff
nfsd: Ensure lookup_clientid() takes client_lock
authorTrond Myklebust <trond.myklebust@primarydata.com>
Wed, 30 Jul 2014 12:27:09 +0000 (08:27 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 1 Aug 2014 20:28:23 +0000 (16:28 -0400)
Ensure that the client lookup is done safely under the client_lock, so
we're not relying on the client_mutex.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c

index 68383b09c7dce649f64944ef18050f79fd5357c9..f9d077d800ee7d1214f2ad1334f4fc6f8bc52dfb 100644 (file)
@@ -3451,13 +3451,17 @@ static __be32 lookup_clientid(clientid_t *clid,
         * will be false.
         */
        WARN_ON_ONCE(cstate->session);
+       spin_lock(&nn->client_lock);
        found = find_confirmed_client(clid, false, nn);
-       if (!found)
+       if (!found) {
+               spin_unlock(&nn->client_lock);
                return nfserr_expired;
+       }
+       atomic_inc(&found->cl_refcount);
+       spin_unlock(&nn->client_lock);
 
        /* Cache the nfs4_client in cstate! */
        cstate->clp = found;
-       atomic_inc(&found->cl_refcount);
        return nfs_ok;
 }