Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of version 2 of the GNU General Public License as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it would be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 | * | |
12 | * Further, this software is distributed without any warranty that it is | |
13 | * free of the rightful claim of any third person regarding infringement | |
14 | * or the like. Any license provided herein, whether implied or | |
15 | * otherwise, applies only to this software file. Patent licenses, if | |
16 | * any, provided herein do not apply to combinations of this program with | |
17 | * other software, or any other product whatsoever. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | |
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | |
22 | * | |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | |
24 | * Mountain View, CA 94043, or: | |
25 | * | |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | |
31 | */ | |
32 | #ifndef __XFS_INODE_ITEM_H__ | |
33 | #define __XFS_INODE_ITEM_H__ | |
34 | ||
35 | /* | |
36 | * This is the structure used to lay out an inode log item in the | |
37 | * log. The size of the inline data/extents/b-tree root to be logged | |
38 | * (if any) is indicated in the ilf_dsize field. Changes to this structure | |
39 | * must be added on to the end. | |
40 | * | |
41 | * Convention for naming inode log item versions : The current version | |
42 | * is always named XFS_LI_INODE. When an inode log item gets superseded, | |
43 | * add the latest version of IRIX that will generate logs with that item | |
44 | * to the version name. | |
45 | * | |
46 | * -Version 1 of this structure (XFS_LI_5_3_INODE) included up to the first | |
47 | * union (ilf_u) field. This was released with IRIX 5.3-XFS. | |
48 | * -Version 2 of this structure (XFS_LI_6_1_INODE) is currently the entire | |
49 | * structure. This was released with IRIX 6.0.1-XFS and IRIX 6.1. | |
50 | * -Version 3 of this structure (XFS_LI_INODE) is the same as version 2 | |
51 | * so a new structure definition wasn't necessary. However, we had | |
52 | * to add a new type because the inode cluster size changed from 4K | |
53 | * to 8K and the version number had to be rev'ved to keep older kernels | |
54 | * from trying to recover logs with the 8K buffers in them. The logging | |
55 | * code can handle recovery on different-sized clusters now so hopefully | |
56 | * this'll be the last time we need to change the inode log item just | |
57 | * for a change in the inode cluster size. This new version was | |
58 | * released with IRIX 6.2. | |
59 | */ | |
60 | typedef struct xfs_inode_log_format { | |
61 | unsigned short ilf_type; /* inode log item type */ | |
62 | unsigned short ilf_size; /* size of this item */ | |
63 | uint ilf_fields; /* flags for fields logged */ | |
64 | ushort ilf_asize; /* size of attr d/ext/root */ | |
65 | ushort ilf_dsize; /* size of data/ext/root */ | |
66 | xfs_ino_t ilf_ino; /* inode number */ | |
67 | union { | |
68 | xfs_dev_t ilfu_rdev; /* rdev value for dev inode*/ | |
69 | uuid_t ilfu_uuid; /* mount point value */ | |
70 | } ilf_u; | |
71 | __int64_t ilf_blkno; /* blkno of inode buffer */ | |
72 | int ilf_len; /* len of inode buffer */ | |
73 | int ilf_boffset; /* off of inode in buffer */ | |
74 | } xfs_inode_log_format_t; | |
75 | ||
76 | /* Initial version shipped with IRIX 5.3-XFS */ | |
77 | typedef struct xfs_inode_log_format_v1 { | |
78 | unsigned short ilf_type; /* inode log item type */ | |
79 | unsigned short ilf_size; /* size of this item */ | |
80 | uint ilf_fields; /* flags for fields logged */ | |
81 | uint ilf_dsize; /* size of data/ext/root */ | |
82 | xfs_ino_t ilf_ino; /* inode number */ | |
83 | union { | |
84 | xfs_dev_t ilfu_rdev; /* rdev value for dev inode*/ | |
85 | uuid_t ilfu_uuid; /* mount point value */ | |
86 | } ilf_u; | |
87 | } xfs_inode_log_format_t_v1; | |
88 | ||
89 | /* | |
90 | * Flags for xfs_trans_log_inode flags field. | |
91 | */ | |
92 | #define XFS_ILOG_CORE 0x001 /* log standard inode fields */ | |
93 | #define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */ | |
94 | #define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */ | |
95 | #define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */ | |
96 | #define XFS_ILOG_DEV 0x010 /* log the dev field */ | |
97 | #define XFS_ILOG_UUID 0x020 /* log the uuid field */ | |
98 | #define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */ | |
99 | #define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */ | |
100 | #define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */ | |
101 | ||
102 | #define XFS_ILOG_NONCORE (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ | |
103 | XFS_ILOG_DBROOT | XFS_ILOG_DEV | \ | |
104 | XFS_ILOG_UUID | XFS_ILOG_ADATA | \ | |
105 | XFS_ILOG_AEXT | XFS_ILOG_ABROOT) | |
106 | ||
107 | #define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ | |
108 | XFS_ILOG_DBROOT) | |
109 | ||
110 | #define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ | |
111 | XFS_ILOG_ABROOT) | |
112 | ||
113 | #define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \ | |
114 | XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \ | |
115 | XFS_ILOG_DEV | XFS_ILOG_UUID | \ | |
116 | XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ | |
117 | XFS_ILOG_ABROOT) | |
118 | ||
119 | #define XFS_ILI_HOLD 0x1 | |
120 | #define XFS_ILI_IOLOCKED_EXCL 0x2 | |
121 | #define XFS_ILI_IOLOCKED_SHARED 0x4 | |
122 | ||
123 | #define XFS_ILI_IOLOCKED_ANY (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED) | |
124 | ||
125 | ||
126 | #ifdef __KERNEL__ | |
127 | ||
128 | struct xfs_buf; | |
129 | struct xfs_bmbt_rec_64; | |
130 | struct xfs_inode; | |
131 | struct xfs_mount; | |
132 | ||
133 | ||
134 | typedef struct xfs_inode_log_item { | |
135 | xfs_log_item_t ili_item; /* common portion */ | |
136 | struct xfs_inode *ili_inode; /* inode ptr */ | |
137 | xfs_lsn_t ili_flush_lsn; /* lsn at last flush */ | |
138 | xfs_lsn_t ili_last_lsn; /* lsn at last transaction */ | |
139 | unsigned short ili_ilock_recur; /* lock recursion count */ | |
140 | unsigned short ili_iolock_recur; /* lock recursion count */ | |
141 | unsigned short ili_flags; /* misc flags */ | |
142 | unsigned short ili_logged; /* flushed logged data */ | |
143 | unsigned int ili_last_fields; /* fields when flushed */ | |
144 | struct xfs_bmbt_rec_64 *ili_extents_buf; /* array of logged | |
145 | data exts */ | |
146 | struct xfs_bmbt_rec_64 *ili_aextents_buf; /* array of logged | |
147 | attr exts */ | |
148 | unsigned int ili_pushbuf_flag; /* one bit used in push_ail */ | |
149 | ||
150 | #ifdef DEBUG | |
151 | uint64_t ili_push_owner; /* one who sets pushbuf_flag | |
152 | above gets to push the buf */ | |
153 | #endif | |
154 | #ifdef XFS_TRANS_DEBUG | |
155 | int ili_root_size; | |
156 | char *ili_orig_root; | |
157 | #endif | |
158 | xfs_inode_log_format_t ili_format; /* logged structure */ | |
159 | } xfs_inode_log_item_t; | |
160 | ||
161 | ||
1da177e4 | 162 | #define XFS_ILOG_FDATA(w) xfs_ilog_fdata(w) |
a844f451 NS |
163 | static inline int xfs_ilog_fdata(int w) |
164 | { | |
165 | return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA); | |
166 | } | |
1da177e4 LT |
167 | |
168 | #endif /* __KERNEL__ */ | |
169 | ||
1da177e4 | 170 | #define XFS_ILOG_FBROOT(w) xfs_ilog_fbroot(w) |
a844f451 NS |
171 | static inline int xfs_ilog_fbroot(int w) |
172 | { | |
173 | return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT); | |
174 | } | |
175 | ||
1da177e4 | 176 | #define XFS_ILOG_FEXT(w) xfs_ilog_fext(w) |
a844f451 NS |
177 | static inline int xfs_ilog_fext(int w) |
178 | { | |
179 | return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT); | |
180 | } | |
1da177e4 LT |
181 | |
182 | #ifdef __KERNEL__ | |
183 | ||
a844f451 NS |
184 | extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); |
185 | extern void xfs_inode_item_destroy(struct xfs_inode *); | |
186 | extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *); | |
187 | extern void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *); | |
188 | extern void xfs_iflush_abort(struct xfs_inode *); | |
1da177e4 LT |
189 | |
190 | #endif /* __KERNEL__ */ | |
191 | ||
192 | #endif /* __XFS_INODE_ITEM_H__ */ |