[PATCH] knfsd: nfsd4: fix owner-override on open
[firefly-linux-kernel-4.4.55.git] / fs / lockd / svc4proc.c
index a2dd9ccb9b321057b2dd414198e3eba6ce2e3bca..fa370f6eb07b27ddf2b1dc2b984ed5633b3d7c82 100644 (file)
@@ -38,8 +38,8 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
                return nlm_lck_denied_nolocks;
 
        /* Obtain host handle */
-       if (!(host = nlmsvc_lookup_host(rqstp))
-        || (argp->monitor && !host->h_monitored && nsm_monitor(host) < 0))
+       if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
+        || (argp->monitor && nsm_monitor(host) < 0))
                goto no_locks;
        *hostp = host;
 
@@ -260,7 +260,9 @@ static int nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *a
        struct nlm_rqst *call;
        int stat;
 
-       host = nlmsvc_lookup_host(rqstp);
+       host = nlmsvc_lookup_host(rqstp,
+                                 argp->lock.caller,
+                                 argp->lock.len);
        if (host == NULL)
                return rpc_system_err;
 
@@ -420,10 +422,6 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
                                              void              *resp)
 {
        struct sockaddr_in      saddr = rqstp->rq_addr;
-       int                     vers = argp->vers;
-       int                     prot = argp->proto >> 1;
-
-       struct nlm_host         *host;
 
        dprintk("lockd: SM_NOTIFY     called\n");
        if (saddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK)
@@ -438,21 +436,10 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
        /* Obtain the host pointer for this NFS server and try to
         * reclaim all locks we hold on this server.
         */
+       memset(&saddr, 0, sizeof(saddr));
        saddr.sin_addr.s_addr = argp->addr;
+       nlm_host_rebooted(&saddr, argp->mon, argp->len, argp->state);
 
-       if ((argp->proto & 1)==0) {
-               if ((host = nlmclnt_lookup_host(&saddr, prot, vers)) != NULL) {
-                       nlmclnt_recovery(host, argp->state);
-                       nlm_release_host(host);
-               }
-       } else {
-               /* If we run on an NFS server, delete all locks held by the client */
-
-               if ((host = nlm_lookup_host(1, &saddr, prot, vers)) != NULL) {
-                       nlmsvc_free_host_resources(host);
-                       nlm_release_host(host);
-               }
-       }
        return rpc_success;
 }
 
@@ -468,7 +455,7 @@ nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res  *argp,
 
         dprintk("lockd: GRANTED_RES   called\n");
 
-        nlmsvc_grant_reply(rqstp, &argp->cookie, argp->status);
+        nlmsvc_grant_reply(&argp->cookie, argp->status);
         return rpc_success;
 }