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
| 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
|
167 * Socket errors ignored for connectionless sockets?? 168 * For now, ignore them all 169 */ 170#define NFSIGNORE_SOERROR(s, e) \ 171 ((e) != EINTR && (e) != EIO && \ 172 (e) != ERESTART && (e) != EWOULDBLOCK && \ 173 ((s) & PR_CONNREQUIRED) == 0) 174 175/* 176 * Nfs outstanding request list element 177 */ 178struct nfsreq { 179 TAILQ_ENTRY(nfsreq) r_chain; 180 struct mbuf *r_mreq; 181 struct mbuf *r_mrep; 182 struct mbuf *r_md; 183 caddr_t r_dpos; 184 struct nfsmount *r_nmp; 185 struct vnode *r_vp; 186 u_int32_t r_xid; 187 int r_flags; /* flags on request, see below */ 188 int r_retry; /* max retransmission count */ 189 int r_rexmit; /* current retrans count */ 190 int r_timer; /* tick counter on reply */ 191 u_int32_t r_procnum; /* NFS procedure number */ 192 int r_rtt; /* RTT for rpc */ 193 int r_lastmsg; /* last tprintf */ 194 struct thread *r_td; /* Proc that did I/O system call */ 195}; 196 197/* 198 * Queue head for nfsreq's 199 */ 200extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq; 201 202/* Flag values for r_flags */ 203#define R_TIMING 0x01 /* timing request (in mntp) */ 204#define R_SENT 0x02 /* request has been sent */ 205#define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 206#define R_RESENDERR 0x08 /* Resend failed */ 207#define R_SOCKERR 0x10 /* Fatal error on socket */ 208#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 209#define R_MUSTRESEND 0x40 /* Must resend request */ 210#define R_GETONEREP 0x80 /* Probe for one reply only */ 211 212/* 213 * Pointers to ops that differ from v3 to v4 214 */ 215struct nfs_rpcops { 216 int (*nr_readrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred); 217 int (*nr_writerpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred, 218 int *iomode, int *must_commit); 219 int (*nr_writebp)(struct buf *bp, int force, struct thread *td); 220 int (*nr_readlinkrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred); 221 void (*nr_invaldir)(struct vnode *vp); 222 int (*nr_commit)(struct vnode *vp, u_quad_t offset, int cnt, 223 struct ucred *cred, struct thread *td); 224}; 225 226/* 227 * Defines for WebNFS 228 */ 229 230#define WEBNFS_ESC_CHAR '%' 231#define WEBNFS_SPECCHAR_START 0x80 232 233#define WEBNFS_NATIVE_CHAR 0x80 234/* 235 * .. 236 * Possibly more here in the future. 237 */ 238 239/* 240 * Macro for converting escape characters in WebNFS pathnames. 241 * Should really be in libkern. 242 */ 243 244#define HEXTOC(c) \ 245 ((c) >= 'a' ? ((c) - ('a' - 10)) : \ 246 ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0'))) 247#define HEXSTRTOI(p) \ 248 ((HEXTOC(p[0]) << 4) + HEXTOC(p[1])) 249 250/* nfs_sigintr() helper, when 'rep' has all we need */ 251#define NFS_SIGREP(rep) nfs_sigintr((rep)->r_nmp, (rep), (rep)->r_td) 252 253#ifdef NFS_DEBUG 254 255extern int nfs_debug; 256#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ 257#define NFS_DEBUG_WG 2 /* server write gathering */ 258#define NFS_DEBUG_RC 4 /* server request caching */ 259 260#define NFS_DPF(cat, args) \ 261 do { \ 262 if (nfs_debug & NFS_DEBUG_##cat) printf args; \ 263 } while (0) 264 265#else 266 267#define NFS_DPF(cat, args) 268 269#endif 270 271vfs_init_t nfs_init; 272vfs_uninit_t nfs_uninit; 273int nfs_mountroot(struct mount *mp, struct thread *td); 274 275#ifndef NFS4_USE_RPCCLNT 276int nfs_send(struct socket *, struct sockaddr *, struct mbuf *, 277 struct nfsreq *); 278int nfs_sndlock(struct nfsreq *); 279void nfs_sndunlock(struct nfsreq *); 280#endif /* ! NFS4_USE_RPCCLNT */ 281 282int nfs_vinvalbuf(struct vnode *, int, struct ucred *, struct thread *, 283 int); 284int nfs_readrpc(struct vnode *, struct uio *, struct ucred *); 285int nfs_writerpc(struct vnode *, struct uio *, struct ucred *, int *, 286 int *); 287int nfs_commit(struct vnode *vp, u_quad_t offset, int cnt, 288 struct ucred *cred, struct thread *td); 289int nfs_readdirrpc(struct vnode *, struct uio *, struct ucred *); 290int nfs_nfsiodnew(void); 291int nfs_asyncio(struct nfsmount *, struct buf *, struct ucred *, struct thread *); 292int nfs_doio(struct vnode *, struct buf *, struct ucred *, struct thread *); 293void nfs_up(struct nfsreq *, struct nfsmount *, struct thread *, 294 const char *, int); 295void nfs_down(struct nfsreq *, struct nfsmount *, struct thread *, 296 const char *, int, int); 297int nfs_readlinkrpc(struct vnode *, struct uio *, struct ucred *); 298int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct thread *); 299int nfs_readdirplusrpc(struct vnode *, struct uio *, struct ucred *); 300int nfs_request(struct vnode *, struct mbuf *, int, struct thread *, 301 struct ucred *, struct mbuf **, struct mbuf **, caddr_t *); 302int nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *, 303 struct vattr *, int); 304int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *); 305void nfs_nhinit(void); 306void nfs_nhuninit(void); 307int nfs_nmcancelreqs(struct nfsmount *); 308void nfs_timer(void*); 309 310int nfs_connect(struct nfsmount *, struct nfsreq *); 311void nfs_disconnect(struct nfsmount *); 312void nfs_safedisconnect(struct nfsmount *); 313int nfs_getattrcache(struct vnode *, struct vattr *); 314int nfsm_strtmbuf(struct mbuf **, char **, const char *, long); 315int nfs_bioread(struct vnode *, struct uio *, int, struct ucred *); 316int nfsm_uiotombuf(struct uio *, struct mbuf **, int, caddr_t *); 317void nfs_clearcommit(struct mount *); 318int nfs_writebp(struct buf *, int, struct thread *); 319int nfs_fsinfo(struct nfsmount *, struct vnode *, struct ucred *, 320 struct thread *); 321int nfs_meta_setsize (struct vnode *, struct ucred *, 322 struct thread *, u_quad_t); 323
| 152 * Socket errors ignored for connectionless sockets?? 153 * For now, ignore them all 154 */ 155#define NFSIGNORE_SOERROR(s, e) \ 156 ((e) != EINTR && (e) != EIO && \ 157 (e) != ERESTART && (e) != EWOULDBLOCK && \ 158 ((s) & PR_CONNREQUIRED) == 0) 159 160/* 161 * Nfs outstanding request list element 162 */ 163struct nfsreq { 164 TAILQ_ENTRY(nfsreq) r_chain; 165 struct mbuf *r_mreq; 166 struct mbuf *r_mrep; 167 struct mbuf *r_md; 168 caddr_t r_dpos; 169 struct nfsmount *r_nmp; 170 struct vnode *r_vp; 171 u_int32_t r_xid; 172 int r_flags; /* flags on request, see below */ 173 int r_retry; /* max retransmission count */ 174 int r_rexmit; /* current retrans count */ 175 int r_timer; /* tick counter on reply */ 176 u_int32_t r_procnum; /* NFS procedure number */ 177 int r_rtt; /* RTT for rpc */ 178 int r_lastmsg; /* last tprintf */ 179 struct thread *r_td; /* Proc that did I/O system call */ 180}; 181 182/* 183 * Queue head for nfsreq's 184 */ 185extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq; 186 187/* Flag values for r_flags */ 188#define R_TIMING 0x01 /* timing request (in mntp) */ 189#define R_SENT 0x02 /* request has been sent */ 190#define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 191#define R_RESENDERR 0x08 /* Resend failed */ 192#define R_SOCKERR 0x10 /* Fatal error on socket */ 193#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 194#define R_MUSTRESEND 0x40 /* Must resend request */ 195#define R_GETONEREP 0x80 /* Probe for one reply only */ 196 197/* 198 * Pointers to ops that differ from v3 to v4 199 */ 200struct nfs_rpcops { 201 int (*nr_readrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred); 202 int (*nr_writerpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred, 203 int *iomode, int *must_commit); 204 int (*nr_writebp)(struct buf *bp, int force, struct thread *td); 205 int (*nr_readlinkrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred); 206 void (*nr_invaldir)(struct vnode *vp); 207 int (*nr_commit)(struct vnode *vp, u_quad_t offset, int cnt, 208 struct ucred *cred, struct thread *td); 209}; 210 211/* 212 * Defines for WebNFS 213 */ 214 215#define WEBNFS_ESC_CHAR '%' 216#define WEBNFS_SPECCHAR_START 0x80 217 218#define WEBNFS_NATIVE_CHAR 0x80 219/* 220 * .. 221 * Possibly more here in the future. 222 */ 223 224/* 225 * Macro for converting escape characters in WebNFS pathnames. 226 * Should really be in libkern. 227 */ 228 229#define HEXTOC(c) \ 230 ((c) >= 'a' ? ((c) - ('a' - 10)) : \ 231 ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0'))) 232#define HEXSTRTOI(p) \ 233 ((HEXTOC(p[0]) << 4) + HEXTOC(p[1])) 234 235/* nfs_sigintr() helper, when 'rep' has all we need */ 236#define NFS_SIGREP(rep) nfs_sigintr((rep)->r_nmp, (rep), (rep)->r_td) 237 238#ifdef NFS_DEBUG 239 240extern int nfs_debug; 241#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ 242#define NFS_DEBUG_WG 2 /* server write gathering */ 243#define NFS_DEBUG_RC 4 /* server request caching */ 244 245#define NFS_DPF(cat, args) \ 246 do { \ 247 if (nfs_debug & NFS_DEBUG_##cat) printf args; \ 248 } while (0) 249 250#else 251 252#define NFS_DPF(cat, args) 253 254#endif 255 256vfs_init_t nfs_init; 257vfs_uninit_t nfs_uninit; 258int nfs_mountroot(struct mount *mp, struct thread *td); 259 260#ifndef NFS4_USE_RPCCLNT 261int nfs_send(struct socket *, struct sockaddr *, struct mbuf *, 262 struct nfsreq *); 263int nfs_sndlock(struct nfsreq *); 264void nfs_sndunlock(struct nfsreq *); 265#endif /* ! NFS4_USE_RPCCLNT */ 266 267int nfs_vinvalbuf(struct vnode *, int, struct ucred *, struct thread *, 268 int); 269int nfs_readrpc(struct vnode *, struct uio *, struct ucred *); 270int nfs_writerpc(struct vnode *, struct uio *, struct ucred *, int *, 271 int *); 272int nfs_commit(struct vnode *vp, u_quad_t offset, int cnt, 273 struct ucred *cred, struct thread *td); 274int nfs_readdirrpc(struct vnode *, struct uio *, struct ucred *); 275int nfs_nfsiodnew(void); 276int nfs_asyncio(struct nfsmount *, struct buf *, struct ucred *, struct thread *); 277int nfs_doio(struct vnode *, struct buf *, struct ucred *, struct thread *); 278void nfs_up(struct nfsreq *, struct nfsmount *, struct thread *, 279 const char *, int); 280void nfs_down(struct nfsreq *, struct nfsmount *, struct thread *, 281 const char *, int, int); 282int nfs_readlinkrpc(struct vnode *, struct uio *, struct ucred *); 283int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct thread *); 284int nfs_readdirplusrpc(struct vnode *, struct uio *, struct ucred *); 285int nfs_request(struct vnode *, struct mbuf *, int, struct thread *, 286 struct ucred *, struct mbuf **, struct mbuf **, caddr_t *); 287int nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *, 288 struct vattr *, int); 289int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *); 290void nfs_nhinit(void); 291void nfs_nhuninit(void); 292int nfs_nmcancelreqs(struct nfsmount *); 293void nfs_timer(void*); 294 295int nfs_connect(struct nfsmount *, struct nfsreq *); 296void nfs_disconnect(struct nfsmount *); 297void nfs_safedisconnect(struct nfsmount *); 298int nfs_getattrcache(struct vnode *, struct vattr *); 299int nfsm_strtmbuf(struct mbuf **, char **, const char *, long); 300int nfs_bioread(struct vnode *, struct uio *, int, struct ucred *); 301int nfsm_uiotombuf(struct uio *, struct mbuf **, int, caddr_t *); 302void nfs_clearcommit(struct mount *); 303int nfs_writebp(struct buf *, int, struct thread *); 304int nfs_fsinfo(struct nfsmount *, struct vnode *, struct ucred *, 305 struct thread *); 306int nfs_meta_setsize (struct vnode *, struct ucred *, 307 struct thread *, u_quad_t); 308
|