patch-2.2.18 linux/fs/lockd/svcproc.c
Next file: linux/fs/lockd/svcshare.c
Previous file: linux/fs/lockd/svclock.c
Back to the patch index
Back to the overall index
- Lines: 191
- Date:
Sat Nov 18 00:57:44 2000
- Orig file:
v2.2.17/fs/lockd/svcproc.c
- Orig date:
Fri Apr 21 12:46:43 2000
diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/fs/lockd/svcproc.c linux/fs/lockd/svcproc.c
@@ -14,6 +14,8 @@
#include <linux/sunrpc/svc.h>
#include <linux/sunrpc/clnt.h>
#include <linux/nfsd/nfsd.h>
+#include <linux/lockd/xdr.h>
+#include <linux/lockd/xdr4.h>
#include <linux/lockd/lockd.h>
#include <linux/lockd/share.h>
#include <linux/lockd/sm_inter.h>
@@ -23,6 +25,7 @@
static u32 nlmsvc_callback(struct svc_rqst *, u32, struct nlm_res *);
static void nlmsvc_callback_exit(struct rpc_task *);
+static u32 cast_to_nlm(u32, u32);
/*
* Obtain client and file from arguments
@@ -93,6 +96,7 @@
{
struct nlm_host *host;
struct nlm_file *file;
+ u32 status;
dprintk("lockd: TEST called\n");
resp->cookie = argp->cookie;
@@ -108,9 +112,12 @@
return rpc_success;
/* Now check for conflicting locks */
- resp->status = nlmsvc_testlock(file, &argp->lock, &resp->lock);
+ status = nlmsvc_testlock(file, &argp->lock, &resp->lock);
+ dprintk("test: status before %d\n", ntohl(status));
+ resp->status = cast_to_nlm(status, rqstp->rq_vers);
- dprintk("lockd: TEST status %d\n", ntohl(resp->status));
+ 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;
@@ -122,6 +129,7 @@
{
struct nlm_host *host;
struct nlm_file *file;
+ u32 status;
dprintk("lockd: LOCK called\n");
@@ -150,8 +158,9 @@
#endif
/* Now try to lock the file */
- resp->status = nlmsvc_lock(rqstp, file, &argp->lock,
- argp->block, &argp->cookie);
+ status = nlmsvc_lock(rqstp, file, &argp->lock,
+ argp->block, &argp->cookie);
+ resp->status = cast_to_nlm(status, rqstp->rq_vers);
dprintk("lockd: LOCK status %d\n", ntohl(resp->status));
nlm_release_host(host);
@@ -165,6 +174,7 @@
{
struct nlm_host *host;
struct nlm_file *file;
+ u32 status;
dprintk("lockd: CANCEL called\n");
@@ -181,7 +191,8 @@
return rpc_success;
/* Try to cancel request. */
- resp->status = nlmsvc_cancel_blocked(file, &argp->lock);
+ status = nlmsvc_cancel_blocked(file, &argp->lock);
+ resp->status = cast_to_nlm(status, rqstp->rq_vers);
dprintk("lockd: CANCEL status %d\n", ntohl(resp->status));
nlm_release_host(host);
@@ -198,6 +209,7 @@
{
struct nlm_host *host;
struct nlm_file *file;
+ u32 status;
dprintk("lockd: UNLOCK called\n");
@@ -214,7 +226,8 @@
return rpc_success;
/* Now try to remove the lock */
- resp->status = nlmsvc_unlock(file, &argp->lock);
+ status = nlmsvc_unlock(file, &argp->lock);
+ resp->status = cast_to_nlm(status, rqstp->rq_vers);
dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status));
nlm_release_host(host);
@@ -322,6 +335,7 @@
{
struct nlm_host *host;
struct nlm_file *file;
+ u32 status;
dprintk("lockd: SHARE called\n");
@@ -338,7 +352,8 @@
return rpc_success;
/* Now try to create the share */
- resp->status = nlmsvc_share_file(host, file, argp);
+ status = nlmsvc_share_file(host, file, argp);
+ resp->status = cast_to_nlm(status, rqstp->rq_vers);
dprintk("lockd: SHARE status %d\n", ntohl(resp->status));
nlm_release_host(host);
@@ -355,6 +370,7 @@
{
struct nlm_host *host;
struct nlm_file *file;
+ u32 status;
dprintk("lockd: UNSHARE called\n");
@@ -371,7 +387,8 @@
return rpc_success;
/* Now try to lock the file */
- resp->status = nlmsvc_unshare_file(host, file, argp);
+ status = nlmsvc_unshare_file(host, file, argp);
+ resp->status = cast_to_nlm(status, rqstp->rq_vers);
dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status));
nlm_release_host(host);
@@ -446,8 +463,8 @@
if ((clnt = nlmsvc_ops->exp_getclient(&saddr)) != NULL
&& (host = nlm_lookup_host(clnt, &saddr, 0, 0)) != NULL) {
nlmsvc_free_host_resources(host);
+ nlm_release_host(host);
}
- nlm_release_host(host);
}
return rpc_success;
@@ -476,10 +493,14 @@
call->a_host = host;
memcpy(&call->a_args, resp, sizeof(*resp));
- if (nlmclnt_async_call(call, proc, nlmsvc_callback_exit) < 0)
- return rpc_system_err;
+ if (nlmsvc_async_call(call, proc, nlmsvc_callback_exit) < 0)
+ goto error;
return rpc_success;
+ error:
+ nlm_release_host(host);
+ kfree(call);
+ return rpc_system_err;
}
static void
@@ -492,10 +513,30 @@
task->tk_pid, -task->tk_status);
}
nlm_release_host(call->a_host);
- rpc_release_task(task);
kfree(call);
}
+static u32
+cast_to_nlm(u32 status, u32 vers)
+{
+
+ if (vers != 4){
+ switch(ntohl(status)){
+ case NLM_LCK_GRANTED:
+ case NLM_LCK_DENIED:
+ case NLM_LCK_DENIED_NOLOCKS:
+ case NLM_LCK_BLOCKED:
+ case NLM_LCK_DENIED_GRACE_PERIOD:
+ break;
+ default:
+ status = NLM_LCK_DENIED_NOLOCKS;
+ }
+ }
+
+ return (status);
+
+}
+
/*
* NLM Server procedures.
*/
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)