1
/* -*- mode: c; c-basic-offset: 8; -*-
2
* vim: noexpandtab sw=8 ts=8 sts=0:
6
* header file extracted from linux/include/linux/jbd2.h
8
* Originally written by Stephen C. Tweedie <sct@redhat.com>
10
* Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
12
* This file is part of the Linux kernel and is made available under
13
* the terms of the GNU General Public License version 2 as published by
14
* the Free Software Foundation.
16
* Definitions for transaction data structures for the buffer cache
17
* filesystem journaling support.
24
* Internal structures used by the logging mechanism:
27
#define JBD2_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
34
* Descriptor block types:
37
#define JBD2_DESCRIPTOR_BLOCK 1
38
#define JBD2_COMMIT_BLOCK 2
39
#define JBD2_SUPERBLOCK_V1 3
40
#define JBD2_SUPERBLOCK_V2 4
41
#define JBD2_REVOKE_BLOCK 5
44
* Standard header for all descriptor blocks:
46
typedef struct journal_header_s
56
#define JBD2_CRC32_CHKSUM 1
57
#define JBD2_MD5_CHKSUM 2
58
#define JBD2_SHA2_CHKSUM 3
60
#define JBD2_CRC32_CHKSUM_SIZE 4
62
#define JBD2_CHECKSUM_BYTES (32 / sizeof(uint32_t))
64
* Commit block header for storing transactional checksums:
66
struct commit_header {
70
unsigned char h_chksum_type;
71
unsigned char h_chksum_size;
72
unsigned char h_padding[2];
73
__be32 h_chksum[JBD2_CHECKSUM_BYTES];
79
* The block tag: used to describe a single buffer in the journal.
80
* t_blocknr_high is only used if INCOMPAT_64BIT is set, so this
81
* raw struct shouldn't be used for pointer math or sizeof() - use
82
* journal_tag_bytes(journal) instead to compute this.
84
typedef struct journal_block_tag_s
86
__be32 t_blocknr; /* The on-disk block number */
87
__be32 t_flags; /* See below */
88
__be32 t_blocknr_high; /* most-significant high 32bits. */
89
} journal_block_tag_t;
91
#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
92
#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t))
95
* The revoke descriptor: used on disk to describe a series of blocks to
96
* be revoked from the log
98
typedef struct journal_revoke_header_s
100
journal_header_t r_header;
101
int r_count; /* Count of bytes used in the block */
102
} journal_revoke_header_t;
104
/* Definitions for the journal tag flags word: */
105
#define JBD2_FLAG_ESCAPE 1 /* on-disk block is escaped */
106
#define JBD2_FLAG_SAME_UUID 2 /* block has same uuid as previous */
107
#define JBD2_FLAG_DELETED 4 /* block deleted by this transaction */
108
#define JBD2_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
111
* The journal superblock. All fields are in big-endian byte order.
113
typedef struct journal_superblock_s
116
journal_header_t s_header;
119
/* Static information describing the journal */
120
__be32 s_blocksize; /* journal device blocksize */
121
__be32 s_maxlen; /* total blocks in journal file */
122
__be32 s_first; /* first block of log information */
125
/* Dynamic information describing the current state of the log */
126
__be32 s_sequence; /* first commit ID expected in log */
127
__be32 s_start; /* blocknr of start of log */
130
/* Error value, as set by jbd2_journal_abort(). */
134
/* Remaining fields are only valid in a version-2 superblock */
135
__be32 s_feature_compat; /* compatible feature set */
136
__be32 s_feature_incompat; /* incompatible feature set */
137
__be32 s_feature_ro_compat; /* readonly-compatible feature set */
139
__u8 s_uuid[16]; /* 128-bit uuid for journal */
142
__be32 s_nr_users; /* Nr of filesystems sharing log */
144
__be32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
147
__be32 s_max_transaction; /* Limit of journal blocks per trans.*/
148
__be32 s_max_trans_data; /* Limit of data blocks per trans. */
151
__be32 s_padding[44];
154
__u8 s_users[16*48]; /* ids of all fs'es sharing the log */
156
} journal_superblock_t;
158
#define JBD2_HAS_COMPAT_FEATURE(jsb,mask) \
159
(((jsb)->s_header.h_blocktype == JBD2_SUPERBLOCK_V2) && \
160
((jsb)->s_feature_compat & mask))
161
#define JBD2_HAS_RO_COMPAT_FEATURE(jsb,mask) \
162
(((jsb)->s_header.h_blocktype == JBD2_SUPERBLOCK_V2) && \
163
((jsb)->s_feature_ro_compat & mask))
164
#define JBD2_HAS_INCOMPAT_FEATURE(jsb,mask) \
165
(((jsb)->s_header.h_blocktype == JBD2_SUPERBLOCK_V2) && \
166
((jsb)->s_feature_incompat & mask))
168
#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
170
#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
171
#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
172
#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
174
/* Features known to this kernel version: */
175
#define JBD2_KNOWN_COMPAT_FEATURES 0
176
#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
177
#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE \
178
| JBD2_FEATURE_INCOMPAT_64BIT)
180
#endif /* _JBD2_H_ */