patch-2.4.11-dontuse linux/fs/lockd/svc.c
Next file: linux/fs/lockd/svc4proc.c
Previous file: linux/fs/lockd/mon.c
Back to the patch index
Back to the overall index
- Lines: 167
- Date:
Wed Oct 3 22:27:48 2001
- Orig file:
v2.4.10/linux/fs/lockd/svc.c
- Orig date:
Sun Sep 23 11:41:00 2001
diff -u --recursive --new-file v2.4.10/linux/fs/lockd/svc.c linux/fs/lockd/svc.c
@@ -15,6 +15,7 @@
#define __KERNEL_SYSCALLS__
#include <linux/config.h>
#include <linux/module.h>
+#include <linux/init.h>
#include <linux/sched.h>
#include <linux/errno.h>
@@ -43,7 +44,7 @@
static DECLARE_MUTEX(nlmsvc_sema);
static unsigned int nlmsvc_users;
static pid_t nlmsvc_pid;
-unsigned long nlmsvc_grace_period;
+int nlmsvc_grace_period;
unsigned long nlmsvc_timeout;
static DECLARE_MUTEX_LOCKED(lockd_start);
@@ -55,6 +56,26 @@
*/
unsigned long nlm_grace_period;
unsigned long nlm_timeout = LOCKD_DFLT_TIMEO;
+unsigned long nlm_udpport, nlm_tcpport;
+
+static unsigned long set_grace_period(void)
+{
+ unsigned long grace_period;
+
+ /* Note: nlm_timeout should always be nonzero */
+ if (nlm_grace_period)
+ grace_period = ((nlm_grace_period + nlm_timeout - 1)
+ / nlm_timeout) * nlm_timeout * HZ;
+ else
+ grace_period = nlm_timeout * 5 * HZ;
+ nlmsvc_grace_period = 1;
+ return grace_period + jiffies;
+}
+
+static inline void clear_grace_period(void)
+{
+ nlmsvc_grace_period = 0;
+}
/*
* This is the lockd kernel thread
@@ -84,7 +105,7 @@
spin_lock_irq(¤t->sigmask_lock);
siginitsetinv(¤t->blocked, sigmask(SIGKILL));
recalc_sigpending(current);
- spin_unlock_irq(¤t->sigmask_lock);
+ spin_unlock_irq(¤t->sigmask_lock);
/* kick rpciod */
rpciod_up();
@@ -93,21 +114,10 @@
if (!nlm_timeout)
nlm_timeout = LOCKD_DFLT_TIMEO;
-
-#ifdef RPC_DEBUG
- nlmsvc_grace_period = 10 * HZ;
-#else
- if (nlm_grace_period) {
- nlmsvc_grace_period += (1 + nlm_grace_period / nlm_timeout)
- * nlm_timeout * HZ;
- } else {
- nlmsvc_grace_period += 5 * nlm_timeout * HZ;
- }
-#endif
-
- grace_period_expire = nlmsvc_grace_period + jiffies;
nlmsvc_timeout = nlm_timeout * HZ;
+ grace_period_expire = set_grace_period();
+
/*
* The main request loop. We don't terminate until the last
* NFS mount or NFS daemon has gone away, and we've been sent a
@@ -122,13 +132,7 @@
spin_unlock_irq(¤t->sigmask_lock);
if (nlmsvc_ops) {
nlmsvc_ops->detach();
-#ifdef RPC_DEBUG
- nlmsvc_grace_period = 10 * HZ;
-#else
- nlmsvc_grace_period += 5 * nlm_timeout * HZ;
-
-#endif
- grace_period_expire = nlmsvc_grace_period + jiffies;
+ grace_period_expire = set_grace_period();
}
}
@@ -140,16 +144,15 @@
*/
if (!nlmsvc_grace_period) {
timeout = nlmsvc_retry_blocked();
- } else if (time_before(nlmsvc_grace_period, jiffies))
- nlmsvc_grace_period = 0;
+ } else if (time_before(grace_period_expire, jiffies))
+ clear_grace_period();
/*
* Find a socket with data available and call its
* recvfrom routine.
*/
- if ((err = svc_recv(serv, rqstp, timeout)) == -EAGAIN
- || err == -EINTR
- )
+ err = svc_recv(serv, rqstp, timeout);
+ if (err == -EAGAIN || err == -EINTR)
continue;
if (err < 0) {
printk(KERN_WARNING
@@ -240,9 +243,9 @@
goto out;
}
- if ((error = svc_makesock(serv, IPPROTO_UDP, 0)) < 0
+ if ((error = svc_makesock(serv, IPPROTO_UDP, nlm_udpport)) < 0
#ifdef CONFIG_NFSD_TCP
- || (error = svc_makesock(serv, IPPROTO_TCP, 0)) < 0
+ || (error = svc_makesock(serv, IPPROTO_TCP, nlm_tcpport)) < 0
#endif
) {
if (warned++ == 0)
@@ -322,6 +325,8 @@
MODULE_DESCRIPTION("NFS file locking service version " LOCKD_VERSION ".");
MODULE_PARM(nlm_grace_period, "10-240l");
MODULE_PARM(nlm_timeout, "3-20l");
+MODULE_PARM(nlm_udpport, "0-65535l");
+MODULE_PARM(nlm_tcpport, "0-65535l");
int
init_module(void)
@@ -339,13 +344,31 @@
/* FIXME: delete all NLM clients */
nlm_shutdown_hosts();
}
+#else
+/* not a module, so process bootargs
+ * lockd.udpport and lockd.tcpport
+ */
+
+static int __init udpport_set(char *str)
+{
+ nlm_udpport = simple_strtoul(str, NULL, 0);
+ return 1;
+}
+static int __init tcpport_set(char *str)
+{
+ nlm_tcpport = simple_strtoul(str, NULL, 0);
+ return 1;
+}
+__setup("lockd.udpport=", udpport_set);
+__setup("lockd.tcpport=", tcpport_set);
+
#endif
/*
* Define NLM program and procedures
*/
static struct svc_version nlmsvc_version1 = {
- 1, 16, nlmsvc_procedures, NULL
+ 1, 17, nlmsvc_procedures, NULL
};
static struct svc_version nlmsvc_version3 = {
3, 24, nlmsvc_procedures, NULL
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)