| 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. | 
|  | 26 | * | 
|  | 27 | * Convention for naming inode log item versions :  The current version | 
|  | 28 | * is always named XFS_LI_INODE.  When an inode log item gets superseded, | 
|  | 29 | * add the latest version of IRIX that will generate logs with that item | 
|  | 30 | * to the version name. | 
|  | 31 | * | 
|  | 32 | * -Version 1 of this structure (XFS_LI_5_3_INODE) included up to the first | 
|  | 33 | *	union (ilf_u) field.  This was released with IRIX 5.3-XFS. | 
|  | 34 | * -Version 2 of this structure (XFS_LI_6_1_INODE) is currently the entire | 
|  | 35 | *	structure.  This was released with IRIX 6.0.1-XFS and IRIX 6.1. | 
|  | 36 | * -Version 3 of this structure (XFS_LI_INODE) is the same as version 2 | 
|  | 37 | *	so a new structure definition wasn't necessary.  However, we had | 
|  | 38 | *	to add a new type because the inode cluster size changed from 4K | 
|  | 39 | *	to 8K and the version number had to be rev'ved to keep older kernels | 
|  | 40 | *	from trying to recover logs with the 8K buffers in them.  The logging | 
|  | 41 | *	code can handle recovery on different-sized clusters now so hopefully | 
|  | 42 | *	this'll be the last time we need to change the inode log item just | 
|  | 43 | *	for a change in the inode cluster size.  This new version was | 
|  | 44 | *	released with IRIX 6.2. | 
|  | 45 | */ | 
|  | 46 | typedef struct xfs_inode_log_format { | 
|  | 47 | unsigned short		ilf_type;	/* inode log item type */ | 
|  | 48 | unsigned short		ilf_size;	/* size of this item */ | 
|  | 49 | uint			ilf_fields;	/* flags for fields logged */ | 
|  | 50 | ushort			ilf_asize;	/* size of attr d/ext/root */ | 
|  | 51 | ushort			ilf_dsize;	/* size of data/ext/root */ | 
|  | 52 | xfs_ino_t		ilf_ino;	/* inode number */ | 
|  | 53 | union { | 
|  | 54 | xfs_dev_t	ilfu_rdev;	/* rdev value for dev inode*/ | 
|  | 55 | uuid_t		ilfu_uuid;	/* mount point value */ | 
|  | 56 | } ilf_u; | 
|  | 57 | __int64_t		ilf_blkno;	/* blkno of inode buffer */ | 
|  | 58 | int			ilf_len;	/* len of inode buffer */ | 
|  | 59 | int			ilf_boffset;	/* off of inode in buffer */ | 
|  | 60 | } xfs_inode_log_format_t; | 
|  | 61 |  | 
|  | 62 | /* Initial version shipped with IRIX 5.3-XFS */ | 
|  | 63 | typedef struct xfs_inode_log_format_v1 { | 
|  | 64 | unsigned short		ilf_type;	/* inode log item type */ | 
|  | 65 | unsigned short		ilf_size;	/* size of this item */ | 
|  | 66 | uint			ilf_fields;	/* flags for fields logged */ | 
|  | 67 | uint			ilf_dsize;	/* size of data/ext/root */ | 
|  | 68 | xfs_ino_t		ilf_ino;	/* inode number */ | 
|  | 69 | union { | 
|  | 70 | xfs_dev_t	ilfu_rdev;	/* rdev value for dev inode*/ | 
|  | 71 | uuid_t		ilfu_uuid;	/* mount point value */ | 
|  | 72 | } ilf_u; | 
|  | 73 | } xfs_inode_log_format_t_v1; | 
|  | 74 |  | 
|  | 75 | /* | 
|  | 76 | * Flags for xfs_trans_log_inode flags field. | 
|  | 77 | */ | 
|  | 78 | #define	XFS_ILOG_CORE	0x001	/* log standard inode fields */ | 
|  | 79 | #define	XFS_ILOG_DDATA	0x002	/* log i_df.if_data */ | 
|  | 80 | #define	XFS_ILOG_DEXT	0x004	/* log i_df.if_extents */ | 
|  | 81 | #define	XFS_ILOG_DBROOT	0x008	/* log i_df.i_broot */ | 
|  | 82 | #define	XFS_ILOG_DEV	0x010	/* log the dev field */ | 
|  | 83 | #define	XFS_ILOG_UUID	0x020	/* log the uuid field */ | 
|  | 84 | #define	XFS_ILOG_ADATA	0x040	/* log i_af.if_data */ | 
|  | 85 | #define	XFS_ILOG_AEXT	0x080	/* log i_af.if_extents */ | 
|  | 86 | #define	XFS_ILOG_ABROOT	0x100	/* log i_af.i_broot */ | 
|  | 87 |  | 
|  | 88 | #define	XFS_ILOG_NONCORE	(XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ | 
|  | 89 | XFS_ILOG_DBROOT | XFS_ILOG_DEV | \ | 
|  | 90 | XFS_ILOG_UUID | XFS_ILOG_ADATA | \ | 
|  | 91 | XFS_ILOG_AEXT | XFS_ILOG_ABROOT) | 
|  | 92 |  | 
|  | 93 | #define	XFS_ILOG_DFORK		(XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ | 
|  | 94 | XFS_ILOG_DBROOT) | 
|  | 95 |  | 
|  | 96 | #define	XFS_ILOG_AFORK		(XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ | 
|  | 97 | XFS_ILOG_ABROOT) | 
|  | 98 |  | 
|  | 99 | #define	XFS_ILOG_ALL		(XFS_ILOG_CORE | XFS_ILOG_DDATA | \ | 
|  | 100 | XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \ | 
|  | 101 | XFS_ILOG_DEV | XFS_ILOG_UUID | \ | 
|  | 102 | XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ | 
|  | 103 | XFS_ILOG_ABROOT) | 
|  | 104 |  | 
|  | 105 | #define	XFS_ILI_HOLD		0x1 | 
|  | 106 | #define	XFS_ILI_IOLOCKED_EXCL	0x2 | 
|  | 107 | #define	XFS_ILI_IOLOCKED_SHARED	0x4 | 
|  | 108 |  | 
|  | 109 | #define	XFS_ILI_IOLOCKED_ANY   (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED) | 
|  | 110 |  | 
|  | 111 |  | 
|  | 112 | #ifdef __KERNEL__ | 
|  | 113 |  | 
|  | 114 | struct xfs_buf; | 
|  | 115 | struct xfs_bmbt_rec_64; | 
|  | 116 | struct xfs_inode; | 
|  | 117 | struct xfs_mount; | 
|  | 118 |  | 
|  | 119 |  | 
|  | 120 | typedef struct xfs_inode_log_item { | 
|  | 121 | xfs_log_item_t		ili_item;	   /* common portion */ | 
|  | 122 | struct xfs_inode	*ili_inode;	   /* inode ptr */ | 
|  | 123 | xfs_lsn_t		ili_flush_lsn;	   /* lsn at last flush */ | 
|  | 124 | xfs_lsn_t		ili_last_lsn;	   /* lsn at last transaction */ | 
|  | 125 | unsigned short		ili_ilock_recur;   /* lock recursion count */ | 
|  | 126 | unsigned short		ili_iolock_recur;  /* lock recursion count */ | 
|  | 127 | unsigned short		ili_flags;	   /* misc flags */ | 
|  | 128 | unsigned short		ili_logged;	   /* flushed logged data */ | 
|  | 129 | unsigned int		ili_last_fields;   /* fields when flushed */ | 
|  | 130 | struct xfs_bmbt_rec_64	*ili_extents_buf;  /* array of logged | 
|  | 131 | data exts */ | 
|  | 132 | struct xfs_bmbt_rec_64	*ili_aextents_buf; /* array of logged | 
|  | 133 | attr exts */ | 
|  | 134 | unsigned int            ili_pushbuf_flag;  /* one bit used in push_ail */ | 
|  | 135 |  | 
|  | 136 | #ifdef DEBUG | 
|  | 137 | uint64_t                ili_push_owner;    /* one who sets pushbuf_flag | 
|  | 138 | above gets to push the buf */ | 
|  | 139 | #endif | 
|  | 140 | #ifdef XFS_TRANS_DEBUG | 
|  | 141 | int			ili_root_size; | 
|  | 142 | char			*ili_orig_root; | 
|  | 143 | #endif | 
|  | 144 | xfs_inode_log_format_t	ili_format;	   /* logged structure */ | 
|  | 145 | } xfs_inode_log_item_t; | 
|  | 146 |  | 
|  | 147 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | #define	XFS_ILOG_FDATA(w)	xfs_ilog_fdata(w) | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 149 | static inline int xfs_ilog_fdata(int w) | 
|  | 150 | { | 
|  | 151 | return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA); | 
|  | 152 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 |  | 
|  | 154 | #endif	/* __KERNEL__ */ | 
|  | 155 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | #define	XFS_ILOG_FBROOT(w)	xfs_ilog_fbroot(w) | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 157 | static inline int xfs_ilog_fbroot(int w) | 
|  | 158 | { | 
|  | 159 | return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT); | 
|  | 160 | } | 
|  | 161 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | #define	XFS_ILOG_FEXT(w)	xfs_ilog_fext(w) | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 163 | static inline int xfs_ilog_fext(int w) | 
|  | 164 | { | 
|  | 165 | return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT); | 
|  | 166 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 |  | 
|  | 168 | #ifdef __KERNEL__ | 
|  | 169 |  | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 170 | extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); | 
|  | 171 | extern void xfs_inode_item_destroy(struct xfs_inode *); | 
|  | 172 | extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *); | 
|  | 173 | extern void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *); | 
|  | 174 | extern void xfs_iflush_abort(struct xfs_inode *); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 |  | 
|  | 176 | #endif	/* __KERNEL__ */ | 
|  | 177 |  | 
|  | 178 | #endif	/* __XFS_INODE_ITEM_H__ */ |