[XFS] kill the v_number member in struct bhv_vnode
[deliverable/linux.git] / fs / xfs / linux-2.6 / xfs_vnode.h
CommitLineData
1da177e4 1/*
7b718769
NS
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
1da177e4 4 *
7b718769
NS
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
1da177e4
LT
7 * published by the Free Software Foundation.
8 *
7b718769
NS
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
1da177e4 13 *
7b718769
NS
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1da177e4
LT
17 */
18#ifndef __XFS_VNODE_H__
19#define __XFS_VNODE_H__
20
1da177e4 21struct file;
8285fb58
NS
22struct bhv_vfs;
23struct bhv_vattr;
1da177e4
LT
24struct xfs_iomap;
25struct attrlist_cursor_kern;
26
8285fb58
NS
27typedef struct dentry bhv_vname_t;
28typedef __u64 bhv_vnumber_t;
1da177e4 29
67fcaa73 30typedef struct bhv_vnode {
9effd8e6
ES
31 struct inode v_inode; /* Linux inode */
32 /* inode MUST be last */
67fcaa73 33} bhv_vnode_t;
1da177e4 34
0432dab2
CH
35#define VN_ISLNK(vp) S_ISLNK((vp)->v_inode.i_mode)
36#define VN_ISREG(vp) S_ISREG((vp)->v_inode.i_mode)
37#define VN_ISDIR(vp) S_ISDIR((vp)->v_inode.i_mode)
38#define VN_ISCHR(vp) S_ISCHR((vp)->v_inode.i_mode)
39#define VN_ISBLK(vp) S_ISBLK((vp)->v_inode.i_mode)
40
1da177e4
LT
41/*
42 * Vnode to Linux inode mapping.
43 */
67fcaa73 44static inline struct bhv_vnode *vn_from_inode(struct inode *inode)
ec86dc02 45{
71306f3b 46 return container_of(inode, bhv_vnode_t, v_inode);
ec86dc02 47}
67fcaa73 48static inline struct inode *vn_to_inode(struct bhv_vnode *vnode)
ec86dc02
NS
49{
50 return &vnode->v_inode;
51}
1da177e4 52
1da177e4 53/*
67fcaa73 54 * Values for the vop_rwlock/rwunlock flags parameter.
1da177e4 55 */
8285fb58 56typedef enum bhv_vrwlock {
1da177e4
LT
57 VRWLOCK_NONE,
58 VRWLOCK_READ,
59 VRWLOCK_WRITE,
60 VRWLOCK_WRITE_DIRECT,
61 VRWLOCK_TRY_READ,
62 VRWLOCK_TRY_WRITE
8285fb58 63} bhv_vrwlock_t;
1da177e4
LT
64
65/*
739bfb2a 66 * Return values for xfs_inactive. A return value of
1da177e4
LT
67 * VN_INACTIVE_NOCACHE implies that the file system behavior
68 * has disassociated its state and bhv_desc_t from the vnode.
69 */
70#define VN_INACTIVE_CACHE 0
71#define VN_INACTIVE_NOCACHE 1
72
1da177e4
LT
73/*
74 * Flags for read/write calls - same values as IRIX
75 */
76#define IO_ISAIO 0x00001 /* don't wait for completion */
77#define IO_ISDIRECT 0x00004 /* bypass page cache */
78#define IO_INVIS 0x00020 /* don't update inode timestamps */
79
80/*
67fcaa73 81 * Flags for vop_iflush call
1da177e4
LT
82 */
83#define FLUSH_SYNC 1 /* wait for flush to complete */
84#define FLUSH_INODE 2 /* flush the inode itself */
85#define FLUSH_LOG 4 /* force the last log entry for
86 * this inode out to disk */
87
88/*
67fcaa73 89 * Flush/Invalidate options for vop_toss/flush/flushinval_pages.
1da177e4
LT
90 */
91#define FI_NONE 0 /* none */
92#define FI_REMAPF 1 /* Do a remapf prior to the operation */
93#define FI_REMAPF_LOCKED 2 /* Do a remapf prior to the operation.
94 Prevent VM access to the pages until
95 the operation completes. */
96
97/*
98 * Vnode attributes. va_mask indicates those attributes the caller
99 * wants to set or extract.
100 */
8285fb58 101typedef struct bhv_vattr {
1da177e4 102 int va_mask; /* bit-mask of attributes present */
1da177e4 103 mode_t va_mode; /* file access mode and type */
31b084ae 104 xfs_nlink_t va_nlink; /* number of references to file */
1da177e4
LT
105 uid_t va_uid; /* owner user id */
106 gid_t va_gid; /* owner group id */
107 xfs_ino_t va_nodeid; /* file id */
108 xfs_off_t va_size; /* file size in bytes */
109 u_long va_blocksize; /* blocksize preferred for i/o */
110 struct timespec va_atime; /* time of last access */
111 struct timespec va_mtime; /* time of last modification */
112 struct timespec va_ctime; /* time file changed */
113 u_int va_gen; /* generation number of file */
114 xfs_dev_t va_rdev; /* device the special file represents */
115 __int64_t va_nblocks; /* number of blocks allocated */
116 u_long va_xflags; /* random extended file flags */
117 u_long va_extsize; /* file extent size */
118 u_long va_nextents; /* number of extents in file */
119 u_long va_anextents; /* number of attr extents in file */
b74e2159 120 prid_t va_projid; /* project id */
8285fb58 121} bhv_vattr_t;
1da177e4
LT
122
123/*
124 * setattr or getattr attributes
125 */
126#define XFS_AT_TYPE 0x00000001
127#define XFS_AT_MODE 0x00000002
128#define XFS_AT_UID 0x00000004
129#define XFS_AT_GID 0x00000008
130#define XFS_AT_FSID 0x00000010
131#define XFS_AT_NODEID 0x00000020
132#define XFS_AT_NLINK 0x00000040
133#define XFS_AT_SIZE 0x00000080
134#define XFS_AT_ATIME 0x00000100
135#define XFS_AT_MTIME 0x00000200
136#define XFS_AT_CTIME 0x00000400
137#define XFS_AT_RDEV 0x00000800
138#define XFS_AT_BLKSIZE 0x00001000
139#define XFS_AT_NBLOCKS 0x00002000
140#define XFS_AT_VCODE 0x00004000
141#define XFS_AT_MAC 0x00008000
142#define XFS_AT_UPDATIME 0x00010000
143#define XFS_AT_UPDMTIME 0x00020000
144#define XFS_AT_UPDCTIME 0x00040000
145#define XFS_AT_ACL 0x00080000
146#define XFS_AT_CAP 0x00100000
147#define XFS_AT_INF 0x00200000
148#define XFS_AT_XFLAGS 0x00400000
149#define XFS_AT_EXTSIZE 0x00800000
150#define XFS_AT_NEXTENTS 0x01000000
151#define XFS_AT_ANEXTENTS 0x02000000
152#define XFS_AT_PROJID 0x04000000
153#define XFS_AT_SIZE_NOPERM 0x08000000
154#define XFS_AT_GENCOUNT 0x10000000
155
156#define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
157 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
158 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
159 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
160 XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
161 XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
162
163#define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
164 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
165 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
166 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_PROJID)
167
168#define XFS_AT_TIMES (XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME)
169
170#define XFS_AT_UPDTIMES (XFS_AT_UPDATIME|XFS_AT_UPDMTIME|XFS_AT_UPDCTIME)
171
172#define XFS_AT_NOSET (XFS_AT_NLINK|XFS_AT_RDEV|XFS_AT_FSID|XFS_AT_NODEID|\
173 XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\
174 XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT)
175
176/*
177 * Modes.
178 */
179#define VSUID S_ISUID /* set user id on execution */
180#define VSGID S_ISGID /* set group id on execution */
181#define VSVTX S_ISVTX /* save swapped text even after use */
182#define VREAD S_IRUSR /* read, write, execute permissions */
183#define VWRITE S_IWUSR
184#define VEXEC S_IXUSR
185
186#define MODEMASK S_IALLUGO /* mode bits plus permission bits */
187
188/*
189 * Check whether mandatory file locking is enabled.
190 */
191#define MANDLOCK(vp, mode) \
0432dab2 192 (VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
1da177e4
LT
193
194extern void vn_init(void);
67fcaa73
NS
195extern bhv_vnode_t *vn_initialize(struct inode *);
196extern int vn_revalidate(struct bhv_vnode *);
8285fb58
NS
197extern int __vn_revalidate(struct bhv_vnode *, bhv_vattr_t *);
198extern void vn_revalidate_core(struct bhv_vnode *, bhv_vattr_t *);
1da177e4 199
b677c210
CH
200/*
201 * Yeah, these don't take vnode anymore at all, all this should be
202 * cleaned up at some point.
203 */
204extern void vn_iowait(struct xfs_inode *ip);
205extern void vn_iowake(struct xfs_inode *ip);
206extern void vn_ioerror(struct xfs_inode *ip, int error, char *f, int l);
7d04a335 207
67fcaa73 208static inline int vn_count(struct bhv_vnode *vp)
1da177e4 209{
ec86dc02 210 return atomic_read(&vn_to_inode(vp)->i_count);
1da177e4
LT
211}
212
213/*
214 * Vnode reference counting functions (and macros for compatibility).
215 */
67fcaa73 216extern bhv_vnode_t *vn_hold(struct bhv_vnode *);
1da177e4
LT
217
218#if defined(XFS_VNODE_TRACE)
219#define VN_HOLD(vp) \
220 ((void)vn_hold(vp), \
1543d79c 221 vn_trace_hold(xfs_vtoi(vp), __FILE__, __LINE__, (inst_t *)__return_address))
1da177e4 222#define VN_RELE(vp) \
1543d79c 223 (vn_trace_rele(xfs_vtoi(vp), __FILE__, __LINE__, (inst_t *)__return_address), \
ec86dc02 224 iput(vn_to_inode(vp)))
1da177e4
LT
225#else
226#define VN_HOLD(vp) ((void)vn_hold(vp))
ec86dc02 227#define VN_RELE(vp) (iput(vn_to_inode(vp)))
1da177e4
LT
228#endif
229
67fcaa73 230static inline struct bhv_vnode *vn_grab(struct bhv_vnode *vp)
cdb62687 231{
ec86dc02
NS
232 struct inode *inode = igrab(vn_to_inode(vp));
233 return inode ? vn_from_inode(inode) : NULL;
cdb62687
CH
234}
235
1da177e4
LT
236/*
237 * Vname handling macros.
238 */
239#define VNAME(dentry) ((char *) (dentry)->d_name.name)
240#define VNAMELEN(dentry) ((dentry)->d_name.len)
ec86dc02 241#define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode))
1da177e4 242
1da177e4
LT
243/*
244 * Dealing with bad inodes
245 */
67fcaa73 246static inline void vn_mark_bad(struct bhv_vnode *vp)
1da177e4 247{
ec86dc02 248 make_bad_inode(vn_to_inode(vp));
1da177e4
LT
249}
250
67fcaa73 251static inline int VN_BAD(struct bhv_vnode *vp)
1da177e4 252{
ec86dc02 253 return is_bad_inode(vn_to_inode(vp));
1da177e4
LT
254}
255
ca5ccbf9
NS
256/*
257 * Extracting atime values in various formats
258 */
67fcaa73 259static inline void vn_atime_to_bstime(bhv_vnode_t *vp, xfs_bstime_t *bs_atime)
ca5ccbf9
NS
260{
261 bs_atime->tv_sec = vp->v_inode.i_atime.tv_sec;
262 bs_atime->tv_nsec = vp->v_inode.i_atime.tv_nsec;
263}
264
67fcaa73 265static inline void vn_atime_to_timespec(bhv_vnode_t *vp, struct timespec *ts)
ca5ccbf9
NS
266{
267 *ts = vp->v_inode.i_atime;
268}
269
67fcaa73 270static inline void vn_atime_to_time_t(bhv_vnode_t *vp, time_t *tt)
ca5ccbf9
NS
271{
272 *tt = vp->v_inode.i_atime.tv_sec;
273}
274
1da177e4
LT
275/*
276 * Some useful predicates.
277 */
ec86dc02
NS
278#define VN_MAPPED(vp) mapping_mapped(vn_to_inode(vp)->i_mapping)
279#define VN_CACHED(vp) (vn_to_inode(vp)->i_mapping->nrpages)
280#define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \
1da177e4 281 PAGECACHE_TAG_DIRTY)
1da177e4
LT
282
283/*
67fcaa73 284 * Flags to vop_setattr/getattr.
1da177e4
LT
285 */
286#define ATTR_UTIME 0x01 /* non-default utime(2) request */
287#define ATTR_DMI 0x08 /* invocation from a DMI function */
288#define ATTR_LAZY 0x80 /* set/get attributes lazily */
289#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
5fcbab35 290#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
1f730e3b 291#define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */
1da177e4
LT
292
293/*
67fcaa73 294 * Flags to vop_fsync/reclaim.
1da177e4
LT
295 */
296#define FSYNC_NOWAIT 0 /* asynchronous flush */
297#define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */
298#define FSYNC_INVAL 0x2 /* flush and invalidate cached data */
299#define FSYNC_DATA 0x4 /* synchronous fsync of data only */
300
301/*
302 * Tracking vnode activity.
303 */
304#if defined(XFS_VNODE_TRACE)
305
306#define VNODE_TRACE_SIZE 16 /* number of trace entries */
307#define VNODE_KTRACE_ENTRY 1
308#define VNODE_KTRACE_EXIT 2
309#define VNODE_KTRACE_HOLD 3
310#define VNODE_KTRACE_REF 4
311#define VNODE_KTRACE_RELE 5
312
1543d79c
CH
313extern void vn_trace_entry(struct xfs_inode *, const char *, inst_t *);
314extern void vn_trace_exit(struct xfs_inode *, const char *, inst_t *);
315extern void vn_trace_hold(struct xfs_inode *, char *, int, inst_t *);
316extern void vn_trace_ref(struct xfs_inode *, char *, int, inst_t *);
317extern void vn_trace_rele(struct xfs_inode *, char *, int, inst_t *);
1da177e4
LT
318#else
319#define vn_trace_entry(a,b,c)
320#define vn_trace_exit(a,b,c)
321#define vn_trace_hold(a,b,c,d)
322#define vn_trace_ref(a,b,c,d)
323#define vn_trace_rele(a,b,c,d)
1da177e4
LT
324#endif
325
326#endif /* __XFS_VNODE_H__ */
This page took 0.293399 seconds and 5 git commands to generate.