The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/nfs/nqnfs.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: nqnfs.h,v 1.21 2006/09/02 12:40:36 yamt Exp $  */
    2 
    3 /*
    4  * Copyright (c) 1992, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * This code is derived from software contributed to Berkeley by
    8  * Rick Macklem at The University of Guelph.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. Neither the name of the University nor the names of its contributors
   19  *    may be used to endorse or promote products derived from this software
   20  *    without specific prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  *
   34  *      @(#)nqnfs.h     8.3 (Berkeley) 3/30/95
   35  */
   36 
   37 
   38 #ifndef _NFS_NQNFS_H_
   39 #define _NFS_NQNFS_H_
   40 
   41 /*
   42  * Definitions for NQNFS (Not Quite NFS) cache consistency protocol.
   43  */
   44 
   45 /* Tunable constants */
   46 #define NQ_CLOCKSKEW    3       /* Clock skew factor (sec) */
   47 #define NQ_WRITESLACK   5       /* Delay for write cache flushing */
   48 #define NQ_MAXLEASE     60      /* Max lease duration (sec) */
   49 #define NQ_MINLEASE     5       /* Min lease duration (sec) */
   50 #define NQ_DEFLEASE     30      /* Default lease duration (sec) */
   51 #define NQ_RENEWAL      3       /* Time before expiry (sec) to renew */
   52 #define NQ_MAXNUMLEASE  2048    /* Upper bound on number of server leases */
   53 #define NQ_DEADTHRESH   NQ_NEVERDEAD    /* Default nm_deadthresh */
   54 #define NQ_NEVERDEAD    9       /* Greater than max. nm_timeouts */
   55 #define NQLCHSZ         256     /* Server hash table size */
   56 
   57 #define NQNFS_PROG      300105  /* As assigned by Sun */
   58 #define NQNFS_VER3      3
   59 #define NQNFS_EVICTSIZ  156     /* Size of eviction request in bytes */
   60 
   61 #ifdef _KERNEL
   62 /*
   63  * Definitions used for saving the "last lease expires" time in Non-volatile
   64  * RAM on the server. The default definitions below assume that NOVRAM is not
   65  * available.
   66  */
   67 #ifdef HASNVRAM
   68 #  undef HASNVRAM
   69 #endif
   70 #define NQSTORENOVRAM(t)
   71 #define NQLOADNOVRAM(t)
   72 
   73 /*
   74  * Defn and structs used on the server to maintain state for current leases.
   75  * The list of host(s) that hold the lease are kept as nqhost structures.
   76  * The first one lives in nqlease and any others are held in a linked
   77  * list of nqm structures hanging off of nqlease.
   78  *
   79  * Each nqlease structure is chained into two lists. The first is a list
   80  * ordered by increasing expiry time for nqsrv_timer() and the second is a chain
   81  * hashed on lc_fh.
   82  */
   83 #define LC_MOREHOSTSIZ  10
   84 
   85 struct nqhost {
   86         union {
   87                 struct {
   88                         u_int16_t udp_flag;
   89                         u_int16_t       udp_port;
   90                         union nethostaddr udp_haddr;
   91                 } un_udp;
   92                 struct {
   93                         u_int16_t connless_flag;
   94                         u_int16_t connless_spare;
   95                         union nethostaddr connless_haddr;
   96                 } un_connless;
   97                 struct {
   98                         u_int16_t conn_flag;
   99                         u_int16_t conn_spare;
  100                         struct nfssvc_sock *conn_slp;
  101                 } un_conn;
  102         } lph_un;
  103 };
  104 #define lph_flag        lph_un.un_udp.udp_flag
  105 #define lph_port        lph_un.un_udp.udp_port
  106 #define lph_haddr       lph_un.un_udp.udp_haddr
  107 #define lph_inetaddr    lph_un.un_udp.udp_haddr.had_inetaddr
  108 #define lph_claddr      lph_un.un_connless.connless_haddr
  109 #define lph_nam         lph_un.un_connless.connless_haddr.had_nam
  110 #define lph_slp         lph_un.un_conn.conn_slp
  111 
  112 struct nqlease {
  113         LIST_ENTRY(nqlease) lc_hash;    /* Fhandle hash list */
  114         CIRCLEQ_ENTRY(nqlease) lc_timer; /* Timer queue list */
  115         time_t          lc_expiry;      /* Expiry time (sec) */
  116         struct nqhost   lc_host;        /* Host that got lease */
  117         struct nqm      *lc_morehosts;  /* Other hosts that share read lease */
  118         nfsrvfh_t       lc_fh;
  119         struct vnode    *lc_vp;         /* Soft reference to associated vnode */
  120 };
  121 #define lc_flag         lc_host.lph_un.un_udp.udp_flag
  122 
  123 /* lc_flag bits */
  124 #define LC_VALID        0x0001  /* Host address valid */
  125 #define LC_WRITE        0x0002  /* Write cache */
  126 #define LC_NONCACHABLE  0x0004  /* Non-cachable lease */
  127 #define LC_LOCKED       0x0008  /* Locked */
  128 #define LC_WANTED       0x0010  /* Lock wanted */
  129 #define LC_EXPIREDWANTED 0x0020 /* Want lease when expired */
  130 #define LC_UDP          0x0040  /* Host address for udp socket */
  131 #define LC_CLTP         0x0080  /* Host address for other connectionless */
  132 #define LC_LOCAL        0x0100  /* Host is server */
  133 #define LC_VACATED      0x0200  /* Host has vacated lease */
  134 #define LC_WRITTEN      0x0400  /* Recently wrote to the leased file */
  135 #define LC_SREF         0x0800  /* Holds a nfssvc_sock reference */
  136 #define LC_UDP6         0x1000  /* Host address for udp6 socket */
  137 
  138 struct nqm {
  139         struct nqm      *lpm_next;
  140         struct nqhost   lpm_hosts[LC_MOREHOSTSIZ];
  141 };
  142 
  143 /*
  144  * Special value for slp for local server calls.
  145  */
  146 #define NQLOCALSLP      ((struct nfssvc_sock *) -1)
  147 
  148 /*
  149  * Server side macros.
  150  */
  151 #define nqsrv_getl(v, l) \
  152                 (void) nqsrv_getlease((v), &nfsd->nd_duration, \
  153                  ((nfsd->nd_flag & ND_LEASE) ? (nfsd->nd_flag & ND_LEASE) : \
  154                  ((l) | ND_CHECK)), \
  155                  slp, lwp, nfsd->nd_nam, &cache, &frev, cred)
  156 
  157 /*
  158  * Client side macros that check for a valid lease.
  159  */
  160 #define NQNFS_CKINVALID(v, n, f) \
  161  ((time_second > (n)->n_expiry && \
  162  VFSTONFS((v)->v_mount)->nm_timeouts < VFSTONFS((v)->v_mount)->nm_deadthresh) \
  163   || ((f) == ND_WRITE && ((n)->n_flag & NQNFSWRITE) == 0))
  164 
  165 #define NQNFS_CKCACHABLE(v, f) \
  166  ((time_second <= VTONFS(v)->n_expiry || \
  167   VFSTONFS((v)->v_mount)->nm_timeouts >= VFSTONFS((v)->v_mount)->nm_deadthresh) \
  168    && (VTONFS(v)->n_flag & NQNFSNONCACHE) == 0 && \
  169    ((f) == ND_READ || (VTONFS(v)->n_flag & NQNFSWRITE)))
  170 
  171 #define NQNFS_NEEDLEASE(n, p) \
  172                 (time_second > (n)->n_expiry ? \
  173                  (((n)->n_flag & NQNFSEVICTED) ? 0 : nqnfs_piggy[p]) : \
  174                  (((time_second + NQ_RENEWAL) > (n)->n_expiry && \
  175                    nqnfs_piggy[p]) ? \
  176                    (((n)->n_flag & NQNFSWRITE) ? \
  177                     ND_WRITE : nqnfs_piggy[p]) : 0))
  178 
  179 /*
  180  * List head for timer queue.
  181  */
  182 extern CIRCLEQ_HEAD(nqleasehead, nqlease) nqtimerhead;
  183 
  184 /*
  185  * List head for the file handle hash table.
  186  */
  187 #define NQFHHASH(f) \
  188         (&nqfhhashtbl[(*((u_int32_t *)(f))) & nqfhhash])
  189 extern LIST_HEAD(nqfhhashhead, nqlease) *nqfhhashtbl;
  190 extern u_long nqfhhash;
  191 extern int nqsrv_writeslack;
  192 
  193 /*
  194  * Nqnfs return status numbers.
  195  */
  196 #define NQNFS_EXPIRED   500
  197 #define NQNFS_TRYLATER  501
  198 
  199 void    nqnfs_lease_updatetime __P((int));
  200 int     nqsrv_cmpnam __P((struct nfssvc_sock *,struct mbuf *,struct nqhost *));
  201 int     nqsrv_getlease __P((struct vnode *, u_int32_t *, int,
  202                 struct nfssvc_sock *, struct lwp *, struct mbuf *, int *,
  203                 u_quad_t *, kauth_cred_t));
  204 int     nqnfs_getlease __P((struct vnode *, int, kauth_cred_t, struct lwp *));
  205 int     nqnfs_callback __P((struct nfsmount *, struct mbuf *, struct mbuf *,
  206                 caddr_t, struct lwp *));
  207 int     nqnfs_clientd __P((struct nfsmount *, kauth_cred_t,
  208                 struct nfsd_cargs *, int, caddr_t, struct lwp *));
  209 #endif /* _KERNEL */
  210 
  211 #endif /* _NFS_NQNFS_H_ */

Cache object: 77aed6a6fc05f5ed1eff83a4a3e4b68e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.