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,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_ITEM_H__ |
| 19 | #define __XFS_INODE_ITEM_H__ |
| 20 | |
| 21 | /* |
| 22 | * This is the structure used to lay out an inode log item in the |
| 23 | * log. The size of the inline data/extents/b-tree root to be logged |
| 24 | * (if any) is indicated in the ilf_dsize field. Changes to this structure |
| 25 | * must be added on to the end. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | */ |
| 27 | typedef struct xfs_inode_log_format { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 28 | __uint16_t ilf_type; /* inode log item type */ |
| 29 | __uint16_t ilf_size; /* size of this item */ |
| 30 | __uint32_t ilf_fields; /* flags for fields logged */ |
| 31 | __uint16_t ilf_asize; /* size of attr d/ext/root */ |
| 32 | __uint16_t ilf_dsize; /* size of data/ext/root */ |
| 33 | __uint64_t ilf_ino; /* inode number */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | union { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 35 | __uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | uuid_t ilfu_uuid; /* mount point value */ |
| 37 | } ilf_u; |
| 38 | __int64_t ilf_blkno; /* blkno of inode buffer */ |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 39 | __int32_t ilf_len; /* len of inode buffer */ |
| 40 | __int32_t ilf_boffset; /* off of inode in buffer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | } xfs_inode_log_format_t; |
| 42 | |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 43 | typedef struct xfs_inode_log_format_32 { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 44 | __uint16_t ilf_type; /* inode log item type */ |
| 45 | __uint16_t ilf_size; /* size of this item */ |
| 46 | __uint32_t ilf_fields; /* flags for fields logged */ |
| 47 | __uint16_t ilf_asize; /* size of attr d/ext/root */ |
| 48 | __uint16_t ilf_dsize; /* size of data/ext/root */ |
| 49 | __uint64_t ilf_ino; /* inode number */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | union { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 51 | __uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
| 52 | uuid_t ilfu_uuid; /* mount point value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | } ilf_u; |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 54 | __int64_t ilf_blkno; /* blkno of inode buffer */ |
| 55 | __int32_t ilf_len; /* len of inode buffer */ |
| 56 | __int32_t ilf_boffset; /* off of inode in buffer */ |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 57 | } __attribute__((packed)) xfs_inode_log_format_32_t; |
| 58 | |
| 59 | typedef struct xfs_inode_log_format_64 { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 60 | __uint16_t ilf_type; /* inode log item type */ |
| 61 | __uint16_t ilf_size; /* size of this item */ |
| 62 | __uint32_t ilf_fields; /* flags for fields logged */ |
| 63 | __uint16_t ilf_asize; /* size of attr d/ext/root */ |
| 64 | __uint16_t ilf_dsize; /* size of data/ext/root */ |
| 65 | __uint32_t ilf_pad; /* pad for 64 bit boundary */ |
| 66 | __uint64_t ilf_ino; /* inode number */ |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 67 | union { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 68 | __uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
| 69 | uuid_t ilfu_uuid; /* mount point value */ |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 70 | } ilf_u; |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 71 | __int64_t ilf_blkno; /* blkno of inode buffer */ |
| 72 | __int32_t ilf_len; /* len of inode buffer */ |
| 73 | __int32_t ilf_boffset; /* off of inode in buffer */ |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 74 | } xfs_inode_log_format_64_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
| 76 | /* |
| 77 | * Flags for xfs_trans_log_inode flags field. |
| 78 | */ |
| 79 | #define XFS_ILOG_CORE 0x001 /* log standard inode fields */ |
| 80 | #define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */ |
| 81 | #define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */ |
| 82 | #define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */ |
| 83 | #define XFS_ILOG_DEV 0x010 /* log the dev field */ |
| 84 | #define XFS_ILOG_UUID 0x020 /* log the uuid field */ |
| 85 | #define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */ |
| 86 | #define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */ |
| 87 | #define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */ |
| 88 | |
Christoph Hellwig | 8f639dd | 2012-02-29 09:53:55 +0000 | [diff] [blame] | 89 | |
| 90 | /* |
| 91 | * The timestamps are dirty, but not necessarily anything else in the inode |
| 92 | * core. Unlike the other fields above this one must never make it to disk |
| 93 | * in the ilf_fields of the inode_log_format, but is purely store in-memory in |
| 94 | * ili_fields in the inode_log_item. |
| 95 | */ |
| 96 | #define XFS_ILOG_TIMESTAMP 0x4000 |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #define XFS_ILOG_NONCORE (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ |
| 99 | XFS_ILOG_DBROOT | XFS_ILOG_DEV | \ |
| 100 | XFS_ILOG_UUID | XFS_ILOG_ADATA | \ |
| 101 | XFS_ILOG_AEXT | XFS_ILOG_ABROOT) |
| 102 | |
| 103 | #define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ |
| 104 | XFS_ILOG_DBROOT) |
| 105 | |
| 106 | #define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ |
| 107 | XFS_ILOG_ABROOT) |
| 108 | |
| 109 | #define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \ |
| 110 | XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \ |
| 111 | XFS_ILOG_DEV | XFS_ILOG_UUID | \ |
| 112 | XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ |
Christoph Hellwig | 8f639dd | 2012-02-29 09:53:55 +0000 | [diff] [blame] | 113 | XFS_ILOG_ABROOT | XFS_ILOG_TIMESTAMP) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 115 | static inline int xfs_ilog_fbroot(int w) |
| 116 | { |
| 117 | return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT); |
| 118 | } |
| 119 | |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 120 | static inline int xfs_ilog_fext(int w) |
| 121 | { |
| 122 | return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT); |
| 123 | } |
| 124 | |
Barry Naujok | 847fff5 | 2008-10-30 17:05:38 +1100 | [diff] [blame] | 125 | static inline int xfs_ilog_fdata(int w) |
| 126 | { |
| 127 | return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA); |
| 128 | } |
| 129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | #ifdef __KERNEL__ |
| 131 | |
| 132 | struct xfs_buf; |
Christoph Hellwig | a5f9be5 | 2009-12-04 10:19:07 +0000 | [diff] [blame] | 133 | struct xfs_bmbt_rec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | struct xfs_inode; |
| 135 | struct xfs_mount; |
| 136 | |
| 137 | |
| 138 | typedef struct xfs_inode_log_item { |
| 139 | xfs_log_item_t ili_item; /* common portion */ |
| 140 | struct xfs_inode *ili_inode; /* inode ptr */ |
| 141 | xfs_lsn_t ili_flush_lsn; /* lsn at last flush */ |
| 142 | xfs_lsn_t ili_last_lsn; /* lsn at last transaction */ |
Christoph Hellwig | 898621d | 2010-06-24 11:36:58 +1000 | [diff] [blame] | 143 | unsigned short ili_lock_flags; /* lock flags */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | unsigned short ili_logged; /* flushed logged data */ |
| 145 | unsigned int ili_last_fields; /* fields when flushed */ |
Christoph Hellwig | f5d8d5c | 2012-02-29 09:53:54 +0000 | [diff] [blame] | 146 | unsigned int ili_fields; /* fields to be logged */ |
Christoph Hellwig | a5f9be5 | 2009-12-04 10:19:07 +0000 | [diff] [blame] | 147 | struct xfs_bmbt_rec *ili_extents_buf; /* array of logged |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | data exts */ |
Christoph Hellwig | a5f9be5 | 2009-12-04 10:19:07 +0000 | [diff] [blame] | 149 | struct xfs_bmbt_rec *ili_aextents_buf; /* array of logged |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | attr exts */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | #ifdef XFS_TRANS_DEBUG |
| 152 | int ili_root_size; |
| 153 | char *ili_orig_root; |
| 154 | #endif |
| 155 | xfs_inode_log_format_t ili_format; /* logged structure */ |
| 156 | } xfs_inode_log_item_t; |
| 157 | |
| 158 | |
David Chinner | 3354040 | 2008-03-06 13:43:59 +1100 | [diff] [blame] | 159 | static inline int xfs_inode_clean(xfs_inode_t *ip) |
| 160 | { |
Christoph Hellwig | f5d8d5c | 2012-02-29 09:53:54 +0000 | [diff] [blame] | 161 | return !ip->i_itemp || !(ip->i_itemp->ili_fields & XFS_ILOG_ALL); |
David Chinner | 3354040 | 2008-03-06 13:43:59 +1100 | [diff] [blame] | 162 | } |
| 163 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 164 | extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); |
| 165 | extern void xfs_inode_item_destroy(struct xfs_inode *); |
Christoph Hellwig | ca30b2a | 2010-06-23 18:11:15 +1000 | [diff] [blame] | 166 | extern void xfs_iflush_done(struct xfs_buf *, struct xfs_log_item *); |
| 167 | extern void xfs_istale_done(struct xfs_buf *, struct xfs_log_item *); |
Dave Chinner | 04913fd | 2012-04-23 15:58:41 +1000 | [diff] [blame] | 168 | extern void xfs_iflush_abort(struct xfs_inode *, bool); |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 169 | extern int xfs_inode_item_format_convert(xfs_log_iovec_t *, |
| 170 | xfs_inode_log_format_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | #endif /* __KERNEL__ */ |
| 173 | |
| 174 | #endif /* __XFS_INODE_ITEM_H__ */ |