nfsnode.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* $OpenBSD: nfsnode.h,v 1.39 2009/12/15 15:53:48 beck Exp $ */
  2. /* $NetBSD: nfsnode.h,v 1.16 1996/02/18 11:54:04 fvdl Exp $ */
  3. /*
  4. * Copyright (c) 1989, 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. * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95
  35. */
  36. #ifndef _NFS_NFSNODE_H_
  37. #define _NFS_NFSNODE_H_
  38. #ifndef _NFS_NFS_H_
  39. #include <nfs/nfs.h>
  40. #endif
  41. #include <sys/rwlock.h>
  42. /*
  43. * Silly rename structure that hangs off the nfsnode until the name
  44. * can be removed by nfs_inactive()
  45. */
  46. struct sillyrename {
  47. struct ucred *s_cred;
  48. struct vnode *s_dvp;
  49. long s_namlen;
  50. char s_name[24];
  51. };
  52. /*
  53. * The nfsnode is the nfs equivalent to ufs's inode. Any similarity
  54. * is purely coincidental.
  55. * There is a unique nfsnode allocated for each active file,
  56. * each current directory, each mounted-on file, text file, and the root.
  57. * An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
  58. * If this structure exceeds 256 bytes (it is currently 256 using 4.4BSD-Lite
  59. * type definitions), file handles of > 32 bytes should probably be split out
  60. * into a separate malloc()'d data structure. (Reduce the size of nfsfh_t by
  61. * changing the definition in sys/mount.h of NFS_SMALLFH.)
  62. * NB: Hopefully the current order of the fields is such that everything will
  63. * be well aligned and, therefore, tightly packed.
  64. */
  65. struct nfsnode {
  66. RB_ENTRY(nfsnode) n_entry; /* filehandle/node tree. */
  67. u_quad_t n_size; /* Current size of file */
  68. struct vattr n_vattr; /* Vnode attribute cache */
  69. time_t n_attrstamp; /* Attr. cache timestamp */
  70. struct timespec n_mtime; /* Prev modify time. */
  71. time_t n_ctime; /* Prev create time. */
  72. nfsfh_t *n_fhp; /* NFS File Handle */
  73. struct vnode *n_vnode; /* associated vnode */
  74. struct lockf *n_lockf; /* Locking record of file */
  75. int n_error; /* Save write error value */
  76. union {
  77. struct timespec nf_atim; /* Special file times */
  78. nfsuint64 nd_cookieverf; /* Cookie verifier (dir only) */
  79. } n_un1;
  80. union {
  81. struct timespec nf_mtim;
  82. off_t nd_direof; /* Dir. EOF offset cache */
  83. } n_un2;
  84. struct sillyrename *n_sillyrename; /* Ptr to silly rename struct */
  85. short n_fhsize; /* size in bytes, of fh */
  86. short n_flag; /* Flag for locking.. */
  87. nfsfh_t n_fh; /* Small File Handle */
  88. time_t n_accstamp; /* Access cache timestamp */
  89. uid_t n_accuid; /* Last access requester */
  90. int n_accmode; /* Last mode requested */
  91. int n_accerror; /* Last returned error */
  92. struct ucred *n_rcred;
  93. struct ucred *n_wcred;
  94. off_t n_pushedlo; /* 1st blk in commited range */
  95. off_t n_pushedhi; /* Last block in range */
  96. off_t n_pushlo; /* 1st block in commit range */
  97. off_t n_pushhi; /* Last block in range */
  98. struct rwlock n_commitlock; /* Serialize commits */
  99. int n_commitflags;
  100. };
  101. /*
  102. * Values for n_commitflags
  103. */
  104. #define NFS_COMMIT_PUSH_VALID 0x0001 /* push range valid */
  105. #define NFS_COMMIT_PUSHED_VALID 0x0002 /* pushed range valid */
  106. #define n_atim n_un1.nf_atim
  107. #define n_mtim n_un2.nf_mtim
  108. #define n_cookieverf n_un1.nd_cookieverf
  109. #define n_direofoffset n_un2.nd_direof
  110. /*
  111. * Flags for n_flag
  112. */
  113. #define NFLUSHWANT 0x0001 /* Want wakeup from a flush in prog. */
  114. #define NFLUSHINPROG 0x0002 /* Avoid multiple calls to vinvalbuf() */
  115. #define NMODIFIED 0x0004 /* Might have a modified buffer in bio */
  116. #define NWRITEERR 0x0008 /* Flag write errors so close will know */
  117. #define NACC 0x0100 /* Special file accessed */
  118. #define NUPD 0x0200 /* Special file updated */
  119. #define NCHG 0x0400 /* Special file times changed */
  120. #define NFS_INVALIDATE_ATTRCACHE(np) ((np)->n_attrstamp = 0)
  121. /*
  122. * Convert between nfsnode pointers and vnode pointers
  123. */
  124. #define VTONFS(vp) ((struct nfsnode *)(vp)->v_data)
  125. #define NFSTOV(np) ((np)->n_vnode)
  126. /*
  127. * Queue head for nfsiod's
  128. */
  129. extern TAILQ_HEAD(nfs_bufqhead, buf) nfs_bufq;
  130. extern uint32_t nfs_bufqlen, nfs_bufqmax;
  131. #endif /* _NFS_NFSNODE_H_ */