diff -u --recursive --new-file linux-2.4.7-locks/fs/lockd/clntlock.c linux-2.4.7-reclaim/fs/lockd/clntlock.c --- linux-2.4.7-locks/fs/lockd/clntlock.c Tue Nov 7 19:18:57 2000 +++ linux-2.4.7-reclaim/fs/lockd/clntlock.c Wed Jul 18 15:47:57 2001 @@ -138,7 +138,7 @@ 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 @@ -153,7 +153,7 @@ host->h_nsmstate = newstate; host->h_state++; nlm_get_host(host); - kernel_thread(reclaimer, host, 0); + kernel_thread(reclaimer, host, CLONE_SIGNAL); } } @@ -167,12 +167,24 @@ /* This one ensures that our parent doesn't terminate while the * reclaim is in progress */ lock_kernel(); + + daemonize(); + strcpy(current->comm, "lockd-reclaim"); + + /* Block signals */ + spin_lock_irq(¤t->sigmask_lock); + siginitsetinv(¤t->blocked, sigmask(SIGKILL)); + recalc_sigpending(current); + spin_unlock_irq(¤t->sigmask_lock); + lockd_up(); + exit_files(current); + /* First, reclaim all locks that have been granted previously. */ restart: tmp = file_lock_list.next; - while (tmp != &file_lock_list) { + while (tmp != &file_lock_list && ! signalled()) { 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 && diff -u --recursive --new-file linux-2.4.7-locks/fs/lockd/host.c linux-2.4.7-reclaim/fs/lockd/host.c --- linux-2.4.7-locks/fs/lockd/host.c Fri Feb 9 20:29:44 2001 +++ linux-2.4.7-reclaim/fs/lockd/host.c Wed Jul 18 15:46:53 2001 @@ -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)) { diff -u --recursive --new-file linux-2.4.7-locks/fs/lockd/mon.c linux-2.4.7-reclaim/fs/lockd/mon.c --- linux-2.4.7-locks/fs/lockd/mon.c Tue Jun 12 04:15:27 2001 +++ linux-2.4.7-reclaim/fs/lockd/mon.c Wed Jul 18 15:46:53 2001 @@ -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)); diff -u --recursive --new-file linux-2.4.7-locks/fs/lockd/svc.c linux-2.4.7-reclaim/fs/lockd/svc.c --- linux-2.4.7-locks/fs/lockd/svc.c Fri Feb 9 20:29:44 2001 +++ linux-2.4.7-reclaim/fs/lockd/svc.c Wed Jul 18 16:36:16 2001 @@ -65,6 +65,7 @@ struct svc_serv *serv = rqstp->rq_server; int err = 0; unsigned long grace_period_expire; + struct k_sigaction sa; /* Lock module and set up kernel thread */ MOD_INC_USE_COUNT; @@ -76,16 +77,20 @@ nlmsvc_pid = current->pid; up(&lockd_start); - exit_mm(current); - current->session = 1; - current->pgrp = 1; + daemonize(); sprintf(current->comm, "lockd"); /* Process request with signals blocked. */ spin_lock_irq(¤t->sigmask_lock); - siginitsetinv(¤t->blocked, sigmask(SIGKILL)); + siginitsetinv(¤t->blocked, sigmask(SIGKILL)|sigmask(SIGCHLD)); recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); + spin_unlock_irq(¤t->sigmask_lock); + + /* Install a handler so SIGCLD is ignored */ + sa.sa.sa_handler = SIG_IGN; + sa.sa.sa_flags = 0; + siginitset(&sa.sa.sa_mask, sigmask(SIGCHLD)); + do_sigaction(SIGCHLD, &sa, NULL); /* kick rpciod */ rpciod_up(); @@ -105,10 +110,10 @@ nlmsvc_grace_period = 10 * HZ; #else if (nlm_grace_period) { - nlmsvc_grace_period += (1 + nlm_grace_period / nlm_timeout) + nlmsvc_grace_period = (1 + nlm_grace_period / nlm_timeout) * nlm_timeout * HZ; } else { - nlmsvc_grace_period += 5 * nlm_timeout * HZ; + nlmsvc_grace_period = 5 * nlm_timeout * HZ; } #endif @@ -135,10 +140,12 @@ * (Theoretically, there shouldn't even be blocked locks * during grace period). */ - if (!nlmsvc_grace_period) { + if (!grace_period_expire) { timeout = nlmsvc_retry_blocked(); - } else if (time_before(nlmsvc_grace_period, jiffies)) + } else if (time_before(grace_period_expire, jiffies)) { + grace_period_expire = 0; nlmsvc_grace_period = 0; + } /* * Find a socket with data available and call its @@ -339,7 +346,7 @@ * 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 diff -u --recursive --new-file linux-2.4.7-locks/fs/lockd/svc4proc.c linux-2.4.7-reclaim/fs/lockd/svc4proc.c --- linux-2.4.7-locks/fs/lockd/svc4proc.c Fri Feb 9 20:29:44 2001 +++ linux-2.4.7-reclaim/fs/lockd/svc4proc.c Wed Jul 18 15:46:53 2001 @@ -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 = htonl(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), }; diff -u --recursive --new-file linux-2.4.7-locks/fs/lockd/svcproc.c linux-2.4.7-reclaim/fs/lockd/svcproc.c --- linux-2.4.7-locks/fs/lockd/svcproc.c Fri Feb 9 20:29:44 2001 +++ linux-2.4.7-reclaim/fs/lockd/svcproc.c Wed Jul 18 15:46:53 2001 @@ -445,6 +445,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 +462,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 = htonl(argp->addr); + if ((host = nlmclnt_lookup_host(&saddr, prot, vers)) != NULL) { nlmclnt_recovery(host, argp->state); nlm_release_host(host); } @@ -574,7 +576,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 +586,4 @@ PROC(nm_lock, lockargs, res, args, res), PROC(free_all, notify, void, args, void), - /* statd callback */ - PROC(sm_notify, reboot, void, reboot, void), }; diff -u --recursive --new-file linux-2.4.7-locks/include/linux/lockd/nlm.h linux-2.4.7-reclaim/include/linux/lockd/nlm.h --- linux-2.4.7-locks/include/linux/lockd/nlm.h Mon Dec 11 22:25:38 2000 +++ linux-2.4.7-reclaim/include/linux/lockd/nlm.h Wed Jul 18 16:03:55 2001 @@ -49,10 +49,10 @@ #define NLMPROC_CANCEL_RES 13 #define NLMPROC_UNLOCK_RES 14 #define NLMPROC_GRANTED_RES 15 +#define NLMPROC_NSM_NOTIFY 16 /* statd callback */ #define NLMPROC_SHARE 20 #define NLMPROC_UNSHARE 21 #define NLMPROC_NM_LOCK 22 #define NLMPROC_FREE_ALL 23 -#define NLMPROC_NSM_NOTIFY 24 /* statd callback */ #endif /* LINUX_LOCKD_NLM_H */ diff -u --recursive --new-file linux-2.4.7-locks/kernel/ksyms.c linux-2.4.7-reclaim/kernel/ksyms.c --- linux-2.4.7-locks/kernel/ksyms.c Wed Jul 18 15:42:35 2001 +++ linux-2.4.7-reclaim/kernel/ksyms.c Wed Jul 18 17:29:32 2001 @@ -467,6 +467,7 @@ EXPORT_SYMBOL(cap_bset); EXPORT_SYMBOL(daemonize); EXPORT_SYMBOL(csum_partial); /* for networking and md */ +EXPORT_SYMBOL(do_sigaction); /* Program loader interfaces */ EXPORT_SYMBOL(setup_arg_pages); diff -u --recursive --new-file linux-2.4.7-locks/net/sunrpc/sched.c linux-2.4.7-reclaim/net/sunrpc/sched.c --- linux-2.4.7-locks/net/sunrpc/sched.c Wed Jul 18 15:43:02 2001 +++ linux-2.4.7-reclaim/net/sunrpc/sched.c Wed Jul 18 15:49:51 2001 @@ -1150,7 +1150,7 @@ /* * Create the rpciod thread and wait for it to start. */ - error = kernel_thread(rpciod, &rpciod_killer, 0); + error = kernel_thread(rpciod, &rpciod_killer, CLONE_SIGNAL); if (error < 0) { printk(KERN_WARNING "rpciod_up: create thread failed, error=%d\n", error); rpciod_users--; diff -u --recursive --new-file linux-2.4.7-locks/net/sunrpc/svc.c linux-2.4.7-reclaim/net/sunrpc/svc.c --- linux-2.4.7-locks/net/sunrpc/svc.c Thu Jun 21 02:42:19 2001 +++ linux-2.4.7-reclaim/net/sunrpc/svc.c Wed Jul 18 15:50:10 2001 @@ -136,7 +136,7 @@ serv->sv_nrthreads++; rqstp->rq_server = serv; - error = kernel_thread((int (*)(void *)) func, rqstp, 0); + error = kernel_thread((int (*)(void *)) func, rqstp, CLONE_SIGNAL); if (error < 0) goto out_thread; error = 0;