xfs: split out on-disk transaction definitions
[deliverable/linux.git] / fs / xfs / xfs_log_format.h
CommitLineData
fc06c6d0
DC
1/*
2 * Copyright (c) 2000-2003,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_LOG_FORMAT_H__
19#define __XFS_LOG_FORMAT_H__
20
69432832
DC
21/*
22 * On-disk Log Format definitions.
23 *
24 * This file contains all the on-disk format definitions used within the log. It
25 * includes the physical log structure itself, as well as all the log item
26 * format structures that are written into the log and intepreted by log
27 * recovery. We start with the physical log format definitions, and then work
28 * through all the log items definitions and everything they encode into the
29 * log.
30 */
fc06c6d0
DC
31typedef __uint32_t xlog_tid_t;
32
33#define XLOG_MIN_ICLOGS 2
34#define XLOG_MAX_ICLOGS 8
35#define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe /* Invalid cycle number */
36#define XLOG_VERSION_1 1
37#define XLOG_VERSION_2 2 /* Large IClogs, Log sunit */
38#define XLOG_VERSION_OKBITS (XLOG_VERSION_1 | XLOG_VERSION_2)
39#define XLOG_MIN_RECORD_BSIZE (16*1024) /* eventually 32k */
40#define XLOG_BIG_RECORD_BSIZE (32*1024) /* 32k buffers */
41#define XLOG_MAX_RECORD_BSIZE (256*1024)
42#define XLOG_HEADER_CYCLE_SIZE (32*1024) /* cycle data in header */
43#define XLOG_MIN_RECORD_BSHIFT 14 /* 16384 == 1 << 14 */
44#define XLOG_BIG_RECORD_BSHIFT 15 /* 32k == 1 << 15 */
45#define XLOG_MAX_RECORD_BSHIFT 18 /* 256k == 1 << 18 */
46#define XLOG_BTOLSUNIT(log, b) (((b)+(log)->l_mp->m_sb.sb_logsunit-1) / \
47 (log)->l_mp->m_sb.sb_logsunit)
48#define XLOG_LSUNITTOB(log, su) ((su) * (log)->l_mp->m_sb.sb_logsunit)
49
50#define XLOG_HEADER_SIZE 512
51
52#define XLOG_REC_SHIFT(log) \
53 BTOBB(1 << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \
54 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
55#define XLOG_TOTAL_REC_SHIFT(log) \
56 BTOBB(XLOG_MAX_ICLOGS << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \
57 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
58
59/* get lsn fields */
60#define CYCLE_LSN(lsn) ((uint)((lsn)>>32))
61#define BLOCK_LSN(lsn) ((uint)(lsn))
62
63/* this is used in a spot where we might otherwise double-endian-flip */
64#define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0])
65
66static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block)
67{
68 return ((xfs_lsn_t)cycle << 32) | block;
69}
70
71static inline uint xlog_get_cycle(char *ptr)
72{
73 if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM)
74 return be32_to_cpu(*((__be32 *)ptr + 1));
75 else
76 return be32_to_cpu(*(__be32 *)ptr);
77}
78
79/* Log Clients */
80#define XFS_TRANSACTION 0x69
81#define XFS_VOLUME 0x2
82#define XFS_LOG 0xaa
83
84#define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */
85
86/* Region types for iovec's i_type */
87#define XLOG_REG_TYPE_BFORMAT 1
88#define XLOG_REG_TYPE_BCHUNK 2
89#define XLOG_REG_TYPE_EFI_FORMAT 3
90#define XLOG_REG_TYPE_EFD_FORMAT 4
91#define XLOG_REG_TYPE_IFORMAT 5
92#define XLOG_REG_TYPE_ICORE 6
93#define XLOG_REG_TYPE_IEXT 7
94#define XLOG_REG_TYPE_IBROOT 8
95#define XLOG_REG_TYPE_ILOCAL 9
96#define XLOG_REG_TYPE_IATTR_EXT 10
97#define XLOG_REG_TYPE_IATTR_BROOT 11
98#define XLOG_REG_TYPE_IATTR_LOCAL 12
99#define XLOG_REG_TYPE_QFORMAT 13
100#define XLOG_REG_TYPE_DQUOT 14
101#define XLOG_REG_TYPE_QUOTAOFF 15
102#define XLOG_REG_TYPE_LRHEADER 16
103#define XLOG_REG_TYPE_UNMOUNT 17
104#define XLOG_REG_TYPE_COMMIT 18
105#define XLOG_REG_TYPE_TRANSHDR 19
106#define XLOG_REG_TYPE_ICREATE 20
107#define XLOG_REG_TYPE_MAX 20
108
109/*
110 * Flags to log operation header
111 *
112 * The first write of a new transaction will be preceded with a start
113 * record, XLOG_START_TRANS. Once a transaction is committed, a commit
114 * record is written, XLOG_COMMIT_TRANS. If a single region can not fit into
115 * the remainder of the current active in-core log, it is split up into
116 * multiple regions. Each partial region will be marked with a
117 * XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS.
118 *
119 */
120#define XLOG_START_TRANS 0x01 /* Start a new transaction */
121#define XLOG_COMMIT_TRANS 0x02 /* Commit this transaction */
122#define XLOG_CONTINUE_TRANS 0x04 /* Cont this trans into new region */
123#define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */
124#define XLOG_END_TRANS 0x10 /* End a continued transaction */
125#define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */
126
127
128typedef struct xlog_op_header {
129 __be32 oh_tid; /* transaction id of operation : 4 b */
130 __be32 oh_len; /* bytes in data region : 4 b */
131 __u8 oh_clientid; /* who sent me this : 1 b */
132 __u8 oh_flags; /* : 1 b */
133 __u16 oh_res2; /* 32 bit align : 2 b */
134} xlog_op_header_t;
135
136
137/* valid values for h_fmt */
138#define XLOG_FMT_UNKNOWN 0
139#define XLOG_FMT_LINUX_LE 1
140#define XLOG_FMT_LINUX_BE 2
141#define XLOG_FMT_IRIX_BE 3
142
143/* our fmt */
144#ifdef XFS_NATIVE_HOST
145#define XLOG_FMT XLOG_FMT_LINUX_BE
146#else
147#define XLOG_FMT XLOG_FMT_LINUX_LE
148#endif
149
150typedef struct xlog_rec_header {
151 __be32 h_magicno; /* log record (LR) identifier : 4 */
152 __be32 h_cycle; /* write cycle of log : 4 */
153 __be32 h_version; /* LR version : 4 */
154 __be32 h_len; /* len in bytes; should be 64-bit aligned: 4 */
155 __be64 h_lsn; /* lsn of this LR : 8 */
156 __be64 h_tail_lsn; /* lsn of 1st LR w/ buffers not committed: 8 */
157 __le32 h_crc; /* crc of log record : 4 */
158 __be32 h_prev_block; /* block number to previous LR : 4 */
159 __be32 h_num_logops; /* number of log operations in this LR : 4 */
160 __be32 h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE];
161 /* new fields */
162 __be32 h_fmt; /* format of log record : 4 */
163 uuid_t h_fs_uuid; /* uuid of FS : 16 */
164 __be32 h_size; /* iclog size : 4 */
165} xlog_rec_header_t;
166
167typedef struct xlog_rec_ext_header {
168 __be32 xh_cycle; /* write cycle of log : 4 */
169 __be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */
170} xlog_rec_ext_header_t;
171
172/*
173 * Quite misnamed, because this union lays out the actual on-disk log buffer.
174 */
175typedef union xlog_in_core2 {
176 xlog_rec_header_t hic_header;
177 xlog_rec_ext_header_t hic_xheader;
178 char hic_sector[XLOG_HEADER_SIZE];
179} xlog_in_core_2_t;
180
181/* not an on-disk structure, but needed by log recovery in userspace */
182typedef struct xfs_log_iovec {
183 void *i_addr; /* beginning address of region */
184 int i_len; /* length in bytes of region */
185 uint i_type; /* type of region */
186} xfs_log_iovec_t;
187
69432832 188
2a3c0acc
DC
189/*
190 * Transaction Header definitions.
191 *
192 * This is the structure written in the log at the head of every transaction. It
193 * identifies the type and id of the transaction, and contains the number of
194 * items logged by the transaction so we know how many to expect during
195 * recovery.
196 *
197 * Do not change the below structure without redoing the code in
198 * xlog_recover_add_to_trans() and xlog_recover_add_to_cont_trans().
199 */
200typedef struct xfs_trans_header {
201 uint th_magic; /* magic number */
202 uint th_type; /* transaction type */
203 __int32_t th_tid; /* transaction id (unused) */
204 uint th_num_items; /* num items logged by trans */
205} xfs_trans_header_t;
206
207#define XFS_TRANS_HEADER_MAGIC 0x5452414e /* TRAN */
208
209/*
210 * Log item types.
211 */
212#define XFS_LI_EFI 0x1236
213#define XFS_LI_EFD 0x1237
214#define XFS_LI_IUNLINK 0x1238
215#define XFS_LI_INODE 0x123b /* aligned ino chunks, var-size ibufs */
216#define XFS_LI_BUF 0x123c /* v2 bufs, variable sized inode bufs */
217#define XFS_LI_DQUOT 0x123d
218#define XFS_LI_QUOTAOFF 0x123e
219#define XFS_LI_ICREATE 0x123f
220
221#define XFS_LI_TYPE_DESC \
222 { XFS_LI_EFI, "XFS_LI_EFI" }, \
223 { XFS_LI_EFD, "XFS_LI_EFD" }, \
224 { XFS_LI_IUNLINK, "XFS_LI_IUNLINK" }, \
225 { XFS_LI_INODE, "XFS_LI_INODE" }, \
226 { XFS_LI_BUF, "XFS_LI_BUF" }, \
227 { XFS_LI_DQUOT, "XFS_LI_DQUOT" }, \
228 { XFS_LI_QUOTAOFF, "XFS_LI_QUOTAOFF" }, \
229 { XFS_LI_ICREATE, "XFS_LI_ICREATE" }
230
231/*
232 * Transaction types. Used to distinguish types of buffers.
233 */
234#define XFS_TRANS_SETATTR_NOT_SIZE 1
235#define XFS_TRANS_SETATTR_SIZE 2
236#define XFS_TRANS_INACTIVE 3
237#define XFS_TRANS_CREATE 4
238#define XFS_TRANS_CREATE_TRUNC 5
239#define XFS_TRANS_TRUNCATE_FILE 6
240#define XFS_TRANS_REMOVE 7
241#define XFS_TRANS_LINK 8
242#define XFS_TRANS_RENAME 9
243#define XFS_TRANS_MKDIR 10
244#define XFS_TRANS_RMDIR 11
245#define XFS_TRANS_SYMLINK 12
246#define XFS_TRANS_SET_DMATTRS 13
247#define XFS_TRANS_GROWFS 14
248#define XFS_TRANS_STRAT_WRITE 15
249#define XFS_TRANS_DIOSTRAT 16
250/* 17 was XFS_TRANS_WRITE_SYNC */
251#define XFS_TRANS_WRITEID 18
252#define XFS_TRANS_ADDAFORK 19
253#define XFS_TRANS_ATTRINVAL 20
254#define XFS_TRANS_ATRUNCATE 21
255#define XFS_TRANS_ATTR_SET 22
256#define XFS_TRANS_ATTR_RM 23
257#define XFS_TRANS_ATTR_FLAG 24
258#define XFS_TRANS_CLEAR_AGI_BUCKET 25
259#define XFS_TRANS_QM_SBCHANGE 26
260/*
261 * Dummy entries since we use the transaction type to index into the
262 * trans_type[] in xlog_recover_print_trans_head()
263 */
264#define XFS_TRANS_DUMMY1 27
265#define XFS_TRANS_DUMMY2 28
266#define XFS_TRANS_QM_QUOTAOFF 29
267#define XFS_TRANS_QM_DQALLOC 30
268#define XFS_TRANS_QM_SETQLIM 31
269#define XFS_TRANS_QM_DQCLUSTER 32
270#define XFS_TRANS_QM_QINOCREATE 33
271#define XFS_TRANS_QM_QUOTAOFF_END 34
272#define XFS_TRANS_SB_UNIT 35
273#define XFS_TRANS_FSYNC_TS 36
274#define XFS_TRANS_GROWFSRT_ALLOC 37
275#define XFS_TRANS_GROWFSRT_ZERO 38
276#define XFS_TRANS_GROWFSRT_FREE 39
277#define XFS_TRANS_SWAPEXT 40
278#define XFS_TRANS_SB_COUNT 41
279#define XFS_TRANS_CHECKPOINT 42
280#define XFS_TRANS_ICREATE 43
281#define XFS_TRANS_TYPE_MAX 43
282/* new transaction types need to be reflected in xfs_logprint(8) */
283
284#define XFS_TRANS_TYPES \
285 { XFS_TRANS_SETATTR_NOT_SIZE, "SETATTR_NOT_SIZE" }, \
286 { XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \
287 { XFS_TRANS_INACTIVE, "INACTIVE" }, \
288 { XFS_TRANS_CREATE, "CREATE" }, \
289 { XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \
290 { XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \
291 { XFS_TRANS_REMOVE, "REMOVE" }, \
292 { XFS_TRANS_LINK, "LINK" }, \
293 { XFS_TRANS_RENAME, "RENAME" }, \
294 { XFS_TRANS_MKDIR, "MKDIR" }, \
295 { XFS_TRANS_RMDIR, "RMDIR" }, \
296 { XFS_TRANS_SYMLINK, "SYMLINK" }, \
297 { XFS_TRANS_SET_DMATTRS, "SET_DMATTRS" }, \
298 { XFS_TRANS_GROWFS, "GROWFS" }, \
299 { XFS_TRANS_STRAT_WRITE, "STRAT_WRITE" }, \
300 { XFS_TRANS_DIOSTRAT, "DIOSTRAT" }, \
301 { XFS_TRANS_WRITEID, "WRITEID" }, \
302 { XFS_TRANS_ADDAFORK, "ADDAFORK" }, \
303 { XFS_TRANS_ATTRINVAL, "ATTRINVAL" }, \
304 { XFS_TRANS_ATRUNCATE, "ATRUNCATE" }, \
305 { XFS_TRANS_ATTR_SET, "ATTR_SET" }, \
306 { XFS_TRANS_ATTR_RM, "ATTR_RM" }, \
307 { XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \
308 { XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \
309 { XFS_TRANS_QM_SBCHANGE, "QM_SBCHANGE" }, \
310 { XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \
311 { XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \
312 { XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \
313 { XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \
314 { XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \
315 { XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \
316 { XFS_TRANS_SB_UNIT, "SB_UNIT" }, \
317 { XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \
318 { XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \
319 { XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \
320 { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \
321 { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \
322 { XFS_TRANS_SB_COUNT, "SB_COUNT" }, \
323 { XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \
324 { XFS_TRANS_DUMMY1, "DUMMY1" }, \
325 { XFS_TRANS_DUMMY2, "DUMMY2" }, \
326 { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" }
327
328/*
329 * This structure is used to track log items associated with
330 * a transaction. It points to the log item and keeps some
331 * flags to track the state of the log item. It also tracks
332 * the amount of space needed to log the item it describes
333 * once we get to commit processing (see xfs_trans_commit()).
334 */
335struct xfs_log_item_desc {
336 struct xfs_log_item *lid_item;
337 struct list_head lid_trans;
338 unsigned char lid_flags;
339};
340
341#define XFS_LID_DIRTY 0x1
342
343/*
344 * Values for t_flags.
345 */
346#define XFS_TRANS_DIRTY 0x01 /* something needs to be logged */
347#define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */
348#define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */
349#define XFS_TRANS_SYNC 0x08 /* make commit synchronous */
350#define XFS_TRANS_DQ_DIRTY 0x10 /* at least one dquot in trx dirty */
351#define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */
352#define XFS_TRANS_FREEZE_PROT 0x40 /* Transaction has elevated writer
353 count in superblock */
354
355/*
356 * Values for call flags parameter.
357 */
358#define XFS_TRANS_RELEASE_LOG_RES 0x4
359#define XFS_TRANS_ABORT 0x8
360
361/*
362 * Field values for xfs_trans_mod_sb.
363 */
364#define XFS_TRANS_SB_ICOUNT 0x00000001
365#define XFS_TRANS_SB_IFREE 0x00000002
366#define XFS_TRANS_SB_FDBLOCKS 0x00000004
367#define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008
368#define XFS_TRANS_SB_FREXTENTS 0x00000010
369#define XFS_TRANS_SB_RES_FREXTENTS 0x00000020
370#define XFS_TRANS_SB_DBLOCKS 0x00000040
371#define XFS_TRANS_SB_AGCOUNT 0x00000080
372#define XFS_TRANS_SB_IMAXPCT 0x00000100
373#define XFS_TRANS_SB_REXTSIZE 0x00000200
374#define XFS_TRANS_SB_RBMBLOCKS 0x00000400
375#define XFS_TRANS_SB_RBLOCKS 0x00000800
376#define XFS_TRANS_SB_REXTENTS 0x00001000
377#define XFS_TRANS_SB_REXTSLOG 0x00002000
378
379/*
380 * Here we centralize the specification of XFS meta-data buffer
381 * reference count values. This determine how hard the buffer
382 * cache tries to hold onto the buffer.
383 */
384#define XFS_AGF_REF 4
385#define XFS_AGI_REF 4
386#define XFS_AGFL_REF 3
387#define XFS_INO_BTREE_REF 3
388#define XFS_ALLOC_BTREE_REF 2
389#define XFS_BMAP_BTREE_REF 2
390#define XFS_DIR_BTREE_REF 2
391#define XFS_INO_REF 2
392#define XFS_ATTR_BTREE_REF 1
393#define XFS_DQUOT_REF 1
394
69432832
DC
395/*
396 * Inode Log Item Format definitions.
397 *
398 * This is the structure used to lay out an inode log item in the
399 * log. The size of the inline data/extents/b-tree root to be logged
400 * (if any) is indicated in the ilf_dsize field. Changes to this structure
401 * must be added on to the end.
402 */
403typedef struct xfs_inode_log_format {
404 __uint16_t ilf_type; /* inode log item type */
405 __uint16_t ilf_size; /* size of this item */
406 __uint32_t ilf_fields; /* flags for fields logged */
407 __uint16_t ilf_asize; /* size of attr d/ext/root */
408 __uint16_t ilf_dsize; /* size of data/ext/root */
409 __uint64_t ilf_ino; /* inode number */
410 union {
411 __uint32_t ilfu_rdev; /* rdev value for dev inode*/
412 uuid_t ilfu_uuid; /* mount point value */
413 } ilf_u;
414 __int64_t ilf_blkno; /* blkno of inode buffer */
415 __int32_t ilf_len; /* len of inode buffer */
416 __int32_t ilf_boffset; /* off of inode in buffer */
417} xfs_inode_log_format_t;
418
419typedef struct xfs_inode_log_format_32 {
420 __uint16_t ilf_type; /* inode log item type */
421 __uint16_t ilf_size; /* size of this item */
422 __uint32_t ilf_fields; /* flags for fields logged */
423 __uint16_t ilf_asize; /* size of attr d/ext/root */
424 __uint16_t ilf_dsize; /* size of data/ext/root */
425 __uint64_t ilf_ino; /* inode number */
426 union {
427 __uint32_t ilfu_rdev; /* rdev value for dev inode*/
428 uuid_t ilfu_uuid; /* mount point value */
429 } ilf_u;
430 __int64_t ilf_blkno; /* blkno of inode buffer */
431 __int32_t ilf_len; /* len of inode buffer */
432 __int32_t ilf_boffset; /* off of inode in buffer */
433} __attribute__((packed)) xfs_inode_log_format_32_t;
434
435typedef struct xfs_inode_log_format_64 {
436 __uint16_t ilf_type; /* inode log item type */
437 __uint16_t ilf_size; /* size of this item */
438 __uint32_t ilf_fields; /* flags for fields logged */
439 __uint16_t ilf_asize; /* size of attr d/ext/root */
440 __uint16_t ilf_dsize; /* size of data/ext/root */
441 __uint32_t ilf_pad; /* pad for 64 bit boundary */
442 __uint64_t ilf_ino; /* inode number */
443 union {
444 __uint32_t ilfu_rdev; /* rdev value for dev inode*/
445 uuid_t ilfu_uuid; /* mount point value */
446 } ilf_u;
447 __int64_t ilf_blkno; /* blkno of inode buffer */
448 __int32_t ilf_len; /* len of inode buffer */
449 __int32_t ilf_boffset; /* off of inode in buffer */
450} xfs_inode_log_format_64_t;
451
452/*
453 * Flags for xfs_trans_log_inode flags field.
454 */
455#define XFS_ILOG_CORE 0x001 /* log standard inode fields */
456#define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */
457#define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
458#define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */
459#define XFS_ILOG_DEV 0x010 /* log the dev field */
460#define XFS_ILOG_UUID 0x020 /* log the uuid field */
461#define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */
462#define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */
463#define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */
464
465
466/*
467 * The timestamps are dirty, but not necessarily anything else in the inode
468 * core. Unlike the other fields above this one must never make it to disk
469 * in the ilf_fields of the inode_log_format, but is purely store in-memory in
470 * ili_fields in the inode_log_item.
471 */
472#define XFS_ILOG_TIMESTAMP 0x4000
473
474#define XFS_ILOG_NONCORE (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
475 XFS_ILOG_DBROOT | XFS_ILOG_DEV | \
476 XFS_ILOG_UUID | XFS_ILOG_ADATA | \
477 XFS_ILOG_AEXT | XFS_ILOG_ABROOT)
478
479#define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
480 XFS_ILOG_DBROOT)
481
482#define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
483 XFS_ILOG_ABROOT)
484
485#define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \
486 XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \
487 XFS_ILOG_DEV | XFS_ILOG_UUID | \
488 XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
489 XFS_ILOG_ABROOT | XFS_ILOG_TIMESTAMP)
490
491static inline int xfs_ilog_fbroot(int w)
492{
493 return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
494}
495
496static inline int xfs_ilog_fext(int w)
497{
498 return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
499}
500
501static inline int xfs_ilog_fdata(int w)
502{
503 return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
504}
505
506/*
507 * Incore version of the on-disk inode core structures. We log this directly
508 * into the journal in host CPU format (for better or worse) and as such
509 * directly mirrors the xfs_dinode structure as it must contain all the same
510 * information.
511 */
512typedef struct xfs_ictimestamp {
513 __int32_t t_sec; /* timestamp seconds */
514 __int32_t t_nsec; /* timestamp nanoseconds */
515} xfs_ictimestamp_t;
516
517/*
518 * NOTE: This structure must be kept identical to struct xfs_dinode
519 * in xfs_dinode.h except for the endianness annotations.
520 */
521typedef struct xfs_icdinode {
522 __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */
523 __uint16_t di_mode; /* mode and type of file */
524 __int8_t di_version; /* inode version */
525 __int8_t di_format; /* format of di_c data */
526 __uint16_t di_onlink; /* old number of links to file */
527 __uint32_t di_uid; /* owner's user id */
528 __uint32_t di_gid; /* owner's group id */
529 __uint32_t di_nlink; /* number of links to file */
530 __uint16_t di_projid_lo; /* lower part of owner's project id */
531 __uint16_t di_projid_hi; /* higher part of owner's project id */
532 __uint8_t di_pad[6]; /* unused, zeroed space */
533 __uint16_t di_flushiter; /* incremented on flush */
534 xfs_ictimestamp_t di_atime; /* time last accessed */
535 xfs_ictimestamp_t di_mtime; /* time last modified */
536 xfs_ictimestamp_t di_ctime; /* time created/inode modified */
537 xfs_fsize_t di_size; /* number of bytes in file */
538 xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */
539 xfs_extlen_t di_extsize; /* basic/minimum extent size for file */
540 xfs_extnum_t di_nextents; /* number of extents in data fork */
541 xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/
542 __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */
543 __int8_t di_aformat; /* format of attr fork's data */
544 __uint32_t di_dmevmask; /* DMIG event mask */
545 __uint16_t di_dmstate; /* DMIG state info */
546 __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */
547 __uint32_t di_gen; /* generation number */
548
549 /* di_next_unlinked is the only non-core field in the old dinode */
550 xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */
551
552 /* start of the extended dinode, writable fields */
553 __uint32_t di_crc; /* CRC of the inode */
554 __uint64_t di_changecount; /* number of attribute changes */
555 xfs_lsn_t di_lsn; /* flush sequence */
556 __uint64_t di_flags2; /* more random flags */
557 __uint8_t di_pad2[16]; /* more padding for future expansion */
558
559 /* fields only written to during inode creation */
560 xfs_ictimestamp_t di_crtime; /* time created */
561 xfs_ino_t di_ino; /* inode number */
562 uuid_t di_uuid; /* UUID of the filesystem */
563
564 /* structure must be padded to 64 bit alignment */
565} xfs_icdinode_t;
566
567static inline uint xfs_icdinode_size(int version)
568{
569 if (version == 3)
570 return sizeof(struct xfs_icdinode);
571 return offsetof(struct xfs_icdinode, di_next_unlinked);
572}
a8da0da2
DC
573
574/*
575 * Buffer Log Format defintions
576 *
577 * These are the physical dirty bitmap defintions for the log format structure.
578 */
579#define XFS_BLF_CHUNK 128
580#define XFS_BLF_SHIFT 7
581#define BIT_TO_WORD_SHIFT 5
582#define NBWORD (NBBY * sizeof(unsigned int))
583
584/*
585 * This flag indicates that the buffer contains on disk inodes
586 * and requires special recovery handling.
587 */
588#define XFS_BLF_INODE_BUF (1<<0)
589
590/*
591 * This flag indicates that the buffer should not be replayed
592 * during recovery because its blocks are being freed.
593 */
594#define XFS_BLF_CANCEL (1<<1)
595
596/*
597 * This flag indicates that the buffer contains on disk
598 * user or group dquots and may require special recovery handling.
599 */
600#define XFS_BLF_UDQUOT_BUF (1<<2)
601#define XFS_BLF_PDQUOT_BUF (1<<3)
602#define XFS_BLF_GDQUOT_BUF (1<<4)
603
604/*
605 * This is the structure used to lay out a buf log item in the
606 * log. The data map describes which 128 byte chunks of the buffer
607 * have been logged.
608 */
609#define XFS_BLF_DATAMAP_SIZE ((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD)
610
611typedef struct xfs_buf_log_format {
612 unsigned short blf_type; /* buf log item type indicator */
613 unsigned short blf_size; /* size of this item */
614 ushort blf_flags; /* misc state */
615 ushort blf_len; /* number of blocks in this buf */
616 __int64_t blf_blkno; /* starting blkno of this buf */
617 unsigned int blf_map_size; /* used size of data bitmap in words */
618 unsigned int blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */
619} xfs_buf_log_format_t;
620
621/*
622 * All buffers now need to tell recovery where the magic number
623 * is so that it can verify and calculate the CRCs on the buffer correctly
624 * once the changes have been replayed into the buffer.
625 *
626 * The type value is held in the upper 5 bits of the blf_flags field, which is
627 * an unsigned 16 bit field. Hence we need to shift it 11 bits up and down.
628 */
629#define XFS_BLFT_BITS 5
630#define XFS_BLFT_SHIFT 11
631#define XFS_BLFT_MASK (((1 << XFS_BLFT_BITS) - 1) << XFS_BLFT_SHIFT)
632
633enum xfs_blft {
634 XFS_BLFT_UNKNOWN_BUF = 0,
635 XFS_BLFT_UDQUOT_BUF,
636 XFS_BLFT_PDQUOT_BUF,
637 XFS_BLFT_GDQUOT_BUF,
638 XFS_BLFT_BTREE_BUF,
639 XFS_BLFT_AGF_BUF,
640 XFS_BLFT_AGFL_BUF,
641 XFS_BLFT_AGI_BUF,
642 XFS_BLFT_DINO_BUF,
643 XFS_BLFT_SYMLINK_BUF,
644 XFS_BLFT_DIR_BLOCK_BUF,
645 XFS_BLFT_DIR_DATA_BUF,
646 XFS_BLFT_DIR_FREE_BUF,
647 XFS_BLFT_DIR_LEAF1_BUF,
648 XFS_BLFT_DIR_LEAFN_BUF,
649 XFS_BLFT_DA_NODE_BUF,
650 XFS_BLFT_ATTR_LEAF_BUF,
651 XFS_BLFT_ATTR_RMT_BUF,
652 XFS_BLFT_SB_BUF,
653 XFS_BLFT_MAX_BUF = (1 << XFS_BLFT_BITS),
654};
655
656static inline void
657xfs_blft_to_flags(struct xfs_buf_log_format *blf, enum xfs_blft type)
658{
659 ASSERT(type > XFS_BLFT_UNKNOWN_BUF && type < XFS_BLFT_MAX_BUF);
660 blf->blf_flags &= ~XFS_BLFT_MASK;
661 blf->blf_flags |= ((type << XFS_BLFT_SHIFT) & XFS_BLFT_MASK);
662}
663
664static inline __uint16_t
665xfs_blft_from_flags(struct xfs_buf_log_format *blf)
666{
667 return (blf->blf_flags & XFS_BLFT_MASK) >> XFS_BLFT_SHIFT;
668}
669
9fbe24d9
DC
670/*
671 * EFI/EFD log format definitions
672 */
673typedef struct xfs_extent {
674 xfs_dfsbno_t ext_start;
675 xfs_extlen_t ext_len;
676} xfs_extent_t;
677
678/*
679 * Since an xfs_extent_t has types (start:64, len: 32)
680 * there are different alignments on 32 bit and 64 bit kernels.
681 * So we provide the different variants for use by a
682 * conversion routine.
683 */
684typedef struct xfs_extent_32 {
685 __uint64_t ext_start;
686 __uint32_t ext_len;
687} __attribute__((packed)) xfs_extent_32_t;
688
689typedef struct xfs_extent_64 {
690 __uint64_t ext_start;
691 __uint32_t ext_len;
692 __uint32_t ext_pad;
693} xfs_extent_64_t;
694
695/*
696 * This is the structure used to lay out an efi log item in the
697 * log. The efi_extents field is a variable size array whose
698 * size is given by efi_nextents.
699 */
700typedef struct xfs_efi_log_format {
701 __uint16_t efi_type; /* efi log item type */
702 __uint16_t efi_size; /* size of this item */
703 __uint32_t efi_nextents; /* # extents to free */
704 __uint64_t efi_id; /* efi identifier */
705 xfs_extent_t efi_extents[1]; /* array of extents to free */
706} xfs_efi_log_format_t;
707
708typedef struct xfs_efi_log_format_32 {
709 __uint16_t efi_type; /* efi log item type */
710 __uint16_t efi_size; /* size of this item */
711 __uint32_t efi_nextents; /* # extents to free */
712 __uint64_t efi_id; /* efi identifier */
713 xfs_extent_32_t efi_extents[1]; /* array of extents to free */
714} __attribute__((packed)) xfs_efi_log_format_32_t;
715
716typedef struct xfs_efi_log_format_64 {
717 __uint16_t efi_type; /* efi log item type */
718 __uint16_t efi_size; /* size of this item */
719 __uint32_t efi_nextents; /* # extents to free */
720 __uint64_t efi_id; /* efi identifier */
721 xfs_extent_64_t efi_extents[1]; /* array of extents to free */
722} xfs_efi_log_format_64_t;
723
724/*
725 * This is the structure used to lay out an efd log item in the
726 * log. The efd_extents array is a variable size array whose
727 * size is given by efd_nextents;
728 */
729typedef struct xfs_efd_log_format {
730 __uint16_t efd_type; /* efd log item type */
731 __uint16_t efd_size; /* size of this item */
732 __uint32_t efd_nextents; /* # of extents freed */
733 __uint64_t efd_efi_id; /* id of corresponding efi */
734 xfs_extent_t efd_extents[1]; /* array of extents freed */
735} xfs_efd_log_format_t;
736
737typedef struct xfs_efd_log_format_32 {
738 __uint16_t efd_type; /* efd log item type */
739 __uint16_t efd_size; /* size of this item */
740 __uint32_t efd_nextents; /* # of extents freed */
741 __uint64_t efd_efi_id; /* id of corresponding efi */
742 xfs_extent_32_t efd_extents[1]; /* array of extents freed */
743} __attribute__((packed)) xfs_efd_log_format_32_t;
744
745typedef struct xfs_efd_log_format_64 {
746 __uint16_t efd_type; /* efd log item type */
747 __uint16_t efd_size; /* size of this item */
748 __uint32_t efd_nextents; /* # of extents freed */
749 __uint64_t efd_efi_id; /* id of corresponding efi */
750 xfs_extent_64_t efd_extents[1]; /* array of extents freed */
751} xfs_efd_log_format_64_t;
752
6ca1c906
DC
753/*
754 * Dquot Log format definitions.
755 *
756 * The first two fields must be the type and size fitting into
757 * 32 bits : log_recovery code assumes that.
758 */
759typedef struct xfs_dq_logformat {
760 __uint16_t qlf_type; /* dquot log item type */
761 __uint16_t qlf_size; /* size of this item */
762 xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */
763 __int64_t qlf_blkno; /* blkno of dquot buffer */
764 __int32_t qlf_len; /* len of dquot buffer */
765 __uint32_t qlf_boffset; /* off of dquot in buffer */
766} xfs_dq_logformat_t;
767
768/*
769 * log format struct for QUOTAOFF records.
770 * The first two fields must be the type and size fitting into
771 * 32 bits : log_recovery code assumes that.
772 * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer
773 * to the first and ensures that the first logitem is taken out of the AIL
774 * only when the last one is securely committed.
775 */
776typedef struct xfs_qoff_logformat {
777 unsigned short qf_type; /* quotaoff log item type */
778 unsigned short qf_size; /* size of this item */
779 unsigned int qf_flags; /* USR and/or GRP */
780 char qf_pad[12]; /* padding for future */
781} xfs_qoff_logformat_t;
782
783
784/*
785 * Disk quotas status in m_qflags, and also sb_qflags. 16 bits.
786 */
787#define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */
788#define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */
789#define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */
790#define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */
791#define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */
792#define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */
793#define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */
794
795/*
796 * Conversion to and from the combined OQUOTA flag (if necessary)
797 * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk()
798 */
799#define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */
800#define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */
801#define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */
802#define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */
803
804#define XFS_ALL_QUOTA_ACCT \
805 (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
806#define XFS_ALL_QUOTA_ENFD \
807 (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD)
808#define XFS_ALL_QUOTA_CHKD \
809 (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)
810
9cd047f3
DC
811/*
812 * Inode create log item structure
813 *
814 * Log recovery assumes the first two entries are the type and size and they fit
815 * in 32 bits. Also in host order (ugh) so they have to be 32 bit aligned so
816 * decoding can be done correctly.
817 */
818struct xfs_icreate_log {
819 __uint16_t icl_type; /* type of log format structure */
820 __uint16_t icl_size; /* size of log format structure */
821 __be32 icl_ag; /* ag being allocated in */
822 __be32 icl_agbno; /* start block of inode range */
823 __be32 icl_count; /* number of inodes to initialise */
824 __be32 icl_isize; /* size of inodes */
825 __be32 icl_length; /* length of extent to initialise */
826 __be32 icl_gen; /* inode generation number to use */
827};
828
fc06c6d0 829#endif /* __XFS_LOG_FORMAT_H__ */
This page took 0.059265 seconds and 5 git commands to generate.