Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / fs / xfs / xfs_inode_item.h
1 /*
2  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
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
7  * published by the Free Software Foundation.
8  *
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.
13  *
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
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 typedef struct xfs_inode_log_format {
28         unsigned short          ilf_type;       /* inode log item type */
29         unsigned short          ilf_size;       /* size of this item */
30         uint                    ilf_fields;     /* flags for fields logged */
31         ushort                  ilf_asize;      /* size of attr d/ext/root */
32         ushort                  ilf_dsize;      /* size of data/ext/root */
33         xfs_ino_t               ilf_ino;        /* inode number */
34         union {
35                 xfs_dev_t       ilfu_rdev;      /* rdev value for dev inode*/
36                 uuid_t          ilfu_uuid;      /* mount point value */
37         } ilf_u;
38         __int64_t               ilf_blkno;      /* blkno of inode buffer */
39         int                     ilf_len;        /* len of inode buffer */
40         int                     ilf_boffset;    /* off of inode in buffer */
41 } xfs_inode_log_format_t;
42
43 typedef struct xfs_inode_log_format_32 {
44         unsigned short          ilf_type;       /* 16: inode log item type */
45         unsigned short          ilf_size;       /* 16: size of this item */
46         uint                    ilf_fields;     /* 32: flags for fields logged */
47         ushort                  ilf_asize;      /* 32: size of attr d/ext/root */
48         ushort                  ilf_dsize;      /* 32: size of data/ext/root */
49         xfs_ino_t               ilf_ino;        /* 64: inode number */
50         union {
51                 xfs_dev_t       ilfu_rdev;      /* 32: rdev value for dev inode*/
52                 uuid_t          ilfu_uuid;      /* 128: mount point value */
53         } ilf_u;
54         __int64_t               ilf_blkno;      /* 64: blkno of inode buffer */
55         int                     ilf_len;        /* 32: len of inode buffer */
56         int                     ilf_boffset;    /* 32: off of inode in buffer */
57 } __attribute__((packed)) xfs_inode_log_format_32_t;
58
59 typedef struct xfs_inode_log_format_64 {
60         unsigned short          ilf_type;       /* 16: inode log item type */
61         unsigned short          ilf_size;       /* 16: size of this item */
62         uint                    ilf_fields;     /* 32: flags for fields logged */
63         ushort                  ilf_asize;      /* 32: size of attr d/ext/root */
64         ushort                  ilf_dsize;      /* 32: size of data/ext/root */
65         __uint32_t              ilf_pad;        /* 32: pad for 64 bit boundary */
66         xfs_ino_t               ilf_ino;        /* 64: inode number */
67         union {
68                 xfs_dev_t       ilfu_rdev;      /* 32: rdev value for dev inode*/
69                 uuid_t          ilfu_uuid;      /* 128: mount point value */
70         } ilf_u;
71         __int64_t               ilf_blkno;      /* 64: blkno of inode buffer */
72         int                     ilf_len;        /* 32: len of inode buffer */
73         int                     ilf_boffset;    /* 32: off of inode in buffer */
74 } xfs_inode_log_format_64_t;
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
89 #define XFS_ILOG_NONCORE        (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
90                                  XFS_ILOG_DBROOT | XFS_ILOG_DEV | \
91                                  XFS_ILOG_UUID | XFS_ILOG_ADATA | \
92                                  XFS_ILOG_AEXT | XFS_ILOG_ABROOT)
93
94 #define XFS_ILOG_DFORK          (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
95                                  XFS_ILOG_DBROOT)
96
97 #define XFS_ILOG_AFORK          (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
98                                  XFS_ILOG_ABROOT)
99
100 #define XFS_ILOG_ALL            (XFS_ILOG_CORE | XFS_ILOG_DDATA | \
101                                  XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \
102                                  XFS_ILOG_DEV | XFS_ILOG_UUID | \
103                                  XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
104                                  XFS_ILOG_ABROOT)
105
106 #define XFS_ILI_HOLD            0x1
107 #define XFS_ILI_IOLOCKED_EXCL   0x2
108 #define XFS_ILI_IOLOCKED_SHARED 0x4
109
110 #define XFS_ILI_IOLOCKED_ANY   (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED)
111
112
113 #ifdef __KERNEL__
114
115 struct xfs_buf;
116 struct xfs_bmbt_rec_64;
117 struct xfs_inode;
118 struct xfs_mount;
119
120
121 typedef struct xfs_inode_log_item {
122         xfs_log_item_t          ili_item;          /* common portion */
123         struct xfs_inode        *ili_inode;        /* inode ptr */
124         xfs_lsn_t               ili_flush_lsn;     /* lsn at last flush */
125         xfs_lsn_t               ili_last_lsn;      /* lsn at last transaction */
126         unsigned short          ili_ilock_recur;   /* lock recursion count */
127         unsigned short          ili_iolock_recur;  /* lock recursion count */
128         unsigned short          ili_flags;         /* misc flags */
129         unsigned short          ili_logged;        /* flushed logged data */
130         unsigned int            ili_last_fields;   /* fields when flushed */
131         struct xfs_bmbt_rec_64  *ili_extents_buf;  /* array of logged
132                                                       data exts */
133         struct xfs_bmbt_rec_64  *ili_aextents_buf; /* array of logged
134                                                       attr exts */
135         unsigned int            ili_pushbuf_flag;  /* one bit used in push_ail */
136
137 #ifdef DEBUG
138         uint64_t                ili_push_owner;    /* one who sets pushbuf_flag
139                                                       above gets to push the buf */
140 #endif
141 #ifdef XFS_TRANS_DEBUG
142         int                     ili_root_size;
143         char                    *ili_orig_root;
144 #endif
145         xfs_inode_log_format_t  ili_format;        /* logged structure */
146 } xfs_inode_log_item_t;
147
148
149 #define XFS_ILOG_FDATA(w)       xfs_ilog_fdata(w)
150 static inline int xfs_ilog_fdata(int w)
151 {
152         return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
153 }
154
155 #endif  /* __KERNEL__ */
156
157 #define XFS_ILOG_FBROOT(w)      xfs_ilog_fbroot(w)
158 static inline int xfs_ilog_fbroot(int w)
159 {
160         return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
161 }
162
163 #define XFS_ILOG_FEXT(w)        xfs_ilog_fext(w)
164 static inline int xfs_ilog_fext(int w)
165 {
166         return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
167 }
168
169 #ifdef __KERNEL__
170
171 extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
172 extern void xfs_inode_item_destroy(struct xfs_inode *);
173 extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *);
174 extern void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *);
175 extern void xfs_iflush_abort(struct xfs_inode *);
176 extern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
177                                          xfs_inode_log_format_t *);
178
179 #endif  /* __KERNEL__ */
180
181 #endif  /* __XFS_INODE_ITEM_H__ */