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/nfsclient/nfs.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1989, 1993, 1995
    3  *      The Regents of the University of California.  All rights reserved.
    4  *
    5  * This code is derived from software contributed to Berkeley by
    6  * Rick Macklem at The University of Guelph.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 4. Neither the name of the University nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  *      @(#)nfs.h       8.4 (Berkeley) 5/1/95
   33  * $FreeBSD: releng/6.4/sys/nfsclient/nfs.h 159057 2006-05-30 01:52:59Z cel $
   34  */
   35 
   36 #ifndef _NFSCLIENT_NFS_H_
   37 #define _NFSCLIENT_NFS_H_
   38 
   39 #ifdef _KERNEL
   40 #include "opt_nfs.h"
   41 #endif
   42 
   43 #include <nfsclient/nfsargs.h>
   44 
   45 /*
   46  * Tunable constants for nfs
   47  */
   48 
   49 #define NFS_TICKINTVL   10              /* Desired time for a tick (msec) */
   50 #define NFS_HZ          (hz / nfs_ticks) /* Ticks/sec */
   51 #define NFS_TIMEO       (1 * NFS_HZ)    /* Default timeout = 1 second */
   52 #define NFS_MINTIMEO    (1 * NFS_HZ)    /* Min timeout to use */
   53 #define NFS_MAXTIMEO    (60 * NFS_HZ)   /* Max timeout to backoff to */
   54 #define NFS_MINIDEMTIMEO (5 * NFS_HZ)   /* Min timeout for non-idempotent ops*/
   55 #define NFS_MAXREXMIT   100             /* Stop counting after this many */
   56 #define NFS_RETRANS     10              /* Num of retrans for UDP soft mounts */
   57 #define NFS_RETRANS_TCP 2               /* Num of retrans for TCP soft mounts */
   58 #define NFS_MAXGRPS     16              /* Max. size of groups list */
   59 #ifndef NFS_MINATTRTIMO
   60 #define NFS_MINATTRTIMO 3               /* VREG attrib cache timeout in sec */
   61 #endif
   62 #ifndef NFS_MAXATTRTIMO
   63 #define NFS_MAXATTRTIMO 60
   64 #endif
   65 #ifndef NFS_MINDIRATTRTIMO
   66 #define NFS_MINDIRATTRTIMO 30           /* VDIR attrib cache timeout in sec */
   67 #endif
   68 #ifndef NFS_MAXDIRATTRTIMO
   69 #define NFS_MAXDIRATTRTIMO 60
   70 #endif
   71 #define NFS_WSIZE       8192            /* Def. write data size <= 8192 */
   72 #define NFS_RSIZE       8192            /* Def. read data size <= 8192 */
   73 #define NFS_READDIRSIZE 8192            /* Def. readdir size */
   74 #define NFS_DEFRAHEAD   1               /* Def. read ahead # blocks */
   75 #define NFS_MAXRAHEAD   4               /* Max. read ahead # blocks */
   76 #define NFS_MAXASYNCDAEMON      64      /* Max. number async_daemons runnable */
   77 #define NFS_DIRBLKSIZ   4096            /* Must be a multiple of DIRBLKSIZ */
   78 #ifdef _KERNEL
   79 #define DIRBLKSIZ       512             /* XXX we used to use ufs's DIRBLKSIZ */
   80 #endif
   81 #define NFS_MAXDEADTHRESH       9       /* How long till we say 'server not responding' */
   82 
   83 /*
   84  * Oddballs
   85  */
   86 #define NFS_CMPFH(n, f, s) \
   87         ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
   88 #define NFS_ISV3(v)     (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
   89 
   90 #define NFSSTA_HASWRITEVERF     0x00040000  /* Has write verifier for V3 */
   91 #define NFSSTA_GOTFSINFO        0x00100000  /* Got the V3 fsinfo */
   92 #define NFSSTA_SNDLOCK          0x01000000  /* Send socket lock */
   93 #define NFSSTA_WANTSND          0x02000000  /* Want above */
   94 #define NFSSTA_TIMEO            0x10000000  /* Experiencing a timeout */
   95 
   96 
   97 /*
   98  * XXX to allow amd to include nfs.h without nfsproto.h
   99  */
  100 #ifdef NFS_NPROCS
  101 #include <nfsclient/nfsstats.h>
  102 #endif
  103 
  104 /*
  105  * vfs.nfs sysctl(3) identifiers
  106  */
  107 #define NFS_NFSSTATS    1               /* struct: struct nfsstats */
  108 
  109 /*
  110  * File context information for nfsv4.  Currently, there is only one
  111  * lockowner for the whole machine "0."
  112  */
  113 struct nfs4_fctx {
  114         TAILQ_ENTRY(nfs4_fstate) next;
  115         uint32_t        refcnt;
  116         struct nfs4_lowner *lop;
  117         struct nfsnode *np;
  118         char            stateid[NFSX_V4STATEID];
  119 };
  120 
  121 #ifdef _KERNEL
  122 
  123 #ifdef MALLOC_DECLARE
  124 MALLOC_DECLARE(M_NFSREQ);
  125 MALLOC_DECLARE(M_NFSDIROFF);
  126 MALLOC_DECLARE(M_NFSBIGFH);
  127 MALLOC_DECLARE(M_NFSHASH);
  128 MALLOC_DECLARE(M_NFSDIRECTIO);
  129 #endif
  130 
  131 extern struct uma_zone *nfsmount_zone;
  132 
  133 extern struct callout nfs_callout;
  134 extern struct nfsstats nfsstats;
  135 
  136 extern int nfs_numasync;
  137 extern unsigned int nfs_iodmax;
  138 extern int nfs_pbuf_freecnt;
  139 extern int nfs_ticks;
  140 
  141 /* Data constants in XDR form */
  142 extern u_int32_t nfs_true, nfs_false, nfs_xdrneg1;
  143 extern u_int32_t rpc_reply, rpc_msgdenied, rpc_mismatch, rpc_vers;
  144 extern u_int32_t rpc_auth_unix, rpc_msgaccepted, rpc_call, rpc_autherr;
  145 
  146 extern int nfsv3_procid[NFS_NPROCS];
  147 
  148 struct uio;
  149 struct buf;
  150 struct vattr;
  151 struct nameidata;
  152 
  153 /*
  154  * Socket errors ignored for connectionless sockets??
  155  * For now, ignore them all
  156  */
  157 #define NFSIGNORE_SOERROR(s, e) \
  158                 ((e) != EINTR && (e) != EIO && \
  159                  (e) != ERESTART && (e) != EWOULDBLOCK && \
  160                 ((s) & PR_CONNREQUIRED) == 0)
  161 
  162 /*
  163  * Nfs outstanding request list element
  164  */
  165 struct nfsreq {
  166         TAILQ_ENTRY(nfsreq) r_chain;
  167         struct mbuf     *r_mreq;
  168         struct mbuf     *r_mrep;
  169         struct mbuf     *r_md;
  170         caddr_t         r_dpos;
  171         struct nfsmount *r_nmp;
  172         struct vnode    *r_vp;
  173         u_int32_t       r_xid;
  174         int             r_flags;        /* flags on request, see below */
  175         int             r_retry;        /* max retransmission count */
  176         int             r_rexmit;       /* current retrans count */
  177         int             r_timer;        /* tick counter on reply */
  178         u_int32_t       r_procnum;      /* NFS procedure number */
  179         int             r_rtt;          /* RTT for rpc */
  180         int             r_lastmsg;      /* last tprintf */
  181         struct thread   *r_td;          /* Proc that did I/O system call */
  182 };
  183 
  184 /*
  185  * Queue head for nfsreq's
  186  */
  187 extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
  188 
  189 /* Flag values for r_flags */
  190 #define R_TIMING        0x01            /* timing request (in mntp) */
  191 #define R_SENT          0x02            /* request has been sent */
  192 #define R_SOFTTERM      0x04            /* soft mnt, too many retries */
  193 #define R_RESENDERR     0x08            /* Resend failed */
  194 #define R_SOCKERR       0x10            /* Fatal error on socket */
  195 #define R_TPRINTFMSG    0x20            /* Did a tprintf msg. */
  196 #define R_MUSTRESEND    0x40            /* Must resend request */
  197 #define R_GETONEREP     0x80            /* Probe for one reply only */
  198 
  199 /*
  200  * Pointers to ops that differ from v3 to v4
  201  */
  202 struct nfs_rpcops {
  203         int     (*nr_readrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred);
  204         int     (*nr_writerpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred,
  205                                int *iomode, int *must_commit);
  206         int     (*nr_writebp)(struct buf *bp, int force, struct thread *td);
  207         int     (*nr_readlinkrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred);
  208         void    (*nr_invaldir)(struct vnode *vp);
  209         int     (*nr_commit)(struct vnode *vp, u_quad_t offset, int cnt,
  210                              struct ucred *cred, struct thread *td);
  211 };
  212 
  213 /*
  214  * Defines for WebNFS
  215  */
  216 
  217 #define WEBNFS_ESC_CHAR         '%'
  218 #define WEBNFS_SPECCHAR_START   0x80
  219 
  220 #define WEBNFS_NATIVE_CHAR      0x80
  221 /*
  222  * ..
  223  * Possibly more here in the future.
  224  */
  225 
  226 /*
  227  * Macro for converting escape characters in WebNFS pathnames.
  228  * Should really be in libkern.
  229  */
  230 
  231 #define HEXTOC(c) \
  232         ((c) >= 'a' ? ((c) - ('a' - 10)) : \
  233             ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '')))
  234 #define HEXSTRTOI(p) \
  235         ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
  236 
  237 /* nfs_sigintr() helper, when 'rep' has all we need */
  238 #define NFS_SIGREP(rep)         nfs_sigintr((rep)->r_nmp, (rep), (rep)->r_td)
  239 
  240 #ifdef NFS_DEBUG
  241 
  242 extern int nfs_debug;
  243 #define NFS_DEBUG_ASYNCIO       1 /* asynchronous i/o */
  244 #define NFS_DEBUG_WG            2 /* server write gathering */
  245 #define NFS_DEBUG_RC            4 /* server request caching */
  246 
  247 #define NFS_DPF(cat, args)                                      \
  248         do {                                                    \
  249                 if (nfs_debug & NFS_DEBUG_##cat) printf args;   \
  250         } while (0)
  251 
  252 #else
  253 
  254 #define NFS_DPF(cat, args)
  255 
  256 #endif
  257 
  258 /*
  259  * On fast networks, the estimator will try to reduce the
  260  * timeout lower than the latency of the server's disks,
  261  * which results in too many timeouts, so cap the lower
  262  * bound.
  263  */
  264 #define NFS_MINRTO      (NFS_HZ >> 2)
  265 
  266 /*
  267  * Keep the RTO from increasing to unreasonably large values
  268  * when a server is not responding.
  269  */
  270 #define NFS_MAXRTO      (20 * NFS_HZ)
  271 
  272 enum nfs_rto_timer_t {
  273         NFS_DEFAULT_TIMER,
  274         NFS_GETATTR_TIMER,
  275         NFS_LOOKUP_TIMER,
  276         NFS_READ_TIMER,
  277         NFS_WRITE_TIMER,
  278 };
  279 #define NFS_MAX_TIMER   (NFS_WRITE_TIMER)
  280 
  281 #define NFS_INITRTT     (NFS_HZ << 3)
  282 
  283 vfs_init_t nfs_init;
  284 vfs_uninit_t nfs_uninit;
  285 int     nfs_mountroot(struct mount *mp, struct thread *td);
  286 
  287 #ifndef NFS4_USE_RPCCLNT
  288 int     nfs_send(struct socket *, struct sockaddr *, struct mbuf *,
  289             struct nfsreq *);
  290 int     nfs_sndlock(struct nfsreq *);
  291 void    nfs_sndunlock(struct nfsreq *);
  292 #endif /* ! NFS4_USE_RPCCLNT */
  293 
  294 int     nfs_vinvalbuf(struct vnode *, int, struct thread *, int);
  295 int     nfs_readrpc(struct vnode *, struct uio *, struct ucred *);
  296 int     nfs_writerpc(struct vnode *, struct uio *, struct ucred *, int *,
  297             int *);
  298 int     nfs_commit(struct vnode *vp, u_quad_t offset, int cnt,
  299             struct ucred *cred, struct thread *td);
  300 int     nfs_readdirrpc(struct vnode *, struct uio *, struct ucred *);
  301 int     nfs_nfsiodnew(void);
  302 int     nfs_asyncio(struct nfsmount *, struct buf *, struct ucred *, struct thread *);
  303 int     nfs_doio(struct vnode *, struct buf *, struct ucred *, struct thread *);
  304 void    nfs_doio_directwrite (struct buf *);
  305 void    nfs_up(struct nfsreq *, struct nfsmount *, struct thread *,
  306             const char *, int);
  307 void    nfs_down(struct nfsreq *, struct nfsmount *, struct thread *,
  308             const char *, int, int);
  309 int     nfs_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
  310 int     nfs_sigintr(struct nfsmount *, struct nfsreq *, struct thread *);
  311 int     nfs_readdirplusrpc(struct vnode *, struct uio *, struct ucred *);
  312 int     nfs_request(struct vnode *, struct mbuf *, int, struct thread *,
  313             struct ucred *, struct mbuf **, struct mbuf **, caddr_t *);
  314 int     nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *,
  315             struct vattr *, int);
  316 int     nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
  317 void    nfs_nhinit(void);
  318 void    nfs_nhuninit(void);
  319 int     nfs_nmcancelreqs(struct nfsmount *);
  320 void    nfs_timer(void*);
  321 
  322 int     nfs_connect(struct nfsmount *, struct nfsreq *);
  323 void    nfs_disconnect(struct nfsmount *);
  324 void    nfs_safedisconnect(struct nfsmount *);
  325 int     nfs_getattrcache(struct vnode *, struct vattr *);
  326 int     nfsm_strtmbuf(struct mbuf **, char **, const char *, long);
  327 int     nfs_bioread(struct vnode *, struct uio *, int, struct ucred *);
  328 int     nfsm_uiotombuf(struct uio *, struct mbuf **, int, caddr_t *);
  329 void    nfs_clearcommit(struct mount *);
  330 int     nfs_writebp(struct buf *, int, struct thread *);
  331 int     nfs_fsinfo(struct nfsmount *, struct vnode *, struct ucred *,
  332             struct thread *);
  333 int     nfs_meta_setsize (struct vnode *, struct ucred *,
  334             struct thread *, u_quad_t);
  335 
  336 void    nfs_set_sigmask __P((struct thread *td, sigset_t *oldset));
  337 void    nfs_restore_sigmask __P((struct thread *td, sigset_t *set));
  338 int     nfs_tsleep __P((struct thread *td, void *ident, int priority, char *wmesg, 
  339                         int timo));
  340 int     nfs_msleep __P((struct thread *td, void *ident, struct mtx *mtx, int priority, 
  341                         char *wmesg, int timo));
  342 
  343 #endif  /* _KERNEL */
  344 
  345 #endif

Cache object: aa9a5a0bdd7ece57988a958db04a3ce7


[ 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.