xfs_vnode.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. *
  32. * Portions Copyright (c) 1989, 1993
  33. * The Regents of the University of California. All rights reserved.
  34. *
  35. * Redistribution and use in source and binary forms, with or without
  36. * modification, are permitted provided that the following conditions
  37. * are met:
  38. * 1. Redistributions of source code must retain the above copyright
  39. * notice, this list of conditions and the following disclaimer.
  40. * 2. Redistributions in binary form must reproduce the above copyright
  41. * notice, this list of conditions and the following disclaimer in the
  42. * documentation and/or other materials provided with the distribution.
  43. * 3. Neither the name of the University nor the names of its contributors
  44. * may be used to endorse or promote products derived from this software
  45. * without specific prior written permission.
  46. *
  47. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  48. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  50. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  51. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  52. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  53. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  54. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  55. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  56. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  57. * SUCH DAMAGE.
  58. */
  59. #ifndef __XFS_VNODE_H__
  60. #define __XFS_VNODE_H__
  61. struct uio;
  62. struct file;
  63. struct vattr;
  64. struct xfs_iomap;
  65. struct attrlist_cursor_kern;
  66. typedef xfs_ino_t vnumber_t;
  67. typedef struct dentry vname_t;
  68. typedef bhv_head_t vn_bhv_head_t;
  69. /*
  70. * MP locking protocols:
  71. * v_flag, v_vfsp VN_LOCK/VN_UNLOCK
  72. */
  73. typedef struct vnode {
  74. __u32 v_flag; /* vnode flags (see below) */
  75. struct vfs *v_vfsp; /* ptr to containing VFS */
  76. vnumber_t v_number; /* in-core vnode number */
  77. vn_bhv_head_t v_bh; /* behavior head */
  78. spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */
  79. #ifdef XFS_VNODE_TRACE
  80. struct ktrace *v_trace; /* trace header structure */
  81. #endif
  82. struct inode v_inode; /* Linux inode */
  83. /* inode MUST be last */
  84. } vnode_t;
  85. #define VN_ISLNK(vp) S_ISLNK((vp)->v_inode.i_mode)
  86. #define VN_ISREG(vp) S_ISREG((vp)->v_inode.i_mode)
  87. #define VN_ISDIR(vp) S_ISDIR((vp)->v_inode.i_mode)
  88. #define VN_ISCHR(vp) S_ISCHR((vp)->v_inode.i_mode)
  89. #define VN_ISBLK(vp) S_ISBLK((vp)->v_inode.i_mode)
  90. #define v_fbhv v_bh.bh_first /* first behavior */
  91. #define v_fops v_bh.bh_first->bd_ops /* first behavior ops */
  92. #define VNODE_POSITION_BASE BHV_POSITION_BASE /* chain bottom */
  93. #define VNODE_POSITION_TOP BHV_POSITION_TOP /* chain top */
  94. #define VNODE_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */
  95. typedef enum {
  96. VN_BHV_UNKNOWN, /* not specified */
  97. VN_BHV_XFS, /* xfs */
  98. VN_BHV_DM, /* data migration */
  99. VN_BHV_QM, /* quota manager */
  100. VN_BHV_IO, /* IO path */
  101. VN_BHV_END /* housekeeping end-of-range */
  102. } vn_bhv_t;
  103. #define VNODE_POSITION_XFS (VNODE_POSITION_BASE)
  104. #define VNODE_POSITION_DM (VNODE_POSITION_BASE+10)
  105. #define VNODE_POSITION_QM (VNODE_POSITION_BASE+20)
  106. #define VNODE_POSITION_IO (VNODE_POSITION_BASE+30)
  107. /*
  108. * Macros for dealing with the behavior descriptor inside of the vnode.
  109. */
  110. #define BHV_TO_VNODE(bdp) ((vnode_t *)BHV_VOBJ(bdp))
  111. #define BHV_TO_VNODE_NULL(bdp) ((vnode_t *)BHV_VOBJNULL(bdp))
  112. #define VN_BHV_HEAD(vp) ((bhv_head_t *)(&((vp)->v_bh)))
  113. #define vn_bhv_head_init(bhp,name) bhv_head_init(bhp,name)
  114. #define vn_bhv_remove(bhp,bdp) bhv_remove(bhp,bdp)
  115. #define vn_bhv_lookup(bhp,ops) bhv_lookup(bhp,ops)
  116. #define vn_bhv_lookup_unlocked(bhp,ops) bhv_lookup_unlocked(bhp,ops)
  117. /*
  118. * Vnode to Linux inode mapping.
  119. */
  120. #define LINVFS_GET_VP(inode) ((vnode_t *)list_entry(inode, vnode_t, v_inode))
  121. #define LINVFS_GET_IP(vp) (&(vp)->v_inode)
  122. /*
  123. * Vnode flags.
  124. */
  125. #define VMODIFIED 0x8 /* XFS inode state possibly differs */
  126. /* to the Linux inode state. */
  127. /*
  128. * Values for the VOP_RWLOCK and VOP_RWUNLOCK flags parameter.
  129. */
  130. typedef enum vrwlock {
  131. VRWLOCK_NONE,
  132. VRWLOCK_READ,
  133. VRWLOCK_WRITE,
  134. VRWLOCK_WRITE_DIRECT,
  135. VRWLOCK_TRY_READ,
  136. VRWLOCK_TRY_WRITE
  137. } vrwlock_t;
  138. /*
  139. * Return values for VOP_INACTIVE. A return value of
  140. * VN_INACTIVE_NOCACHE implies that the file system behavior
  141. * has disassociated its state and bhv_desc_t from the vnode.
  142. */
  143. #define VN_INACTIVE_CACHE 0
  144. #define VN_INACTIVE_NOCACHE 1
  145. /*
  146. * Values for the cmd code given to VOP_VNODE_CHANGE.
  147. */
  148. typedef enum vchange {
  149. VCHANGE_FLAGS_FRLOCKS = 0,
  150. VCHANGE_FLAGS_ENF_LOCKING = 1,
  151. VCHANGE_FLAGS_TRUNCATED = 2,
  152. VCHANGE_FLAGS_PAGE_DIRTY = 3,
  153. VCHANGE_FLAGS_IOEXCL_COUNT = 4
  154. } vchange_t;
  155. typedef int (*vop_open_t)(bhv_desc_t *, struct cred *);
  156. typedef ssize_t (*vop_read_t)(bhv_desc_t *, struct kiocb *,
  157. const struct iovec *, unsigned int,
  158. loff_t *, int, struct cred *);
  159. typedef ssize_t (*vop_write_t)(bhv_desc_t *, struct kiocb *,
  160. const struct iovec *, unsigned int,
  161. loff_t *, int, struct cred *);
  162. typedef ssize_t (*vop_sendfile_t)(bhv_desc_t *, struct file *,
  163. loff_t *, int, size_t, read_actor_t,
  164. void *, struct cred *);
  165. typedef int (*vop_ioctl_t)(bhv_desc_t *, struct inode *, struct file *,
  166. int, unsigned int, void __user *);
  167. typedef int (*vop_getattr_t)(bhv_desc_t *, struct vattr *, int,
  168. struct cred *);
  169. typedef int (*vop_setattr_t)(bhv_desc_t *, struct vattr *, int,
  170. struct cred *);
  171. typedef int (*vop_access_t)(bhv_desc_t *, int, struct cred *);
  172. typedef int (*vop_lookup_t)(bhv_desc_t *, vname_t *, vnode_t **,
  173. int, vnode_t *, struct cred *);
  174. typedef int (*vop_create_t)(bhv_desc_t *, vname_t *, struct vattr *,
  175. vnode_t **, struct cred *);
  176. typedef int (*vop_remove_t)(bhv_desc_t *, vname_t *, struct cred *);
  177. typedef int (*vop_link_t)(bhv_desc_t *, vnode_t *, vname_t *,
  178. struct cred *);
  179. typedef int (*vop_rename_t)(bhv_desc_t *, vname_t *, vnode_t *, vname_t *,
  180. struct cred *);
  181. typedef int (*vop_mkdir_t)(bhv_desc_t *, vname_t *, struct vattr *,
  182. vnode_t **, struct cred *);
  183. typedef int (*vop_rmdir_t)(bhv_desc_t *, vname_t *, struct cred *);
  184. typedef int (*vop_readdir_t)(bhv_desc_t *, struct uio *, struct cred *,
  185. int *);
  186. typedef int (*vop_symlink_t)(bhv_desc_t *, vname_t *, struct vattr *,
  187. char *, vnode_t **, struct cred *);
  188. typedef int (*vop_readlink_t)(bhv_desc_t *, struct uio *, int,
  189. struct cred *);
  190. typedef int (*vop_fsync_t)(bhv_desc_t *, int, struct cred *,
  191. xfs_off_t, xfs_off_t);
  192. typedef int (*vop_inactive_t)(bhv_desc_t *, struct cred *);
  193. typedef int (*vop_fid2_t)(bhv_desc_t *, struct fid *);
  194. typedef int (*vop_release_t)(bhv_desc_t *);
  195. typedef int (*vop_rwlock_t)(bhv_desc_t *, vrwlock_t);
  196. typedef void (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
  197. typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
  198. struct xfs_iomap *, int *);
  199. typedef int (*vop_reclaim_t)(bhv_desc_t *);
  200. typedef int (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int,
  201. struct cred *);
  202. typedef int (*vop_attr_set_t)(bhv_desc_t *, char *, char *, int, int,
  203. struct cred *);
  204. typedef int (*vop_attr_remove_t)(bhv_desc_t *, char *, int, struct cred *);
  205. typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int,
  206. struct attrlist_cursor_kern *, struct cred *);
  207. typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int);
  208. typedef void (*vop_vnode_change_t)(bhv_desc_t *, vchange_t, __psint_t);
  209. typedef void (*vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
  210. typedef void (*vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
  211. typedef int (*vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t,
  212. uint64_t, int);
  213. typedef int (*vop_iflush_t)(bhv_desc_t *, int);
  214. typedef struct vnodeops {
  215. bhv_position_t vn_position; /* position within behavior chain */
  216. vop_open_t vop_open;
  217. vop_read_t vop_read;
  218. vop_write_t vop_write;
  219. vop_sendfile_t vop_sendfile;
  220. vop_ioctl_t vop_ioctl;
  221. vop_getattr_t vop_getattr;
  222. vop_setattr_t vop_setattr;
  223. vop_access_t vop_access;
  224. vop_lookup_t vop_lookup;
  225. vop_create_t vop_create;
  226. vop_remove_t vop_remove;
  227. vop_link_t vop_link;
  228. vop_rename_t vop_rename;
  229. vop_mkdir_t vop_mkdir;
  230. vop_rmdir_t vop_rmdir;
  231. vop_readdir_t vop_readdir;
  232. vop_symlink_t vop_symlink;
  233. vop_readlink_t vop_readlink;
  234. vop_fsync_t vop_fsync;
  235. vop_inactive_t vop_inactive;
  236. vop_fid2_t vop_fid2;
  237. vop_rwlock_t vop_rwlock;
  238. vop_rwunlock_t vop_rwunlock;
  239. vop_bmap_t vop_bmap;
  240. vop_reclaim_t vop_reclaim;
  241. vop_attr_get_t vop_attr_get;
  242. vop_attr_set_t vop_attr_set;
  243. vop_attr_remove_t vop_attr_remove;
  244. vop_attr_list_t vop_attr_list;
  245. vop_link_removed_t vop_link_removed;
  246. vop_vnode_change_t vop_vnode_change;
  247. vop_ptossvp_t vop_tosspages;
  248. vop_pflushinvalvp_t vop_flushinval_pages;
  249. vop_pflushvp_t vop_flush_pages;
  250. vop_release_t vop_release;
  251. vop_iflush_t vop_iflush;
  252. } vnodeops_t;
  253. /*
  254. * VOP's.
  255. */
  256. #define _VOP_(op, vp) (*((vnodeops_t *)(vp)->v_fops)->op)
  257. #define VOP_READ(vp,file,iov,segs,offset,ioflags,cr,rv) \
  258. rv = _VOP_(vop_read, vp)((vp)->v_fbhv,file,iov,segs,offset,ioflags,cr)
  259. #define VOP_WRITE(vp,file,iov,segs,offset,ioflags,cr,rv) \
  260. rv = _VOP_(vop_write, vp)((vp)->v_fbhv,file,iov,segs,offset,ioflags,cr)
  261. #define VOP_SENDFILE(vp,f,off,ioflags,cnt,act,targ,cr,rv) \
  262. rv = _VOP_(vop_sendfile, vp)((vp)->v_fbhv,f,off,ioflags,cnt,act,targ,cr)
  263. #define VOP_BMAP(vp,of,sz,rw,b,n,rv) \
  264. rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,b,n)
  265. #define VOP_OPEN(vp, cr, rv) \
  266. rv = _VOP_(vop_open, vp)((vp)->v_fbhv, cr)
  267. #define VOP_GETATTR(vp, vap, f, cr, rv) \
  268. rv = _VOP_(vop_getattr, vp)((vp)->v_fbhv, vap, f, cr)
  269. #define VOP_SETATTR(vp, vap, f, cr, rv) \
  270. rv = _VOP_(vop_setattr, vp)((vp)->v_fbhv, vap, f, cr)
  271. #define VOP_ACCESS(vp, mode, cr, rv) \
  272. rv = _VOP_(vop_access, vp)((vp)->v_fbhv, mode, cr)
  273. #define VOP_LOOKUP(vp,d,vpp,f,rdir,cr,rv) \
  274. rv = _VOP_(vop_lookup, vp)((vp)->v_fbhv,d,vpp,f,rdir,cr)
  275. #define VOP_CREATE(dvp,d,vap,vpp,cr,rv) \
  276. rv = _VOP_(vop_create, dvp)((dvp)->v_fbhv,d,vap,vpp,cr)
  277. #define VOP_REMOVE(dvp,d,cr,rv) \
  278. rv = _VOP_(vop_remove, dvp)((dvp)->v_fbhv,d,cr)
  279. #define VOP_LINK(tdvp,fvp,d,cr,rv) \
  280. rv = _VOP_(vop_link, tdvp)((tdvp)->v_fbhv,fvp,d,cr)
  281. #define VOP_RENAME(fvp,fnm,tdvp,tnm,cr,rv) \
  282. rv = _VOP_(vop_rename, fvp)((fvp)->v_fbhv,fnm,tdvp,tnm,cr)
  283. #define VOP_MKDIR(dp,d,vap,vpp,cr,rv) \
  284. rv = _VOP_(vop_mkdir, dp)((dp)->v_fbhv,d,vap,vpp,cr)
  285. #define VOP_RMDIR(dp,d,cr,rv) \
  286. rv = _VOP_(vop_rmdir, dp)((dp)->v_fbhv,d,cr)
  287. #define VOP_READDIR(vp,uiop,cr,eofp,rv) \
  288. rv = _VOP_(vop_readdir, vp)((vp)->v_fbhv,uiop,cr,eofp)
  289. #define VOP_SYMLINK(dvp,d,vap,tnm,vpp,cr,rv) \
  290. rv = _VOP_(vop_symlink, dvp) ((dvp)->v_fbhv,d,vap,tnm,vpp,cr)
  291. #define VOP_READLINK(vp,uiop,fl,cr,rv) \
  292. rv = _VOP_(vop_readlink, vp)((vp)->v_fbhv,uiop,fl,cr)
  293. #define VOP_FSYNC(vp,f,cr,b,e,rv) \
  294. rv = _VOP_(vop_fsync, vp)((vp)->v_fbhv,f,cr,b,e)
  295. #define VOP_INACTIVE(vp, cr, rv) \
  296. rv = _VOP_(vop_inactive, vp)((vp)->v_fbhv, cr)
  297. #define VOP_RELEASE(vp, rv) \
  298. rv = _VOP_(vop_release, vp)((vp)->v_fbhv)
  299. #define VOP_FID2(vp, fidp, rv) \
  300. rv = _VOP_(vop_fid2, vp)((vp)->v_fbhv, fidp)
  301. #define VOP_RWLOCK(vp,i) \
  302. (void)_VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
  303. #define VOP_RWLOCK_TRY(vp,i) \
  304. _VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
  305. #define VOP_RWUNLOCK(vp,i) \
  306. (void)_VOP_(vop_rwunlock, vp)((vp)->v_fbhv, i)
  307. #define VOP_FRLOCK(vp,c,fl,flags,offset,fr,rv) \
  308. rv = _VOP_(vop_frlock, vp)((vp)->v_fbhv,c,fl,flags,offset,fr)
  309. #define VOP_RECLAIM(vp, rv) \
  310. rv = _VOP_(vop_reclaim, vp)((vp)->v_fbhv)
  311. #define VOP_ATTR_GET(vp, name, val, vallenp, fl, cred, rv) \
  312. rv = _VOP_(vop_attr_get, vp)((vp)->v_fbhv,name,val,vallenp,fl,cred)
  313. #define VOP_ATTR_SET(vp, name, val, vallen, fl, cred, rv) \
  314. rv = _VOP_(vop_attr_set, vp)((vp)->v_fbhv,name,val,vallen,fl,cred)
  315. #define VOP_ATTR_REMOVE(vp, name, flags, cred, rv) \
  316. rv = _VOP_(vop_attr_remove, vp)((vp)->v_fbhv,name,flags,cred)
  317. #define VOP_ATTR_LIST(vp, buf, buflen, fl, cursor, cred, rv) \
  318. rv = _VOP_(vop_attr_list, vp)((vp)->v_fbhv,buf,buflen,fl,cursor,cred)
  319. #define VOP_LINK_REMOVED(vp, dvp, linkzero) \
  320. (void)_VOP_(vop_link_removed, vp)((vp)->v_fbhv, dvp, linkzero)
  321. #define VOP_VNODE_CHANGE(vp, cmd, val) \
  322. (void)_VOP_(vop_vnode_change, vp)((vp)->v_fbhv,cmd,val)
  323. /*
  324. * These are page cache functions that now go thru VOPs.
  325. * 'last' parameter is unused and left in for IRIX compatibility
  326. */
  327. #define VOP_TOSS_PAGES(vp, first, last, fiopt) \
  328. _VOP_(vop_tosspages, vp)((vp)->v_fbhv,first, last, fiopt)
  329. /*
  330. * 'last' parameter is unused and left in for IRIX compatibility
  331. */
  332. #define VOP_FLUSHINVAL_PAGES(vp, first, last, fiopt) \
  333. _VOP_(vop_flushinval_pages, vp)((vp)->v_fbhv,first,last,fiopt)
  334. /*
  335. * 'last' parameter is unused and left in for IRIX compatibility
  336. */
  337. #define VOP_FLUSH_PAGES(vp, first, last, flags, fiopt, rv) \
  338. rv = _VOP_(vop_flush_pages, vp)((vp)->v_fbhv,first,last,flags,fiopt)
  339. #define VOP_IOCTL(vp, inode, filp, fl, cmd, arg, rv) \
  340. rv = _VOP_(vop_ioctl, vp)((vp)->v_fbhv,inode,filp,fl,cmd,arg)
  341. #define VOP_IFLUSH(vp, flags, rv) \
  342. rv = _VOP_(vop_iflush, vp)((vp)->v_fbhv, flags)
  343. /*
  344. * Flags for read/write calls - same values as IRIX
  345. */
  346. #define IO_ISAIO 0x00001 /* don't wait for completion */
  347. #define IO_ISDIRECT 0x00004 /* bypass page cache */
  348. #define IO_INVIS 0x00020 /* don't update inode timestamps */
  349. /*
  350. * Flags for VOP_IFLUSH call
  351. */
  352. #define FLUSH_SYNC 1 /* wait for flush to complete */
  353. #define FLUSH_INODE 2 /* flush the inode itself */
  354. #define FLUSH_LOG 4 /* force the last log entry for
  355. * this inode out to disk */
  356. /*
  357. * Flush/Invalidate options for VOP_TOSS_PAGES, VOP_FLUSHINVAL_PAGES and
  358. * VOP_FLUSH_PAGES.
  359. */
  360. #define FI_NONE 0 /* none */
  361. #define FI_REMAPF 1 /* Do a remapf prior to the operation */
  362. #define FI_REMAPF_LOCKED 2 /* Do a remapf prior to the operation.
  363. Prevent VM access to the pages until
  364. the operation completes. */
  365. /*
  366. * Vnode attributes. va_mask indicates those attributes the caller
  367. * wants to set or extract.
  368. */
  369. typedef struct vattr {
  370. int va_mask; /* bit-mask of attributes present */
  371. mode_t va_mode; /* file access mode and type */
  372. xfs_nlink_t va_nlink; /* number of references to file */
  373. uid_t va_uid; /* owner user id */
  374. gid_t va_gid; /* owner group id */
  375. xfs_ino_t va_nodeid; /* file id */
  376. xfs_off_t va_size; /* file size in bytes */
  377. u_long va_blocksize; /* blocksize preferred for i/o */
  378. struct timespec va_atime; /* time of last access */
  379. struct timespec va_mtime; /* time of last modification */
  380. struct timespec va_ctime; /* time file changed */
  381. u_int va_gen; /* generation number of file */
  382. xfs_dev_t va_rdev; /* device the special file represents */
  383. __int64_t va_nblocks; /* number of blocks allocated */
  384. u_long va_xflags; /* random extended file flags */
  385. u_long va_extsize; /* file extent size */
  386. u_long va_nextents; /* number of extents in file */
  387. u_long va_anextents; /* number of attr extents in file */
  388. prid_t va_projid; /* project id */
  389. } vattr_t;
  390. /*
  391. * setattr or getattr attributes
  392. */
  393. #define XFS_AT_TYPE 0x00000001
  394. #define XFS_AT_MODE 0x00000002
  395. #define XFS_AT_UID 0x00000004
  396. #define XFS_AT_GID 0x00000008
  397. #define XFS_AT_FSID 0x00000010
  398. #define XFS_AT_NODEID 0x00000020
  399. #define XFS_AT_NLINK 0x00000040
  400. #define XFS_AT_SIZE 0x00000080
  401. #define XFS_AT_ATIME 0x00000100
  402. #define XFS_AT_MTIME 0x00000200
  403. #define XFS_AT_CTIME 0x00000400
  404. #define XFS_AT_RDEV 0x00000800
  405. #define XFS_AT_BLKSIZE 0x00001000
  406. #define XFS_AT_NBLOCKS 0x00002000
  407. #define XFS_AT_VCODE 0x00004000
  408. #define XFS_AT_MAC 0x00008000
  409. #define XFS_AT_UPDATIME 0x00010000
  410. #define XFS_AT_UPDMTIME 0x00020000
  411. #define XFS_AT_UPDCTIME 0x00040000
  412. #define XFS_AT_ACL 0x00080000
  413. #define XFS_AT_CAP 0x00100000
  414. #define XFS_AT_INF 0x00200000
  415. #define XFS_AT_XFLAGS 0x00400000
  416. #define XFS_AT_EXTSIZE 0x00800000
  417. #define XFS_AT_NEXTENTS 0x01000000
  418. #define XFS_AT_ANEXTENTS 0x02000000
  419. #define XFS_AT_PROJID 0x04000000
  420. #define XFS_AT_SIZE_NOPERM 0x08000000
  421. #define XFS_AT_GENCOUNT 0x10000000
  422. #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
  423. XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
  424. XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
  425. XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
  426. XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
  427. XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
  428. #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
  429. XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
  430. XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
  431. XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_PROJID)
  432. #define XFS_AT_TIMES (XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME)
  433. #define XFS_AT_UPDTIMES (XFS_AT_UPDATIME|XFS_AT_UPDMTIME|XFS_AT_UPDCTIME)
  434. #define XFS_AT_NOSET (XFS_AT_NLINK|XFS_AT_RDEV|XFS_AT_FSID|XFS_AT_NODEID|\
  435. XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\
  436. XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT)
  437. /*
  438. * Modes.
  439. */
  440. #define VSUID S_ISUID /* set user id on execution */
  441. #define VSGID S_ISGID /* set group id on execution */
  442. #define VSVTX S_ISVTX /* save swapped text even after use */
  443. #define VREAD S_IRUSR /* read, write, execute permissions */
  444. #define VWRITE S_IWUSR
  445. #define VEXEC S_IXUSR
  446. #define MODEMASK S_IALLUGO /* mode bits plus permission bits */
  447. /*
  448. * Check whether mandatory file locking is enabled.
  449. */
  450. #define MANDLOCK(vp, mode) \
  451. (VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
  452. extern void vn_init(void);
  453. extern vnode_t *vn_initialize(struct inode *);
  454. /*
  455. * vnode_map structures _must_ match vn_epoch and vnode structure sizes.
  456. */
  457. typedef struct vnode_map {
  458. vfs_t *v_vfsp;
  459. vnumber_t v_number; /* in-core vnode number */
  460. xfs_ino_t v_ino; /* inode # */
  461. } vmap_t;
  462. #define VMAP(vp, vmap) {(vmap).v_vfsp = (vp)->v_vfsp, \
  463. (vmap).v_number = (vp)->v_number, \
  464. (vmap).v_ino = (vp)->v_inode.i_ino; }
  465. extern void vn_purge(struct vnode *, vmap_t *);
  466. extern int vn_revalidate(struct vnode *);
  467. extern void vn_revalidate_core(struct vnode *, vattr_t *);
  468. extern void vn_remove(struct vnode *);
  469. static inline int vn_count(struct vnode *vp)
  470. {
  471. return atomic_read(&LINVFS_GET_IP(vp)->i_count);
  472. }
  473. /*
  474. * Vnode reference counting functions (and macros for compatibility).
  475. */
  476. extern vnode_t *vn_hold(struct vnode *);
  477. extern void vn_rele(struct vnode *);
  478. #if defined(XFS_VNODE_TRACE)
  479. #define VN_HOLD(vp) \
  480. ((void)vn_hold(vp), \
  481. vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
  482. #define VN_RELE(vp) \
  483. (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
  484. iput(LINVFS_GET_IP(vp)))
  485. #else
  486. #define VN_HOLD(vp) ((void)vn_hold(vp))
  487. #define VN_RELE(vp) (iput(LINVFS_GET_IP(vp)))
  488. #endif
  489. static inline struct vnode *vn_grab(struct vnode *vp)
  490. {
  491. struct inode *inode = igrab(LINVFS_GET_IP(vp));
  492. return inode ? LINVFS_GET_VP(inode) : NULL;
  493. }
  494. /*
  495. * Vname handling macros.
  496. */
  497. #define VNAME(dentry) ((char *) (dentry)->d_name.name)
  498. #define VNAMELEN(dentry) ((dentry)->d_name.len)
  499. #define VNAME_TO_VNODE(dentry) (LINVFS_GET_VP((dentry)->d_inode))
  500. /*
  501. * Vnode spinlock manipulation.
  502. */
  503. #define VN_LOCK(vp) mutex_spinlock(&(vp)->v_lock)
  504. #define VN_UNLOCK(vp, s) mutex_spinunlock(&(vp)->v_lock, s)
  505. #define VN_FLAGSET(vp,b) vn_flagset(vp,b)
  506. #define VN_FLAGCLR(vp,b) vn_flagclr(vp,b)
  507. static __inline__ void vn_flagset(struct vnode *vp, uint flag)
  508. {
  509. spin_lock(&vp->v_lock);
  510. vp->v_flag |= flag;
  511. spin_unlock(&vp->v_lock);
  512. }
  513. static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
  514. {
  515. spin_lock(&vp->v_lock);
  516. vp->v_flag &= ~flag;
  517. spin_unlock(&vp->v_lock);
  518. }
  519. /*
  520. * Update modify/access/change times on the vnode
  521. */
  522. #define VN_MTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_mtime = *(tvp))
  523. #define VN_ATIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_atime = *(tvp))
  524. #define VN_CTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_ctime = *(tvp))
  525. /*
  526. * Dealing with bad inodes
  527. */
  528. static inline void vn_mark_bad(struct vnode *vp)
  529. {
  530. make_bad_inode(LINVFS_GET_IP(vp));
  531. }
  532. static inline int VN_BAD(struct vnode *vp)
  533. {
  534. return is_bad_inode(LINVFS_GET_IP(vp));
  535. }
  536. /*
  537. * Some useful predicates.
  538. */
  539. #define VN_MAPPED(vp) mapping_mapped(LINVFS_GET_IP(vp)->i_mapping)
  540. #define VN_CACHED(vp) (LINVFS_GET_IP(vp)->i_mapping->nrpages)
  541. #define VN_DIRTY(vp) mapping_tagged(LINVFS_GET_IP(vp)->i_mapping, \
  542. PAGECACHE_TAG_DIRTY)
  543. #define VMODIFY(vp) VN_FLAGSET(vp, VMODIFIED)
  544. #define VUNMODIFY(vp) VN_FLAGCLR(vp, VMODIFIED)
  545. /*
  546. * Flags to VOP_SETATTR/VOP_GETATTR.
  547. */
  548. #define ATTR_UTIME 0x01 /* non-default utime(2) request */
  549. #define ATTR_DMI 0x08 /* invocation from a DMI function */
  550. #define ATTR_LAZY 0x80 /* set/get attributes lazily */
  551. #define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
  552. #define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
  553. /*
  554. * Flags to VOP_FSYNC and VOP_RECLAIM.
  555. */
  556. #define FSYNC_NOWAIT 0 /* asynchronous flush */
  557. #define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */
  558. #define FSYNC_INVAL 0x2 /* flush and invalidate cached data */
  559. #define FSYNC_DATA 0x4 /* synchronous fsync of data only */
  560. /*
  561. * Tracking vnode activity.
  562. */
  563. #if defined(XFS_VNODE_TRACE)
  564. #define VNODE_TRACE_SIZE 16 /* number of trace entries */
  565. #define VNODE_KTRACE_ENTRY 1
  566. #define VNODE_KTRACE_EXIT 2
  567. #define VNODE_KTRACE_HOLD 3
  568. #define VNODE_KTRACE_REF 4
  569. #define VNODE_KTRACE_RELE 5
  570. extern void vn_trace_entry(struct vnode *, const char *, inst_t *);
  571. extern void vn_trace_exit(struct vnode *, const char *, inst_t *);
  572. extern void vn_trace_hold(struct vnode *, char *, int, inst_t *);
  573. extern void vn_trace_ref(struct vnode *, char *, int, inst_t *);
  574. extern void vn_trace_rele(struct vnode *, char *, int, inst_t *);
  575. #define VN_TRACE(vp) \
  576. vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address)
  577. #else
  578. #define vn_trace_entry(a,b,c)
  579. #define vn_trace_exit(a,b,c)
  580. #define vn_trace_hold(a,b,c,d)
  581. #define vn_trace_ref(a,b,c,d)
  582. #define vn_trace_rele(a,b,c,d)
  583. #define VN_TRACE(vp)
  584. #endif
  585. #endif /* __XFS_VNODE_H__ */