| 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 | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 43 | #ifndef HAVE_FORMAT32 | 
| Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 44 | typedef struct xfs_inode_log_format_32 { | 
| Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 45 | __uint16_t		ilf_type;	/* inode log item type */ | 
|  | 46 | __uint16_t		ilf_size;	/* size of this item */ | 
|  | 47 | __uint32_t		ilf_fields;	/* flags for fields logged */ | 
|  | 48 | __uint16_t		ilf_asize;	/* size of attr d/ext/root */ | 
|  | 49 | __uint16_t		ilf_dsize;	/* size of data/ext/root */ | 
|  | 50 | __uint64_t		ilf_ino;	/* inode number */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | union { | 
| Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 52 | __uint32_t	ilfu_rdev;	/* rdev value for dev inode*/ | 
|  | 53 | uuid_t		ilfu_uuid;	/* mount point value */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | } ilf_u; | 
| Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 55 | __int64_t		ilf_blkno;	/* blkno of inode buffer */ | 
|  | 56 | __int32_t		ilf_len;	/* len of inode buffer */ | 
|  | 57 | __int32_t		ilf_boffset;	/* off of inode in buffer */ | 
| Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 58 | } __attribute__((packed)) xfs_inode_log_format_32_t; | 
| Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 59 | #endif | 
| Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 60 |  | 
|  | 61 | typedef struct xfs_inode_log_format_64 { | 
| Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 62 | __uint16_t		ilf_type;	/* inode log item type */ | 
|  | 63 | __uint16_t		ilf_size;	/* size of this item */ | 
|  | 64 | __uint32_t		ilf_fields;	/* flags for fields logged */ | 
|  | 65 | __uint16_t		ilf_asize;	/* size of attr d/ext/root */ | 
|  | 66 | __uint16_t		ilf_dsize;	/* size of data/ext/root */ | 
|  | 67 | __uint32_t		ilf_pad;	/* pad for 64 bit boundary */ | 
|  | 68 | __uint64_t		ilf_ino;	/* inode number */ | 
| Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 69 | union { | 
| Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 70 | __uint32_t	ilfu_rdev;	/* rdev value for dev inode*/ | 
|  | 71 | uuid_t		ilfu_uuid;	/* mount point value */ | 
| Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 72 | } ilf_u; | 
| Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 73 | __int64_t		ilf_blkno;	/* blkno of inode buffer */ | 
|  | 74 | __int32_t		ilf_len;	/* len of inode buffer */ | 
|  | 75 | __int32_t		ilf_boffset;	/* off of inode in buffer */ | 
| Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 76 | } xfs_inode_log_format_64_t; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 |  | 
|  | 78 | /* | 
|  | 79 | * Flags for xfs_trans_log_inode flags field. | 
|  | 80 | */ | 
|  | 81 | #define	XFS_ILOG_CORE	0x001	/* log standard inode fields */ | 
|  | 82 | #define	XFS_ILOG_DDATA	0x002	/* log i_df.if_data */ | 
|  | 83 | #define	XFS_ILOG_DEXT	0x004	/* log i_df.if_extents */ | 
|  | 84 | #define	XFS_ILOG_DBROOT	0x008	/* log i_df.i_broot */ | 
|  | 85 | #define	XFS_ILOG_DEV	0x010	/* log the dev field */ | 
|  | 86 | #define	XFS_ILOG_UUID	0x020	/* log the uuid field */ | 
|  | 87 | #define	XFS_ILOG_ADATA	0x040	/* log i_af.if_data */ | 
|  | 88 | #define	XFS_ILOG_AEXT	0x080	/* log i_af.if_extents */ | 
|  | 89 | #define	XFS_ILOG_ABROOT	0x100	/* log i_af.i_broot */ | 
|  | 90 |  | 
|  | 91 | #define	XFS_ILOG_NONCORE	(XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ | 
|  | 92 | XFS_ILOG_DBROOT | XFS_ILOG_DEV | \ | 
|  | 93 | XFS_ILOG_UUID | XFS_ILOG_ADATA | \ | 
|  | 94 | XFS_ILOG_AEXT | XFS_ILOG_ABROOT) | 
|  | 95 |  | 
|  | 96 | #define	XFS_ILOG_DFORK		(XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ | 
|  | 97 | XFS_ILOG_DBROOT) | 
|  | 98 |  | 
|  | 99 | #define	XFS_ILOG_AFORK		(XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ | 
|  | 100 | XFS_ILOG_ABROOT) | 
|  | 101 |  | 
|  | 102 | #define	XFS_ILOG_ALL		(XFS_ILOG_CORE | XFS_ILOG_DDATA | \ | 
|  | 103 | XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \ | 
|  | 104 | XFS_ILOG_DEV | XFS_ILOG_UUID | \ | 
|  | 105 | XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ | 
|  | 106 | XFS_ILOG_ABROOT) | 
|  | 107 |  | 
|  | 108 | #define	XFS_ILI_HOLD		0x1 | 
|  | 109 | #define	XFS_ILI_IOLOCKED_EXCL	0x2 | 
|  | 110 | #define	XFS_ILI_IOLOCKED_SHARED	0x4 | 
|  | 111 |  | 
|  | 112 | #define	XFS_ILI_IOLOCKED_ANY   (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED) | 
|  | 113 |  | 
|  | 114 |  | 
|  | 115 | #ifdef __KERNEL__ | 
|  | 116 |  | 
|  | 117 | struct xfs_buf; | 
|  | 118 | struct xfs_bmbt_rec_64; | 
|  | 119 | struct xfs_inode; | 
|  | 120 | struct xfs_mount; | 
|  | 121 |  | 
|  | 122 |  | 
|  | 123 | typedef struct xfs_inode_log_item { | 
|  | 124 | xfs_log_item_t		ili_item;	   /* common portion */ | 
|  | 125 | struct xfs_inode	*ili_inode;	   /* inode ptr */ | 
|  | 126 | xfs_lsn_t		ili_flush_lsn;	   /* lsn at last flush */ | 
|  | 127 | xfs_lsn_t		ili_last_lsn;	   /* lsn at last transaction */ | 
|  | 128 | unsigned short		ili_ilock_recur;   /* lock recursion count */ | 
|  | 129 | unsigned short		ili_iolock_recur;  /* lock recursion count */ | 
|  | 130 | unsigned short		ili_flags;	   /* misc flags */ | 
|  | 131 | unsigned short		ili_logged;	   /* flushed logged data */ | 
|  | 132 | unsigned int		ili_last_fields;   /* fields when flushed */ | 
|  | 133 | struct xfs_bmbt_rec_64	*ili_extents_buf;  /* array of logged | 
|  | 134 | data exts */ | 
|  | 135 | struct xfs_bmbt_rec_64	*ili_aextents_buf; /* array of logged | 
|  | 136 | attr exts */ | 
|  | 137 | unsigned int            ili_pushbuf_flag;  /* one bit used in push_ail */ | 
|  | 138 |  | 
|  | 139 | #ifdef DEBUG | 
|  | 140 | uint64_t                ili_push_owner;    /* one who sets pushbuf_flag | 
|  | 141 | above gets to push the buf */ | 
|  | 142 | #endif | 
|  | 143 | #ifdef XFS_TRANS_DEBUG | 
|  | 144 | int			ili_root_size; | 
|  | 145 | char			*ili_orig_root; | 
|  | 146 | #endif | 
|  | 147 | xfs_inode_log_format_t	ili_format;	   /* logged structure */ | 
|  | 148 | } xfs_inode_log_item_t; | 
|  | 149 |  | 
|  | 150 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | #define	XFS_ILOG_FDATA(w)	xfs_ilog_fdata(w) | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 152 | static inline int xfs_ilog_fdata(int w) | 
|  | 153 | { | 
|  | 154 | return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA); | 
|  | 155 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 |  | 
|  | 157 | #endif	/* __KERNEL__ */ | 
|  | 158 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | #define	XFS_ILOG_FBROOT(w)	xfs_ilog_fbroot(w) | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 160 | static inline int xfs_ilog_fbroot(int w) | 
|  | 161 | { | 
|  | 162 | return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT); | 
|  | 163 | } | 
|  | 164 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | #define	XFS_ILOG_FEXT(w)	xfs_ilog_fext(w) | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 166 | static inline int xfs_ilog_fext(int w) | 
|  | 167 | { | 
|  | 168 | return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT); | 
|  | 169 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 |  | 
| David Chinner | 3354040 | 2008-03-06 13:43:59 +1100 | [diff] [blame] | 171 | static inline int xfs_inode_clean(xfs_inode_t *ip) | 
|  | 172 | { | 
|  | 173 | return (!ip->i_itemp || | 
|  | 174 | !(ip->i_itemp->ili_format.ilf_fields & XFS_ILOG_ALL)) && | 
|  | 175 | !ip->i_update_core; | 
|  | 176 | } | 
|  | 177 |  | 
|  | 178 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | #ifdef __KERNEL__ | 
|  | 180 |  | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 181 | extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); | 
|  | 182 | extern void xfs_inode_item_destroy(struct xfs_inode *); | 
|  | 183 | extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *); | 
|  | 184 | extern void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *); | 
|  | 185 | extern void xfs_iflush_abort(struct xfs_inode *); | 
| Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 186 | extern int xfs_inode_item_format_convert(xfs_log_iovec_t *, | 
|  | 187 | xfs_inode_log_format_t *); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 |  | 
|  | 189 | #endif	/* __KERNEL__ */ | 
|  | 190 |  | 
|  | 191 | #endif	/* __XFS_INODE_ITEM_H__ */ |