~wb-munzinger/+junk/ocfs2-tools

« back to all changes in this revision

Viewing changes to include/ocfs2/jbd2.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2009-07-06 07:26:30 UTC
  • mfrom: (1.1.7 upstream) (0.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090706072630-59335sl51k3rvu74
Tags: 1.4.2-1
* New upstream release (Closes: #535471).
* Drop patch for limits.h, included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c; c-basic-offset: 8; -*-
 
2
 * vim: noexpandtab sw=8 ts=8 sts=0:
 
3
 *
 
4
 * jbd2.h
 
5
 *
 
6
 * header file extracted from linux/include/linux/jbd2.h
 
7
 *
 
8
 * Originally written by Stephen C. Tweedie <sct@redhat.com>
 
9
 *
 
10
 * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
 
11
 *
 
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.
 
15
 *
 
16
 * Definitions for transaction data structures for the buffer cache
 
17
 * filesystem journaling support.
 
18
 */
 
19
 
 
20
#ifndef _JBD2_H_
 
21
#define _JBD2_H_
 
22
 
 
23
/*
 
24
 * Internal structures used by the logging mechanism:
 
25
 */
 
26
 
 
27
#define JBD2_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
 
28
 
 
29
/*
 
30
 * On-disk structures
 
31
 */
 
32
 
 
33
/* 
 
34
 * Descriptor block types:
 
35
 */
 
36
 
 
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
 
42
 
 
43
/*
 
44
 * Standard header for all descriptor blocks:
 
45
 */
 
46
typedef struct journal_header_s
 
47
{
 
48
        __be32          h_magic;
 
49
        __be32          h_blocktype;
 
50
        __be32          h_sequence;
 
51
} journal_header_t;
 
52
 
 
53
/*
 
54
 * Checksum types.
 
55
 */
 
56
#define JBD2_CRC32_CHKSUM       1
 
57
#define JBD2_MD5_CHKSUM         2
 
58
#define JBD2_SHA2_CHKSUM        3
 
59
 
 
60
#define JBD2_CRC32_CHKSUM_SIZE  4
 
61
 
 
62
#define JBD2_CHECKSUM_BYTES (32 / sizeof(uint32_t))
 
63
/*
 
64
 * Commit block header for storing transactional checksums:
 
65
 */
 
66
struct commit_header {
 
67
        __be32          h_magic;
 
68
        __be32          h_blocktype;
 
69
        __be32          h_sequence;
 
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];
 
74
        __be64          h_commit_sec;
 
75
        __be32          h_commit_nsec;
 
76
};
 
77
 
 
78
/*
 
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.
 
83
 */
 
84
typedef struct journal_block_tag_s
 
85
{
 
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;
 
90
 
 
91
#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
 
92
#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t))
 
93
 
 
94
/* 
 
95
 * The revoke descriptor: used on disk to describe a series of blocks to
 
96
 * be revoked from the log 
 
97
 */
 
98
typedef struct journal_revoke_header_s
 
99
{
 
100
        journal_header_t r_header;
 
101
        int              r_count;       /* Count of bytes used in the block */
 
102
} journal_revoke_header_t;
 
103
 
 
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 */
 
109
 
 
110
/*
 
111
 * The journal superblock.  All fields are in big-endian byte order.
 
112
 */
 
113
typedef struct journal_superblock_s
 
114
{
 
115
/* 0x0000 */
 
116
        journal_header_t s_header;
 
117
 
 
118
/* 0x000C */
 
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 */
 
123
        
 
124
/* 0x0018 */
 
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 */
 
128
 
 
129
/* 0x0020 */
 
130
        /* Error value, as set by jbd2_journal_abort(). */
 
131
        __be32  s_errno;
 
132
 
 
133
/* 0x0024 */
 
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 */
 
138
/* 0x0030 */
 
139
        __u8    s_uuid[16];             /* 128-bit uuid for journal */
 
140
 
 
141
/* 0x0040 */
 
142
        __be32  s_nr_users;             /* Nr of filesystems sharing log */
 
143
        
 
144
        __be32  s_dynsuper;             /* Blocknr of dynamic superblock copy*/
 
145
        
 
146
/* 0x0048 */
 
147
        __be32  s_max_transaction;      /* Limit of journal blocks per trans.*/
 
148
        __be32  s_max_trans_data;       /* Limit of data blocks per trans. */
 
149
 
 
150
/* 0x0050 */
 
151
        __be32  s_padding[44];
 
152
 
 
153
/* 0x0100 */
 
154
        __u8    s_users[16*48];         /* ids of all fs'es sharing the log */
 
155
/* 0x0400 */
 
156
} journal_superblock_t;
 
157
 
 
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))
 
167
 
 
168
#define JBD2_FEATURE_COMPAT_CHECKSUM            0x00000001
 
169
 
 
170
#define JBD2_FEATURE_INCOMPAT_REVOKE            0x00000001
 
171
#define JBD2_FEATURE_INCOMPAT_64BIT             0x00000002
 
172
#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT      0x00000004
 
173
 
 
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)
 
179
 
 
180
#endif          /* _JBD2_H_ */