From nobody@FreeBSD.org  Fri Jan  5 01:28:14 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 034ED16A416
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  5 Jan 2007 01:28:14 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id E8C2113C469
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  5 Jan 2007 01:28:13 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l051SDvO050922
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 5 Jan 2007 01:28:13 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l051SDx6050921;
	Fri, 5 Jan 2007 01:28:13 GMT
	(envelope-from nobody)
Message-Id: <200701050128.l051SDx6050921@www.freebsd.org>
Date: Fri, 5 Jan 2007 01:28:13 GMT
From: Douglas Rudoff<joseph.blough@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [rpc] 30 second delay in NFS lock of file after waiting for lock
X-Send-Pr-Version: www-3.0

>Number:         107555
>Category:       kern
>Synopsis:       [rpc] 30 second delay in NFS lock of file after waiting for lock
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    dfr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 05 01:30:30 GMT 2007
>Closed-Date:    Tue May 06 16:27:19 UTC 2008
>Last-Modified:  Tue May 06 16:27:19 UTC 2008
>Originator:     Douglas Rudoff
>Release:        6.1
>Organization:
Isilon
>Environment:
FreeBSD drudoffbsd.isilon.com 6.1-RELEASE-p7 FreeBSD 6.1-RELEASE-p7 #3: Tue Sep 26 14:10:13 PDT 2006 root@:/usr/obj/usr/src/sys/SM865DESKTOP i386
>Description:
With a certain Linux release if a process places a waiting NFS lock on
a file on a FreeBSD NFS server, when the lock on the file is available
it takes a multiple of 30 seconds for the client's lock request to complete
even if the lock is availble after waiting only a few seconds.

The Linux release is "CentOS release 4.1 (Final)" with uname printing
2.6.9-11.ELsmp #1 SMP Wed Jun 8 17:54:20 CDT 2005 i686 i386.

This problem does not occur with a Solaris NFS server

This problem does not occur if the Linux client is RedHat "Fedora Core
release 3 (Heidelberg)" with uname "2.6.9-1.667smp #1 SMP Tue Nov 2
14:59:52 EST 2004" after the patch in
http://www.freebsd.org/cgi/query-pr.cgi?pr=misc/107530 is made to
FreeBSD's rpc.lockd.

I have my test program below, but I've included the procedure here to
explain what I'm seeing.

1) Have a FreeBSD NFS server mounted on the Linux box with the release
mentioned above.

2) Have two shells on the Linux box.

3) In one shell run the test program (A) to lock a file on the FreeBSD
box and sleep. Something like "./lock_test /mnt/bsd/test/a 10" to sleep
for 10 seconds.

4) While the test program (A) has locked the file and is sleeping, run
the test program (B) in the other shell "./lock_test /mnt/bsd/test/a"

After A finishes its sleep and unlocks the file, B should get the lock
immediately. Instead it will take exactly 30 seconds for to execute
B's call to fcntl() for the waiting lock request.

If A is given a sleep greater than 30 seconds, B will take exactly 60
seconds to complete its lock request. If A is given a sleep greater
than 60 seconds, B will take 90 seconds to complete its lock request.

I discovered a difference in the order of NLM messags sent from the
lockd between FreeBSD and Sun.

Here are the NLM messages with a FreeBSD NFS server (with A and first
process requesting the lock and B the second process):

Lock Request (from A)
Lock Reply GRANTED (to A)
Lock Request (from B)
Lock Reply BLOCKED (to B)
[After A is finished sleeping while locking the file]
Unlock Request (from A)
Lock GRANTED callback (to B)
Unlock Reply GRANTED (to A)
[Now nothing happens until 30 seconds after A's initial lock request]
Lock Request (from B)
Lock Reply GRANTED (to B)
Unlock Request (from B)
Unlock Reply GRANTED (to B)

Notes:
1) rpc.lockd grants B's waiting request for lock before it informs A
   that it's been unlocked.
2) B isn't acknowledging the granted lock callback.
2) B requests a lock again after it receives its granted callback even
   though it should be necessary.

Trace of NLM calls using a Solaris NFS server (with same Linux client):

Lock Request (from A)
Lock Reply GRANTED (to A)
Lock Request (from B)
Lock Reply BLOCKED (to B)
[After A is finished sleeping while locking the file]
Unlock Request (from A)
Unlock Reply GRANTED (to A)
Lock GRANTED callback (to B)
Lock GRANTED Reply GRANTED (from B)
Unlock Request (from B)
Unlock Request (from A)
Unlock Reply GRANTED (to B)
Unlock Reply GRANTED (to A)

Notes:
1) Solaris' lockd replies to A's unlock request before granting the
   lock to B.
2) B accepts the lock callback (as expected)
3) A does an unneeded lock request at the end right before it exits

It doesn't matter if A and B are running on the same machine, as long
as B is on the problem Linux release the 30 second wait occurs. (This
was a test to see if it the wait was internal to the Linux kernel if
it was aware of two locks on the same file with different processes).

Running FreeBSD's rpc.lockd in debug mode showed a near 30 second gap
in log messages after A unlocked the file until B's lock was
processed (it's not a 30 second gap as it doesn't include the wait
between starting A and B):

Jan  4 14:57:05 <16.7> anadoug-1(id1) rpc.lockd: Exiting unlock...
Jan  4 14:57:27 <16.7> anadoug-1(id1) rpc.lockd: nlm4_lock from 10.54.141.75


Analysis:
1) Solaris's and FreeBSD's lockd process requests in not quite
   the same order.
2) The Solaris version works as expected with this Linux
   client.
3) The FreeBSD version does work but has those mysterious 30
   second wait added to the locking process.
4) The multiple of 30 second wait is very bizarre. It's not clear
   whether it's happening on the server or client

>How-To-Repeat:
See test procedure above using this source code:

#include <stdio.h>
#include <fcntl.h>
#include <time.h>
#include <errno.h>

int main(int argc, char **argv)
{
	int fd;
	char *filename;
	struct flock fl;
	int sleeptime = 0;
	time_t start;

	if (argc < 2) {
		printf("Missing file name arg\n");
		exit(1);
	}
	filename = argv[1];
	fd = open(filename, O_RDWR|O_CREAT,0644);
	if (fd < 0) {
		perror("open");
		exit(1);
	}
	if (argc == 3) {
		sleeptime = atoi(argv[2]);
	}

	fl.l_type = F_WRLCK;
	fl.l_whence = SEEK_SET;
	fl.l_start = 0;
	fl.l_len = 0;
	printf("Requesting fcntl lock of %s...\n", filename);
	start = time(0);
	if( fcntl (fd, F_SETLKW, &fl) < 0 ) {
		printf("Error: '%s' (lock request elapsed time %d secs)\n",
		    strerror(errno), time(0) - start);
		exit(1);
	}
	printf("fcntl lock %s : OK (time to lock %d secs)\n", filename, time(0) - start);
	printf("Sleeping for %d secs...\n", sleeptime);
	sleep(sleeptime);

	fl.l_type = F_UNLCK;
	fl.l_whence = SEEK_SET;
	fl.l_start = 0;
	fl.l_len = 0;
	printf("Unlocking...\n");
	start = time(0);
	if( fcntl (fd, F_SETLK, &fl) < 0 ) {
		printf("Error (unlock elapsed time %d secs): ", time(0) - start);
		perror("fcntl unlock");
		exit(1);
	}
	printf("Unlocked  (time to unlock %d secs)\n", time(0) - start);
}

>Fix:

>Release-Note:
>Audit-Trail:

From: Doug Rudoff <joseph.blough@yahoo.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/107555: [rpc] 30 second delay in NFS lock of file after waiting for lock
Date: Wed, 7 Feb 2007 16:48:01 -0800 (PST)

 I've discovered what's happening.
 
 On this particular Linux client, a "rpcinfo -p" showed
 no registered nfs rpc services, including the
 important "nlockmgr". This was despite nfs and lockd
 running on the Linux client.
 
 On the FreeBSD side, when the original lock is
 released by the first client app, lockd then attempts
 to send a NLM_GRANTED to the waiting second client
 app. But with nlockmgr not a registered rpc service,
 lockd is not able to create an rpc client handle and
 thus is unable to send the message. However, lockd
 does no error checking after attempting to send the
 granted message and assumes the message was sent
 successfully. At this point lockd has the file locked
 by a client that is unaware it has a lock
 
 The waiting Linux client app gives up waiting for the
 NLM_GRANTED from FreeBSD's lockd after a set period
 and sends a new lock request. Since lockd is already
 holding the lock on the file for the client the lock
 is granted.
 
 When I restarted nfs on the Linux client, nlockmgr was
 listed as an rpc service, and the 30 second delay in
 getting a lock did not occur.
 
 You may wonder how any other messages are returned to
 the client if the client's rpc services aren't
 registered. Because when lockd receives a message, it
 knows the client handle that sent the message and can
 immediately reply to the same handle. But for the
 NLM_GRANTED message, the client handle isn't stored
 with the list of and it has to ask the client host for
 the handle through the rpc services that are
 registered.
 
 To sum things up:
 1) The problem was due to the missing nlockmgr rpc
 service on the Linux client.
 2) FreeBSD's lockd assumes it sent an NLM_GRANTED to a
 client waiting for a lock, even if it's unable to send
 the message.
 3) Since lockd assumes it sent the message, lockd
 holds the lock for the client, with the client being
 unaware it has the lock.
 4) Since the client never received the NLM_GRANTED
 while it was waiting for a lock, after 30 seconds it
 asks for the lock again, and is receives it because
 lockd is already holding the lock for the client.
 
 In send_granted(), if the client handle kept be
 obtained, there's this comment:
 
 "We fail to notify remote that the lock has been
 granted. The client will timeout and retry, the lock
 will be granted at this time."
 
 So, it was clearly intentional to not care if the
 client received the NLM_GRANTED message. This is
 further shown to be the case by the fact the lockd
 does not look for the reply from the client that it
 has accepted the granted lock.
 
 I'm going to suggest that if it is absolutely known
 that the client didn't receive the granted message,
 then the lock should not be granted.
 
 Now this won't affect the problematic behavior. It
 will still take 30 seconds for the client to timeout
 and request the lock again. But during those 30
 seconds another client could succesfully grab a lock.
 Otherwise, if the waiting client dies, lockd will
 still be holding the lock unaware that the client is
 gone and no other client will be able to get the lock.
 
 My suggestion on how to fix this:
 In lockd_lock.c, send_granted() is defined with a void
 return. Change it to an int return, with a -1 returned
 if the client handle was not obtained, and 0 if the
 message was sent.
 
 In retry_blockingfilelocklist(), if send_granted()
 returns a -1, then the initial lock request is denied
 and the client will have to ask for the lock again.
 
 I was thinking an alternative fix would be to add the
 client handle to struct file_lock. But reading the
 comments before get_client() in lock_proc.c gives good
 reasons why you don't want to do that (e.g. the client
 host reboots and the client handle is no longer
 valid).
 
 I have create a patch, but until I can get a Linux
 client into the state where nfs and lockd are running
 on it but not listed in the rpc registry I won't be
 able to test it exactly (although I could do a test by
 altering the code so that send_granted() always
 failed).
 
 
 
  
 ____________________________________________________________________________________
 Don't get soaked.  Take a quick peak at the forecast
 with the Yahoo! Search weather shortcut.
 http://tools.search.yahoo.com/shortcuts/#loc_weather
Responsible-Changed-From-To: freebsd-bugs->dfr 
Responsible-Changed-By: dfr 
Responsible-Changed-When: Sun Mar 2 10:05:34 UTC 2008 
Responsible-Changed-Why:  
I'm re-writing the NLM. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=107555 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/107555: commit references a PR
Date: Wed, 26 Mar 2008 15:23:25 +0000 (UTC)

 dfr         2008-03-26 15:23:13 UTC
 
   FreeBSD src repository
 
   Modified files:
     lib/libc/gen         lockf.c 
     lib/libc/sys         Symbol.map fcntl.2 
     sys/compat/freebsd32 syscalls.master 
     sys/compat/linux     linux_file.c 
     sys/compat/svr4      svr4_fcntl.c 
     sys/conf             NOTES files options 
     sys/contrib/opensolaris/uts/common/fs/zfs zfs_vnops.c 
     sys/fs/msdosfs       msdosfs_vnops.c 
     sys/fs/tmpfs         tmpfs_vnops.c 
     sys/i386/ibcs2       ibcs2_fcntl.c 
     sys/kern             kern_descrip.c kern_lockf.c 
                          syscalls.master vnode_if.src 
     sys/nfs4client       nfs4_vnops.c 
     sys/nfsclient        nfs_lock.c nfs_vnops.c 
     sys/rpc              types.h 
     sys/sys              fcntl.h lockf.h 
     sys/ufs/ufs          ufs_vnops.c 
     usr.sbin             Makefile 
     usr.sbin/rpc.lockd   lockd.c rpc.lockd.8 
   Added files:
     sys/nlm              nlm.h nlm_prot.h nlm_prot_clnt.c 
                          nlm_prot_impl.c nlm_prot_server.c 
                          nlm_prot_svc.c nlm_prot_xdr.c sm_inter.h 
                          sm_inter_xdr.c 
     sys/rpc              auth.h auth_none.c auth_unix.c 
                          authunix_prot.c clnt.h clnt_dg.c 
                          clnt_rc.c clnt_stat.h clnt_vc.c 
                          getnetconfig.c inet_ntop.c inet_pton.c 
                          netconfig.h nettype.h pmap_prot.h rpc.h 
                          rpc_callmsg.c rpc_com.h rpc_generic.c 
                          rpc_msg.h rpc_prot.c rpcb_clnt.c 
                          rpcb_clnt.h rpcb_prot.c rpcb_prot.h svc.c 
                          svc.h svc_auth.c svc_auth.h 
                          svc_auth_unix.c svc_dg.c svc_generic.c 
                          svc_vc.c xdr.h 
     sys/xdr              xdr.c xdr_array.c xdr_mbuf.c xdr_mem.c 
                          xdr_reference.c xdr_sizeof.c 
     usr.sbin/clear_locks Makefile clear_locks.8 clear_locks.c 
   Log:
   Add the new kernel-mode NFS Lock Manager. To use it instead of the
   user-mode lock manager, build a kernel with the NFSLOCKD option and
   add '-k' to 'rpc_lockd_flags' in rc.conf.
   
   Highlights include:
   
   * Thread-safe kernel RPC client - many threads can use the same RPC
     client handle safely with replies being de-multiplexed at the socket
     upcall (typically driven directly by the NIC interrupt) and handed
     off to whichever thread matches the reply. For UDP sockets, many RPC
     clients can share the same socket. This allows the use of a single
     privileged UDP port number to talk to an arbitrary number of remote
     hosts.
   
   * Single-threaded kernel RPC server. Adding support for multi-threaded
     server would be relatively straightforward and would follow
     approximately the Solaris KPI. A single thread should be sufficient
     for the NLM since it should rarely block in normal operation.
   
   * Kernel mode NLM server supporting cancel requests and granted
     callbacks. I've tested the NLM server reasonably extensively - it
     passes both my own tests and the NFS Connectathon locking tests
     running on Solaris, Mac OS X and Ubuntu Linux.
   
   * Userland NLM client supported. While the NLM server doesn't have
     support for the local NFS client's locking needs, it does have to
     field async replies and granted callbacks from remote NLMs that the
     local client has contacted. We relay these replies to the userland
     rpc.lockd over a local domain RPC socket.
   
   * Robust deadlock detection for the local lock manager. In particular
     it will detect deadlocks caused by a lock request that covers more
     than one blocking request. As required by the NLM protocol, all
     deadlock detection happens synchronously - a user is guaranteed that
     if a lock request isn't rejected immediately, the lock will
     eventually be granted. The old system allowed for a 'deferred
     deadlock' condition where a blocked lock request could wake up and
     find that some other deadlock-causing lock owner had beaten them to
     the lock.
   
   * Since both local and remote locks are managed by the same kernel
     locking code, local and remote processes can safely use file locks
     for mutual exclusion. Local processes have no fairness advantage
     compared to remote processes when contending to lock a region that
     has just been unlocked - the local lock manager enforces a strict
     first-come first-served model for both local and remote lockers.
   
   Sponsored by:   Isilon Systems
   PR:             95247 107555 115524 116679
   MFC after:      2 weeks
   
   Revision  Changes     Path
   1.9       +1 -1       src/lib/libc/gen/lockf.c
   1.12      +1 -0       src/lib/libc/sys/Symbol.map
   1.47      +7 -2       src/lib/libc/sys/fcntl.2
   1.99      +2 -1       src/sys/compat/freebsd32/syscalls.master
   1.110     +2 -0       src/sys/compat/linux/linux_file.c
   1.45      +2 -2       src/sys/compat/svr4/svr4_fcntl.c
   1.1477    +1 -0       src/sys/conf/NOTES
   1.1284    +32 -0      src/sys/conf/files
   1.622     +2 -0       src/sys/conf/options
   1.29      +20 -0      src/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
   1.184     +18 -0      src/sys/fs/msdosfs/msdosfs_vnops.c
   1.17      +15 -0      src/sys/fs/tmpfs/tmpfs_vnops.c
   1.29      +2 -1       src/sys/i386/ibcs2/ibcs2_fcntl.c
   1.329     +66 -7      src/sys/kern/kern_descrip.c
   1.60      +1894 -471  src/sys/kern/kern_lockf.c
   1.241     +2 -1       src/sys/kern/syscalls.master
   1.91      +13 -0      src/sys/kern/vnode_if.src
   1.43      +18 -0      src/sys/nfs4client/nfs4_vnops.c
   1.46      +1 -0       src/sys/nfsclient/nfs_lock.c
   1.283     +23 -0      src/sys/nfsclient/nfs_vnops.c
   1.1       +119 -0     src/sys/nlm/nlm.h (new)
   1.1       +448 -0     src/sys/nlm/nlm_prot.h (new)
   1.1       +372 -0     src/sys/nlm/nlm_prot_clnt.c (new)
   1.1       +1783 -0    src/sys/nlm/nlm_prot_impl.c (new)
   1.1       +762 -0     src/sys/nlm/nlm_prot_server.c (new)
   1.1       +509 -0     src/sys/nlm/nlm_prot_svc.c (new)
   1.1       +454 -0     src/sys/nlm/nlm_prot_xdr.c (new)
   1.1       +112 -0     src/sys/nlm/sm_inter.h (new)
   1.1       +107 -0     src/sys/nlm/sm_inter_xdr.c (new)
   1.1       +361 -0     src/sys/rpc/auth.h (new)
   1.1       +148 -0     src/sys/rpc/auth_none.c (new)
   1.1       +299 -0     src/sys/rpc/auth_unix.c (new)
   1.1       +122 -0     src/sys/rpc/authunix_prot.c (new)
   1.1       +620 -0     src/sys/rpc/clnt.h (new)
   1.1       +865 -0     src/sys/rpc/clnt_dg.c (new)
   1.1       +307 -0     src/sys/rpc/clnt_rc.c (new)
   1.1       +83 -0      src/sys/rpc/clnt_stat.h (new)
   1.1       +827 -0     src/sys/rpc/clnt_vc.c (new)
   1.1       +138 -0     src/sys/rpc/getnetconfig.c (new)
   1.1       +187 -0     src/sys/rpc/inet_ntop.c (new)
   1.1       +224 -0     src/sys/rpc/inet_pton.c (new)
   1.1       +99 -0      src/sys/rpc/netconfig.h (new)
   1.1       +68 -0      src/sys/rpc/nettype.h (new)
   1.1       +107 -0     src/sys/rpc/pmap_prot.h (new)
   1.1       +125 -0     src/sys/rpc/rpc.h (new)
   1.1       +200 -0     src/sys/rpc/rpc_callmsg.c (new)
   1.1       +126 -0     src/sys/rpc/rpc_com.h (new)
   1.1       +716 -0     src/sys/rpc/rpc_generic.c (new)
   1.1       +214 -0     src/sys/rpc/rpc_msg.h (new)
   1.1       +348 -0     src/sys/rpc/rpc_prot.c (new)
   1.1       +1382 -0    src/sys/rpc/rpcb_clnt.c (new)
   1.1       +89 -0      src/sys/rpc/rpcb_clnt.h (new)
   1.1       +244 -0     src/sys/rpc/rpcb_prot.c (new)
   1.1       +579 -0     src/sys/rpc/rpcb_prot.h (new)
   1.1       +574 -0     src/sys/rpc/svc.c (new)
   1.1       +614 -0     src/sys/rpc/svc.h (new)
   1.1       +133 -0     src/sys/rpc/svc_auth.c (new)
   1.1       +67 -0      src/sys/rpc/svc_auth.h (new)
   1.1       +144 -0     src/sys/rpc/svc_auth_unix.c (new)
   1.1       +334 -0     src/sys/rpc/svc_dg.c (new)
   1.1       +407 -0     src/sys/rpc/svc_generic.c (new)
   1.1       +746 -0     src/sys/rpc/svc_vc.c (new)
   1.13      +17 -7      src/sys/rpc/types.h
   1.1       +368 -0     src/sys/rpc/xdr.h (new)
   1.19      +23 -3      src/sys/sys/fcntl.h
   1.21      +70 -18     src/sys/sys/lockf.h
   1.296     +21 -0      src/sys/ufs/ufs/ufs_vnops.c
   1.1       +816 -0     src/sys/xdr/xdr.c (new)
   1.1       +155 -0     src/sys/xdr/xdr_array.c (new)
   1.1       +238 -0     src/sys/xdr/xdr_mbuf.c (new)
   1.1       +232 -0     src/sys/xdr/xdr_mem.c (new)
   1.1       +135 -0     src/sys/xdr/xdr_reference.c (new)
   1.1       +162 -0     src/sys/xdr/xdr_sizeof.c (new)
   1.383     +1 -0       src/usr.sbin/Makefile
   1.1       +8 -0       src/usr.sbin/clear_locks/Makefile (new)
   1.1       +51 -0      src/usr.sbin/clear_locks/clear_locks.8 (new)
   1.1       +70 -0      src/usr.sbin/clear_locks/clear_locks.c (new)
   1.23      +251 -17    src/usr.sbin/rpc.lockd/lockd.c
   1.19      +6 -0       src/usr.sbin/rpc.lockd/rpc.lockd.8
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/107555: commit references a PR
Date: Thu, 27 Mar 2008 00:30:40 +0000 (UTC)

 dfr         2008-03-26 15:23:13 UTC
 
   FreeBSD src repository
 
   Modified files:
     lib/libc/gen         lockf.c 
     lib/libc/sys         Symbol.map fcntl.2 
     sys/compat/freebsd32 syscalls.master 
     sys/compat/linux     linux_file.c 
     sys/compat/svr4      svr4_fcntl.c 
     sys/conf             NOTES files options 
     sys/contrib/opensolaris/uts/common/fs/zfs zfs_vnops.c 
     sys/fs/msdosfs       msdosfs_vnops.c 
     sys/fs/tmpfs         tmpfs_vnops.c 
     sys/i386/ibcs2       ibcs2_fcntl.c 
     sys/kern             kern_descrip.c kern_lockf.c 
                          syscalls.master vnode_if.src 
     sys/nfs4client       nfs4_vnops.c 
     sys/nfsclient        nfs_lock.c nfs_vnops.c 
     sys/rpc              types.h 
     sys/sys              fcntl.h lockf.h 
     sys/ufs/ufs          ufs_vnops.c 
     usr.sbin             Makefile 
     usr.sbin/rpc.lockd   lockd.c rpc.lockd.8 
   Added files:
     sys/nlm              nlm.h nlm_prot.h nlm_prot_clnt.c 
                          nlm_prot_impl.c nlm_prot_server.c 
                          nlm_prot_svc.c nlm_prot_xdr.c sm_inter.h 
                          sm_inter_xdr.c 
     sys/rpc              auth.h auth_none.c auth_unix.c 
                          authunix_prot.c clnt.h clnt_dg.c 
                          clnt_rc.c clnt_stat.h clnt_vc.c 
                          getnetconfig.c inet_ntop.c inet_pton.c 
                          netconfig.h nettype.h pmap_prot.h rpc.h 
                          rpc_callmsg.c rpc_com.h rpc_generic.c 
                          rpc_msg.h rpc_prot.c rpcb_clnt.c 
                          rpcb_clnt.h rpcb_prot.c rpcb_prot.h svc.c 
                          svc.h svc_auth.c svc_auth.h 
                          svc_auth_unix.c svc_dg.c svc_generic.c 
                          svc_vc.c xdr.h 
     sys/xdr              xdr.c xdr_array.c xdr_mbuf.c xdr_mem.c 
                          xdr_reference.c xdr_sizeof.c 
     usr.sbin/clear_locks Makefile clear_locks.8 clear_locks.c 
   Log:
   Add the new kernel-mode NFS Lock Manager. To use it instead of the
   user-mode lock manager, build a kernel with the NFSLOCKD option and
   add '-k' to 'rpc_lockd_flags' in rc.conf.
   
   Highlights include:
   
   * Thread-safe kernel RPC client - many threads can use the same RPC
     client handle safely with replies being de-multiplexed at the socket
     upcall (typically driven directly by the NIC interrupt) and handed
     off to whichever thread matches the reply. For UDP sockets, many RPC
     clients can share the same socket. This allows the use of a single
     privileged UDP port number to talk to an arbitrary number of remote
     hosts.
   
   * Single-threaded kernel RPC server. Adding support for multi-threaded
     server would be relatively straightforward and would follow
     approximately the Solaris KPI. A single thread should be sufficient
     for the NLM since it should rarely block in normal operation.
   
   * Kernel mode NLM server supporting cancel requests and granted
     callbacks. I've tested the NLM server reasonably extensively - it
     passes both my own tests and the NFS Connectathon locking tests
     running on Solaris, Mac OS X and Ubuntu Linux.
   
   * Userland NLM client supported. While the NLM server doesn't have
     support for the local NFS client's locking needs, it does have to
     field async replies and granted callbacks from remote NLMs that the
     local client has contacted. We relay these replies to the userland
     rpc.lockd over a local domain RPC socket.
   
   * Robust deadlock detection for the local lock manager. In particular
     it will detect deadlocks caused by a lock request that covers more
     than one blocking request. As required by the NLM protocol, all
     deadlock detection happens synchronously - a user is guaranteed that
     if a lock request isn't rejected immediately, the lock will
     eventually be granted. The old system allowed for a 'deferred
     deadlock' condition where a blocked lock request could wake up and
     find that some other deadlock-causing lock owner had beaten them to
     the lock.
   
   * Since both local and remote locks are managed by the same kernel
     locking code, local and remote processes can safely use file locks
     for mutual exclusion. Local processes have no fairness advantage
     compared to remote processes when contending to lock a region that
     has just been unlocked - the local lock manager enforces a strict
     first-come first-served model for both local and remote lockers.
   
   Sponsored by:   Isilon Systems
   PR:             95247 107555 115524 116679
   MFC after:      2 weeks
   
   Revision  Changes     Path
   1.9       +1 -1       src/lib/libc/gen/lockf.c
   1.12      +1 -0       src/lib/libc/sys/Symbol.map
   1.47      +7 -2       src/lib/libc/sys/fcntl.2
   1.99      +2 -1       src/sys/compat/freebsd32/syscalls.master
   1.110     +2 -0       src/sys/compat/linux/linux_file.c
   1.45      +2 -2       src/sys/compat/svr4/svr4_fcntl.c
   1.1477    +1 -0       src/sys/conf/NOTES
   1.1284    +32 -0      src/sys/conf/files
   1.622     +2 -0       src/sys/conf/options
   1.29      +20 -0      src/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
   1.184     +18 -0      src/sys/fs/msdosfs/msdosfs_vnops.c
   1.17      +15 -0      src/sys/fs/tmpfs/tmpfs_vnops.c
   1.29      +2 -1       src/sys/i386/ibcs2/ibcs2_fcntl.c
   1.329     +66 -7      src/sys/kern/kern_descrip.c
   1.60      +1894 -471  src/sys/kern/kern_lockf.c
   1.241     +2 -1       src/sys/kern/syscalls.master
   1.91      +13 -0      src/sys/kern/vnode_if.src
   1.43      +18 -0      src/sys/nfs4client/nfs4_vnops.c
   1.46      +1 -0       src/sys/nfsclient/nfs_lock.c
   1.283     +23 -0      src/sys/nfsclient/nfs_vnops.c
   1.1       +119 -0     src/sys/nlm/nlm.h (new)
   1.1       +448 -0     src/sys/nlm/nlm_prot.h (new)
   1.1       +372 -0     src/sys/nlm/nlm_prot_clnt.c (new)
   1.1       +1783 -0    src/sys/nlm/nlm_prot_impl.c (new)
   1.1       +762 -0     src/sys/nlm/nlm_prot_server.c (new)
   1.1       +509 -0     src/sys/nlm/nlm_prot_svc.c (new)
   1.1       +454 -0     src/sys/nlm/nlm_prot_xdr.c (new)
   1.1       +112 -0     src/sys/nlm/sm_inter.h (new)
   1.1       +107 -0     src/sys/nlm/sm_inter_xdr.c (new)
   1.1       +361 -0     src/sys/rpc/auth.h (new)
   1.1       +148 -0     src/sys/rpc/auth_none.c (new)
   1.1       +299 -0     src/sys/rpc/auth_unix.c (new)
   1.1       +122 -0     src/sys/rpc/authunix_prot.c (new)
   1.1       +620 -0     src/sys/rpc/clnt.h (new)
   1.1       +865 -0     src/sys/rpc/clnt_dg.c (new)
   1.1       +307 -0     src/sys/rpc/clnt_rc.c (new)
   1.1       +83 -0      src/sys/rpc/clnt_stat.h (new)
   1.1       +827 -0     src/sys/rpc/clnt_vc.c (new)
   1.1       +138 -0     src/sys/rpc/getnetconfig.c (new)
   1.1       +187 -0     src/sys/rpc/inet_ntop.c (new)
   1.1       +224 -0     src/sys/rpc/inet_pton.c (new)
   1.1       +99 -0      src/sys/rpc/netconfig.h (new)
   1.1       +68 -0      src/sys/rpc/nettype.h (new)
   1.1       +107 -0     src/sys/rpc/pmap_prot.h (new)
   1.1       +125 -0     src/sys/rpc/rpc.h (new)
   1.1       +200 -0     src/sys/rpc/rpc_callmsg.c (new)
   1.1       +126 -0     src/sys/rpc/rpc_com.h (new)
   1.1       +716 -0     src/sys/rpc/rpc_generic.c (new)
   1.1       +214 -0     src/sys/rpc/rpc_msg.h (new)
   1.1       +348 -0     src/sys/rpc/rpc_prot.c (new)
   1.1       +1382 -0    src/sys/rpc/rpcb_clnt.c (new)
   1.1       +89 -0      src/sys/rpc/rpcb_clnt.h (new)
   1.1       +244 -0     src/sys/rpc/rpcb_prot.c (new)
   1.1       +579 -0     src/sys/rpc/rpcb_prot.h (new)
   1.1       +574 -0     src/sys/rpc/svc.c (new)
   1.1       +614 -0     src/sys/rpc/svc.h (new)
   1.1       +133 -0     src/sys/rpc/svc_auth.c (new)
   1.1       +67 -0      src/sys/rpc/svc_auth.h (new)
   1.1       +144 -0     src/sys/rpc/svc_auth_unix.c (new)
   1.1       +334 -0     src/sys/rpc/svc_dg.c (new)
   1.1       +407 -0     src/sys/rpc/svc_generic.c (new)
   1.1       +746 -0     src/sys/rpc/svc_vc.c (new)
   1.13      +17 -7      src/sys/rpc/types.h
   1.1       +368 -0     src/sys/rpc/xdr.h (new)
   1.19      +23 -3      src/sys/sys/fcntl.h
   1.21      +70 -18     src/sys/sys/lockf.h
   1.296     +21 -0      src/sys/ufs/ufs/ufs_vnops.c
   1.1       +816 -0     src/sys/xdr/xdr.c (new)
   1.1       +155 -0     src/sys/xdr/xdr_array.c (new)
   1.1       +238 -0     src/sys/xdr/xdr_mbuf.c (new)
   1.1       +232 -0     src/sys/xdr/xdr_mem.c (new)
   1.1       +135 -0     src/sys/xdr/xdr_reference.c (new)
   1.1       +162 -0     src/sys/xdr/xdr_sizeof.c (new)
   1.383     +1 -0       src/usr.sbin/Makefile
   1.1       +8 -0       src/usr.sbin/clear_locks/Makefile (new)
   1.1       +51 -0      src/usr.sbin/clear_locks/clear_locks.8 (new)
   1.1       +70 -0      src/usr.sbin/clear_locks/clear_locks.c (new)
   1.23      +251 -17    src/usr.sbin/rpc.lockd/lockd.c
   1.19      +6 -0       src/usr.sbin/rpc.lockd/rpc.lockd.8
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: dfr 
State-Changed-When: Tue May 6 16:26:43 UTC 2008 
State-Changed-Why:  
Fixed in the new NFSLOCKD code which is available in: 

RELENG_6 after __FreeBSD_version 603102 
RELENG_7 after __FreeBSD_version 700103 
current after __FreeBSD_version 800028 

To use the new NFS locking server, either add the NFSLOCKD kernel option or 
build the nfslockd.ko and krpc.ko kernel modules. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=107555 
>Unformatted:
