1 | /* vi: set sw=4 ts=4: */
|
---|
2 | /*
|
---|
3 | * linux/include/linux/jbd.h
|
---|
4 | *
|
---|
5 | * Written by Stephen C. Tweedie <sct@redhat.com>
|
---|
6 | *
|
---|
7 | * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
|
---|
8 | *
|
---|
9 | * This file is part of the Linux kernel and is made available under
|
---|
10 | * the terms of the GNU General Public License, version 2, or at your
|
---|
11 | * option, any later version, incorporated herein by reference.
|
---|
12 | *
|
---|
13 | * Definitions for transaction data structures for the buffer cache
|
---|
14 | * filesystem journaling support.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef _LINUX_JBD_H
|
---|
18 | #define _LINUX_JBD_H
|
---|
19 |
|
---|
20 | #include <sys/types.h>
|
---|
21 | #include <linux/types.h>
|
---|
22 | #include "ext2fs.h"
|
---|
23 |
|
---|
24 | /*
|
---|
25 | * Standard header for all descriptor blocks:
|
---|
26 | */
|
---|
27 |
|
---|
28 | typedef struct journal_header_s
|
---|
29 | {
|
---|
30 | __u32 h_magic;
|
---|
31 | __u32 h_blocktype;
|
---|
32 | __u32 h_sequence;
|
---|
33 | } journal_header_t;
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * This is the global e2fsck structure.
|
---|
37 | */
|
---|
38 | typedef struct e2fsck_struct *e2fsck_t;
|
---|
39 |
|
---|
40 |
|
---|
41 | struct inode {
|
---|
42 | e2fsck_t i_ctx;
|
---|
43 | ext2_ino_t i_ino;
|
---|
44 | struct ext2_inode i_ext2;
|
---|
45 | };
|
---|
46 |
|
---|
47 |
|
---|
48 | /*
|
---|
49 | * The journal superblock. All fields are in big-endian byte order.
|
---|
50 | */
|
---|
51 | typedef struct journal_superblock_s
|
---|
52 | {
|
---|
53 | /* 0x0000 */
|
---|
54 | journal_header_t s_header;
|
---|
55 |
|
---|
56 | /* 0x000C */
|
---|
57 | /* Static information describing the journal */
|
---|
58 | __u32 s_blocksize; /* journal device blocksize */
|
---|
59 | __u32 s_maxlen; /* total blocks in journal file */
|
---|
60 | __u32 s_first; /* first block of log information */
|
---|
61 |
|
---|
62 | /* 0x0018 */
|
---|
63 | /* Dynamic information describing the current state of the log */
|
---|
64 | __u32 s_sequence; /* first commit ID expected in log */
|
---|
65 | __u32 s_start; /* blocknr of start of log */
|
---|
66 |
|
---|
67 | /* 0x0020 */
|
---|
68 | /* Error value, as set by journal_abort(). */
|
---|
69 | __s32 s_errno;
|
---|
70 |
|
---|
71 | /* 0x0024 */
|
---|
72 | /* Remaining fields are only valid in a version-2 superblock */
|
---|
73 | __u32 s_feature_compat; /* compatible feature set */
|
---|
74 | __u32 s_feature_incompat; /* incompatible feature set */
|
---|
75 | __u32 s_feature_ro_compat; /* readonly-compatible feature set */
|
---|
76 | /* 0x0030 */
|
---|
77 | __u8 s_uuid[16]; /* 128-bit uuid for journal */
|
---|
78 |
|
---|
79 | /* 0x0040 */
|
---|
80 | __u32 s_nr_users; /* Nr of filesystems sharing log */
|
---|
81 |
|
---|
82 | __u32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
|
---|
83 |
|
---|
84 | /* 0x0048 */
|
---|
85 | __u32 s_max_transaction; /* Limit of journal blocks per trans.*/
|
---|
86 | __u32 s_max_trans_data; /* Limit of data blocks per trans. */
|
---|
87 |
|
---|
88 | /* 0x0050 */
|
---|
89 | __u32 s_padding[44];
|
---|
90 |
|
---|
91 | /* 0x0100 */
|
---|
92 | __u8 s_users[16*48]; /* ids of all fs'es sharing the log */
|
---|
93 | /* 0x0400 */
|
---|
94 | } journal_superblock_t;
|
---|
95 |
|
---|
96 |
|
---|
97 | extern int journal_blocks_per_page(struct inode *inode);
|
---|
98 | extern int jbd_blocks_per_page(struct inode *inode);
|
---|
99 |
|
---|
100 | #define JFS_MIN_JOURNAL_BLOCKS 1024
|
---|
101 |
|
---|
102 |
|
---|
103 | /*
|
---|
104 | * Internal structures used by the logging mechanism:
|
---|
105 | */
|
---|
106 |
|
---|
107 | #define JFS_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
|
---|
108 |
|
---|
109 | /*
|
---|
110 | * Descriptor block types:
|
---|
111 | */
|
---|
112 |
|
---|
113 | #define JFS_DESCRIPTOR_BLOCK 1
|
---|
114 | #define JFS_COMMIT_BLOCK 2
|
---|
115 | #define JFS_SUPERBLOCK_V1 3
|
---|
116 | #define JFS_SUPERBLOCK_V2 4
|
---|
117 | #define JFS_REVOKE_BLOCK 5
|
---|
118 |
|
---|
119 | /*
|
---|
120 | * The block tag: used to describe a single buffer in the journal
|
---|
121 | */
|
---|
122 | typedef struct journal_block_tag_s
|
---|
123 | {
|
---|
124 | __u32 t_blocknr; /* The on-disk block number */
|
---|
125 | __u32 t_flags; /* See below */
|
---|
126 | } journal_block_tag_t;
|
---|
127 |
|
---|
128 | /*
|
---|
129 | * The revoke descriptor: used on disk to describe a series of blocks to
|
---|
130 | * be revoked from the log
|
---|
131 | */
|
---|
132 | typedef struct journal_revoke_header_s
|
---|
133 | {
|
---|
134 | journal_header_t r_header;
|
---|
135 | int r_count; /* Count of bytes used in the block */
|
---|
136 | } journal_revoke_header_t;
|
---|
137 |
|
---|
138 |
|
---|
139 | /* Definitions for the journal tag flags word: */
|
---|
140 | #define JFS_FLAG_ESCAPE 1 /* on-disk block is escaped */
|
---|
141 | #define JFS_FLAG_SAME_UUID 2 /* block has same uuid as previous */
|
---|
142 | #define JFS_FLAG_DELETED 4 /* block deleted by this transaction */
|
---|
143 | #define JFS_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
|
---|
144 |
|
---|
145 |
|
---|
146 |
|
---|
147 |
|
---|
148 | #define JFS_HAS_COMPAT_FEATURE(j,mask) \
|
---|
149 | ((j)->j_format_version >= 2 && \
|
---|
150 | ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
|
---|
151 | #define JFS_HAS_RO_COMPAT_FEATURE(j,mask) \
|
---|
152 | ((j)->j_format_version >= 2 && \
|
---|
153 | ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
|
---|
154 | #define JFS_HAS_INCOMPAT_FEATURE(j,mask) \
|
---|
155 | ((j)->j_format_version >= 2 && \
|
---|
156 | ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
|
---|
157 |
|
---|
158 | #define JFS_FEATURE_INCOMPAT_REVOKE 0x00000001
|
---|
159 |
|
---|
160 | /* Features known to this kernel version: */
|
---|
161 | #define JFS_KNOWN_COMPAT_FEATURES 0
|
---|
162 | #define JFS_KNOWN_ROCOMPAT_FEATURES 0
|
---|
163 | #define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE
|
---|
164 |
|
---|
165 | /* Comparison functions for transaction IDs: perform comparisons using
|
---|
166 | * modulo arithmetic so that they work over sequence number wraps. */
|
---|
167 |
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * Definitions which augment the buffer_head layer
|
---|
171 | */
|
---|
172 |
|
---|
173 | /* journaling buffer types */
|
---|
174 | #define BJ_None 0 /* Not journaled */
|
---|
175 | #define BJ_SyncData 1 /* Normal data: flush before commit */
|
---|
176 | #define BJ_AsyncData 2 /* writepage data: wait on it before commit */
|
---|
177 | #define BJ_Metadata 3 /* Normal journaled metadata */
|
---|
178 | #define BJ_Forget 4 /* Buffer superceded by this transaction */
|
---|
179 | #define BJ_IO 5 /* Buffer is for temporary IO use */
|
---|
180 | #define BJ_Shadow 6 /* Buffer contents being shadowed to the log */
|
---|
181 | #define BJ_LogCtl 7 /* Buffer contains log descriptors */
|
---|
182 | #define BJ_Reserved 8 /* Buffer is reserved for access by journal */
|
---|
183 | #define BJ_Types 9
|
---|
184 |
|
---|
185 |
|
---|
186 | struct kdev_s {
|
---|
187 | e2fsck_t k_ctx;
|
---|
188 | int k_dev;
|
---|
189 | };
|
---|
190 |
|
---|
191 | typedef struct kdev_s *kdev_t;
|
---|
192 | typedef unsigned int tid_t;
|
---|
193 |
|
---|
194 | struct journal_s
|
---|
195 | {
|
---|
196 | unsigned long j_flags;
|
---|
197 | int j_errno;
|
---|
198 | struct buffer_head * j_sb_buffer;
|
---|
199 | struct journal_superblock_s *j_superblock;
|
---|
200 | int j_format_version;
|
---|
201 | unsigned long j_head;
|
---|
202 | unsigned long j_tail;
|
---|
203 | unsigned long j_free;
|
---|
204 | unsigned long j_first, j_last;
|
---|
205 | kdev_t j_dev;
|
---|
206 | kdev_t j_fs_dev;
|
---|
207 | int j_blocksize;
|
---|
208 | unsigned int j_blk_offset;
|
---|
209 | unsigned int j_maxlen;
|
---|
210 | struct inode * j_inode;
|
---|
211 | tid_t j_tail_sequence;
|
---|
212 | tid_t j_transaction_sequence;
|
---|
213 | __u8 j_uuid[16];
|
---|
214 | struct jbd_revoke_table_s *j_revoke;
|
---|
215 | };
|
---|
216 |
|
---|
217 | typedef struct journal_s journal_t;
|
---|
218 |
|
---|
219 | extern int journal_recover (journal_t *journal);
|
---|
220 | extern int journal_skip_recovery (journal_t *);
|
---|
221 |
|
---|
222 | /* Primary revoke support */
|
---|
223 | extern int journal_init_revoke(journal_t *, int);
|
---|
224 | extern void journal_destroy_revoke_caches(void);
|
---|
225 | extern int journal_init_revoke_caches(void);
|
---|
226 |
|
---|
227 | /* Recovery revoke support */
|
---|
228 | extern int journal_set_revoke(journal_t *, unsigned long, tid_t);
|
---|
229 | extern int journal_test_revoke(journal_t *, unsigned long, tid_t);
|
---|
230 | extern void journal_clear_revoke(journal_t *);
|
---|
231 | extern void journal_brelse_array(struct buffer_head *b[], int n);
|
---|
232 |
|
---|
233 | extern void journal_destroy_revoke(journal_t *);
|
---|
234 |
|
---|
235 |
|
---|
236 | #endif /* _LINUX_JBD_H */
|
---|