18 #ifndef __XFS_INODE_H__
19 #define __XFS_INODE_H__
28 #define XFS_DATA_FORK 0
29 #define XFS_ATTR_FORK 1
59 #define XFS_IEXT_BUFSZ 4096
60 #define XFS_LINEAR_EXTS (XFS_IEXT_BUFSZ / (uint)sizeof(xfs_bmbt_rec_t))
61 #define XFS_INLINE_EXTS 2
62 #define XFS_INLINE_DATA 32
158 #define XFS_ICHGTIME_MOD 0x1
159 #define XFS_ICHGTIME_CHG 0x2
164 #define XFS_IFINLINE 0x01
165 #define XFS_IFEXTENTS 0x02
166 #define XFS_IFBROOT 0x04
167 #define XFS_IFEXTIREC 0x08
173 #define XFS_IFORK_Q(ip) ((ip)->i_d.di_forkoff != 0)
174 #define XFS_IFORK_BOFF(ip) ((int)((ip)->i_d.di_forkoff << 3))
176 #define XFS_IFORK_PTR(ip,w) \
177 ((w) == XFS_DATA_FORK ? \
180 #define XFS_IFORK_DSIZE(ip) \
182 XFS_IFORK_BOFF(ip) : \
183 XFS_LITINO((ip)->i_mount))
184 #define XFS_IFORK_ASIZE(ip) \
186 XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : \
188 #define XFS_IFORK_SIZE(ip,w) \
189 ((w) == XFS_DATA_FORK ? \
190 XFS_IFORK_DSIZE(ip) : \
192 #define XFS_IFORK_FORMAT(ip,w) \
193 ((w) == XFS_DATA_FORK ? \
194 (ip)->i_d.di_format : \
195 (ip)->i_d.di_aformat)
196 #define XFS_IFORK_FMT_SET(ip,w,n) \
197 ((w) == XFS_DATA_FORK ? \
198 ((ip)->i_d.di_format = (n)) : \
199 ((ip)->i_d.di_aformat = (n)))
200 #define XFS_IFORK_NEXTENTS(ip,w) \
201 ((w) == XFS_DATA_FORK ? \
202 (ip)->i_d.di_nextents : \
203 (ip)->i_d.di_anextents)
204 #define XFS_IFORK_NEXT_SET(ip,w,n) \
205 ((w) == XFS_DATA_FORK ? \
206 ((ip)->i_d.di_nextents = (n)) : \
207 ((ip)->i_d.di_anextents = (n)))
208 #define XFS_IFORK_MAXEXT(ip, w) \
209 (XFS_IFORK_SIZE(ip, w) / sizeof(xfs_bmbt_rec_t))
217 struct xfs_inode_log_item;
222 typedef struct xfs_inode {
224 struct xfs_mount *i_mount;
237 struct xfs_inode_log_item *i_itemp;
243 unsigned long i_flags;
244 unsigned int i_delayed_blks;
249 struct inode i_vnode;
253 static inline struct xfs_inode *XFS_I(
struct inode *
inode)
259 static inline struct inode *VFS_I(
struct xfs_inode *
ip)
272 return i_size_read(VFS_I(ip));
273 return ip->i_d.di_size;
281 xfs_new_eof(
struct xfs_inode *ip,
xfs_fsize_t new_size)
285 if (new_size > i_size)
287 return new_size > ip->i_d.di_size ? new_size : 0;
294 __xfs_iflags_set(xfs_inode_t *ip,
unsigned short flags)
296 ip->i_flags |=
flags;
300 xfs_iflags_set(xfs_inode_t *ip,
unsigned short flags)
302 spin_lock(&ip->i_flags_lock);
303 __xfs_iflags_set(ip, flags);
304 spin_unlock(&ip->i_flags_lock);
308 xfs_iflags_clear(xfs_inode_t *ip,
unsigned short flags)
310 spin_lock(&ip->i_flags_lock);
311 ip->i_flags &= ~flags;
312 spin_unlock(&ip->i_flags_lock);
316 __xfs_iflags_test(xfs_inode_t *ip,
unsigned short flags)
318 return (ip->i_flags & flags);
322 xfs_iflags_test(xfs_inode_t *ip,
unsigned short flags)
325 spin_lock(&ip->i_flags_lock);
326 ret = __xfs_iflags_test(ip, flags);
327 spin_unlock(&ip->i_flags_lock);
332 xfs_iflags_test_and_clear(xfs_inode_t *ip,
unsigned short flags)
336 spin_lock(&ip->i_flags_lock);
337 ret = ip->i_flags &
flags;
339 ip->i_flags &= ~flags;
340 spin_unlock(&ip->i_flags_lock);
345 xfs_iflags_test_and_set(xfs_inode_t *ip,
unsigned short flags)
349 spin_lock(&ip->i_flags_lock);
350 ret = ip->i_flags &
flags;
352 ip->i_flags |=
flags;
353 spin_unlock(&ip->i_flags_lock);
363 xfs_get_projid(
struct xfs_inode *ip)
365 return (prid_t)ip->i_d.di_projid_hi << 16 | ip->i_d.di_projid_lo;
369 xfs_set_projid(
struct xfs_inode *ip,
372 ip->i_d.di_projid_hi = (__uint16_t) (projid >> 16);
373 ip->i_d.di_projid_lo = (__uint16_t) (projid & 0xffff);
379 #define XFS_IRECLAIM (1 << 0)
380 #define XFS_ISTALE (1 << 1)
381 #define XFS_IRECLAIMABLE (1 << 2)
382 #define XFS_INEW (1 << 3)
383 #define XFS_IFILESTREAM (1 << 4)
384 #define XFS_ITRUNCATED (1 << 5)
385 #define XFS_IDIRTY_RELEASE (1 << 6)
386 #define __XFS_IFLOCK_BIT 7
387 #define XFS_IFLOCK (1 << __XFS_IFLOCK_BIT)
388 #define __XFS_IPINNED_BIT 8
389 #define XFS_IPINNED (1 << __XFS_IPINNED_BIT)
390 #define XFS_IDONTCACHE (1 << 9)
397 #define XFS_IRECLAIM_RESET_FLAGS \
398 (XFS_IRECLAIMABLE | XFS_IRECLAIM | \
399 XFS_IDIRTY_RELEASE | XFS_ITRUNCATED | \
408 static inline int xfs_iflock_nowait(
struct xfs_inode *ip)
410 return !xfs_iflags_test_and_set(ip, XFS_IFLOCK);
413 static inline void xfs_iflock(
struct xfs_inode *ip)
415 if (!xfs_iflock_nowait(ip))
419 static inline void xfs_ifunlock(
struct xfs_inode *ip)
421 xfs_iflags_clear(ip, XFS_IFLOCK);
425 static inline int xfs_isiflocked(
struct xfs_inode *ip)
427 return xfs_iflags_test(ip, XFS_IFLOCK);
435 #define XFS_IOLOCK_EXCL (1<<0)
436 #define XFS_IOLOCK_SHARED (1<<1)
437 #define XFS_ILOCK_EXCL (1<<2)
438 #define XFS_ILOCK_SHARED (1<<3)
440 #define XFS_LOCK_MASK (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED \
441 | XFS_ILOCK_EXCL | XFS_ILOCK_SHARED)
443 #define XFS_LOCK_FLAGS \
444 { XFS_IOLOCK_EXCL, "IOLOCK_EXCL" }, \
445 { XFS_IOLOCK_SHARED, "IOLOCK_SHARED" }, \
446 { XFS_ILOCK_EXCL, "ILOCK_EXCL" }, \
447 { XFS_ILOCK_SHARED, "ILOCK_SHARED" }
470 #define XFS_LOCK_PARENT 1
471 #define XFS_LOCK_RTBITMAP 2
472 #define XFS_LOCK_RTSUM 3
473 #define XFS_LOCK_INUMORDER 4
475 #define XFS_IOLOCK_SHIFT 16
476 #define XFS_IOLOCK_PARENT (XFS_LOCK_PARENT << XFS_IOLOCK_SHIFT)
478 #define XFS_ILOCK_SHIFT 24
479 #define XFS_ILOCK_PARENT (XFS_LOCK_PARENT << XFS_ILOCK_SHIFT)
480 #define XFS_ILOCK_RTBITMAP (XFS_LOCK_RTBITMAP << XFS_ILOCK_SHIFT)
481 #define XFS_ILOCK_RTSUM (XFS_LOCK_RTSUM << XFS_ILOCK_SHIFT)
483 #define XFS_IOLOCK_DEP_MASK 0x00ff0000
484 #define XFS_ILOCK_DEP_MASK 0xff000000
485 #define XFS_LOCK_DEP_MASK (XFS_IOLOCK_DEP_MASK | XFS_ILOCK_DEP_MASK)
487 #define XFS_IOLOCK_DEP(flags) (((flags) & XFS_IOLOCK_DEP_MASK) >> XFS_IOLOCK_SHIFT)
488 #define XFS_ILOCK_DEP(flags) (((flags) & XFS_ILOCK_DEP_MASK) >> XFS_ILOCK_SHIFT)
495 #define XFS_INHERIT_GID(pip) \
496 (((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \
497 ((pip)->i_d.di_mode & S_ISGID))
502 int xfs_iget(
struct xfs_mount *,
struct xfs_trans *, xfs_ino_t,
508 int xfs_isilocked(xfs_inode_t *,
uint);
517 xfs_nlink_t, xfs_dev_t, prid_t,
int,
518 struct xfs_buf **, xfs_inode_t **);
522 int xfs_ifree(
struct xfs_trans *, xfs_inode_t *,
526 int xfs_iunlink(
struct xfs_trans *, xfs_inode_t *);
528 void xfs_iext_realloc(xfs_inode_t *,
int,
int);
538 ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0) ; \
540 trace_xfs_ihold(ip, _THIS_IP_); \
545 trace_xfs_irele(ip, _THIS_IP_); \
554 #define XFS_IGET_CREATE 0x1
555 #define XFS_IGET_UNTRUSTED 0x2
556 #define XFS_IGET_DONTCACHE 0x4
561 int xfs_iread(
struct xfs_mount *,
struct xfs_trans *,
562 struct xfs_inode *,
uint);
595 #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount))
600 #define xfs_inobp_check(mp, bp)