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