|
From: Andy P. <at...@us...> - 2002-04-09 15:08:12
|
Update of /cvsroot/linux-vax/kernel-2.4/fs/lockd
In directory usw-pr-cvs1:/tmp/cvs-serv29245/lockd
Modified Files:
clntlock.c clntproc.c host.c lockd_syms.c mon.c svc.c
svc4proc.c svclock.c svcproc.c svcsubs.c xdr.c xdr4.c
Log Message:
synch 2.4.15 commit 13
Index: clntlock.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/clntlock.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- clntlock.c 14 Jan 2001 16:29:33 -0000 1.1.1.1
+++ clntlock.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -8,6 +8,7 @@
#define __KERNEL_SYSCALLS__
+#include <linux/module.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/nfs_fs.h>
@@ -17,7 +18,7 @@
#include <linux/lockd/lockd.h>
#include <linux/smp_lock.h>
-#define NLMDBG_FACILITY NLMDBG_CIENT
+#define NLMDBG_FACILITY NLMDBG_CLIENT
/*
* Local function prototypes
@@ -131,29 +132,63 @@
*/
/*
+ * Mark the locks for reclaiming.
+ * FIXME: In 2.5 we don't want to iterate through any global file_lock_list.
+ * Maintain NLM lock reclaiming lists in the nlm_host instead.
+ */
+static
+void nlmclnt_mark_reclaim(struct nlm_host *host)
+{
+ struct file_lock *fl;
+ struct inode *inode;
+ struct list_head *tmp;
+
+ list_for_each(tmp, &file_lock_list) {
+ fl = list_entry(tmp, struct file_lock, fl_link);
+
+ inode = fl->fl_file->f_dentry->d_inode;
+ if (inode->i_sb->s_magic != NFS_SUPER_MAGIC)
+ continue;
+ if (fl->fl_u.nfs_fl.host != host)
+ continue;
+ if (!(fl->fl_u.nfs_fl.flags & NFS_LCK_GRANTED))
+ continue;
+ fl->fl_u.nfs_fl.flags |= NFS_LCK_RECLAIM;
+ }
+}
+
+/*
+ * Someone has sent us an SM_NOTIFY. Ensure we bind to the new port number,
+ * that we mark locks for reclaiming, and that we bump the pseudo NSM state.
+ */
+static inline
+void nlmclnt_prepare_reclaim(struct nlm_host *host, u32 newstate)
+{
+ host->h_monitored = 0;
+ host->h_nsmstate = newstate;
+ host->h_state++;
+ host->h_nextrebind = 0;
+ nlm_rebind_host(host);
+ nlmclnt_mark_reclaim(host);
+ dprintk("NLM: reclaiming locks for host %s", host->h_name);
+}
+
+/*
* Reclaim all locks on server host. We do this by spawning a separate
* reclaimer thread.
- * FIXME: should bump MOD_USE_COUNT while reclaiming
*/
void
nlmclnt_recovery(struct nlm_host *host, u32 newstate)
{
- if (!host->h_reclaiming++) {
+ if (host->h_reclaiming++) {
if (host->h_nsmstate == newstate)
return;
- printk(KERN_WARNING
- "lockd: Uh-oh! Interfering reclaims for host %s",
- host->h_name);
- host->h_monitored = 0;
- host->h_nsmstate = newstate;
- host->h_state++;
- nlm_release_host(host);
+ nlmclnt_prepare_reclaim(host, newstate);
} else {
- host->h_monitored = 0;
- host->h_nsmstate = newstate;
- host->h_state++;
+ nlmclnt_prepare_reclaim(host, newstate);
nlm_get_host(host);
- kernel_thread(reclaimer, host, 0);
+ MOD_INC_USE_COUNT;
+ kernel_thread(reclaimer, host, CLONE_SIGNAL);
}
}
@@ -163,27 +198,38 @@
struct nlm_host *host = (struct nlm_host *) ptr;
struct nlm_wait *block;
struct list_head *tmp;
+ struct file_lock *fl;
+ struct inode *inode;
+
+ daemonize();
+ reparent_to_init();
+ snprintf(current->comm, sizeof(current->comm),
+ "%s-reclaim",
+ host->h_name);
/* This one ensures that our parent doesn't terminate while the
* reclaim is in progress */
lock_kernel();
lockd_up();
- /* First, reclaim all locks that have been granted previously. */
+ /* First, reclaim all locks that have been marked. */
restart:
- tmp = file_lock_list.next;
- while (tmp != &file_lock_list) {
- struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
- struct inode *inode = fl->fl_file->f_dentry->d_inode;
- if (inode->i_sb->s_magic == NFS_SUPER_MAGIC &&
- nlm_cmp_addr(NFS_ADDR(inode), &host->h_addr) &&
- fl->fl_u.nfs_fl.state != host->h_state &&
- (fl->fl_u.nfs_fl.flags & NFS_LCK_GRANTED)) {
- fl->fl_u.nfs_fl.flags &= ~ NFS_LCK_GRANTED;
- nlmclnt_reclaim(host, fl); /* This sleeps */
- goto restart;
- }
- tmp = tmp->next;
+ list_for_each(tmp, &file_lock_list) {
+ fl = list_entry(tmp, struct file_lock, fl_link);
+
+ inode = fl->fl_file->f_dentry->d_inode;
+ if (inode->i_sb->s_magic != NFS_SUPER_MAGIC)
+ continue;
+ if (fl->fl_u.nfs_fl.host != host)
+ continue;
+ if (!(fl->fl_u.nfs_fl.flags & NFS_LCK_RECLAIM))
+ continue;
+
+ fl->fl_u.nfs_fl.flags &= ~NFS_LCK_RECLAIM;
+ nlmclnt_reclaim(host, fl);
+ if (signalled())
+ break;
+ goto restart;
}
host->h_reclaiming = 0;
@@ -201,6 +247,7 @@
nlm_release_host(host);
lockd_down();
unlock_kernel();
+ MOD_DEC_USE_COUNT;
return 0;
}
Index: clntproc.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/clntproc.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- clntproc.c 14 Jan 2001 16:29:35 -0000 1.1.1.1
+++ clntproc.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -6,6 +6,7 @@
* Copyright (C) 1996, Olaf Kirch <ok...@mo...>
*/
+#include <linux/config.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/fs.h>
@@ -18,6 +19,7 @@
#include <linux/lockd/sm_inter.h>
#define NLMDBG_FACILITY NLMDBG_CLIENT
+#define NLMCLNT_GRACE_WAIT (5*HZ)
static int nlmclnt_test(struct nlm_rqst *, struct file_lock *);
static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *);
@@ -142,7 +144,7 @@
/* If we're cleaning up locks because the process is exiting,
* perform the RPC call asynchronously. */
- if ((cmd == F_SETLK || cmd == F_SETLKW)
+ if ((IS_SETLK(cmd) || IS_SETLKW(cmd))
&& fl->fl_type == F_UNLCK
&& (current->flags & PF_EXITING)) {
sigfillset(¤t->blocked); /* Mask all signals */
@@ -166,17 +168,16 @@
/* Set up the argument struct */
nlmclnt_setlockargs(call, fl);
- if (cmd == F_GETLK) {
+ if (IS_SETLK(cmd) || IS_SETLKW(cmd)) {
+ if (fl->fl_type != F_UNLCK) {
+ call->a_args.block = IS_SETLKW(cmd) ? 1 : 0;
+ status = nlmclnt_lock(call, fl);
+ } else
+ status = nlmclnt_unlock(call, fl);
+ } else if (IS_GETLK(cmd))
status = nlmclnt_test(call, fl);
- } else if ((cmd == F_SETLK || cmd == F_SETLKW)
- && fl->fl_type == F_UNLCK) {
- status = nlmclnt_unlock(call, fl);
- } else if (cmd == F_SETLK || cmd == F_SETLKW) {
- call->a_args.block = (cmd == F_SETLKW)? 1 : 0;
- status = nlmclnt_lock(call, fl);
- } else {
+ else
status = -EINVAL;
- }
if (status < 0 && (call->a_flags & RPC_TASK_ASYNC))
kfree(call);
@@ -558,19 +559,22 @@
if (task->tk_status < 0) {
dprintk("lockd: unlock failed (err = %d)\n", -task->tk_status);
- goto retry_unlock;
+ goto retry_rebind;
}
- if (status != NLM_LCK_GRANTED
- && status != NLM_LCK_DENIED_GRACE_PERIOD) {
- printk("lockd: unexpected unlock status: %d\n", status);
+ if (status == NLM_LCK_DENIED_GRACE_PERIOD) {
+ rpc_delay(task, NLMCLNT_GRACE_WAIT);
+ goto retry_unlock;
}
+ if (status != NLM_LCK_GRANTED)
+ printk(KERN_WARNING "lockd: unexpected unlock status: %d\n", status);
die:
nlm_release_host(req->a_host);
kfree(req);
return;
- retry_unlock:
+ retry_rebind:
nlm_rebind_host(req->a_host);
+ retry_unlock:
rpc_restart_call(task);
}
@@ -673,6 +677,18 @@
case NLM_LCK_BLOCKED:
printk(KERN_NOTICE "lockd: unexpected status NLM_BLOCKED\n");
return -ENOLCK;
+#ifdef CONFIG_LOCKD_V4
+ case NLM_DEADLCK:
+ return -EDEADLK;
+ case NLM_ROFS:
+ return -EROFS;
+ case NLM_STALE_FH:
+ return -ESTALE;
+ case NLM_FBIG:
+ return -EOVERFLOW;
+ case NLM_FAILED:
+ return -ENOLCK;
+#endif
}
printk(KERN_NOTICE "lockd: unexpected server status %d\n", status);
return -ENOLCK;
Index: host.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/host.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- host.c 25 Feb 2001 23:14:46 -0000 1.1.1.2
+++ host.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -51,7 +51,8 @@
struct nlm_host *
nlmsvc_lookup_host(struct svc_rqst *rqstp)
{
- return nlm_lookup_host(rqstp->rq_client, &rqstp->rq_addr, 0, 0);
+ return nlm_lookup_host(rqstp->rq_client, &rqstp->rq_addr,
+ rqstp->rq_prot, rqstp->rq_vers);
}
/*
@@ -97,7 +98,9 @@
nlm_gc_hosts();
for (hp = &nlm_hosts[hash]; (host = *hp); hp = &host->h_next) {
- if (host->h_version != version || host->h_proto != proto)
+ if (proto && host->h_proto != proto)
+ continue;
+ if (version && host->h_version != version)
continue;
if (nlm_match_host(host, clnt, sin)) {
@@ -325,7 +328,8 @@
}
dprintk("lockd: delete host %s\n", host->h_name);
*q = host->h_next;
- if (host->h_monitored)
+ /* Don't unmonitor hosts that have been invalidated */
+ if (host->h_monitored && !host->h_killed)
nsm_unmonitor(host);
if ((clnt = host->h_rpcclnt) != NULL) {
if (atomic_read(&clnt->cl_users)) {
Index: lockd_syms.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/lockd_syms.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- lockd_syms.c 14 Jan 2001 16:29:39 -0000 1.1.1.1
+++ lockd_syms.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -35,8 +35,4 @@
EXPORT_SYMBOL(nlmsvc_invalidate_client);
EXPORT_SYMBOL(nlmsvc_ops);
-/* Configuration at insmod time */
-EXPORT_SYMBOL(nlmsvc_grace_period);
-EXPORT_SYMBOL(nlmsvc_timeout);
-
#endif /* CONFIG_MODULES */
Index: mon.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/mon.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- mon.c 14 Jan 2001 16:29:39 -0000 1.1.1.1
+++ mon.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -43,7 +43,7 @@
args.addr = host->h_addr.sin_addr.s_addr;
args.prog = NLM_PROGRAM;
- args.vers = 1;
+ args.vers = host->h_version;
args.proc = NLMPROC_NSM_NOTIFY;
memset(res, 0, sizeof(*res));
@@ -146,7 +146,7 @@
u32 addr = ntohl(argp->addr);
dprintk("nsm: xdr_encode_mon(%08x, %d, %d, %d)\n",
- htonl(argp->addr), htonl(argp->proc),
+ htonl(argp->addr), htonl(argp->prog),
htonl(argp->vers), htonl(argp->proc));
/*
Index: svc.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/svc.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- svc.c 25 Feb 2001 23:14:46 -0000 1.1.1.2
+++ svc.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -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
@@ -76,45 +97,27 @@
nlmsvc_pid = current->pid;
up(&lockd_start);
- exit_mm(current);
- current->session = 1;
- current->pgrp = 1;
+ daemonize();
+ reparent_to_init();
sprintf(current->comm, "lockd");
/* Process request with signals blocked. */
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();
- /*
- * N.B. current do_fork() doesn't like NULL task->files,
- * so we defer closing files until forking rpciod.
- */
- exit_files(current);
-
dprintk("NFS locking service started (ver " LOCKD_VERSION ").\n");
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
@@ -127,6 +130,10 @@
spin_lock_irq(¤t->sigmask_lock);
flush_signals(current);
spin_unlock_irq(¤t->sigmask_lock);
+ if (nlmsvc_ops) {
+ nlmsvc_ops->detach();
+ grace_period_expire = set_grace_period();
+ }
}
/*
@@ -137,20 +144,20 @@
*/
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 = svc_recv(serv, rqstp, timeout);
+ if (err == -EAGAIN || err == -EINTR)
continue;
if (err < 0) {
- if (err != -EINTR)
- printk(KERN_WARNING
- "lockd: terminating on error %d\n",
- -err);
+ printk(KERN_WARNING
+ "lockd: terminating on error %d\n",
+ -err);
break;
}
@@ -180,6 +187,8 @@
* shutting down the hosts and clearing the slot.
*/
if (!nlmsvc_pid || current->pid == nlmsvc_pid) {
+ if (nlmsvc_ops)
+ nlmsvc_ops->detach();
nlm_shutdown_hosts();
nlmsvc_pid = 0;
} else
@@ -234,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)
@@ -314,8 +323,11 @@
MODULE_AUTHOR("Olaf Kirch <ok...@mo...>");
MODULE_DESCRIPTION("NFS file locking service version " LOCKD_VERSION ".");
+MODULE_LICENSE("GPL");
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)
@@ -333,13 +345,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
Index: svc4proc.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/svc4proc.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- svc4proc.c 25 Feb 2001 23:14:46 -0000 1.1.1.2
+++ svc4proc.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -420,6 +420,8 @@
void *resp)
{
struct sockaddr_in saddr = rqstp->rq_addr;
+ int vers = rqstp->rq_vers;
+ int prot = rqstp->rq_prot;
struct nlm_host *host;
dprintk("lockd: SM_NOTIFY called\n");
@@ -435,8 +437,8 @@
/* Obtain the host pointer for this NFS server and try to
* reclaim all locks we hold on this server.
*/
- saddr.sin_addr.s_addr = argp->addr;
- if ((host = nlm_lookup_host(NULL, &saddr, IPPROTO_UDP, 1)) != NULL) {
+ saddr.sin_addr.s_addr = argp->addr;
+ if ((host = nlmclnt_lookup_host(&saddr, prot, vers)) != NULL) {
nlmclnt_recovery(host, argp->state);
nlm_release_host(host);
}
@@ -444,7 +446,7 @@
/* If we run on an NFS server, delete all locks held by the client */
if (nlmsvc_ops != NULL) {
struct svc_client *clnt;
- saddr.sin_addr.s_addr = argp->addr;
+ saddr.sin_addr.s_addr = argp->addr;
if ((clnt = nlmsvc_ops->exp_getclient(&saddr)) != NULL
&& (host = nlm_lookup_host(clnt, &saddr, 0, 0)) != NULL) {
nlmsvc_free_host_resources(host);
@@ -549,7 +551,8 @@
PROC(cancel_res, cancelres, norep, res, void),
PROC(unlock_res, unlockres, norep, res, void),
PROC(granted_res, grantedres, norep, res, void),
- PROC(none, void, void, void, void),
+ /* statd callback */
+ PROC(sm_notify, reboot, void, reboot, void),
PROC(none, void, void, void, void),
PROC(none, void, void, void, void),
PROC(none, void, void, void, void),
@@ -558,6 +561,4 @@
PROC(nm_lock, lockargs, res, args, res),
PROC(free_all, notify, void, args, void),
- /* statd callback */
- PROC(sm_notify, reboot, void, reboot, void),
};
Index: svclock.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/svclock.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- svclock.c 14 Jan 2001 16:29:42 -0000 1.1.1.1
+++ svclock.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -31,9 +31,14 @@
#include <linux/lockd/nlm.h>
#include <linux/lockd/lockd.h>
-
#define NLMDBG_FACILITY NLMDBG_SVCLOCK
+#ifdef CONFIG_LOCKD_V4
+#define nlm_deadlock nlm4_deadlock
+#else
+#define nlm_deadlock nlm_lck_denied
+#endif
+
static void nlmsvc_insert_block(struct nlm_block *block, unsigned long);
static int nlmsvc_remove_block(struct nlm_block *block);
static void nlmsvc_grant_callback(struct rpc_task *task);
@@ -330,12 +335,7 @@
case 0:
return nlm_granted;
case EDEADLK:
-#ifdef CONFIG_LOCKD_V4
- return nlm4_deadlock; /* will be downgraded to lck_deined if this
- * is a NLMv1,3 request */
-#else
- /* no applicable NLM status */
-#endif
+ return nlm_deadlock;
case EAGAIN:
return nlm_lck_denied;
default: /* includes ENOLCK */
@@ -346,6 +346,11 @@
if (!wait) {
up(&file->f_sema);
return nlm_lck_denied;
+ }
+
+ if (posix_locks_deadlock(&lock->fl, conflock)) {
+ up(&file->f_sema);
+ return nlm_deadlock;
}
/* If we don't have a block, create and initialize it. Then
Index: svcproc.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/svcproc.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- svcproc.c 25 Feb 2001 23:14:46 -0000 1.1.1.2
+++ svcproc.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -29,17 +29,20 @@
static u32
cast_to_nlm(u32 status, u32 vers)
{
-
+ /* Note: status is assumed to be in network byte order !!! */
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:
+ switch (status) {
+ case nlm_granted:
+ case nlm_lck_denied:
+ case nlm_lck_denied_nolocks:
+ case nlm_lck_blocked:
+ case nlm_lck_denied_grace_period:
+ break;
+ case nlm4_deadlock:
+ status = nlm_lck_denied;
break;
default:
- status = NLM_LCK_DENIED_NOLOCKS;
+ status = nlm_lck_denied_nolocks;
}
}
@@ -445,6 +448,8 @@
void *resp)
{
struct sockaddr_in saddr = rqstp->rq_addr;
+ int vers = rqstp->rq_vers;
+ int prot = rqstp->rq_prot;
struct nlm_host *host;
dprintk("lockd: SM_NOTIFY called\n");
@@ -460,8 +465,8 @@
/* Obtain the host pointer for this NFS server and try to
* reclaim all locks we hold on this server.
*/
- saddr.sin_addr.s_addr = argp->addr;
- if ((host = nlm_lookup_host(NULL, &saddr, IPPROTO_UDP, 1)) != NULL) {
+ saddr.sin_addr.s_addr = argp->addr;
+ if ((host = nlmclnt_lookup_host(&saddr, prot, vers)) != NULL) {
nlmclnt_recovery(host, argp->state);
nlm_release_host(host);
}
@@ -574,7 +579,8 @@
PROC(cancel_res, cancelres, norep, res, void),
PROC(unlock_res, unlockres, norep, res, void),
PROC(granted_res, grantedres, norep, res, void),
- PROC(none, void, void, void, void),
+ /* statd callback */
+ PROC(sm_notify, reboot, void, reboot, void),
PROC(none, void, void, void, void),
PROC(none, void, void, void, void),
PROC(none, void, void, void, void),
@@ -583,6 +589,4 @@
PROC(nm_lock, lockargs, res, args, res),
PROC(free_all, notify, void, args, void),
- /* statd callback */
- PROC(sm_notify, reboot, void, reboot, void),
};
Index: svcsubs.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/svcsubs.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- svcsubs.c 14 Jan 2001 16:29:37 -0000 1.1.1.1
+++ svcsubs.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -305,6 +305,7 @@
dprintk("lockd: invalidating client for %s\n", host->h_name);
nlmsvc_free_host_resources(host);
host->h_expires = 0;
+ host->h_killed = 1;
nlm_release_host(host);
}
}
Index: xdr.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/xdr.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- xdr.c 14 Jan 2001 16:29:46 -0000 1.1.1.1
+++ xdr.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -91,6 +91,7 @@
return NULL;
}
f->size = NFS2_FHSIZE;
+ memset(f->data, 0, sizeof(f->data));
memcpy(f->data, p, NFS2_FHSIZE);
return p + XDR_QUADLEN(NFS2_FHSIZE);
}
@@ -124,7 +125,9 @@
struct file_lock *fl = &lock->fl;
s32 start, len, end;
- if (!(p = xdr_decode_string(p, &lock->caller, &len, NLM_MAXSTRLEN))
+ if (!(p = xdr_decode_string_inplace(p, &lock->caller,
+ &lock->len,
+ NLM_MAXSTRLEN))
|| !(p = nlm_decode_fh(p, &lock->fh))
|| !(p = nlm_decode_oh(p, &lock->oh)))
return NULL;
@@ -311,14 +314,14 @@
nlmsvc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
{
struct nlm_lock *lock = &argp->lock;
- int len;
memset(lock, 0, sizeof(*lock));
locks_init_lock(&lock->fl);
lock->fl.fl_pid = ~(u32) 0;
if (!(p = nlm_decode_cookie(p, &argp->cookie))
- || !(p = xdr_decode_string(p, &lock->caller, &len, NLM_MAXSTRLEN))
+ || !(p = xdr_decode_string_inplace(p, &lock->caller,
+ &lock->len, NLM_MAXSTRLEN))
|| !(p = nlm_decode_fh(p, &lock->fh))
|| !(p = nlm_decode_oh(p, &lock->oh)))
return 0;
@@ -350,9 +353,9 @@
nlmsvc_decode_notify(struct svc_rqst *rqstp, u32 *p, struct nlm_args *argp)
{
struct nlm_lock *lock = &argp->lock;
- int len;
- if (!(p = xdr_decode_string(p, &lock->caller, &len, NLM_MAXSTRLEN)))
+ if (!(p = xdr_decode_string_inplace(p, &lock->caller,
+ &lock->len, NLM_MAXSTRLEN)))
return 0;
argp->state = ntohl(*p++);
return xdr_argsize_check(rqstp, p);
@@ -361,10 +364,11 @@
int
nlmsvc_decode_reboot(struct svc_rqst *rqstp, u32 *p, struct nlm_reboot *argp)
{
- if (!(p = xdr_decode_string(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
+ if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
return 0;
argp->state = ntohl(*p++);
- argp->addr = ntohl(*p++);
+ /* Preserve the address in network byte order */
+ argp->addr = *p++;
return xdr_argsize_check(rqstp, p);
}
Index: xdr4.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/fs/lockd/xdr4.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- xdr4.c 14 Jan 2001 16:29:50 -0000 1.1.1.1
+++ xdr4.c 9 Apr 2002 13:19:34 -0000 1.2
@@ -124,9 +124,9 @@
{
struct file_lock *fl = &lock->fl;
__s64 len, start, end;
- int tmp;
- if (!(p = xdr_decode_string(p, &lock->caller, &tmp, NLM_MAXSTRLEN))
+ if (!(p = xdr_decode_string_inplace(p, &lock->caller,
+ &lock->len, NLM_MAXSTRLEN))
|| !(p = nlm4_decode_fh(p, &lock->fh))
|| !(p = nlm4_decode_oh(p, &lock->oh)))
return NULL;
@@ -320,14 +320,14 @@
nlm4svc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
{
struct nlm_lock *lock = &argp->lock;
- int len;
memset(lock, 0, sizeof(*lock));
locks_init_lock(&lock->fl);
lock->fl.fl_pid = ~(u32) 0;
if (!(p = nlm4_decode_cookie(p, &argp->cookie))
- || !(p = xdr_decode_string(p, &lock->caller, &len, NLM_MAXSTRLEN))
+ || !(p = xdr_decode_string_inplace(p, &lock->caller,
+ &lock->len, NLM_MAXSTRLEN))
|| !(p = nlm4_decode_fh(p, &lock->fh))
|| !(p = nlm4_decode_oh(p, &lock->oh)))
return 0;
@@ -359,9 +359,9 @@
nlm4svc_decode_notify(struct svc_rqst *rqstp, u32 *p, struct nlm_args *argp)
{
struct nlm_lock *lock = &argp->lock;
- int len;
- if (!(p = xdr_decode_string(p, &lock->caller, &len, NLM_MAXSTRLEN)))
+ if (!(p = xdr_decode_string_inplace(p, &lock->caller,
+ &lock->len, NLM_MAXSTRLEN)))
return 0;
argp->state = ntohl(*p++);
return xdr_argsize_check(rqstp, p);
@@ -370,10 +370,11 @@
int
nlm4svc_decode_reboot(struct svc_rqst *rqstp, u32 *p, struct nlm_reboot *argp)
{
- if (!(p = xdr_decode_string(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
+ if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
return 0;
argp->state = ntohl(*p++);
- argp->addr = ntohl(*p++);
+ /* Preserve the address in network byte order */
+ argp->addr = *p++;
return xdr_argsize_check(rqstp, p);
}
|