From: Trond Myklebust <trond.myklebust@fys.uio.no>

NFSv2/v3 locking: Patch by Patrice Dumas to implement
nlmsvc_proc_granted_res.  When a server receives that callback it should
deallocate the corresponding blocked lock using the nlmsvc_grant_reply
function.


---

 fs/lockd/svc4proc.c         |   21 +++++++++++++++++++--
 fs/lockd/svcproc.c          |   19 +++++++++++++++++--
 include/linux/lockd/lockd.h |    1 +
 3 files changed, 37 insertions(+), 4 deletions(-)

diff -puN fs/lockd/svc4proc.c~nfs-lockd-sync-01 fs/lockd/svc4proc.c
--- 25/fs/lockd/svc4proc.c~nfs-lockd-sync-01	2004-02-29 14:55:39.000000000 -0800
+++ 25-akpm/fs/lockd/svc4proc.c	2004-02-29 14:55:39.000000000 -0800
@@ -453,6 +453,24 @@ nlm4svc_proc_sm_notify(struct svc_rqst *
 }
 
 /*
+ * client sent a GRANTED_RES, let's remove the associated block
+ */
+static int
+nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res  *argp,
+                                                void            *resp)
+{
+        if (!nlmsvc_ops)
+                return rpc_success;
+
+        dprintk("lockd: GRANTED_RES   called\n");
+
+        nlmsvc_grant_reply(&argp->cookie, argp->status);
+        return rpc_success;
+}
+
+
+
+/*
  * This is the generic lockd callback for async RPC calls
  */
 static u32
@@ -515,7 +533,6 @@ nlm4svc_callback_exit(struct rpc_task *t
 #define nlm4svc_proc_lock_res	nlm4svc_proc_null
 #define nlm4svc_proc_cancel_res	nlm4svc_proc_null
 #define nlm4svc_proc_unlock_res	nlm4svc_proc_null
-#define nlm4svc_proc_granted_res	nlm4svc_proc_null
 
 struct nlm_void			{ int dummy; };
 
@@ -548,7 +565,7 @@ struct svc_procedure		nlmsvc_procedures4
   PROC(lock_res,	lockres,	norep,		res,	void, 1),
   PROC(cancel_res,	cancelres,	norep,		res,	void, 1),
   PROC(unlock_res,	unlockres,	norep,		res,	void, 1),
-  PROC(granted_res,	grantedres,	norep,		res,	void, 1),
+  PROC(granted_res,	res,		norep,		res,	void, 1),
   /* statd callback */
   PROC(sm_notify,	reboot,		void,		reboot,	void, 1),
   PROC(none,		void,		void,		void,	void, 0),
diff -puN fs/lockd/svcproc.c~nfs-lockd-sync-01 fs/lockd/svcproc.c
--- 25/fs/lockd/svcproc.c~nfs-lockd-sync-01	2004-02-29 14:55:39.000000000 -0800
+++ 25-akpm/fs/lockd/svcproc.c	2004-02-29 14:55:39.000000000 -0800
@@ -479,6 +479,22 @@ nlmsvc_proc_sm_notify(struct svc_rqst *r
 }
 
 /*
+ * client sent a GRANTED_RES, let's remove the associated block
+ */
+static int
+nlmsvc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res  *argp,
+                                                void            *resp)
+{
+	if (!nlmsvc_ops)
+		return rpc_success;
+
+	dprintk("lockd: GRANTED_RES   called\n");
+
+	nlmsvc_grant_reply(&argp->cookie, argp->status);
+	return rpc_success;
+}
+
+/*
  * This is the generic lockd callback for async RPC calls
  */
 static u32
@@ -541,7 +557,6 @@ nlmsvc_callback_exit(struct rpc_task *ta
 #define nlmsvc_proc_lock_res	nlmsvc_proc_null
 #define nlmsvc_proc_cancel_res	nlmsvc_proc_null
 #define nlmsvc_proc_unlock_res	nlmsvc_proc_null
-#define nlmsvc_proc_granted_res	nlmsvc_proc_null
 
 struct nlm_void			{ int dummy; };
 
@@ -576,7 +591,7 @@ struct svc_procedure		nlmsvc_procedures[
   PROC(lock_res,	lockres,	norep,		res,	void, 1),
   PROC(cancel_res,	cancelres,	norep,		res,	void, 1),
   PROC(unlock_res,	unlockres,	norep,		res,	void, 1),
-  PROC(granted_res,	grantedres,	norep,		res,	void, 1),
+  PROC(granted_res,	res,		norep,		res,	void, 1),
   /* statd callback */
   PROC(sm_notify,	reboot,		void,		reboot,	void, 1),
   PROC(none,		void,		void,		void,	void, 1),
diff -puN include/linux/lockd/lockd.h~nfs-lockd-sync-01 include/linux/lockd/lockd.h
--- 25/include/linux/lockd/lockd.h~nfs-lockd-sync-01	2004-02-29 14:55:39.000000000 -0800
+++ 25-akpm/include/linux/lockd/lockd.h	2004-02-29 14:55:39.000000000 -0800
@@ -165,6 +165,7 @@ u32		  nlmsvc_cancel_blocked(struct nlm_
 unsigned long	  nlmsvc_retry_blocked(void);
 int		  nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
 					int action);
+void	  nlmsvc_grant_reply(struct nlm_cookie *cookie, u32 status);
 
 /*
  * File handling for the server personality

_