From nobody@FreeBSD.org  Tue Aug 14 18:53:27 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 184CF16A419
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 14 Aug 2007 18:53:27 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 0C7E913C509
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 14 Aug 2007 18:53:27 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l7EIrQDA064993
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 14 Aug 2007 18:53:26 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l7EIrQxB064992;
	Tue, 14 Aug 2007 18:53:26 GMT
	(envelope-from nobody)
Message-Id: <200708141853.l7EIrQxB064992@www.freebsd.org>
Date: Tue, 14 Aug 2007 18:53:26 GMT
From: Douglas Rudoff <joseph.blough@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [rpc][patch] Lockd fails to set RPC authentication for granted lock callback
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         115524
>Category:       kern
>Synopsis:       [rpc][patch] Lockd fails to set RPC authentication for granted lock callback
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    dfr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 14 19:00:07 GMT 2007
>Closed-Date:    Tue May 06 16:28:10 UTC 2008
>Last-Modified:  Tue May 06 16:28:10 UTC 2008
>Originator:     Douglas Rudoff
>Release:        6.1
>Organization:
Isilon
>Environment:
System: 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:
Scenario:
Linux Client1 gets exclusive lock on NFS-mounted file foo, sleeps a bit, then releases the lock. Linux Client2 attempts to lock foo while Client1 is holding the lock. Client2's request is blocked and Client2 is waiting for the lock to be released. When Client1 releases the lock, instead of the lock being granted immediately to Client2, the lock is obtained 30 seconds after Client2 initially requested the lock.

I previously submitted PR kern/10755 (http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/107555) about this problem. More detailed description can be found there including test code to run on clients.

What's happening:
When lockd attempts to send the NLM_GRANTED callback to Client 2, the RPC call fails due to an authentication error. Lockd is sending AUTH_NULL as its credentials and Linux doesn't accept that as a valid credential. Lockd doesn't bother to check if the RPC call failed and assigns the lock to Client2, but Client2 never received the NLM_GRANTED message so it is unaware it has the lock. Client2 waits 30 seconds after its initial request for the lock and asks again. Since lockd is already holding the lock for Client2, this second lock request succeeds and Client2 is now aware that it has the lock.

(This problem doesn't happen with FreeBSD clients. FreeBSD isn't as picky as Linux about the authentication credentials in the NLM_GRANTED messages sent from lockd.)
>How-To-Repeat:
Run rpc.lockd with a debug level 3 or above. Follow the directions that are in PR kern/10755 on how to run the Linux clients. If you feel like it, run tcpdump on the FreeBSD server during the test.

Afterwards in lockd's log you'll see "rpc.lockd: clnt_call returns 7(RPC: Authentication error) for granted".

Analyze the pcap in Wireshark and see that the Linux client rejects the NLM_GRANTED call with an AUTH_ERROR (Note that there's a bug in NLM filtering in Wireshark. To see the AUTH_ERROR reply you have to filter for both NLM and RPC).
>Fix:
The patch does this:

1) send_granted() gives RPC messages to the client an authentication with authunix_create_default(). The Linux client will now accept the NLM_GRANTED message and locks the file when the lock is first available. No more 30 second wait to receive the lock.

2) Previously, the status of the RPC call in send_granted() was ignored. In the case of failure, lockd held the lock for a client that was unaware it held the lock. The fix is if send_granted() fails, lockd does not hold on to the lock for the client _and_ the client's blocked lock is removed from the blocked list, requiring the client to ask again for the lock. Another alternative would be to leave the lock on the blocked list if send_granted() fails, but if it's impossible to send a message to clients, the lock requests would accumulate on the blocked list and never be removed. It seemed requiring the client to ask again is the better solution (and effectively that is what is done now when send_granted() fails).

3) Fixed typo in get_lock_matching_unlock() debug message.

Patch attached with submission follows:

Index: lockd_lock.c
===================================================================
--- lockd_lock.c	(revision 79264)
+++ lockd_lock.c	(working copy)
@@ -146,21 +146,21 @@ enum partialfilelock_status { PFL_GRANTE
 			      PFL_NFSDENIED, PFL_NFSBLOCKED, PFL_NFSDENIED_NOLOCK, PFL_NFSRESERR,
 			      PFL_HWDENIED,  PFL_HWBLOCKED,  PFL_HWDENIED_NOLOCK, PFL_HWRESERR};
 
 enum LFLAGS {LEDGE_LEFT, LEDGE_LBOUNDARY, LEDGE_INSIDE, LEDGE_RBOUNDARY, LEDGE_RIGHT};
 enum RFLAGS {REDGE_LEFT, REDGE_LBOUNDARY, REDGE_INSIDE, REDGE_RBOUNDARY, REDGE_RIGHT};
 /* XXX: WARNING! I HAVE OVERLOADED THIS STATUS ENUM!  SPLIT IT APART INTO TWO */
 enum split_status {SPL_DISJOINT=0, SPL_LOCK1=1, SPL_LOCK2=2, SPL_CONTAINED=4, SPL_RESERR=8};
 
 enum partialfilelock_status lock_partialfilelock(struct file_lock *fl);
 
-void send_granted(struct file_lock *fl, int opcode);
+int send_granted(struct file_lock *fl, int opcode);
 void siglock(void);
 void sigunlock(void);
 void monitor_lock_host(const char *hostname);
 void unmonitor_lock_host(char *hostname);
 
 void	copy_nlm4_lock_to_nlm4_holder(const struct nlm4_lock *src,
     const bool_t exclusive, struct nlm4_holder *dest);
 struct file_lock *	allocate_file_lock(const netobj *lockowner,
 					   const netobj *matchcookie,
 					   const struct sockaddr *addr,
@@ -760,21 +760,21 @@ get_lock_matching_unlock(const struct fi
 		    ifl->client.l_offset,ifl->client.l_len);
 
 		/* Regions overlap, check the identity */
 		if (!same_filelock_identity(fl,ifl))
 			continue;
 
 		debuglog("get_lock_matching_unlock: Duplicate lock id.  Granting\n");
 		return (ifl);
 	}
 
-	debuglog("Exiting bet_lock_matching_unlock\n");
+	debuglog("Exiting get_lock_matching_unlock\n");
 
 	return (NULL);
 }
 
 /*
  * test_nfslock: check for NFS lock in lock list
  *
  * This routine makes the following assumptions:
  *    1) Nothing will adjust the lock list during a lookup
  *
@@ -1309,21 +1309,31 @@ retry_blockingfilelocklist(void)
 		 * before being allowed to participate in the new list
 		 * which will automatically add it in if necessary.
 		 */
 
 		LIST_REMOVE(ifl, nfslocklist);
 		pflstatus = lock_partialfilelock(ifl);
 
 		if (pflstatus == PFL_GRANTED || pflstatus == PFL_GRANTED_DUPLICATE) {
 			debuglog("Granted blocked lock\n");
 			/* lock granted and is now being used */
-			send_granted(ifl,0);
+                       if (send_granted(ifl,0) == 0) {
+                               /* lock granted and is now being used */
+                               debuglog("Sent granted message to client\n");
+                       }
+                       else {
+                               syslog(LOG_NOTICE, "Failed to send lock granted "
+				   "message to client. Client must ask again "
+				   "for lock");
+			       /* Previous lock is no longer valid */
+			       unlock_partialfilelock(ifl);
+                       }
 		} else {
 			/* Reinsert lock back into blocked list */
 			debuglog("Replacing blocked lock\n");
 			LIST_INSERT_HEAD(&blockedlocklist_head, ifl, nfslocklist);
 		}
 	}
 
 	debuglog("Exiting retry_blockingfilelocklist\n");
 }
 
@@ -2177,21 +2187,21 @@ notify(const char *hostname, const int s
 {
 	debuglog("notify from %s, new state %d", hostname, state);
 
 	siglock();
 	do_clear(hostname);
 	sigunlock();
 
 	debuglog("Leaving notify\n");
 }
 
-void
+int
 send_granted(fl, opcode)
 	struct file_lock *fl;
 	int opcode __unused;
 {
 	CLIENT *cli;
 	static char dummy;
 	struct timeval timeo;
 	int success;
 	static struct nlm_res retval;
 	static struct nlm4_res retval4;
@@ -2201,25 +2211,27 @@ send_granted(fl, opcode)
 	cli = get_client(fl->addr,
 	    (fl->flags & LOCK_V4) ? NLM_VERS4 : NLM_VERS);
 	if (cli == NULL) {
 		syslog(LOG_NOTICE, "failed to get CLIENT for %s",
 		    fl->client_name);
 		/*
 		 * 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.
 		 */
-		return;
+		return -1;
 	}
 	timeo.tv_sec = 0;
 	timeo.tv_usec = (fl->flags & LOCK_ASYNC) ? 0 : 500000; /* 0.5s */
 
+	cli->cl_auth = authunix_create_default();
+
 	if (fl->flags & LOCK_V4) {
 		static nlm4_testargs res;
 		res.cookie = fl->client_cookie;
 		res.exclusive = fl->client.exclusive;
 		res.alock.caller_name = fl->client_name;
 		res.alock.fh.n_len = sizeof(fhandle_t);
 		res.alock.fh.n_bytes = (char*)&fl->filehandle;
 		res.alock.oh = fl->client.oh;
 		res.alock.svid = fl->client.svid;
 		res.alock.l_offset = fl->client.l_offset;
@@ -2253,23 +2265,24 @@ send_granted(fl, opcode)
 			success = clnt_call(cli, NLM_GRANTED_MSG,
 			    (xdrproc_t)xdr_nlm_testargs, &res,
 			    (xdrproc_t)xdr_void, &dummy, timeo);
 		} else {
 			success = clnt_call(cli, NLM_GRANTED,
 			    (xdrproc_t)xdr_nlm_testargs, &res,
 			    (xdrproc_t)xdr_nlm_res, &retval, timeo);
 		}
 	}
 	if (debug_level > 2)
-		debuglog("clnt_call returns %d(%s) for granted",
-			 success, clnt_sperrno(success));
-
+		debuglog("clnt_call returns %d for granted: %s",
+			 success, clnt_sperror(cli, ""));
+	auth_destroy(cli->cl_auth);
+	return success;
 }
 
 /*
  * Routines below here have not been modified in the overhaul
  */
 
 /*
  * Are these two routines still required since lockd is not spawning off
  * children to service locks anymore?  Presumably they were originally
  * put in place to prevent a one child from changing the lock list out


>Release-Note:
>Audit-Trail:

From: Doug Rudoff <joseph.blough@yahoo.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/115524: [rpc][patch] Lockd fails to set RPC authentication for granted lock callback
Date: Wed, 22 Aug 2007 15:26:43 -0700 (PDT)

 I reported this bug a week ago and there have been no
 followups as of yet. Any comments? Preventing the
 possibility of a client unaware it has been granted a
 file lock, and allowing Linux clients to accept an
 asynchronous lock granted message are bugs worth
 fixing, IMO.
 
 Tbanks.
 
 
        
 ____________________________________________________________________________________
 Sick sense of humor? Visit Yahoo! TV's 
 Comedy with an Edge to see what's on, when. 
 http://tv.yahoo.com/collections/222
Responsible-Changed-From-To: freebsd-bugs->dfr 
Responsible-Changed-By: dfr 
Responsible-Changed-When: Sun Mar 2 10:07:04 UTC 2008 
Responsible-Changed-Why:  
I'm re-writing the NLM. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/115524: 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/115524: 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:27:30 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=115524 
>Unformatted:
