Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | #ifndef __XFS_INODE_H__ |
| 19 | #define __XFS_INODE_H__ |
| 20 | |
Christoph Hellwig | ef14f0c | 2009-06-10 17:07:47 +0200 | [diff] [blame] | 21 | struct posix_acl; |
Christoph Hellwig | 347d1c0 | 2007-08-28 13:57:51 +1000 | [diff] [blame] | 22 | struct xfs_dinode; |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 23 | struct xfs_inode; |
Christoph Hellwig | 347d1c0 | 2007-08-28 13:57:51 +1000 | [diff] [blame] | 24 | |
Dave Chinner | 5c4d97d | 2013-08-12 20:49:33 +1000 | [diff] [blame^] | 25 | #include "xfs_inode_fork.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | /* |
Christoph Hellwig | 92bfc6e | 2008-11-28 14:23:41 +1100 | [diff] [blame] | 28 | * Inode location information. Stored in the inode and passed to |
| 29 | * xfs_imap_to_bp() to get a buffer and dinode for a given inode. |
| 30 | */ |
| 31 | struct xfs_imap { |
| 32 | xfs_daddr_t im_blkno; /* starting BB of inode chunk */ |
| 33 | ushort im_len; /* length in BBs of inode chunk */ |
| 34 | ushort im_boffset; /* inode offset in block in bytes */ |
| 35 | }; |
| 36 | |
| 37 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | * This is the xfs in-core inode structure. |
| 39 | * Most of the on-disk inode is embedded in the i_d field. |
| 40 | * |
| 41 | * The extent pointers/inline file space, however, are managed |
| 42 | * separately. The memory for this information is pointed to by |
| 43 | * the if_u1 unions depending on the type of the data. |
| 44 | * This is used to linearize the array of extents for fast in-core |
| 45 | * access. This is used until the file's number of extents |
| 46 | * surpasses XFS_MAX_INCORE_EXTENTS, at which point all extent pointers |
| 47 | * are accessed through the buffer cache. |
| 48 | * |
| 49 | * Other state kept in the in-core inode is used for identification, |
| 50 | * locking, transactional updating, etc of the inode. |
| 51 | * |
| 52 | * Generally, we do not want to hold the i_rlock while holding the |
| 53 | * i_ilock. Hierarchy is i_iolock followed by i_rlock. |
| 54 | * |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 55 | * xfs_iptr_t contains all the inode fields up to and including the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | * i_mnext and i_mprev fields, it is used as a marker in the inode |
| 57 | * chain off the mount structure by xfs_sync calls. |
| 58 | */ |
| 59 | |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 60 | /* |
| 61 | * Flags for xfs_ichgtime(). |
| 62 | */ |
| 63 | #define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */ |
| 64 | #define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */ |
Christoph Hellwig | 93848a9 | 2013-04-03 16:11:17 +1100 | [diff] [blame] | 65 | #define XFS_ICHGTIME_CREATE 0x4 /* inode create timestamp */ |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 66 | |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 67 | |
| 68 | #ifdef __KERNEL__ |
| 69 | |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 70 | struct xfs_buf; |
| 71 | struct xfs_bmap_free; |
| 72 | struct xfs_bmbt_irec; |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 73 | struct xfs_inode_log_item; |
| 74 | struct xfs_mount; |
| 75 | struct xfs_trans; |
| 76 | struct xfs_dquot; |
| 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | typedef struct xfs_inode { |
| 79 | /* Inode linking and identification information. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | struct xfs_mount *i_mount; /* fs mount struct ptr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | struct xfs_dquot *i_udquot; /* user dquot */ |
| 82 | struct xfs_dquot *i_gdquot; /* group dquot */ |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 83 | struct xfs_dquot *i_pdquot; /* project dquot */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | /* Inode location stuff */ |
| 86 | xfs_ino_t i_ino; /* inode number (agno/agino)*/ |
Christoph Hellwig | 92bfc6e | 2008-11-28 14:23:41 +1100 | [diff] [blame] | 87 | struct xfs_imap i_imap; /* location for xfs_imap() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
| 89 | /* Extent information. */ |
| 90 | xfs_ifork_t *i_afp; /* attribute fork pointer */ |
| 91 | xfs_ifork_t i_df; /* data fork */ |
| 92 | |
| 93 | /* Transaction and locking information. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | struct xfs_inode_log_item *i_itemp; /* logging information */ |
| 95 | mrlock_t i_lock; /* inode lock */ |
| 96 | mrlock_t i_iolock; /* inode IO lock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | atomic_t i_pincount; /* inode pin count */ |
David Chinner | f273ab8 | 2006-09-28 11:06:03 +1000 | [diff] [blame] | 98 | spinlock_t i_flags_lock; /* inode i_flags lock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | /* Miscellaneous state. */ |
Christoph Hellwig | 49e4c70 | 2011-12-18 20:00:08 +0000 | [diff] [blame] | 100 | unsigned long i_flags; /* see defined flags below */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | unsigned int i_delayed_blks; /* count of delay alloc blks */ |
| 102 | |
Christoph Hellwig | 347d1c0 | 2007-08-28 13:57:51 +1000 | [diff] [blame] | 103 | xfs_icdinode_t i_d; /* most of ondisk inode */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 105 | /* VFS inode */ |
| 106 | struct inode i_vnode; /* embedded VFS inode */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } xfs_inode_t; |
| 108 | |
David Chinner | 0165164 | 2008-08-13 15:45:15 +1000 | [diff] [blame] | 109 | /* Convert from vfs inode to xfs inode */ |
| 110 | static inline struct xfs_inode *XFS_I(struct inode *inode) |
| 111 | { |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 112 | return container_of(inode, struct xfs_inode, i_vnode); |
David Chinner | 0165164 | 2008-08-13 15:45:15 +1000 | [diff] [blame] | 113 | } |
| 114 | |
David Chinner | 0165164 | 2008-08-13 15:45:15 +1000 | [diff] [blame] | 115 | /* convert from xfs inode to vfs inode */ |
| 116 | static inline struct inode *VFS_I(struct xfs_inode *ip) |
| 117 | { |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 118 | return &ip->i_vnode; |
David Chinner | 0165164 | 2008-08-13 15:45:15 +1000 | [diff] [blame] | 119 | } |
David Chinner | 0165164 | 2008-08-13 15:45:15 +1000 | [diff] [blame] | 120 | |
David Chinner | 7a18c38 | 2006-11-11 18:04:54 +1100 | [diff] [blame] | 121 | /* |
Christoph Hellwig | ce7ae151 | 2011-12-18 20:00:11 +0000 | [diff] [blame] | 122 | * For regular files we only update the on-disk filesize when actually |
| 123 | * writing data back to disk. Until then only the copy in the VFS inode |
| 124 | * is uptodate. |
| 125 | */ |
| 126 | static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip) |
| 127 | { |
| 128 | if (S_ISREG(ip->i_d.di_mode)) |
| 129 | return i_size_read(VFS_I(ip)); |
| 130 | return ip->i_d.di_size; |
| 131 | } |
| 132 | |
| 133 | /* |
Christoph Hellwig | 6923e68 | 2012-02-29 09:53:49 +0000 | [diff] [blame] | 134 | * If this I/O goes past the on-disk inode size update it unless it would |
| 135 | * be past the current in-core inode size. |
| 136 | */ |
| 137 | static inline xfs_fsize_t |
| 138 | xfs_new_eof(struct xfs_inode *ip, xfs_fsize_t new_size) |
| 139 | { |
| 140 | xfs_fsize_t i_size = i_size_read(VFS_I(ip)); |
| 141 | |
| 142 | if (new_size > i_size) |
| 143 | new_size = i_size; |
| 144 | return new_size > ip->i_d.di_size ? new_size : 0; |
| 145 | } |
| 146 | |
| 147 | /* |
David Chinner | 7a18c38 | 2006-11-11 18:04:54 +1100 | [diff] [blame] | 148 | * i_flags helper functions |
| 149 | */ |
| 150 | static inline void |
| 151 | __xfs_iflags_set(xfs_inode_t *ip, unsigned short flags) |
| 152 | { |
| 153 | ip->i_flags |= flags; |
| 154 | } |
| 155 | |
| 156 | static inline void |
| 157 | xfs_iflags_set(xfs_inode_t *ip, unsigned short flags) |
| 158 | { |
| 159 | spin_lock(&ip->i_flags_lock); |
| 160 | __xfs_iflags_set(ip, flags); |
| 161 | spin_unlock(&ip->i_flags_lock); |
| 162 | } |
| 163 | |
| 164 | static inline void |
| 165 | xfs_iflags_clear(xfs_inode_t *ip, unsigned short flags) |
| 166 | { |
| 167 | spin_lock(&ip->i_flags_lock); |
| 168 | ip->i_flags &= ~flags; |
| 169 | spin_unlock(&ip->i_flags_lock); |
| 170 | } |
| 171 | |
| 172 | static inline int |
| 173 | __xfs_iflags_test(xfs_inode_t *ip, unsigned short flags) |
| 174 | { |
| 175 | return (ip->i_flags & flags); |
| 176 | } |
| 177 | |
| 178 | static inline int |
| 179 | xfs_iflags_test(xfs_inode_t *ip, unsigned short flags) |
| 180 | { |
| 181 | int ret; |
| 182 | spin_lock(&ip->i_flags_lock); |
| 183 | ret = __xfs_iflags_test(ip, flags); |
| 184 | spin_unlock(&ip->i_flags_lock); |
| 185 | return ret; |
| 186 | } |
Christoph Hellwig | 09262b43 | 2007-08-29 11:44:50 +1000 | [diff] [blame] | 187 | |
| 188 | static inline int |
| 189 | xfs_iflags_test_and_clear(xfs_inode_t *ip, unsigned short flags) |
| 190 | { |
| 191 | int ret; |
| 192 | |
| 193 | spin_lock(&ip->i_flags_lock); |
| 194 | ret = ip->i_flags & flags; |
| 195 | if (ret) |
| 196 | ip->i_flags &= ~flags; |
| 197 | spin_unlock(&ip->i_flags_lock); |
| 198 | return ret; |
| 199 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
Christoph Hellwig | 474fce0 | 2011-12-18 20:00:09 +0000 | [diff] [blame] | 201 | static inline int |
| 202 | xfs_iflags_test_and_set(xfs_inode_t *ip, unsigned short flags) |
| 203 | { |
| 204 | int ret; |
| 205 | |
| 206 | spin_lock(&ip->i_flags_lock); |
| 207 | ret = ip->i_flags & flags; |
| 208 | if (!ret) |
| 209 | ip->i_flags |= flags; |
| 210 | spin_unlock(&ip->i_flags_lock); |
| 211 | return ret; |
| 212 | } |
| 213 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | /* |
Arkadiusz Mi?kiewicz | 6743099 | 2010-09-26 06:10:18 +0000 | [diff] [blame] | 215 | * Project quota id helpers (previously projid was 16bit only |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 216 | * and using two 16bit values to hold new 32bit projid was chosen |
Arkadiusz Mi?kiewicz | 6743099 | 2010-09-26 06:10:18 +0000 | [diff] [blame] | 217 | * to retain compatibility with "old" filesystems). |
| 218 | */ |
| 219 | static inline prid_t |
| 220 | xfs_get_projid(struct xfs_inode *ip) |
| 221 | { |
| 222 | return (prid_t)ip->i_d.di_projid_hi << 16 | ip->i_d.di_projid_lo; |
| 223 | } |
| 224 | |
| 225 | static inline void |
| 226 | xfs_set_projid(struct xfs_inode *ip, |
| 227 | prid_t projid) |
| 228 | { |
| 229 | ip->i_d.di_projid_hi = (__uint16_t) (projid >> 16); |
| 230 | ip->i_d.di_projid_lo = (__uint16_t) (projid & 0xffff); |
| 231 | } |
| 232 | |
| 233 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | * In-core inode flags. |
| 235 | */ |
Christoph Hellwig | 474fce0 | 2011-12-18 20:00:09 +0000 | [diff] [blame] | 236 | #define XFS_IRECLAIM (1 << 0) /* started reclaiming this inode */ |
| 237 | #define XFS_ISTALE (1 << 1) /* inode has been staled */ |
| 238 | #define XFS_IRECLAIMABLE (1 << 2) /* inode can be reclaimed */ |
| 239 | #define XFS_INEW (1 << 3) /* inode has just been allocated */ |
| 240 | #define XFS_IFILESTREAM (1 << 4) /* inode is in a filestream dir. */ |
| 241 | #define XFS_ITRUNCATED (1 << 5) /* truncated down so flush-on-close */ |
| 242 | #define XFS_IDIRTY_RELEASE (1 << 6) /* dirty release already seen */ |
| 243 | #define __XFS_IFLOCK_BIT 7 /* inode is being flushed right now */ |
| 244 | #define XFS_IFLOCK (1 << __XFS_IFLOCK_BIT) |
Christoph Hellwig | f392e63 | 2011-12-18 20:00:10 +0000 | [diff] [blame] | 245 | #define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */ |
| 246 | #define XFS_IPINNED (1 << __XFS_IPINNED_BIT) |
Dave Chinner | 5132ba8 | 2012-03-22 05:15:10 +0000 | [diff] [blame] | 247 | #define XFS_IDONTCACHE (1 << 9) /* don't cache the inode long term */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
| 249 | /* |
Dave Chinner | 778e24b | 2011-06-23 01:34:59 +0000 | [diff] [blame] | 250 | * Per-lifetime flags need to be reset when re-using a reclaimable inode during |
Dave Chinner | 5132ba8 | 2012-03-22 05:15:10 +0000 | [diff] [blame] | 251 | * inode lookup. This prevents unintended behaviour on the new inode from |
Dave Chinner | 778e24b | 2011-06-23 01:34:59 +0000 | [diff] [blame] | 252 | * ocurring. |
| 253 | */ |
| 254 | #define XFS_IRECLAIM_RESET_FLAGS \ |
| 255 | (XFS_IRECLAIMABLE | XFS_IRECLAIM | \ |
| 256 | XFS_IDIRTY_RELEASE | XFS_ITRUNCATED | \ |
| 257 | XFS_IFILESTREAM); |
| 258 | |
| 259 | /* |
Christoph Hellwig | 474fce0 | 2011-12-18 20:00:09 +0000 | [diff] [blame] | 260 | * Synchronize processes attempting to flush the in-core inode back to disk. |
| 261 | */ |
| 262 | |
| 263 | extern void __xfs_iflock(struct xfs_inode *ip); |
| 264 | |
| 265 | static inline int xfs_iflock_nowait(struct xfs_inode *ip) |
| 266 | { |
| 267 | return !xfs_iflags_test_and_set(ip, XFS_IFLOCK); |
| 268 | } |
| 269 | |
| 270 | static inline void xfs_iflock(struct xfs_inode *ip) |
| 271 | { |
| 272 | if (!xfs_iflock_nowait(ip)) |
| 273 | __xfs_iflock(ip); |
| 274 | } |
| 275 | |
| 276 | static inline void xfs_ifunlock(struct xfs_inode *ip) |
| 277 | { |
| 278 | xfs_iflags_clear(ip, XFS_IFLOCK); |
Alex Elder | 311f08a | 2013-02-04 10:13:11 -0600 | [diff] [blame] | 279 | smp_mb(); |
Christoph Hellwig | 474fce0 | 2011-12-18 20:00:09 +0000 | [diff] [blame] | 280 | wake_up_bit(&ip->i_flags, __XFS_IFLOCK_BIT); |
| 281 | } |
| 282 | |
| 283 | static inline int xfs_isiflocked(struct xfs_inode *ip) |
| 284 | { |
| 285 | return xfs_iflags_test(ip, XFS_IFLOCK); |
| 286 | } |
| 287 | |
| 288 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | * Flags for inode locking. |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 290 | * Bit ranges: 1<<1 - 1<<16-1 -- iolock/ilock modes (bitfield) |
| 291 | * 1<<16 - 1<<32-1 -- lockdep annotation (integers) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | */ |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 293 | #define XFS_IOLOCK_EXCL (1<<0) |
| 294 | #define XFS_IOLOCK_SHARED (1<<1) |
| 295 | #define XFS_ILOCK_EXCL (1<<2) |
| 296 | #define XFS_ILOCK_SHARED (1<<3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 298 | #define XFS_LOCK_MASK (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED \ |
Christoph Hellwig | 579aa9c | 2008-04-22 17:34:00 +1000 | [diff] [blame] | 299 | | XFS_ILOCK_EXCL | XFS_ILOCK_SHARED) |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 300 | |
Christoph Hellwig | 0b1b213 | 2009-12-14 23:14:59 +0000 | [diff] [blame] | 301 | #define XFS_LOCK_FLAGS \ |
| 302 | { XFS_IOLOCK_EXCL, "IOLOCK_EXCL" }, \ |
| 303 | { XFS_IOLOCK_SHARED, "IOLOCK_SHARED" }, \ |
| 304 | { XFS_ILOCK_EXCL, "ILOCK_EXCL" }, \ |
Christoph Hellwig | 5b03ff1 | 2012-02-20 02:31:22 +0000 | [diff] [blame] | 305 | { XFS_ILOCK_SHARED, "ILOCK_SHARED" } |
Christoph Hellwig | 0b1b213 | 2009-12-14 23:14:59 +0000 | [diff] [blame] | 306 | |
| 307 | |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 308 | /* |
| 309 | * Flags for lockdep annotations. |
| 310 | * |
Christoph Hellwig | 9681153 | 2011-01-25 09:06:21 +0000 | [diff] [blame] | 311 | * XFS_LOCK_PARENT - for directory operations that require locking a |
| 312 | * parent directory inode and a child entry inode. The parent gets locked |
| 313 | * with this flag so it gets a lockdep subclass of 1 and the child entry |
| 314 | * lock will have a lockdep subclass of 0. |
| 315 | * |
| 316 | * XFS_LOCK_RTBITMAP/XFS_LOCK_RTSUM - the realtime device bitmap and summary |
| 317 | * inodes do not participate in the normal lock order, and thus have their |
| 318 | * own subclasses. |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 319 | * |
David Chinner | 0f1145c | 2007-06-29 17:26:09 +1000 | [diff] [blame] | 320 | * XFS_LOCK_INUMORDER - for locking several inodes at the some time |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 321 | * with xfs_lock_inodes(). This flag is used as the starting subclass |
| 322 | * and each subsequent lock acquired will increment the subclass by one. |
Christoph Hellwig | 9681153 | 2011-01-25 09:06:21 +0000 | [diff] [blame] | 323 | * So the first lock acquired will have a lockdep subclass of 4, the |
| 324 | * second lock will have a lockdep subclass of 5, and so on. It is |
David Chinner | 0f1145c | 2007-06-29 17:26:09 +1000 | [diff] [blame] | 325 | * the responsibility of the class builder to shift this to the correct |
| 326 | * portion of the lock_mode lockdep mask. |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 327 | */ |
David Chinner | 0f1145c | 2007-06-29 17:26:09 +1000 | [diff] [blame] | 328 | #define XFS_LOCK_PARENT 1 |
Christoph Hellwig | 9681153 | 2011-01-25 09:06:21 +0000 | [diff] [blame] | 329 | #define XFS_LOCK_RTBITMAP 2 |
| 330 | #define XFS_LOCK_RTSUM 3 |
| 331 | #define XFS_LOCK_INUMORDER 4 |
David Chinner | 0f1145c | 2007-06-29 17:26:09 +1000 | [diff] [blame] | 332 | |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 333 | #define XFS_IOLOCK_SHIFT 16 |
David Chinner | 0f1145c | 2007-06-29 17:26:09 +1000 | [diff] [blame] | 334 | #define XFS_IOLOCK_PARENT (XFS_LOCK_PARENT << XFS_IOLOCK_SHIFT) |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 335 | |
| 336 | #define XFS_ILOCK_SHIFT 24 |
David Chinner | 0f1145c | 2007-06-29 17:26:09 +1000 | [diff] [blame] | 337 | #define XFS_ILOCK_PARENT (XFS_LOCK_PARENT << XFS_ILOCK_SHIFT) |
Christoph Hellwig | 9681153 | 2011-01-25 09:06:21 +0000 | [diff] [blame] | 338 | #define XFS_ILOCK_RTBITMAP (XFS_LOCK_RTBITMAP << XFS_ILOCK_SHIFT) |
| 339 | #define XFS_ILOCK_RTSUM (XFS_LOCK_RTSUM << XFS_ILOCK_SHIFT) |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 340 | |
| 341 | #define XFS_IOLOCK_DEP_MASK 0x00ff0000 |
| 342 | #define XFS_ILOCK_DEP_MASK 0xff000000 |
| 343 | #define XFS_LOCK_DEP_MASK (XFS_IOLOCK_DEP_MASK | XFS_ILOCK_DEP_MASK) |
| 344 | |
| 345 | #define XFS_IOLOCK_DEP(flags) (((flags) & XFS_IOLOCK_DEP_MASK) >> XFS_IOLOCK_SHIFT) |
| 346 | #define XFS_ILOCK_DEP(flags) (((flags) & XFS_ILOCK_DEP_MASK) >> XFS_ILOCK_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | |
| 348 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | * For multiple groups support: if S_ISGID bit is set in the parent |
| 350 | * directory, group of new file is set to that of the parent, and |
| 351 | * new subdirectory gets S_ISGID bit from parent. |
| 352 | */ |
Christoph Hellwig | bd186aa | 2007-08-30 17:21:12 +1000 | [diff] [blame] | 353 | #define XFS_INHERIT_GID(pip) \ |
| 354 | (((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \ |
| 355 | ((pip)->i_d.di_mode & S_ISGID)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | |
Dave Chinner | 33479e0 | 2012-10-08 21:56:11 +1100 | [diff] [blame] | 357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | /* |
Dave Chinner | 33479e0 | 2012-10-08 21:56:11 +1100 | [diff] [blame] | 359 | * xfs_inode.c prototypes. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | void xfs_ilock(xfs_inode_t *, uint); |
| 362 | int xfs_ilock_nowait(xfs_inode_t *, uint); |
| 363 | void xfs_iunlock(xfs_inode_t *, uint); |
| 364 | void xfs_ilock_demote(xfs_inode_t *, uint); |
Christoph Hellwig | 579aa9c | 2008-04-22 17:34:00 +1000 | [diff] [blame] | 365 | int xfs_isilocked(xfs_inode_t *, uint); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | uint xfs_ilock_map_shared(xfs_inode_t *); |
| 367 | void xfs_iunlock_map_shared(xfs_inode_t *, uint); |
Al Viro | 576b1d6 | 2011-07-26 02:50:15 -0400 | [diff] [blame] | 368 | int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, umode_t, |
Arkadiusz Mi?kiewicz | 6743099 | 2010-09-26 06:10:18 +0000 | [diff] [blame] | 369 | xfs_nlink_t, xfs_dev_t, prid_t, int, |
Christoph Hellwig | 0835890 | 2012-07-04 10:54:47 -0400 | [diff] [blame] | 370 | struct xfs_buf **, xfs_inode_t **); |
Christoph Hellwig | 347d1c0 | 2007-08-28 13:57:51 +1000 | [diff] [blame] | 371 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | uint xfs_ip2xflags(struct xfs_inode *); |
Christoph Hellwig | 45ba598 | 2007-12-07 14:07:20 +1100 | [diff] [blame] | 373 | uint xfs_dic2xflags(struct xfs_dinode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | int xfs_ifree(struct xfs_trans *, xfs_inode_t *, |
| 375 | struct xfs_bmap_free *); |
Christoph Hellwig | 8f04c47 | 2011-07-08 14:34:34 +0200 | [diff] [blame] | 376 | int xfs_itruncate_extents(struct xfs_trans **, struct xfs_inode *, |
| 377 | int, xfs_fsize_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | void xfs_iext_realloc(xfs_inode_t *, int, int); |
Dave Chinner | 777df5a | 2010-02-06 12:37:26 +1100 | [diff] [blame] | 381 | void xfs_iunpin_wait(xfs_inode_t *); |
Christoph Hellwig | 4c46819 | 2012-04-23 15:58:36 +1000 | [diff] [blame] | 382 | int xfs_iflush(struct xfs_inode *, struct xfs_buf **); |
Christoph Hellwig | cfa853e | 2008-04-22 17:34:06 +1000 | [diff] [blame] | 383 | void xfs_lock_inodes(xfs_inode_t **, int, uint); |
Christoph Hellwig | e1cccd9 | 2008-08-13 16:18:07 +1000 | [diff] [blame] | 384 | void xfs_lock_two_inodes(xfs_inode_t *, xfs_inode_t *, uint); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | |
Dave Chinner | 2a0ec1d | 2012-04-23 15:59:02 +1000 | [diff] [blame] | 386 | xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip); |
| 387 | |
Christoph Hellwig | 5a8d0f3 | 2008-12-03 12:20:40 +0100 | [diff] [blame] | 388 | #define IHOLD(ip) \ |
| 389 | do { \ |
| 390 | ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0) ; \ |
Al Viro | 7de9c6ee | 2010-10-23 11:11:40 -0400 | [diff] [blame] | 391 | ihold(VFS_I(ip)); \ |
Christoph Hellwig | 0b1b213 | 2009-12-14 23:14:59 +0000 | [diff] [blame] | 392 | trace_xfs_ihold(ip, _THIS_IP_); \ |
Christoph Hellwig | 5a8d0f3 | 2008-12-03 12:20:40 +0100 | [diff] [blame] | 393 | } while (0) |
| 394 | |
| 395 | #define IRELE(ip) \ |
| 396 | do { \ |
Christoph Hellwig | 0b1b213 | 2009-12-14 23:14:59 +0000 | [diff] [blame] | 397 | trace_xfs_irele(ip, _THIS_IP_); \ |
Christoph Hellwig | 5a8d0f3 | 2008-12-03 12:20:40 +0100 | [diff] [blame] | 398 | iput(VFS_I(ip)); \ |
| 399 | } while (0) |
| 400 | |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 401 | #endif /* __KERNEL__ */ |
| 402 | |
Christoph Hellwig | 6d73cf1 | 2008-12-09 04:47:32 -0500 | [diff] [blame] | 403 | /* |
| 404 | * Flags for xfs_iget() |
| 405 | */ |
| 406 | #define XFS_IGET_CREATE 0x1 |
Dave Chinner | 1920779 | 2010-06-24 11:15:47 +1000 | [diff] [blame] | 407 | #define XFS_IGET_UNTRUSTED 0x2 |
Dave Chinner | 5132ba8 | 2012-03-22 05:15:10 +0000 | [diff] [blame] | 408 | #define XFS_IGET_DONTCACHE 0x4 |
Christoph Hellwig | 6d73cf1 | 2008-12-09 04:47:32 -0500 | [diff] [blame] | 409 | |
Christoph Hellwig | 475ee41 | 2012-07-03 12:21:22 -0400 | [diff] [blame] | 410 | int xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *, |
| 411 | struct xfs_imap *, struct xfs_dinode **, |
| 412 | struct xfs_buf **, uint, uint); |
Christoph Hellwig | 6d73cf1 | 2008-12-09 04:47:32 -0500 | [diff] [blame] | 413 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, |
Dave Chinner | 7b6259e | 2010-06-24 11:35:17 +1000 | [diff] [blame] | 414 | struct xfs_inode *, uint); |
Christoph Hellwig | 93848a9 | 2013-04-03 16:11:17 +1100 | [diff] [blame] | 415 | void xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *); |
Christoph Hellwig | 81591fe | 2008-11-28 14:23:39 +1100 | [diff] [blame] | 416 | void xfs_dinode_to_disk(struct xfs_dinode *, |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 417 | struct xfs_icdinode *); |
Brian Foster | 72b53ef | 2012-11-06 09:50:40 -0500 | [diff] [blame] | 418 | bool xfs_can_free_eofblocks(struct xfs_inode *, bool); |
Mandy Kirkconnell | 4eea22f | 2006-03-14 13:29:52 +1100 | [diff] [blame] | 419 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) |
| 421 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | #if defined(DEBUG) |
| 423 | void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *); |
| 424 | #else |
| 425 | #define xfs_inobp_check(mp, bp) |
| 426 | #endif /* DEBUG */ |
| 427 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | extern struct kmem_zone *xfs_inode_zone; |
Dave Chinner | 1813dd6 | 2012-11-14 17:54:40 +1100 | [diff] [blame] | 429 | extern const struct xfs_buf_ops xfs_inode_buf_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | #endif /* __XFS_INODE_H__ */ |