Skip to contentSkip to conversation

NLM lock failover

PATCH In review Wendy Cheng 1 participant 1 message Aug 1, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 NLM lock failover

The patch piggy-backs the logic into "rq_daddr" field of struct svc_rqst where NFS server ip address is stored. Upon writing IPv4 address in standard dot notation into /proc/fs/nfsd/nlm_unlock, the logic examines NLM's global nlm_files list and subsequently unlock the associated file if server ip address matches.

fs/lockd/svcsubs.c | 58 +++++++++++++++++++++++++++++++++++++
+++----
fs/nfsd/nfsctl.c | 57 +++++++++++++++++++++++++++++++++++++
+++++

include/linux/lockd/bind.h  |    5 +++
include/linux/lockd/lockd.h |    3 ++
include/linux/nfsd/debug.h  |    1
net/sunrpc/svcsock.c        |    5 +++
6 files changed, 124 insertions(+), 5 deletions(-)
include/linux/lockd/lockd.h +3 -0
@@ -105,6 +105,7 @@ struct nlm_file {
 	unsigned int		f_count;	/* reference count */
 	struct semaphore	f_sema;		/* avoid concurrent access */
 	int		       	f_hash;		/* hash of f_handle */
+	__u32			f_iaddr;	/* server ip for failover */
 };
 
 /*
@@ -133,6 +134,7 @@ struct nlm_block {
 #define NLM_ACT_CHECK		0		/* check for locks */
 #define NLM_ACT_MARK		1		/* mark & sweep */
 #define NLM_ACT_UNLOCK		2		/* release all locks */
+#define NLM_ACT_FO_UNLOCK	3		/* failover release locks */
 
 /*
  * Global variables
@@ -196,6 +198,7 @@ void		  nlm_release_file(struct nlm_file
 void		  nlmsvc_mark_resources(void);
 void		  nlmsvc_free_host_resources(struct nlm_host *);
 void		  nlmsvc_invalidate_all(void);
+int 		  nlmsvc_fo_unlock(struct in_addr *);
 
 static __inline__ struct inode *
 nlmsvc_file_inode(struct nlm_file *file)
net/sunrpc/svcsock.c +5 -0
@@ -454,6 +454,7 @@ svc_recvfrom(struct svc_rqst *rqstp, str
 	struct msghdr	msg;
 	struct socket	*sock;
 	int		len, alen;
+	struct sockaddr_in   daddr;
 
 	rqstp->rq_addrlen = sizeof(rqstp->rq_addr);
 	sock = rqstp->rq_sock->sk_sock;
@@ -474,6 +475,10 @@ svc_recvfrom(struct svc_rqst *rqstp, str
 	alen = sizeof(rqstp->rq_addr);
 	sock->ops->getname(sock, (struct sockaddr *)&rqstp->rq_addr, &alen, 1);
 
+	/* add server ip for nlm lock failover */
+	sock->ops->getname(sock, (struct sockaddr *)&daddr, &alen, 0);
+	rqstp->rq_daddr = daddr.sin_addr.s_addr;
+
 	dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n",
 		rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len);
 
fs/lockd/svcsubs.c +53 -5

106 lines not on this page · raw message

include/linux/lockd/bind.h +5 -0
@@ -33,4 +33,9 @@ extern int	nlmclnt_proc(struct inode *, 
 extern int	lockd_up(void);
 extern void	lockd_down(void);
 
+/*
+ * NLM failover
+ */
+extern int     nlmsvc_fo_unlock(struct in_addr *);
+
 #endif /* LINUX_LOCKD_BIND_H */
fs/nfsd/nfsctl.c +57 -0

93 lines not on this page · raw message

include/linux/nfsd/debug.h +1 -0
@@ -32,6 +32,7 @@
 #define NFSDDBG_REPCACHE	0x0080
 #define NFSDDBG_XDR		0x0100
 #define NFSDDBG_LOCKD		0x0200
+#define NFSDDBG_CLUSTER 	0x0400
 #define NFSDDBG_ALL		0x7FFF
 #define NFSDDBG_NOCHANGE	0xFFFF
 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs