Merge branch 'for-2.6.27' of git://linux-nfs.org/~bfields/linux
[pandora-kernel.git] / fs / lockd / svcproc.c
index 31cb484..76019d2 100644 (file)
@@ -33,6 +33,7 @@ cast_to_nlm(__be32 status, u32 vers)
                case nlm_lck_denied_nolocks:
                case nlm_lck_blocked:
                case nlm_lck_denied_grace_period:
+               case nlm_drop_reply:
                        break;
                case nlm4_deadlock:
                        status = nlm_lck_denied;
@@ -86,8 +87,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
        return 0;
 
 no_locks:
-       if (host)
-               nlm_release_host(host);
+       nlm_release_host(host);
        if (error)
                return error;
        return nlm_lck_denied_nolocks;
@@ -112,6 +112,7 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
 {
        struct nlm_host *host;
        struct nlm_file *file;
+       int rc = rpc_success;
 
        dprintk("lockd: TEST          called\n");
        resp->cookie = argp->cookie;
@@ -119,7 +120,7 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
        /* Don't accept test requests during grace period */
        if (nlmsvc_grace_period) {
                resp->status = nlm_lck_denied_grace_period;
-               return rpc_success;
+               return rc;
        }
 
        /* Obtain client and file */
@@ -127,13 +128,16 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
                return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
 
        /* Now check for conflicting locks */
-       resp->status = cast_status(nlmsvc_testlock(file, &argp->lock, &resp->lock));
+       resp->status = cast_status(nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie));
+       if (resp->status == nlm_drop_reply)
+               rc = rpc_drop_reply;
+       else
+               dprintk("lockd: TEST          status %d vers %d\n",
+                       ntohl(resp->status), rqstp->rq_vers);
 
-       dprintk("lockd: TEST          status %d vers %d\n",
-               ntohl(resp->status), rqstp->rq_vers);
        nlm_release_host(host);
        nlm_release_file(file);
-       return rpc_success;
+       return rc;
 }
 
 static __be32
@@ -142,6 +146,7 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
 {
        struct nlm_host *host;
        struct nlm_file *file;
+       int rc = rpc_success;
 
        dprintk("lockd: LOCK          called\n");
 
@@ -150,7 +155,7 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
        /* Don't accept new lock requests during grace period */
        if (nlmsvc_grace_period && !argp->reclaim) {
                resp->status = nlm_lck_denied_grace_period;
-               return rpc_success;
+               return rc;
        }
 
        /* Obtain client and file */
@@ -170,13 +175,16 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
 #endif
 
        /* Now try to lock the file */
-       resp->status = cast_status(nlmsvc_lock(rqstp, file, &argp->lock,
+       resp->status = cast_status(nlmsvc_lock(rqstp, file, host, &argp->lock,
                                               argp->block, &argp->cookie));
+       if (resp->status == nlm_drop_reply)
+               rc = rpc_drop_reply;
+       else
+               dprintk("lockd: LOCK         status %d\n", ntohl(resp->status));
 
-       dprintk("lockd: LOCK          status %d\n", ntohl(resp->status));
        nlm_release_host(host);
        nlm_release_file(file);
-       return rpc_success;
+       return rc;
 }
 
 static __be32
@@ -269,7 +277,9 @@ static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
 
 static void nlmsvc_callback_release(void *data)
 {
+       lock_kernel();
        nlm_release_call(data);
+       unlock_kernel();
 }
 
 static const struct rpc_call_ops nlmsvc_callback_ops = {