blob: d3dee61e6d91fde1671157b3ee2deeee8df49fcd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * 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 Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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 Torvalds1da177e2005-04-16 15:20:36 -070017 */
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 Torvalds1da177e2005-04-16 15:20:36 -070026 */
27typedef struct xfs_inode_log_format {
Tim Shimmin128dabc2006-09-28 10:55:43 +100028 __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 Torvalds1da177e2005-04-16 15:20:36 -070034 union {
Tim Shimmin128dabc2006-09-28 10:55:43 +100035 __uint32_t ilfu_rdev; /* rdev value for dev inode*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 uuid_t ilfu_uuid; /* mount point value */
37 } ilf_u;
38 __int64_t ilf_blkno; /* blkno of inode buffer */
Tim Shimmin128dabc2006-09-28 10:55:43 +100039 __int32_t ilf_len; /* len of inode buffer */
40 __int32_t ilf_boffset; /* off of inode in buffer */
Linus Torvalds1da177e2005-04-16 15:20:36 -070041} xfs_inode_log_format_t;
42
Tim Shimmin6d192a92006-06-09 14:55:38 +100043typedef struct xfs_inode_log_format_32 {
Tim Shimmin128dabc2006-09-28 10:55:43 +100044 __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 Torvalds1da177e2005-04-16 15:20:36 -070050 union {
Tim Shimmin128dabc2006-09-28 10:55:43 +100051 __uint32_t ilfu_rdev; /* rdev value for dev inode*/
52 uuid_t ilfu_uuid; /* mount point value */
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 } ilf_u;
Tim Shimmin128dabc2006-09-28 10:55:43 +100054 __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 Shimmin6d192a92006-06-09 14:55:38 +100057} __attribute__((packed)) xfs_inode_log_format_32_t;
58
59typedef struct xfs_inode_log_format_64 {
Tim Shimmin128dabc2006-09-28 10:55:43 +100060 __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 Shimmin6d192a92006-06-09 14:55:38 +100067 union {
Tim Shimmin128dabc2006-09-28 10:55:43 +100068 __uint32_t ilfu_rdev; /* rdev value for dev inode*/
69 uuid_t ilfu_uuid; /* mount point value */
Tim Shimmin6d192a92006-06-09 14:55:38 +100070 } ilf_u;
Tim Shimmin128dabc2006-09-28 10:55:43 +100071 __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 Shimmin6d192a92006-06-09 14:55:38 +100074} xfs_inode_log_format_64_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
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
Barry Naujok847fff52008-10-30 17:05:38 +1100106static inline int xfs_ilog_fbroot(int w)
107{
108 return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
109}
110
Barry Naujok847fff52008-10-30 17:05:38 +1100111static inline int xfs_ilog_fext(int w)
112{
113 return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
114}
115
Barry Naujok847fff52008-10-30 17:05:38 +1100116static inline int xfs_ilog_fdata(int w)
117{
118 return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
119}
120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121#ifdef __KERNEL__
122
123struct xfs_buf;
Christoph Hellwiga5f9be52009-12-04 10:19:07 +0000124struct xfs_bmbt_rec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125struct xfs_inode;
126struct xfs_mount;
127
128
129typedef struct xfs_inode_log_item {
130 xfs_log_item_t ili_item; /* common portion */
131 struct xfs_inode *ili_inode; /* inode ptr */
132 xfs_lsn_t ili_flush_lsn; /* lsn at last flush */
133 xfs_lsn_t ili_last_lsn; /* lsn at last transaction */
Christoph Hellwig898621d2010-06-24 11:36:58 +1000134 unsigned short ili_lock_flags; /* lock flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 unsigned short ili_logged; /* flushed logged data */
136 unsigned int ili_last_fields; /* fields when flushed */
Christoph Hellwiga5f9be52009-12-04 10:19:07 +0000137 struct xfs_bmbt_rec *ili_extents_buf; /* array of logged
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 data exts */
Christoph Hellwiga5f9be52009-12-04 10:19:07 +0000139 struct xfs_bmbt_rec *ili_aextents_buf; /* array of logged
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 attr exts */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#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
David Chinner33540402008-03-06 13:43:59 +1100149static inline int xfs_inode_clean(xfs_inode_t *ip)
150{
151 return (!ip->i_itemp ||
152 !(ip->i_itemp->ili_format.ilf_fields & XFS_ILOG_ALL)) &&
153 !ip->i_update_core;
154}
155
Nathan Scotta844f452005-11-02 14:38:42 +1100156extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
157extern void xfs_inode_item_destroy(struct xfs_inode *);
Christoph Hellwigca30b2a2010-06-23 18:11:15 +1000158extern void xfs_iflush_done(struct xfs_buf *, struct xfs_log_item *);
159extern void xfs_istale_done(struct xfs_buf *, struct xfs_log_item *);
Nathan Scotta844f452005-11-02 14:38:42 +1100160extern void xfs_iflush_abort(struct xfs_inode *);
Tim Shimmin6d192a92006-06-09 14:55:38 +1000161extern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
162 xfs_inode_log_format_t *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164#endif /* __KERNEL__ */
165
166#endif /* __XFS_INODE_ITEM_H__ */