freebsd-skq/sys/nlm/nlm_prot_clnt.c
dfr 79d2dfdaa6 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
2008-03-26 15:23:12 +00:00

373 lines
9.6 KiB
C

/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/systm.h>
#include "nlm_prot.h"
#include <sys/cdefs.h>
#ifndef lint
/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/
/*static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
__RCSID("$NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $");
#endif /* not lint */
__FBSDID("$FreeBSD$");
/* Default timeout can be changed using clnt_control() */
static struct timeval TIMEOUT = { 25, 0 };
enum clnt_stat
nlm_sm_notify_0(struct nlm_sm_status *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_SM_NOTIFY,
(xdrproc_t) xdr_nlm_sm_status, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_test_1(struct nlm_testargs *argp, nlm_testres *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_TEST,
(xdrproc_t) xdr_nlm_testargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm_testres, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_lock_1(struct nlm_lockargs *argp, nlm_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_LOCK,
(xdrproc_t) xdr_nlm_lockargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_cancel_1(struct nlm_cancargs *argp, nlm_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_CANCEL,
(xdrproc_t) xdr_nlm_cancargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_unlock_1(struct nlm_unlockargs *argp, nlm_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_UNLOCK,
(xdrproc_t) xdr_nlm_unlockargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_granted_1(struct nlm_testargs *argp, nlm_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_GRANTED,
(xdrproc_t) xdr_nlm_testargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_test_msg_1(struct nlm_testargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_TEST_MSG,
(xdrproc_t) xdr_nlm_testargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_lock_msg_1(struct nlm_lockargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_LOCK_MSG,
(xdrproc_t) xdr_nlm_lockargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_cancel_msg_1(struct nlm_cancargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_CANCEL_MSG,
(xdrproc_t) xdr_nlm_cancargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_unlock_msg_1(struct nlm_unlockargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_UNLOCK_MSG,
(xdrproc_t) xdr_nlm_unlockargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_granted_msg_1(struct nlm_testargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_GRANTED_MSG,
(xdrproc_t) xdr_nlm_testargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_test_res_1(nlm_testres *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_TEST_RES,
(xdrproc_t) xdr_nlm_testres, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_lock_res_1(nlm_res *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_LOCK_RES,
(xdrproc_t) xdr_nlm_res, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_cancel_res_1(nlm_res *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_CANCEL_RES,
(xdrproc_t) xdr_nlm_res, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_unlock_res_1(nlm_res *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_UNLOCK_RES,
(xdrproc_t) xdr_nlm_res, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_granted_res_1(nlm_res *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_GRANTED_RES,
(xdrproc_t) xdr_nlm_res, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_share_3(nlm_shareargs *argp, nlm_shareres *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_SHARE,
(xdrproc_t) xdr_nlm_shareargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm_shareres, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_unshare_3(nlm_shareargs *argp, nlm_shareres *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_UNSHARE,
(xdrproc_t) xdr_nlm_shareargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm_shareres, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_nm_lock_3(nlm_lockargs *argp, nlm_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_NM_LOCK,
(xdrproc_t) xdr_nlm_lockargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm_free_all_3(nlm_notify *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM_FREE_ALL,
(xdrproc_t) xdr_nlm_notify, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_test_4(nlm4_testargs *argp, nlm4_testres *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_TEST,
(xdrproc_t) xdr_nlm4_testargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm4_testres, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_lock_4(nlm4_lockargs *argp, nlm4_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_LOCK,
(xdrproc_t) xdr_nlm4_lockargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm4_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_cancel_4(nlm4_cancargs *argp, nlm4_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_CANCEL,
(xdrproc_t) xdr_nlm4_cancargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm4_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_unlock_4(nlm4_unlockargs *argp, nlm4_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_UNLOCK,
(xdrproc_t) xdr_nlm4_unlockargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm4_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_granted_4(nlm4_testargs *argp, nlm4_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_GRANTED,
(xdrproc_t) xdr_nlm4_testargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm4_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_test_msg_4(nlm4_testargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_TEST_MSG,
(xdrproc_t) xdr_nlm4_testargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_lock_msg_4(nlm4_lockargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_LOCK_MSG,
(xdrproc_t) xdr_nlm4_lockargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_cancel_msg_4(nlm4_cancargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_CANCEL_MSG,
(xdrproc_t) xdr_nlm4_cancargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_unlock_msg_4(nlm4_unlockargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_UNLOCK_MSG,
(xdrproc_t) xdr_nlm4_unlockargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_granted_msg_4(nlm4_testargs *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_GRANTED_MSG,
(xdrproc_t) xdr_nlm4_testargs, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_test_res_4(nlm4_testres *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_TEST_RES,
(xdrproc_t) xdr_nlm4_testres, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_lock_res_4(nlm4_res *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_LOCK_RES,
(xdrproc_t) xdr_nlm4_res, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_cancel_res_4(nlm4_res *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_CANCEL_RES,
(xdrproc_t) xdr_nlm4_res, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_unlock_res_4(nlm4_res *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_UNLOCK_RES,
(xdrproc_t) xdr_nlm4_res, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_granted_res_4(nlm4_res *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_GRANTED_RES,
(xdrproc_t) xdr_nlm4_res, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_share_4(nlm4_shareargs *argp, nlm4_shareres *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_SHARE,
(xdrproc_t) xdr_nlm4_shareargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm4_shareres, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_unshare_4(nlm4_shareargs *argp, nlm4_shareres *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_UNSHARE,
(xdrproc_t) xdr_nlm4_shareargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm4_shareres, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_nm_lock_4(nlm4_lockargs *argp, nlm4_res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_NM_LOCK,
(xdrproc_t) xdr_nlm4_lockargs, (caddr_t) argp,
(xdrproc_t) xdr_nlm4_res, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
nlm4_free_all_4(nlm4_notify *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, NLM4_FREE_ALL,
(xdrproc_t) xdr_nlm4_notify, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}