2006-07-13 16:00:24 +04:00
|
|
|
/* $NetBSD: nqnfs.h,v 1.20 2006/07/13 12:00:26 martin Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Rick Macklem at The University of Guelph.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-06-08 15:33:09 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1996-02-18 14:53:36 +03:00
|
|
|
* @(#)nqnfs.h 8.3 (Berkeley) 3/30/95
|
1994-06-08 15:33:09 +04:00
|
|
|
*/
|
|
|
|
|
1996-02-18 14:53:36 +03:00
|
|
|
|
|
|
|
#ifndef _NFS_NQNFS_H_
|
|
|
|
#define _NFS_NQNFS_H_
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
/*
|
|
|
|
* Definitions for NQNFS (Not Quite NFS) cache consistency protocol.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Tunable constants */
|
|
|
|
#define NQ_CLOCKSKEW 3 /* Clock skew factor (sec) */
|
|
|
|
#define NQ_WRITESLACK 5 /* Delay for write cache flushing */
|
|
|
|
#define NQ_MAXLEASE 60 /* Max lease duration (sec) */
|
|
|
|
#define NQ_MINLEASE 5 /* Min lease duration (sec) */
|
|
|
|
#define NQ_DEFLEASE 30 /* Default lease duration (sec) */
|
|
|
|
#define NQ_RENEWAL 3 /* Time before expiry (sec) to renew */
|
|
|
|
#define NQ_MAXNUMLEASE 2048 /* Upper bound on number of server leases */
|
|
|
|
#define NQ_DEADTHRESH NQ_NEVERDEAD /* Default nm_deadthresh */
|
|
|
|
#define NQ_NEVERDEAD 9 /* Greater than max. nm_timeouts */
|
|
|
|
#define NQLCHSZ 256 /* Server hash table size */
|
|
|
|
|
|
|
|
#define NQNFS_PROG 300105 /* As assigned by Sun */
|
1996-02-18 14:53:36 +03:00
|
|
|
#define NQNFS_VER3 3
|
1994-06-08 15:33:09 +04:00
|
|
|
#define NQNFS_EVICTSIZ 156 /* Size of eviction request in bytes */
|
|
|
|
|
2003-05-05 17:21:00 +04:00
|
|
|
#ifdef _KERNEL
|
1994-06-08 15:33:09 +04:00
|
|
|
/*
|
|
|
|
* Definitions used for saving the "last lease expires" time in Non-volatile
|
|
|
|
* RAM on the server. The default definitions below assume that NOVRAM is not
|
|
|
|
* available.
|
|
|
|
*/
|
1996-02-18 14:53:36 +03:00
|
|
|
#ifdef HASNVRAM
|
|
|
|
# undef HASNVRAM
|
|
|
|
#endif
|
1994-06-08 15:33:09 +04:00
|
|
|
#define NQSTORENOVRAM(t)
|
|
|
|
#define NQLOADNOVRAM(t)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Defn and structs used on the server to maintain state for current leases.
|
|
|
|
* The list of host(s) that hold the lease are kept as nqhost structures.
|
|
|
|
* The first one lives in nqlease and any others are held in a linked
|
|
|
|
* list of nqm structures hanging off of nqlease.
|
|
|
|
*
|
|
|
|
* Each nqlease structure is chained into two lists. The first is a list
|
|
|
|
* ordered by increasing expiry time for nqsrv_timer() and the second is a chain
|
|
|
|
* hashed on lc_fh.
|
|
|
|
*/
|
|
|
|
#define LC_MOREHOSTSIZ 10
|
2006-07-13 16:00:24 +04:00
|
|
|
#define LC_MAXFIDSIZ 64
|
1994-06-08 15:33:09 +04:00
|
|
|
|
|
|
|
struct nqhost {
|
|
|
|
union {
|
|
|
|
struct {
|
1995-12-20 02:07:11 +03:00
|
|
|
u_int16_t udp_flag;
|
1996-02-18 14:53:36 +03:00
|
|
|
u_int16_t udp_port;
|
1994-06-08 15:33:09 +04:00
|
|
|
union nethostaddr udp_haddr;
|
|
|
|
} un_udp;
|
|
|
|
struct {
|
1995-12-20 02:07:11 +03:00
|
|
|
u_int16_t connless_flag;
|
|
|
|
u_int16_t connless_spare;
|
1994-06-08 15:33:09 +04:00
|
|
|
union nethostaddr connless_haddr;
|
|
|
|
} un_connless;
|
|
|
|
struct {
|
1995-12-20 02:07:11 +03:00
|
|
|
u_int16_t conn_flag;
|
|
|
|
u_int16_t conn_spare;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct nfssvc_sock *conn_slp;
|
|
|
|
} un_conn;
|
|
|
|
} lph_un;
|
|
|
|
};
|
|
|
|
#define lph_flag lph_un.un_udp.udp_flag
|
|
|
|
#define lph_port lph_un.un_udp.udp_port
|
|
|
|
#define lph_haddr lph_un.un_udp.udp_haddr
|
|
|
|
#define lph_inetaddr lph_un.un_udp.udp_haddr.had_inetaddr
|
|
|
|
#define lph_claddr lph_un.un_connless.connless_haddr
|
|
|
|
#define lph_nam lph_un.un_connless.connless_haddr.had_nam
|
|
|
|
#define lph_slp lph_un.un_conn.conn_slp
|
|
|
|
|
|
|
|
struct nqlease {
|
1994-08-19 02:47:43 +04:00
|
|
|
LIST_ENTRY(nqlease) lc_hash; /* Fhandle hash list */
|
|
|
|
CIRCLEQ_ENTRY(nqlease) lc_timer; /* Timer queue list */
|
1994-06-08 15:33:09 +04:00
|
|
|
time_t lc_expiry; /* Expiry time (sec) */
|
|
|
|
struct nqhost lc_host; /* Host that got lease */
|
|
|
|
struct nqm *lc_morehosts; /* Other hosts that share read lease */
|
|
|
|
fsid_t lc_fsid; /* Fhandle */
|
2006-07-13 16:00:24 +04:00
|
|
|
char lc_fiddata[LC_MAXFIDSIZ];
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vnode *lc_vp; /* Soft reference to associated vnode */
|
|
|
|
};
|
|
|
|
#define lc_flag lc_host.lph_un.un_udp.udp_flag
|
|
|
|
|
|
|
|
/* lc_flag bits */
|
|
|
|
#define LC_VALID 0x0001 /* Host address valid */
|
|
|
|
#define LC_WRITE 0x0002 /* Write cache */
|
|
|
|
#define LC_NONCACHABLE 0x0004 /* Non-cachable lease */
|
|
|
|
#define LC_LOCKED 0x0008 /* Locked */
|
|
|
|
#define LC_WANTED 0x0010 /* Lock wanted */
|
|
|
|
#define LC_EXPIREDWANTED 0x0020 /* Want lease when expired */
|
|
|
|
#define LC_UDP 0x0040 /* Host address for udp socket */
|
|
|
|
#define LC_CLTP 0x0080 /* Host address for other connectionless */
|
|
|
|
#define LC_LOCAL 0x0100 /* Host is server */
|
|
|
|
#define LC_VACATED 0x0200 /* Host has vacated lease */
|
|
|
|
#define LC_WRITTEN 0x0400 /* Recently wrote to the leased file */
|
|
|
|
#define LC_SREF 0x0800 /* Holds a nfssvc_sock reference */
|
2000-06-09 04:00:17 +04:00
|
|
|
#define LC_UDP6 0x1000 /* Host address for udp6 socket */
|
1994-06-08 15:33:09 +04:00
|
|
|
|
|
|
|
struct nqm {
|
|
|
|
struct nqm *lpm_next;
|
|
|
|
struct nqhost lpm_hosts[LC_MOREHOSTSIZ];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Special value for slp for local server calls.
|
|
|
|
*/
|
|
|
|
#define NQLOCALSLP ((struct nfssvc_sock *) -1)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Server side macros.
|
|
|
|
*/
|
|
|
|
#define nqsrv_getl(v, l) \
|
|
|
|
(void) nqsrv_getlease((v), &nfsd->nd_duration, \
|
1996-02-18 14:53:36 +03:00
|
|
|
((nfsd->nd_flag & ND_LEASE) ? (nfsd->nd_flag & ND_LEASE) : \
|
|
|
|
((l) | ND_CHECK)), \
|
2005-12-11 15:16:03 +03:00
|
|
|
slp, lwp, nfsd->nd_nam, &cache, &frev, cred)
|
1994-06-08 15:33:09 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Client side macros that check for a valid lease.
|
|
|
|
*/
|
|
|
|
#define NQNFS_CKINVALID(v, n, f) \
|
2006-06-08 02:33:33 +04:00
|
|
|
((time_second > (n)->n_expiry && \
|
1994-06-08 15:33:09 +04:00
|
|
|
VFSTONFS((v)->v_mount)->nm_timeouts < VFSTONFS((v)->v_mount)->nm_deadthresh) \
|
1996-02-18 14:53:36 +03:00
|
|
|
|| ((f) == ND_WRITE && ((n)->n_flag & NQNFSWRITE) == 0))
|
1994-06-08 15:33:09 +04:00
|
|
|
|
|
|
|
#define NQNFS_CKCACHABLE(v, f) \
|
2006-06-08 02:33:33 +04:00
|
|
|
((time_second <= VTONFS(v)->n_expiry || \
|
1994-06-08 15:33:09 +04:00
|
|
|
VFSTONFS((v)->v_mount)->nm_timeouts >= VFSTONFS((v)->v_mount)->nm_deadthresh) \
|
|
|
|
&& (VTONFS(v)->n_flag & NQNFSNONCACHE) == 0 && \
|
1996-02-18 14:53:36 +03:00
|
|
|
((f) == ND_READ || (VTONFS(v)->n_flag & NQNFSWRITE)))
|
1994-06-08 15:33:09 +04:00
|
|
|
|
2003-04-25 01:21:04 +04:00
|
|
|
#define NQNFS_NEEDLEASE(n, p) \
|
2006-06-08 02:33:33 +04:00
|
|
|
(time_second > (n)->n_expiry ? \
|
2003-04-25 01:21:04 +04:00
|
|
|
(((n)->n_flag & NQNFSEVICTED) ? 0 : nqnfs_piggy[p]) : \
|
2006-06-08 02:33:33 +04:00
|
|
|
(((time_second + NQ_RENEWAL) > (n)->n_expiry && \
|
1994-06-08 15:33:09 +04:00
|
|
|
nqnfs_piggy[p]) ? \
|
2003-04-25 01:21:04 +04:00
|
|
|
(((n)->n_flag & NQNFSWRITE) ? \
|
1996-02-18 14:53:36 +03:00
|
|
|
ND_WRITE : nqnfs_piggy[p]) : 0))
|
1994-06-08 15:33:09 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* List head for timer queue.
|
|
|
|
*/
|
2002-05-13 03:04:35 +04:00
|
|
|
extern CIRCLEQ_HEAD(nqleasehead, nqlease) nqtimerhead;
|
1994-08-19 02:47:43 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* List head for the file handle hash table.
|
|
|
|
*/
|
|
|
|
#define NQFHHASH(f) \
|
1995-12-20 02:07:11 +03:00
|
|
|
(&nqfhhashtbl[(*((u_int32_t *)(f))) & nqfhhash])
|
2002-05-13 03:04:35 +04:00
|
|
|
extern LIST_HEAD(nqfhhashhead, nqlease) *nqfhhashtbl;
|
|
|
|
extern u_long nqfhhash;
|
|
|
|
extern int nqsrv_writeslack;
|
1994-06-08 15:33:09 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Nqnfs return status numbers.
|
|
|
|
*/
|
|
|
|
#define NQNFS_EXPIRED 500
|
|
|
|
#define NQNFS_TRYLATER 501
|
1996-02-18 14:53:36 +03:00
|
|
|
|
|
|
|
void nqnfs_lease_updatetime __P((int));
|
|
|
|
int nqsrv_cmpnam __P((struct nfssvc_sock *,struct mbuf *,struct nqhost *));
|
|
|
|
int nqsrv_getlease __P((struct vnode *, u_int32_t *, int,
|
2005-12-11 15:16:03 +03:00
|
|
|
struct nfssvc_sock *, struct lwp *, struct mbuf *, int *,
|
2006-05-15 01:31:52 +04:00
|
|
|
u_quad_t *, kauth_cred_t));
|
|
|
|
int nqnfs_getlease __P((struct vnode *, int, kauth_cred_t, struct lwp *));
|
1996-02-18 14:53:36 +03:00
|
|
|
int nqnfs_callback __P((struct nfsmount *, struct mbuf *, struct mbuf *,
|
2005-12-11 15:16:03 +03:00
|
|
|
caddr_t, struct lwp *));
|
2006-05-15 01:31:52 +04:00
|
|
|
int nqnfs_clientd __P((struct nfsmount *, kauth_cred_t,
|
2003-01-18 11:51:40 +03:00
|
|
|
struct nfsd_cargs *, int, caddr_t, struct lwp *));
|
2003-05-05 17:21:00 +04:00
|
|
|
#endif /* _KERNEL */
|
1996-02-18 14:53:36 +03:00
|
|
|
|
2003-05-05 17:21:00 +04:00
|
|
|
#endif /* _NFS_NQNFS_H_ */
|