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-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 /*-
    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$
   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 soft mounts */
   57 #define NFS_MAXGRPS     16              /* Max. size of groups list */
   58 #ifndef NFS_MINATTRTIMO
   59 #define NFS_MINATTRTIMO 3               /* VREG attrib cache timeout in sec */
   60 #endif
   61 #ifndef NFS_MAXATTRTIMO
   62 #define NFS_MAXATTRTIMO 60
   63 #endif
   64 #ifndef NFS_MINDIRATTRTIMO
   65 #define NFS_MINDIRATTRTIMO 30           /* VDIR attrib cache timeout in sec */
   66 #endif
   67 #ifndef NFS_MAXDIRATTRTIMO
   68 #define NFS_MAXDIRATTRTIMO 60
   69 #endif
   70 #define NFS_WSIZE       8192            /* Def. write data size <= 8192 */
   71 #define NFS_RSIZE       8192            /* Def. read data size <= 8192 */
   72 #define NFS_READDIRSIZE 8192            /* Def. readdir size */
   73 #define NFS_DEFRAHEAD   1               /* Def. read ahead # blocks */
   74 #define NFS_MAXRAHEAD   4               /* Max. read ahead # blocks */
   75 #define NFS_MAXASYNCDAEMON      64      /* Max. number async_daemons runnable */
   76 #define NFS_DIRBLKSIZ   4096            /* Must be a multiple of DIRBLKSIZ */
   77 #ifdef _KERNEL
   78 #define DIRBLKSIZ       512             /* XXX we used to use ufs's DIRBLKSIZ */
   79 #endif
   80 #define NFS_MAXDEADTHRESH       9       /* How long till we say 'server not responding' */
   81 
   82 /*
   83  * Oddballs
   84  */
   85 #define NFS_CMPFH(n, f, s) \
   86         ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
   87 #define NFS_ISV3(v)     (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
   88 
   89 #define NFSSTA_HASWRITEVERF     0x00040000  /* Has write verifier for V3 */
   90 #define NFSSTA_GOTFSINFO        0x00100000  /* Got the V3 fsinfo */
   91 #define NFSSTA_SNDLOCK          0x01000000  /* Send socket lock */
   92 #define NFSSTA_WANTSND          0x02000000  /* Want above */
   93 #define NFSSTA_RCVLOCK          0x04000000  /* Rcv socket lock */
   94 #define NFSSTA_WANTRCV          0x08000000  /* Want above */
   95 #define NFSSTA_TIMEO            0x10000000  /* Experiencing a timeout */
   96 
   97 
   98 /*
   99  * XXX to allow amd to include nfs.h without nfsproto.h
  100  */
  101 #ifdef NFS_NPROCS
  102 #include <nfsclient/nfsstats.h>
  103 #endif
  104 /*
  105  * Flags for nfsclnt() system call.
  106  */
  107 #define NFSCLNT_LOCKDANS 0x200
  108 
  109 /*
  110  * vfs.nfs sysctl(3) identifiers
  111  */
  112 #define NFS_NFSSTATS    1               /* struct: struct nfsstats */
  113 
  114 /*
  115  * File context information for nfsv4.  Currently, there is only one
  116  * lockowner for the whole machine "0."
  117  */
  118 struct nfs4_fctx {
  119         TAILQ_ENTRY(nfs4_fstate) next;
  120         uint32_t        refcnt;
  121         struct nfs4_lowner *lop;
  122         struct nfsnode *np;
  123         char            stateid[NFSX_V4STATEID];
  124 };
  125 
  126 #ifdef _KERNEL
  127 
  128 #ifdef MALLOC_DECLARE
  129 MALLOC_DECLARE(M_NFSREQ);
  130 MALLOC_DECLARE(M_NFSDIROFF);
  131 MALLOC_DECLARE(M_NFSBIGFH);
  132 MALLOC_DECLARE(M_NFSHASH);
  133 #endif
  134 
  135 extern struct uma_zone *nfsmount_zone;
  136 
  137 extern struct callout nfs_callout;
  138 extern struct nfsstats nfsstats;
  139 
  140 extern int nfs_numasync;
  141 extern unsigned int nfs_iodmax;
  142 extern int nfs_pbuf_freecnt;
  143 extern int nfs_ticks;
  144 
  145 /* Data constants in XDR form */
  146 extern u_int32_t nfs_true, nfs_false, nfs_xdrneg1;
  147 extern u_int32_t rpc_reply, rpc_msgdenied, rpc_mismatch, rpc_vers;
  148 extern u_int32_t rpc_auth_unix, rpc_msgaccepted, rpc_call, rpc_autherr;
  149 
  150 extern int nfsv3_procid[NFS_NPROCS];
  151 
  152 struct uio;
  153 struct buf;
  154 struct vattr;
  155 struct nameidata;
  156 
  157 /*
  158  * The set of signals that interrupt an I/O in progress for NFSMNT_INT mounts.
  159  * What should be in this set is open to debate, but I believe that since
  160  * I/O system calls on ufs are never interrupted by signals the set should
  161  * be minimal. My reasoning is that many current programs that use signals
  162  * such as SIGALRM will not expect file I/O system calls to be interrupted
  163  * by them and break.
  164  */
  165 #define NFSINT_SIGMASK(set)                                             \
  166         (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) ||       \
  167          SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) ||       \
  168          SIGISMEMBER(set, SIGQUIT))
  169 
  170 /*
  171  * Socket errors ignored for connectionless sockets??
  172  * For now, ignore them all
  173  */
  174 #define NFSIGNORE_SOERROR(s, e) \
  175                 ((e) != EINTR && (e) != EIO && \
  176                  (e) != ERESTART && (e) != EWOULDBLOCK && \
  177                 ((s) & PR_CONNREQUIRED) == 0)
  178 
  179 /*
  180  * Nfs outstanding request list element
  181  */
  182 struct nfsreq {
  183         TAILQ_ENTRY(nfsreq) r_chain;
  184         struct mbuf     *r_mreq;
  185         struct mbuf     *r_mrep;
  186         struct mbuf     *r_md;
  187         caddr_t         r_dpos;
  188         struct nfsmount *r_nmp;
  189         struct vnode    *r_vp;
  190         u_int32_t       r_xid;
  191         int             r_flags;        /* flags on request, see below */
  192         int             r_retry;        /* max retransmission count */
  193         int             r_rexmit;       /* current retrans count */
  194         int             r_timer;        /* tick counter on reply */
  195         u_int32_t       r_procnum;      /* NFS procedure number */
  196         int             r_rtt;          /* RTT for rpc */
  197         int             r_lastmsg;      /* last tprintf */
  198         struct thread   *r_td;          /* Proc that did I/O system call */
  199 };
  200 
  201 /*
  202  * Queue head for nfsreq's
  203  */
  204 extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
  205 
  206 /* Flag values for r_flags */
  207 #define R_TIMING        0x01            /* timing request (in mntp) */
  208 #define R_SENT          0x02            /* request has been sent */
  209 #define R_SOFTTERM      0x04            /* soft mnt, too many retries */
  210 #define R_RESENDERR     0x08            /* Resend failed */
  211 #define R_SOCKERR       0x10            /* Fatal error on socket */
  212 #define R_TPRINTFMSG    0x20            /* Did a tprintf msg. */
  213 #define R_MUSTRESEND    0x40            /* Must resend request */
  214 #define R_GETONEREP     0x80            /* Probe for one reply only */
  215 
  216 /*
  217  * Pointers to ops that differ from v3 to v4
  218  */
  219 struct nfs_rpcops {
  220         int     (*nr_readrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred);
  221         int     (*nr_writerpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred,
  222                                int *iomode, int *must_commit);
  223         int     (*nr_writebp)(struct buf *bp, int force, struct thread *td);
  224         int     (*nr_readlinkrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred);
  225         void    (*nr_invaldir)(struct vnode *vp);
  226         int     (*nr_commit)(struct vnode *vp, u_quad_t offset, int cnt,
  227                              struct ucred *cred, struct thread *td);
  228 };
  229 
  230 /*
  231  * Defines for WebNFS
  232  */
  233 
  234 #define WEBNFS_ESC_CHAR         '%'
  235 #define WEBNFS_SPECCHAR_START   0x80
  236 
  237 #define WEBNFS_NATIVE_CHAR      0x80
  238 /*
  239  * ..
  240  * Possibly more here in the future.
  241  */
  242 
  243 /*
  244  * Macro for converting escape characters in WebNFS pathnames.
  245  * Should really be in libkern.
  246  */
  247 
  248 #define HEXTOC(c) \
  249         ((c) >= 'a' ? ((c) - ('a' - 10)) : \
  250             ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '')))
  251 #define HEXSTRTOI(p) \
  252         ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
  253 
  254 /* nfs_sigintr() helper, when 'rep' has all we need */
  255 #define NFS_SIGREP(rep)         nfs_sigintr((rep)->r_nmp, (rep), (rep)->r_td)
  256 
  257 #ifdef NFS_DEBUG
  258 
  259 extern int nfs_debug;
  260 #define NFS_DEBUG_ASYNCIO       1 /* asynchronous i/o */
  261 #define NFS_DEBUG_WG            2 /* server write gathering */
  262 #define NFS_DEBUG_RC            4 /* server request caching */
  263 
  264 #define NFS_DPF(cat, args)                                      \
  265         do {                                                    \
  266                 if (nfs_debug & NFS_DEBUG_##cat) printf args;   \
  267         } while (0)
  268 
  269 #else
  270 
  271 #define NFS_DPF(cat, args)
  272 
  273 #endif
  274 
  275 vfs_init_t nfs_init;
  276 vfs_uninit_t nfs_uninit;
  277 int     nfs_mountroot(struct mount *mp, struct thread *td);
  278 
  279 #ifndef NFS4_USE_RPCCLNT
  280 int     nfs_send(struct socket *, struct sockaddr *, struct mbuf *,
  281             struct nfsreq *);
  282 int     nfs_sndlock(struct nfsreq *);
  283 void    nfs_sndunlock(struct nfsreq *);
  284 #endif /* ! NFS4_USE_RPCCLNT */
  285 
  286 int     nfs_vinvalbuf(struct vnode *, int, struct ucred *, struct thread *,
  287             int);
  288 int     nfs_readrpc(struct vnode *, struct uio *, struct ucred *);
  289 int     nfs_writerpc(struct vnode *, struct uio *, struct ucred *, int *,
  290             int *);
  291 int     nfs_commit(struct vnode *vp, u_quad_t offset, int cnt,
  292             struct ucred *cred, struct thread *td);
  293 int     nfs_readdirrpc(struct vnode *, struct uio *, struct ucred *);
  294 int     nfs_nfsiodnew(void);
  295 int     nfs_asyncio(struct buf *, struct ucred *, struct thread *);
  296 int     nfs_doio(struct buf *, struct ucred *, struct thread *);
  297 void    nfs_up(struct nfsreq *, struct nfsmount *, struct thread *,
  298             const char *, int);
  299 void    nfs_down(struct nfsreq *, struct nfsmount *, struct thread *,
  300             const char *, int, int);
  301 int     nfs_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
  302 int     nfs_sigintr(struct nfsmount *, struct nfsreq *, struct thread *);
  303 int     nfs_readdirplusrpc(struct vnode *, struct uio *, struct ucred *);
  304 int     nfs_request(struct vnode *, struct mbuf *, int, struct thread *,
  305             struct ucred *, struct mbuf **, struct mbuf **, caddr_t *);
  306 int     nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *,
  307             struct vattr *, int);
  308 int     nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
  309 void    nfs_nhinit(void);
  310 void    nfs_nhuninit(void);
  311 int     nfs_nmcancelreqs(struct nfsmount *);
  312 void    nfs_timer(void*);
  313 
  314 int     nfs_connect(struct nfsmount *, struct nfsreq *);
  315 void    nfs_disconnect(struct nfsmount *);
  316 void    nfs_safedisconnect(struct nfsmount *);
  317 int     nfs_getattrcache(struct vnode *, struct vattr *);
  318 int     nfsm_strtmbuf(struct mbuf **, char **, const char *, long);
  319 int     nfs_bioread(struct vnode *, struct uio *, int, struct ucred *);
  320 int     nfsm_uiotombuf(struct uio *, struct mbuf **, int, caddr_t *);
  321 void    nfs_clearcommit(struct mount *);
  322 int     nfs_writebp(struct buf *, int, struct thread *);
  323 int     nfs_fsinfo(struct nfsmount *, struct vnode *, struct ucred *,
  324             struct thread *);
  325 int     nfs_meta_setsize (struct vnode *, struct ucred *,
  326             struct thread *, u_quad_t);
  327 
  328 #endif  /* _KERNEL */
  329 
  330 #endif

Cache object: a9474774e188edea5b23f75549385308


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