diff options
author | Rob Landley <rob@landley.net> | 2006-04-01 00:40:33 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-04-01 00:40:33 +0000 |
commit | 43ac88849b9a36948a606a64d94e0369ee7f2ba2 (patch) | |
tree | ab10d683435ae62166e2ef6867419172a4d3cb05 | |
parent | 5cf905a871d696b00115a359bbc253483b82da0f (diff) | |
download | busybox-w32-43ac88849b9a36948a606a64d94e0369ee7f2ba2.tar.gz busybox-w32-43ac88849b9a36948a606a64d94e0369ee7f2ba2.tar.bz2 busybox-w32-43ac88849b9a36948a606a64d94e0369ee7f2ba2.zip |
Ext2fs cleanup from Garrett Kajmowicz.
-rw-r--r-- | e2fsprogs/e2fsck.c | 398 | ||||
-rw-r--r-- | e2fsprogs/e2fsck.h | 351 | ||||
-rw-r--r-- | e2fsprogs/ext2fs/ext2fs_inline.c | 1 | ||||
-rw-r--r-- | e2fsprogs/ext2fs/jfs_compat.h | 67 | ||||
-rw-r--r-- | e2fsprogs/ext2fs/jfs_user.h | 8 | ||||
-rw-r--r-- | e2fsprogs/ext2fs/kernel-jbd.h | 849 | ||||
-rw-r--r-- | e2fsprogs/ext2fs/mkjournal.c | 3 | ||||
-rw-r--r-- | e2fsprogs/tune2fs.c | 2 |
8 files changed, 451 insertions, 1228 deletions
diff --git a/e2fsprogs/e2fsck.c b/e2fsprogs/e2fsck.c index fb1e772a4..52069fe60 100644 --- a/e2fsprogs/e2fsck.c +++ b/e2fsprogs/e2fsck.c | |||
@@ -35,40 +35,8 @@ | |||
35 | #ifndef _GNU_SOURCE | 35 | #ifndef _GNU_SOURCE |
36 | #define _GNU_SOURCE 1 /* get strnlen() */ | 36 | #define _GNU_SOURCE 1 /* get strnlen() */ |
37 | #endif | 37 | #endif |
38 | #include <sys/types.h> | 38 | |
39 | #include <inttypes.h> | 39 | #include "e2fsck.h" /*Put all of our defines here to clean things up*/ |
40 | #include <stdio.h> | ||
41 | #include <string.h> | ||
42 | #include <unistd.h> | ||
43 | #include <stdlib.h> | ||
44 | #include <time.h> | ||
45 | #include <fcntl.h> | ||
46 | #include <ctype.h> | ||
47 | #include <setjmp.h> | ||
48 | #include <errno.h> | ||
49 | #include <getopt.h> | ||
50 | #include <limits.h> | ||
51 | #include <stddef.h> | ||
52 | #include <assert.h> | ||
53 | #include <signal.h> | ||
54 | #include <sys/time.h> | ||
55 | #include <sys/stat.h> | ||
56 | #include <sys/resource.h> | ||
57 | #include <sys/param.h> | ||
58 | #include <sys/mount.h> | ||
59 | #include <sys/ioctl.h> | ||
60 | #include <malloc.h> | ||
61 | #include <termios.h> | ||
62 | #include <mntent.h> | ||
63 | #include <dirent.h> | ||
64 | |||
65 | #include "fsck.h" | ||
66 | |||
67 | #include "ext2fs/ext2_fs.h" | ||
68 | #include "ext2fs/ext2fs.h" | ||
69 | #include "blkid/blkid.h" | ||
70 | #include "ext2fs/ext2_ext_attr.h" | ||
71 | #include "uuid/uuid.h" | ||
72 | 40 | ||
73 | #ifdef __GNUC__ | 41 | #ifdef __GNUC__ |
74 | #define _INLINE_ __inline__ | 42 | #define _INLINE_ __inline__ |
@@ -79,274 +47,6 @@ | |||
79 | #endif | 47 | #endif |
80 | 48 | ||
81 | /* | 49 | /* |
82 | * The last ext2fs revision level that this version of e2fsck is able to | ||
83 | * support | ||
84 | */ | ||
85 | #define E2FSCK_CURRENT_REV 1 | ||
86 | |||
87 | /* | ||
88 | * The directory information structure; stores directory information | ||
89 | * collected in earlier passes, to avoid disk i/o in fetching the | ||
90 | * directory information. | ||
91 | */ | ||
92 | struct dir_info { | ||
93 | ext2_ino_t ino; /* Inode number */ | ||
94 | ext2_ino_t dotdot; /* Parent according to '..' */ | ||
95 | ext2_ino_t parent; /* Parent according to treewalk */ | ||
96 | }; | ||
97 | |||
98 | |||
99 | /* | ||
100 | * The indexed directory information structure; stores information for | ||
101 | * directories which contain a hash tree index. | ||
102 | */ | ||
103 | struct dx_dir_info { | ||
104 | ext2_ino_t ino; /* Inode number */ | ||
105 | int numblocks; /* number of blocks */ | ||
106 | int hashversion; | ||
107 | short depth; /* depth of tree */ | ||
108 | struct dx_dirblock_info *dx_block; /* Array of size numblocks */ | ||
109 | }; | ||
110 | |||
111 | #define DX_DIRBLOCK_ROOT 1 | ||
112 | #define DX_DIRBLOCK_LEAF 2 | ||
113 | #define DX_DIRBLOCK_NODE 3 | ||
114 | #define DX_DIRBLOCK_CORRUPT 4 | ||
115 | #define DX_DIRBLOCK_CLEARED 8 | ||
116 | |||
117 | struct dx_dirblock_info { | ||
118 | int type; | ||
119 | blk_t phys; | ||
120 | int flags; | ||
121 | blk_t parent; | ||
122 | ext2_dirhash_t min_hash; | ||
123 | ext2_dirhash_t max_hash; | ||
124 | ext2_dirhash_t node_min_hash; | ||
125 | ext2_dirhash_t node_max_hash; | ||
126 | }; | ||
127 | |||
128 | #define DX_FLAG_REFERENCED 1 | ||
129 | #define DX_FLAG_DUP_REF 2 | ||
130 | #define DX_FLAG_FIRST 4 | ||
131 | #define DX_FLAG_LAST 8 | ||
132 | |||
133 | #ifdef RESOURCE_TRACK | ||
134 | /* | ||
135 | * This structure is used for keeping track of how much resources have | ||
136 | * been used for a particular pass of e2fsck. | ||
137 | */ | ||
138 | struct resource_track { | ||
139 | struct timeval time_start; | ||
140 | struct timeval user_start; | ||
141 | struct timeval system_start; | ||
142 | void *brk_start; | ||
143 | }; | ||
144 | #endif | ||
145 | |||
146 | /* | ||
147 | * E2fsck options | ||
148 | */ | ||
149 | #define E2F_OPT_READONLY 0x0001 | ||
150 | #define E2F_OPT_PREEN 0x0002 | ||
151 | #define E2F_OPT_YES 0x0004 | ||
152 | #define E2F_OPT_NO 0x0008 | ||
153 | #define E2F_OPT_TIME 0x0010 | ||
154 | #define E2F_OPT_TIME2 0x0020 | ||
155 | #define E2F_OPT_CHECKBLOCKS 0x0040 | ||
156 | #define E2F_OPT_DEBUG 0x0080 | ||
157 | #define E2F_OPT_FORCE 0x0100 | ||
158 | #define E2F_OPT_WRITECHECK 0x0200 | ||
159 | #define E2F_OPT_COMPRESS_DIRS 0x0400 | ||
160 | |||
161 | /* | ||
162 | * E2fsck flags | ||
163 | */ | ||
164 | #define E2F_FLAG_ABORT 0x0001 /* Abort signaled */ | ||
165 | #define E2F_FLAG_CANCEL 0x0002 /* Cancel signaled */ | ||
166 | #define E2F_FLAG_SIGNAL_MASK 0x0003 | ||
167 | #define E2F_FLAG_RESTART 0x0004 /* Restart signaled */ | ||
168 | |||
169 | #define E2F_FLAG_SETJMP_OK 0x0010 /* Setjmp valid for abort */ | ||
170 | |||
171 | #define E2F_FLAG_PROG_BAR 0x0020 /* Progress bar on screen */ | ||
172 | #define E2F_FLAG_PROG_SUPPRESS 0x0040 /* Progress suspended */ | ||
173 | #define E2F_FLAG_JOURNAL_INODE 0x0080 /* Create a new ext3 journal inode */ | ||
174 | #define E2F_FLAG_SB_SPECIFIED 0x0100 /* The superblock was explicitly | ||
175 | * specified by the user */ | ||
176 | #define E2F_FLAG_RESTARTED 0x0200 /* E2fsck has been restarted */ | ||
177 | #define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */ | ||
178 | |||
179 | /* | ||
180 | * Defines for indicating the e2fsck pass number | ||
181 | */ | ||
182 | #define E2F_PASS_1 1 | ||
183 | #define E2F_PASS_2 2 | ||
184 | #define E2F_PASS_3 3 | ||
185 | #define E2F_PASS_4 4 | ||
186 | #define E2F_PASS_5 5 | ||
187 | #define E2F_PASS_1B 6 | ||
188 | |||
189 | |||
190 | /* | ||
191 | * This is the global e2fsck structure. | ||
192 | */ | ||
193 | typedef struct e2fsck_struct *e2fsck_t; | ||
194 | |||
195 | /* | ||
196 | * Define the extended attribute refcount structure | ||
197 | */ | ||
198 | typedef struct ea_refcount *ext2_refcount_t; | ||
199 | |||
200 | struct e2fsck_struct { | ||
201 | ext2_filsys fs; | ||
202 | const char *program_name; | ||
203 | char *filesystem_name; | ||
204 | char *device_name; | ||
205 | char *io_options; | ||
206 | int flags; /* E2fsck internal flags */ | ||
207 | int options; | ||
208 | blk_t use_superblock; /* sb requested by user */ | ||
209 | blk_t superblock; /* sb used to open fs */ | ||
210 | int blocksize; /* blocksize */ | ||
211 | blk_t num_blocks; /* Total number of blocks */ | ||
212 | int mount_flags; | ||
213 | blkid_cache blkid; /* blkid cache */ | ||
214 | |||
215 | jmp_buf abort_loc; | ||
216 | |||
217 | unsigned long abort_code; | ||
218 | |||
219 | int (*progress)(e2fsck_t ctx, int pass, unsigned long cur, | ||
220 | unsigned long max); | ||
221 | |||
222 | ext2fs_inode_bitmap inode_used_map; /* Inodes which are in use */ | ||
223 | ext2fs_inode_bitmap inode_bad_map; /* Inodes which are bad somehow */ | ||
224 | ext2fs_inode_bitmap inode_dir_map; /* Inodes which are directories */ | ||
225 | ext2fs_inode_bitmap inode_bb_map; /* Inodes which are in bad blocks */ | ||
226 | ext2fs_inode_bitmap inode_imagic_map; /* AFS inodes */ | ||
227 | ext2fs_inode_bitmap inode_reg_map; /* Inodes which are regular files*/ | ||
228 | |||
229 | ext2fs_block_bitmap block_found_map; /* Blocks which are in use */ | ||
230 | ext2fs_block_bitmap block_dup_map; /* Blks referenced more than once */ | ||
231 | ext2fs_block_bitmap block_ea_map; /* Blocks which are used by EA's */ | ||
232 | |||
233 | /* | ||
234 | * Inode count arrays | ||
235 | */ | ||
236 | ext2_icount_t inode_count; | ||
237 | ext2_icount_t inode_link_info; | ||
238 | |||
239 | ext2_refcount_t refcount; | ||
240 | ext2_refcount_t refcount_extra; | ||
241 | |||
242 | /* | ||
243 | * Array of flags indicating whether an inode bitmap, block | ||
244 | * bitmap, or inode table is invalid | ||
245 | */ | ||
246 | int *invalid_inode_bitmap_flag; | ||
247 | int *invalid_block_bitmap_flag; | ||
248 | int *invalid_inode_table_flag; | ||
249 | int invalid_bitmaps; /* There are invalid bitmaps/itable */ | ||
250 | |||
251 | /* | ||
252 | * Block buffer | ||
253 | */ | ||
254 | char *block_buf; | ||
255 | |||
256 | /* | ||
257 | * For pass1_check_directory and pass1_get_blocks | ||
258 | */ | ||
259 | ext2_ino_t stashed_ino; | ||
260 | struct ext2_inode *stashed_inode; | ||
261 | |||
262 | /* | ||
263 | * Location of the lost and found directory | ||
264 | */ | ||
265 | ext2_ino_t lost_and_found; | ||
266 | int bad_lost_and_found; | ||
267 | |||
268 | /* | ||
269 | * Directory information | ||
270 | */ | ||
271 | int dir_info_count; | ||
272 | int dir_info_size; | ||
273 | struct dir_info *dir_info; | ||
274 | |||
275 | /* | ||
276 | * Indexed directory information | ||
277 | */ | ||
278 | int dx_dir_info_count; | ||
279 | int dx_dir_info_size; | ||
280 | struct dx_dir_info *dx_dir_info; | ||
281 | |||
282 | /* | ||
283 | * Directories to hash | ||
284 | */ | ||
285 | ext2_u32_list dirs_to_hash; | ||
286 | |||
287 | /* | ||
288 | * Tuning parameters | ||
289 | */ | ||
290 | int process_inode_size; | ||
291 | int inode_buffer_blocks; | ||
292 | |||
293 | /* | ||
294 | * ext3 journal support | ||
295 | */ | ||
296 | io_channel journal_io; | ||
297 | char *journal_name; | ||
298 | |||
299 | #ifdef RESOURCE_TRACK | ||
300 | /* | ||
301 | * For timing purposes | ||
302 | */ | ||
303 | struct resource_track global_rtrack; | ||
304 | #endif | ||
305 | |||
306 | /* | ||
307 | * How we display the progress update (for unix) | ||
308 | */ | ||
309 | int progress_fd; | ||
310 | int progress_pos; | ||
311 | int progress_last_percent; | ||
312 | unsigned int progress_last_time; | ||
313 | int interactive; /* Are we connected directly to a tty? */ | ||
314 | char start_meta[2], stop_meta[2]; | ||
315 | |||
316 | /* File counts */ | ||
317 | int fs_directory_count; | ||
318 | int fs_regular_count; | ||
319 | int fs_blockdev_count; | ||
320 | int fs_chardev_count; | ||
321 | int fs_links_count; | ||
322 | int fs_symlinks_count; | ||
323 | int fs_fast_symlinks_count; | ||
324 | int fs_fifo_count; | ||
325 | int fs_total_count; | ||
326 | int fs_badblocks_count; | ||
327 | int fs_sockets_count; | ||
328 | int fs_ind_count; | ||
329 | int fs_dind_count; | ||
330 | int fs_tind_count; | ||
331 | int fs_fragmented; | ||
332 | int large_files; | ||
333 | int fs_ext_attr_inodes; | ||
334 | int fs_ext_attr_blocks; | ||
335 | |||
336 | int ext_attr_ver; | ||
337 | |||
338 | /* | ||
339 | * For the use of callers of the e2fsck functions; not used by | ||
340 | * e2fsck functions themselves. | ||
341 | */ | ||
342 | void *priv_data; | ||
343 | }; | ||
344 | |||
345 | /* Used by the region allocation code */ | ||
346 | typedef __u32 region_addr_t; | ||
347 | typedef struct region_struct *region_t; | ||
348 | |||
349 | /* | ||
350 | * Procedure declarations | 50 | * Procedure declarations |
351 | */ | 51 | */ |
352 | 52 | ||
@@ -395,6 +95,8 @@ static blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, | |||
395 | static void e2fsck_clear_progbar(e2fsck_t ctx); | 95 | static void e2fsck_clear_progbar(e2fsck_t ctx); |
396 | static int e2fsck_simple_progress(e2fsck_t ctx, const char *label, | 96 | static int e2fsck_simple_progress(e2fsck_t ctx, const char *label, |
397 | float percent, unsigned int dpynum); | 97 | float percent, unsigned int dpynum); |
98 | |||
99 | |||
398 | /* | 100 | /* |
399 | * problem.h --- e2fsck problem error codes | 101 | * problem.h --- e2fsck problem error codes |
400 | */ | 102 | */ |
@@ -1349,7 +1051,6 @@ typedef struct dict_load_t { | |||
1349 | * Pull in the definition of the e2fsck context structure | 1051 | * Pull in the definition of the e2fsck context structure |
1350 | */ | 1052 | */ |
1351 | 1053 | ||
1352 | |||
1353 | struct buffer_head { | 1054 | struct buffer_head { |
1354 | char b_data[8192]; | 1055 | char b_data[8192]; |
1355 | e2fsck_t b_ctx; | 1056 | e2fsck_t b_ctx; |
@@ -1361,22 +1062,10 @@ struct buffer_head { | |||
1361 | int b_err; | 1062 | int b_err; |
1362 | }; | 1063 | }; |
1363 | 1064 | ||
1364 | struct inode { | ||
1365 | e2fsck_t i_ctx; | ||
1366 | ext2_ino_t i_ino; | ||
1367 | struct ext2_inode i_ext2; | ||
1368 | }; | ||
1369 | |||
1370 | struct kdev_s { | ||
1371 | e2fsck_t k_ctx; | ||
1372 | int k_dev; | ||
1373 | }; | ||
1374 | 1065 | ||
1375 | #define K_DEV_FS 1 | 1066 | #define K_DEV_FS 1 |
1376 | #define K_DEV_JOURNAL 2 | 1067 | #define K_DEV_JOURNAL 2 |
1377 | 1068 | ||
1378 | typedef struct kdev_s *kdev_t; | ||
1379 | |||
1380 | #define lock_buffer(bh) do {} while(0) | 1069 | #define lock_buffer(bh) do {} while(0) |
1381 | #define unlock_buffer(bh) do {} while(0) | 1070 | #define unlock_buffer(bh) do {} while(0) |
1382 | #define buffer_req(bh) 1 | 1071 | #define buffer_req(bh) 1 |
@@ -1411,11 +1100,6 @@ static _INLINE_ void do_cache_destroy(kmem_cache_t *cache) | |||
1411 | } | 1100 | } |
1412 | 1101 | ||
1413 | /* | 1102 | /* |
1414 | * Now pull in the real linux/jfs.h definitions. | ||
1415 | */ | ||
1416 | #include "ext2fs/kernel-jbd.h" | ||
1417 | |||
1418 | /* | ||
1419 | * badblocks.c --- replace/append bad blocks to the bad block inode | 1103 | * badblocks.c --- replace/append bad blocks to the bad block inode |
1420 | */ | 1104 | */ |
1421 | 1105 | ||
@@ -2720,11 +2404,6 @@ static void ehandler_init(io_channel channel) | |||
2720 | 2404 | ||
2721 | #define MNT_FL (MS_MGC_VAL | MS_RDONLY) | 2405 | #define MNT_FL (MS_MGC_VAL | MS_RDONLY) |
2722 | 2406 | ||
2723 | |||
2724 | #ifdef __CONFIG_JBD_DEBUG__E2FS /* Enabled by configure --enable-jfs-debug */ | ||
2725 | static int bh_count = 0; | ||
2726 | #endif | ||
2727 | |||
2728 | /* | 2407 | /* |
2729 | * Define USE_INODE_IO to use the inode_io.c / fileio.c codepaths. | 2408 | * Define USE_INODE_IO to use the inode_io.c / fileio.c codepaths. |
2730 | * This creates a larger static binary, and a smaller binary using | 2409 | * This creates a larger static binary, and a smaller binary using |
@@ -2768,9 +2447,6 @@ static struct buffer_head *getblk(kdev_t kdev, blk_t blocknr, int blocksize) | |||
2768 | if (!bh) | 2447 | if (!bh) |
2769 | return NULL; | 2448 | return NULL; |
2770 | 2449 | ||
2771 | jfs_debug(4, "getblk for block %lu (%d bytes)(total %d)\n", | ||
2772 | (unsigned long) blocknr, blocksize, ++bh_count); | ||
2773 | |||
2774 | bh->b_ctx = kdev->k_ctx; | 2450 | bh->b_ctx = kdev->k_ctx; |
2775 | if (kdev->k_dev == K_DEV_FS) | 2451 | if (kdev->k_dev == K_DEV_FS) |
2776 | bh->b_io = kdev->k_ctx->fs->io; | 2452 | bh->b_io = kdev->k_ctx->fs->io; |
@@ -2802,8 +2478,6 @@ static void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) | |||
2802 | for (; nr > 0; --nr) { | 2478 | for (; nr > 0; --nr) { |
2803 | bh = *bhp++; | 2479 | bh = *bhp++; |
2804 | if (rw == READ && !bh->b_uptodate) { | 2480 | if (rw == READ && !bh->b_uptodate) { |
2805 | jfs_debug(3, "reading block %lu/%p\n", | ||
2806 | (unsigned long) bh->b_blocknr, (void *) bh); | ||
2807 | retval = io_channel_read_blk(bh->b_io, | 2481 | retval = io_channel_read_blk(bh->b_io, |
2808 | bh->b_blocknr, | 2482 | bh->b_blocknr, |
2809 | 1, bh->b_data); | 2483 | 1, bh->b_data); |
@@ -2816,8 +2490,6 @@ static void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) | |||
2816 | } | 2490 | } |
2817 | bh->b_uptodate = 1; | 2491 | bh->b_uptodate = 1; |
2818 | } else if (rw == WRITE && bh->b_dirty) { | 2492 | } else if (rw == WRITE && bh->b_dirty) { |
2819 | jfs_debug(3, "writing block %lu/%p\n", | ||
2820 | (unsigned long) bh->b_blocknr, (void *) bh); | ||
2821 | retval = io_channel_write_blk(bh->b_io, | 2493 | retval = io_channel_write_blk(bh->b_io, |
2822 | bh->b_blocknr, | 2494 | bh->b_blocknr, |
2823 | 1, bh->b_data); | 2495 | 1, bh->b_data); |
@@ -2830,10 +2502,6 @@ static void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) | |||
2830 | } | 2502 | } |
2831 | bh->b_dirty = 0; | 2503 | bh->b_dirty = 0; |
2832 | bh->b_uptodate = 1; | 2504 | bh->b_uptodate = 1; |
2833 | } else { | ||
2834 | jfs_debug(3, "no-op %s for block %lu\n", | ||
2835 | rw == READ ? "read" : "write", | ||
2836 | (unsigned long) bh->b_blocknr); | ||
2837 | } | 2505 | } |
2838 | } | 2506 | } |
2839 | } | 2507 | } |
@@ -2852,8 +2520,6 @@ static void brelse(struct buffer_head *bh) | |||
2852 | { | 2520 | { |
2853 | if (bh->b_dirty) | 2521 | if (bh->b_dirty) |
2854 | ll_rw_block(WRITE, 1, &bh); | 2522 | ll_rw_block(WRITE, 1, &bh); |
2855 | jfs_debug(3, "freeing block %lu/%p (total %d)\n", | ||
2856 | (unsigned long) bh->b_blocknr, (void *) bh, --bh_count); | ||
2857 | ext2fs_free_mem(&bh); | 2523 | ext2fs_free_mem(&bh); |
2858 | } | 2524 | } |
2859 | 2525 | ||
@@ -3012,14 +2678,9 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) | |||
3012 | return EXT2_ET_LOAD_EXT_JOURNAL; | 2678 | return EXT2_ET_LOAD_EXT_JOURNAL; |
3013 | } | 2679 | } |
3014 | 2680 | ||
3015 | jfs_debug(1, "Using journal file %s\n", journal_name); | ||
3016 | io_ptr = unix_io_manager; | 2681 | io_ptr = unix_io_manager; |
3017 | } | 2682 | } |
3018 | 2683 | ||
3019 | #if 0 | ||
3020 | test_io_backing_manager = io_ptr; | ||
3021 | io_ptr = test_io_manager; | ||
3022 | #endif | ||
3023 | #ifndef USE_INODE_IO | 2684 | #ifndef USE_INODE_IO |
3024 | if (ext_journal) | 2685 | if (ext_journal) |
3025 | #endif | 2686 | #endif |
@@ -11681,13 +11342,10 @@ static int jread(struct buffer_head **bhp, journal_t *journal, | |||
11681 | 11342 | ||
11682 | *bhp = NULL; | 11343 | *bhp = NULL; |
11683 | 11344 | ||
11684 | J_ASSERT (offset < journal->j_maxlen); | ||
11685 | |||
11686 | err = journal_bmap(journal, offset, &blocknr); | 11345 | err = journal_bmap(journal, offset, &blocknr); |
11687 | 11346 | ||
11688 | if (err) { | 11347 | if (err) { |
11689 | printk (KERN_ERR "JBD: bad block at offset %u\n", | 11348 | printf ("JBD: bad block at offset %u\n", offset); |
11690 | offset); | ||
11691 | return err; | 11349 | return err; |
11692 | } | 11350 | } |
11693 | 11351 | ||
@@ -11704,8 +11362,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal, | |||
11704 | } | 11362 | } |
11705 | 11363 | ||
11706 | if (!buffer_uptodate(bh)) { | 11364 | if (!buffer_uptodate(bh)) { |
11707 | printk (KERN_ERR "JBD: Failed to read block at offset %u\n", | 11365 | printf ("JBD: Failed to read block at offset %u\n", offset); |
11708 | offset); | ||
11709 | brelse(bh); | 11366 | brelse(bh); |
11710 | return -EIO; | 11367 | return -EIO; |
11711 | } | 11368 | } |
@@ -11779,8 +11436,6 @@ int journal_recover(journal_t *journal) | |||
11779 | */ | 11436 | */ |
11780 | 11437 | ||
11781 | if (!sb->s_start) { | 11438 | if (!sb->s_start) { |
11782 | jbd_debug(1, "No recovery required, last transaction %d\n", | ||
11783 | ntohl(sb->s_sequence)); | ||
11784 | journal->j_transaction_sequence = ntohl(sb->s_sequence) + 1; | 11439 | journal->j_transaction_sequence = ntohl(sb->s_sequence) + 1; |
11785 | return 0; | 11440 | return 0; |
11786 | } | 11441 | } |
@@ -11791,12 +11446,6 @@ int journal_recover(journal_t *journal) | |||
11791 | if (!err) | 11446 | if (!err) |
11792 | err = do_one_pass(journal, &info, PASS_REPLAY); | 11447 | err = do_one_pass(journal, &info, PASS_REPLAY); |
11793 | 11448 | ||
11794 | jbd_debug(0, "JBD: recovery, exit status %d, " | ||
11795 | "recovered transactions %u to %u\n", | ||
11796 | err, info.start_transaction, info.end_transaction); | ||
11797 | jbd_debug(0, "JBD: Replayed %d and revoked %d/%d blocks\n", | ||
11798 | info.nr_replays, info.nr_revoke_hits, info.nr_revokes); | ||
11799 | |||
11800 | /* Restart the log at the next transaction ID, thus invalidating | 11449 | /* Restart the log at the next transaction ID, thus invalidating |
11801 | * any existing commit records in the log. */ | 11450 | * any existing commit records in the log. */ |
11802 | journal->j_transaction_sequence = ++info.end_transaction; | 11451 | journal->j_transaction_sequence = ++info.end_transaction; |
@@ -11837,8 +11486,6 @@ static int do_one_pass(journal_t *journal, | |||
11837 | if (pass == PASS_SCAN) | 11486 | if (pass == PASS_SCAN) |
11838 | info->start_transaction = first_commit_ID; | 11487 | info->start_transaction = first_commit_ID; |
11839 | 11488 | ||
11840 | jbd_debug(1, "Starting recovery pass %d\n", pass); | ||
11841 | |||
11842 | /* | 11489 | /* |
11843 | * Now we walk through the log, transaction by transaction, | 11490 | * Now we walk through the log, transaction by transaction, |
11844 | * making sure that each transaction has a commit block in the | 11491 | * making sure that each transaction has a commit block in the |
@@ -11861,14 +11508,10 @@ static int do_one_pass(journal_t *journal, | |||
11861 | if (tid_geq(next_commit_ID, info->end_transaction)) | 11508 | if (tid_geq(next_commit_ID, info->end_transaction)) |
11862 | break; | 11509 | break; |
11863 | 11510 | ||
11864 | jbd_debug(2, "Scanning for sequence ID %u at %lu/%lu\n", | ||
11865 | next_commit_ID, next_log_block, journal->j_last); | ||
11866 | |||
11867 | /* Skip over each chunk of the transaction looking | 11511 | /* Skip over each chunk of the transaction looking |
11868 | * either the next descriptor block or the final commit | 11512 | * either the next descriptor block or the final commit |
11869 | * record. */ | 11513 | * record. */ |
11870 | 11514 | ||
11871 | jbd_debug(3, "JBD: checking block %ld\n", next_log_block); | ||
11872 | err = jread(&bh, journal, next_log_block); | 11515 | err = jread(&bh, journal, next_log_block); |
11873 | if (err) | 11516 | if (err) |
11874 | goto failed; | 11517 | goto failed; |
@@ -11891,8 +11534,6 @@ static int do_one_pass(journal_t *journal, | |||
11891 | 11534 | ||
11892 | blocktype = ntohl(tmp->h_blocktype); | 11535 | blocktype = ntohl(tmp->h_blocktype); |
11893 | sequence = ntohl(tmp->h_sequence); | 11536 | sequence = ntohl(tmp->h_sequence); |
11894 | jbd_debug(3, "Found magic %d, sequence %d\n", | ||
11895 | blocktype, sequence); | ||
11896 | 11537 | ||
11897 | if (sequence != next_commit_ID) { | 11538 | if (sequence != next_commit_ID) { |
11898 | brelse(bh); | 11539 | brelse(bh); |
@@ -11935,14 +11576,12 @@ static int do_one_pass(journal_t *journal, | |||
11935 | /* Recover what we can, but | 11576 | /* Recover what we can, but |
11936 | * report failure at the end. */ | 11577 | * report failure at the end. */ |
11937 | success = err; | 11578 | success = err; |
11938 | printk (KERN_ERR | 11579 | printf ("JBD: IO error %d recovering " |
11939 | "JBD: IO error %d recovering " | ||
11940 | "block %ld in log\n", | 11580 | "block %ld in log\n", |
11941 | err, io_block); | 11581 | err, io_block); |
11942 | } else { | 11582 | } else { |
11943 | unsigned long blocknr; | 11583 | unsigned long blocknr; |
11944 | 11584 | ||
11945 | J_ASSERT(obh != NULL); | ||
11946 | blocknr = ntohl(tag->t_blocknr); | 11585 | blocknr = ntohl(tag->t_blocknr); |
11947 | 11586 | ||
11948 | /* If the block has been | 11587 | /* If the block has been |
@@ -11962,8 +11601,7 @@ static int do_one_pass(journal_t *journal, | |||
11962 | blocknr, | 11601 | blocknr, |
11963 | journal->j_blocksize); | 11602 | journal->j_blocksize); |
11964 | if (nbh == NULL) { | 11603 | if (nbh == NULL) { |
11965 | printk(KERN_ERR | 11604 | printf ("JBD: Out of memory " |
11966 | "JBD: Out of memory " | ||
11967 | "during recovery.\n"); | 11605 | "during recovery.\n"); |
11968 | err = -ENOMEM; | 11606 | err = -ENOMEM; |
11969 | brelse(bh); | 11607 | brelse(bh); |
@@ -11979,10 +11617,8 @@ static int do_one_pass(journal_t *journal, | |||
11979 | htonl(JFS_MAGIC_NUMBER); | 11617 | htonl(JFS_MAGIC_NUMBER); |
11980 | } | 11618 | } |
11981 | 11619 | ||
11982 | BUFFER_TRACE(nbh, "marking dirty"); | ||
11983 | mark_buffer_uptodate(nbh, 1); | 11620 | mark_buffer_uptodate(nbh, 1); |
11984 | mark_buffer_dirty(nbh); | 11621 | mark_buffer_dirty(nbh); |
11985 | BUFFER_TRACE(nbh, "marking uptodate"); | ||
11986 | ++info->nr_replays; | 11622 | ++info->nr_replays; |
11987 | /* ll_rw_block(WRITE, 1, &nbh); */ | 11623 | /* ll_rw_block(WRITE, 1, &nbh); */ |
11988 | unlock_buffer(nbh); | 11624 | unlock_buffer(nbh); |
@@ -12026,8 +11662,6 @@ static int do_one_pass(journal_t *journal, | |||
12026 | continue; | 11662 | continue; |
12027 | 11663 | ||
12028 | default: | 11664 | default: |
12029 | jbd_debug(3, "Unrecognised magic %d, end of scan.\n", | ||
12030 | blocktype); | ||
12031 | goto done; | 11665 | goto done; |
12032 | } | 11666 | } |
12033 | } | 11667 | } |
@@ -12046,7 +11680,7 @@ static int do_one_pass(journal_t *journal, | |||
12046 | /* It's really bad news if different passes end up at | 11680 | /* It's really bad news if different passes end up at |
12047 | * different places (but possible due to IO errors). */ | 11681 | * different places (but possible due to IO errors). */ |
12048 | if (info->end_transaction != next_commit_ID) { | 11682 | if (info->end_transaction != next_commit_ID) { |
12049 | printk (KERN_ERR "JBD: recovery pass %d ended at " | 11683 | printf ("JBD: recovery pass %d ended at " |
12050 | "transaction %u, expected %u\n", | 11684 | "transaction %u, expected %u\n", |
12051 | pass, next_commit_ID, info->end_transaction); | 11685 | pass, next_commit_ID, info->end_transaction); |
12052 | if (!success) | 11686 | if (!success) |
@@ -13067,15 +12701,11 @@ int journal_init_revoke(journal_t *journal, int hash_size) | |||
13067 | { | 12701 | { |
13068 | int shift, tmp; | 12702 | int shift, tmp; |
13069 | 12703 | ||
13070 | J_ASSERT (journal->j_revoke == NULL); | ||
13071 | |||
13072 | journal->j_revoke = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL); | 12704 | journal->j_revoke = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL); |
13073 | if (!journal->j_revoke) | 12705 | if (!journal->j_revoke) |
13074 | return -ENOMEM; | 12706 | return -ENOMEM; |
13075 | 12707 | ||
13076 | /* Check that the hash_size is a power of two */ | 12708 | /* Check that the hash_size is a power of two */ |
13077 | J_ASSERT ((hash_size & (hash_size-1)) == 0); | ||
13078 | |||
13079 | journal->j_revoke->hash_size = hash_size; | 12709 | journal->j_revoke->hash_size = hash_size; |
13080 | 12710 | ||
13081 | shift = 0; | 12711 | shift = 0; |
@@ -13111,7 +12741,6 @@ void journal_destroy_revoke(journal_t *journal) | |||
13111 | 12741 | ||
13112 | for (i=0; i<table->hash_size; i++) { | 12742 | for (i=0; i<table->hash_size; i++) { |
13113 | hash_list = &table->hash_table[i]; | 12743 | hash_list = &table->hash_table[i]; |
13114 | J_ASSERT (list_empty(hash_list)); | ||
13115 | } | 12744 | } |
13116 | 12745 | ||
13117 | free(table->hash_table); | 12746 | free(table->hash_table); |
@@ -14158,15 +13787,6 @@ static void swap_filesys(e2fsck_t ctx) | |||
14158 | * util.c --- miscellaneous utilities | 13787 | * util.c --- miscellaneous utilities |
14159 | */ | 13788 | */ |
14160 | 13789 | ||
14161 | #ifdef HAVE_CONIO_H | ||
14162 | #undef HAVE_TERMIOS_H | ||
14163 | #include <conio.h> | ||
14164 | #define read_a_char() getch() | ||
14165 | #else | ||
14166 | #ifdef HAVE_TERMIOS_H | ||
14167 | #include <termios.h> | ||
14168 | #endif | ||
14169 | #endif | ||
14170 | 13790 | ||
14171 | #if 0 | 13791 | #if 0 |
14172 | void fatal_error(e2fsck_t ctx, const char *msg) | 13792 | void fatal_error(e2fsck_t ctx, const char *msg) |
diff --git a/e2fsprogs/e2fsck.h b/e2fsprogs/e2fsck.h new file mode 100644 index 000000000..1d292b937 --- /dev/null +++ b/e2fsprogs/e2fsck.h | |||
@@ -0,0 +1,351 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <inttypes.h> | ||
3 | #include <stdio.h> | ||
4 | #include <string.h> | ||
5 | #include <unistd.h> | ||
6 | #include <stdlib.h> | ||
7 | #include <time.h> | ||
8 | #include <fcntl.h> | ||
9 | #include <ctype.h> | ||
10 | #include <setjmp.h> | ||
11 | #include <errno.h> | ||
12 | #include <getopt.h> | ||
13 | #include <limits.h> | ||
14 | #include <stddef.h> | ||
15 | #include <assert.h> | ||
16 | #include <signal.h> | ||
17 | #include <sys/time.h> | ||
18 | #include <sys/stat.h> | ||
19 | #include <sys/resource.h> | ||
20 | #include <sys/param.h> | ||
21 | #include <sys/mount.h> | ||
22 | #include <sys/ioctl.h> | ||
23 | #include <malloc.h> | ||
24 | #include <termios.h> | ||
25 | #include <mntent.h> | ||
26 | #include <dirent.h> | ||
27 | #include "ext2fs/kernel-list.h" | ||
28 | #include <sys/types.h> | ||
29 | #include <linux/types.h> | ||
30 | |||
31 | |||
32 | /* | ||
33 | * Now pull in the real linux/jfs.h definitions. | ||
34 | */ | ||
35 | #include "ext2fs/kernel-jbd.h" | ||
36 | |||
37 | |||
38 | |||
39 | #include "fsck.h" | ||
40 | |||
41 | #include "ext2fs/ext2_fs.h" | ||
42 | #include "blkid/blkid.h" | ||
43 | #include "ext2fs/ext2_ext_attr.h" | ||
44 | #include "uuid/uuid.h" | ||
45 | |||
46 | #ifdef HAVE_CONIO_H | ||
47 | #undef HAVE_TERMIOS_H | ||
48 | #include <conio.h> | ||
49 | #define read_a_char() getch() | ||
50 | #else | ||
51 | #ifdef HAVE_TERMIOS_H | ||
52 | #include <termios.h> | ||
53 | #endif | ||
54 | #endif | ||
55 | |||
56 | |||
57 | /* | ||
58 | * The last ext2fs revision level that this version of e2fsck is able to | ||
59 | * support | ||
60 | */ | ||
61 | #define E2FSCK_CURRENT_REV 1 | ||
62 | |||
63 | /* Used by the region allocation code */ | ||
64 | typedef __u32 region_addr_t; | ||
65 | typedef struct region_struct *region_t; | ||
66 | |||
67 | struct dx_dirblock_info { | ||
68 | int type; | ||
69 | blk_t phys; | ||
70 | int flags; | ||
71 | blk_t parent; | ||
72 | ext2_dirhash_t min_hash; | ||
73 | ext2_dirhash_t max_hash; | ||
74 | ext2_dirhash_t node_min_hash; | ||
75 | ext2_dirhash_t node_max_hash; | ||
76 | }; | ||
77 | |||
78 | /* | ||
79 | These defines are used in the type field of dx_dirblock_info | ||
80 | */ | ||
81 | |||
82 | #define DX_DIRBLOCK_ROOT 1 | ||
83 | #define DX_DIRBLOCK_LEAF 2 | ||
84 | #define DX_DIRBLOCK_NODE 3 | ||
85 | #define DX_DIRBLOCK_CORRUPT 4 | ||
86 | #define DX_DIRBLOCK_CLEARED 8 | ||
87 | |||
88 | |||
89 | /* | ||
90 | The following defines are used in the 'flags' field of a dx_dirblock_info | ||
91 | */ | ||
92 | #define DX_FLAG_REFERENCED 1 | ||
93 | #define DX_FLAG_DUP_REF 2 | ||
94 | #define DX_FLAG_FIRST 4 | ||
95 | #define DX_FLAG_LAST 8 | ||
96 | |||
97 | #ifdef RESOURCE_TRACK | ||
98 | /* | ||
99 | * This structure is used for keeping track of how much resources have | ||
100 | * been used for a particular pass of e2fsck. | ||
101 | */ | ||
102 | struct resource_track { | ||
103 | struct timeval time_start; | ||
104 | struct timeval user_start; | ||
105 | struct timeval system_start; | ||
106 | void *brk_start; | ||
107 | }; | ||
108 | #endif | ||
109 | |||
110 | /* | ||
111 | * E2fsck options | ||
112 | */ | ||
113 | #define E2F_OPT_READONLY 0x0001 | ||
114 | #define E2F_OPT_PREEN 0x0002 | ||
115 | #define E2F_OPT_YES 0x0004 | ||
116 | #define E2F_OPT_NO 0x0008 | ||
117 | #define E2F_OPT_TIME 0x0010 | ||
118 | #define E2F_OPT_TIME2 0x0020 | ||
119 | #define E2F_OPT_CHECKBLOCKS 0x0040 | ||
120 | #define E2F_OPT_DEBUG 0x0080 | ||
121 | #define E2F_OPT_FORCE 0x0100 | ||
122 | #define E2F_OPT_WRITECHECK 0x0200 | ||
123 | #define E2F_OPT_COMPRESS_DIRS 0x0400 | ||
124 | |||
125 | /* | ||
126 | * E2fsck flags | ||
127 | */ | ||
128 | #define E2F_FLAG_ABORT 0x0001 /* Abort signaled */ | ||
129 | #define E2F_FLAG_CANCEL 0x0002 /* Cancel signaled */ | ||
130 | #define E2F_FLAG_SIGNAL_MASK 0x0003 | ||
131 | #define E2F_FLAG_RESTART 0x0004 /* Restart signaled */ | ||
132 | |||
133 | #define E2F_FLAG_SETJMP_OK 0x0010 /* Setjmp valid for abort */ | ||
134 | |||
135 | #define E2F_FLAG_PROG_BAR 0x0020 /* Progress bar on screen */ | ||
136 | #define E2F_FLAG_PROG_SUPPRESS 0x0040 /* Progress suspended */ | ||
137 | #define E2F_FLAG_JOURNAL_INODE 0x0080 /* Create a new ext3 journal inode */ | ||
138 | #define E2F_FLAG_SB_SPECIFIED 0x0100 /* The superblock was explicitly | ||
139 | * specified by the user */ | ||
140 | #define E2F_FLAG_RESTARTED 0x0200 /* E2fsck has been restarted */ | ||
141 | #define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */ | ||
142 | |||
143 | /* | ||
144 | * Defines for indicating the e2fsck pass number | ||
145 | */ | ||
146 | #define E2F_PASS_1 1 | ||
147 | #define E2F_PASS_2 2 | ||
148 | #define E2F_PASS_3 3 | ||
149 | #define E2F_PASS_4 4 | ||
150 | #define E2F_PASS_5 5 | ||
151 | #define E2F_PASS_1B 6 | ||
152 | |||
153 | /*Don't know where these come from*/ | ||
154 | #define READ 0 | ||
155 | #define WRITE 1 | ||
156 | #define KERN_ERR "" | ||
157 | #define KERN_DEBUG "" | ||
158 | #define cpu_to_be32(n) htonl(n) | ||
159 | #define be32_to_cpu(n) ntohl(n) | ||
160 | |||
161 | |||
162 | /* | ||
163 | * The directory information structure; stores directory information | ||
164 | * collected in earlier passes, to avoid disk i/o in fetching the | ||
165 | * directory information. | ||
166 | */ | ||
167 | struct dir_info { | ||
168 | ext2_ino_t ino; /* Inode number */ | ||
169 | ext2_ino_t dotdot; /* Parent according to '..' */ | ||
170 | ext2_ino_t parent; /* Parent according to treewalk */ | ||
171 | }; | ||
172 | |||
173 | |||
174 | |||
175 | /* | ||
176 | * The indexed directory information structure; stores information for | ||
177 | * directories which contain a hash tree index. | ||
178 | */ | ||
179 | struct dx_dir_info { | ||
180 | ext2_ino_t ino; /* Inode number */ | ||
181 | int numblocks; /* number of blocks */ | ||
182 | int hashversion; | ||
183 | short depth; /* depth of tree */ | ||
184 | struct dx_dirblock_info *dx_block; /* Array of size numblocks */ | ||
185 | }; | ||
186 | |||
187 | /* | ||
188 | * Define the extended attribute refcount structure | ||
189 | */ | ||
190 | typedef struct ea_refcount *ext2_refcount_t; | ||
191 | |||
192 | struct e2fsck_struct { | ||
193 | ext2_filsys fs; | ||
194 | const char *program_name; | ||
195 | char *filesystem_name; | ||
196 | char *device_name; | ||
197 | char *io_options; | ||
198 | int flags; /* E2fsck internal flags */ | ||
199 | int options; | ||
200 | blk_t use_superblock; /* sb requested by user */ | ||
201 | blk_t superblock; /* sb used to open fs */ | ||
202 | int blocksize; /* blocksize */ | ||
203 | blk_t num_blocks; /* Total number of blocks */ | ||
204 | int mount_flags; | ||
205 | blkid_cache blkid; /* blkid cache */ | ||
206 | |||
207 | jmp_buf abort_loc; | ||
208 | |||
209 | unsigned long abort_code; | ||
210 | |||
211 | int (*progress)(e2fsck_t ctx, int pass, unsigned long cur, | ||
212 | unsigned long max); | ||
213 | |||
214 | ext2fs_inode_bitmap inode_used_map; /* Inodes which are in use */ | ||
215 | ext2fs_inode_bitmap inode_bad_map; /* Inodes which are bad somehow */ | ||
216 | ext2fs_inode_bitmap inode_dir_map; /* Inodes which are directories */ | ||
217 | ext2fs_inode_bitmap inode_bb_map; /* Inodes which are in bad blocks */ | ||
218 | ext2fs_inode_bitmap inode_imagic_map; /* AFS inodes */ | ||
219 | ext2fs_inode_bitmap inode_reg_map; /* Inodes which are regular files*/ | ||
220 | |||
221 | ext2fs_block_bitmap block_found_map; /* Blocks which are in use */ | ||
222 | ext2fs_block_bitmap block_dup_map; /* Blks referenced more than once */ | ||
223 | ext2fs_block_bitmap block_ea_map; /* Blocks which are used by EA's */ | ||
224 | |||
225 | /* | ||
226 | * Inode count arrays | ||
227 | */ | ||
228 | ext2_icount_t inode_count; | ||
229 | ext2_icount_t inode_link_info; | ||
230 | |||
231 | ext2_refcount_t refcount; | ||
232 | ext2_refcount_t refcount_extra; | ||
233 | |||
234 | /* | ||
235 | * Array of flags indicating whether an inode bitmap, block | ||
236 | * bitmap, or inode table is invalid | ||
237 | */ | ||
238 | int *invalid_inode_bitmap_flag; | ||
239 | int *invalid_block_bitmap_flag; | ||
240 | int *invalid_inode_table_flag; | ||
241 | int invalid_bitmaps; /* There are invalid bitmaps/itable */ | ||
242 | |||
243 | /* | ||
244 | * Block buffer | ||
245 | */ | ||
246 | char *block_buf; | ||
247 | |||
248 | /* | ||
249 | * For pass1_check_directory and pass1_get_blocks | ||
250 | */ | ||
251 | ext2_ino_t stashed_ino; | ||
252 | struct ext2_inode *stashed_inode; | ||
253 | |||
254 | /* | ||
255 | * Location of the lost and found directory | ||
256 | */ | ||
257 | ext2_ino_t lost_and_found; | ||
258 | int bad_lost_and_found; | ||
259 | |||
260 | /* | ||
261 | * Directory information | ||
262 | */ | ||
263 | int dir_info_count; | ||
264 | int dir_info_size; | ||
265 | struct dir_info *dir_info; | ||
266 | |||
267 | /* | ||
268 | * Indexed directory information | ||
269 | */ | ||
270 | int dx_dir_info_count; | ||
271 | int dx_dir_info_size; | ||
272 | struct dx_dir_info *dx_dir_info; | ||
273 | |||
274 | /* | ||
275 | * Directories to hash | ||
276 | */ | ||
277 | ext2_u32_list dirs_to_hash; | ||
278 | |||
279 | /* | ||
280 | * Tuning parameters | ||
281 | */ | ||
282 | int process_inode_size; | ||
283 | int inode_buffer_blocks; | ||
284 | |||
285 | /* | ||
286 | * ext3 journal support | ||
287 | */ | ||
288 | io_channel journal_io; | ||
289 | char *journal_name; | ||
290 | |||
291 | #ifdef RESOURCE_TRACK | ||
292 | /* | ||
293 | * For timing purposes | ||
294 | */ | ||
295 | struct resource_track global_rtrack; | ||
296 | #endif | ||
297 | |||
298 | /* | ||
299 | * How we display the progress update (for unix) | ||
300 | */ | ||
301 | int progress_fd; | ||
302 | int progress_pos; | ||
303 | int progress_last_percent; | ||
304 | unsigned int progress_last_time; | ||
305 | int interactive; /* Are we connected directly to a tty? */ | ||
306 | char start_meta[2], stop_meta[2]; | ||
307 | |||
308 | /* File counts */ | ||
309 | int fs_directory_count; | ||
310 | int fs_regular_count; | ||
311 | int fs_blockdev_count; | ||
312 | int fs_chardev_count; | ||
313 | int fs_links_count; | ||
314 | int fs_symlinks_count; | ||
315 | int fs_fast_symlinks_count; | ||
316 | int fs_fifo_count; | ||
317 | int fs_total_count; | ||
318 | int fs_badblocks_count; | ||
319 | int fs_sockets_count; | ||
320 | int fs_ind_count; | ||
321 | int fs_dind_count; | ||
322 | int fs_tind_count; | ||
323 | int fs_fragmented; | ||
324 | int large_files; | ||
325 | int fs_ext_attr_inodes; | ||
326 | int fs_ext_attr_blocks; | ||
327 | |||
328 | int ext_attr_ver; | ||
329 | |||
330 | /* | ||
331 | * For the use of callers of the e2fsck functions; not used by | ||
332 | * e2fsck functions themselves. | ||
333 | */ | ||
334 | void *priv_data; | ||
335 | }; | ||
336 | |||
337 | |||
338 | |||
339 | static inline int tid_gt(tid_t x, tid_t y) | ||
340 | { | ||
341 | int difference = (x - y); | ||
342 | return (difference > 0); | ||
343 | } | ||
344 | |||
345 | static inline int tid_geq(tid_t x, tid_t y) | ||
346 | { | ||
347 | int difference = (x - y); | ||
348 | return (difference >= 0); | ||
349 | } | ||
350 | |||
351 | |||
diff --git a/e2fsprogs/ext2fs/ext2fs_inline.c b/e2fsprogs/ext2fs/ext2fs_inline.c index a363b1992..d670065d2 100644 --- a/e2fsprogs/ext2fs/ext2fs_inline.c +++ b/e2fsprogs/ext2fs/ext2fs_inline.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include "ext2fs.h" | 12 | #include "ext2fs.h" |
13 | #include "bitops.h" | 13 | #include "bitops.h" |
14 | #include <string.h> | ||
14 | 15 | ||
15 | /* | 16 | /* |
16 | * Allocate memory | 17 | * Allocate memory |
diff --git a/e2fsprogs/ext2fs/jfs_compat.h b/e2fsprogs/ext2fs/jfs_compat.h deleted file mode 100644 index 30ad1ef5e..000000000 --- a/e2fsprogs/ext2fs/jfs_compat.h +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | |||
2 | #ifndef _JFS_COMPAT_H | ||
3 | #define _JFS_COMPAT_H | ||
4 | |||
5 | #include "kernel-list.h" | ||
6 | #include <errno.h> | ||
7 | #ifdef HAVE_NETINET_IN_H | ||
8 | #include <netinet/in.h> | ||
9 | #endif | ||
10 | |||
11 | #define printk printf | ||
12 | #define KERN_ERR "" | ||
13 | #define KERN_DEBUG "" | ||
14 | |||
15 | #define READ 0 | ||
16 | #define WRITE 1 | ||
17 | |||
18 | #define cpu_to_be32(n) htonl(n) | ||
19 | #define be32_to_cpu(n) ntohl(n) | ||
20 | |||
21 | typedef unsigned int tid_t; | ||
22 | typedef struct journal_s journal_t; | ||
23 | |||
24 | struct buffer_head; | ||
25 | struct inode; | ||
26 | |||
27 | struct journal_s | ||
28 | { | ||
29 | unsigned long j_flags; | ||
30 | int j_errno; | ||
31 | struct buffer_head * j_sb_buffer; | ||
32 | struct journal_superblock_s *j_superblock; | ||
33 | int j_format_version; | ||
34 | unsigned long j_head; | ||
35 | unsigned long j_tail; | ||
36 | unsigned long j_free; | ||
37 | unsigned long j_first, j_last; | ||
38 | kdev_t j_dev; | ||
39 | kdev_t j_fs_dev; | ||
40 | int j_blocksize; | ||
41 | unsigned int j_blk_offset; | ||
42 | unsigned int j_maxlen; | ||
43 | struct inode * j_inode; | ||
44 | tid_t j_tail_sequence; | ||
45 | tid_t j_transaction_sequence; | ||
46 | __u8 j_uuid[16]; | ||
47 | struct jbd_revoke_table_s *j_revoke; | ||
48 | }; | ||
49 | |||
50 | #define J_ASSERT(assert) \ | ||
51 | do { if (!(assert)) { \ | ||
52 | printf ("Assertion failure in %s() at %s line %d: " \ | ||
53 | "\"%s\"\n", \ | ||
54 | __FUNCTION__, __FILE__, __LINE__, # assert); \ | ||
55 | fatal_error(e2fsck_global_ctx, 0); \ | ||
56 | } } while (0) | ||
57 | |||
58 | #define is_journal_abort(x) 0 | ||
59 | |||
60 | #define BUFFER_TRACE(bh, info) do {} while (0) | ||
61 | |||
62 | /* Need this so we can compile with configure --enable-gcc-wall */ | ||
63 | #ifdef NO_INLINE_FUNCS | ||
64 | #define inline | ||
65 | #endif | ||
66 | |||
67 | #endif /* _JFS_COMPAT_H */ | ||
diff --git a/e2fsprogs/ext2fs/jfs_user.h b/e2fsprogs/ext2fs/jfs_user.h deleted file mode 100644 index 3a521230e..000000000 --- a/e2fsprogs/ext2fs/jfs_user.h +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | #ifndef _JFS_USER_H | ||
2 | #define _JFS_USER_H | ||
3 | |||
4 | typedef unsigned short kdev_t; | ||
5 | |||
6 | #include "kernel-jbd.h" | ||
7 | |||
8 | #endif /* _JFS_USER_H */ | ||
diff --git a/e2fsprogs/ext2fs/kernel-jbd.h b/e2fsprogs/ext2fs/kernel-jbd.h index 8a5de5e3e..56914ea47 100644 --- a/e2fsprogs/ext2fs/kernel-jbd.h +++ b/e2fsprogs/ext2fs/kernel-jbd.h | |||
@@ -16,91 +16,14 @@ | |||
16 | #ifndef _LINUX_JBD_H | 16 | #ifndef _LINUX_JBD_H |
17 | #define _LINUX_JBD_H | 17 | #define _LINUX_JBD_H |
18 | 18 | ||
19 | #if defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE) || !defined(__KERNEL__) | 19 | #include <sys/types.h> |
20 | 20 | #include <linux/types.h> | |
21 | /* Allow this file to be included directly into e2fsprogs */ | 21 | #include "ext2fs/ext2fs.h" |
22 | #ifndef __KERNEL__ | ||
23 | #include "jfs_compat.h" | ||
24 | #define JFS_DEBUG | ||
25 | #define jfs_debug jbd_debug | ||
26 | #else | ||
27 | |||
28 | #include <linux/journal-head.h> | ||
29 | #include <linux/stddef.h> | ||
30 | #include <asm/semaphore.h> | ||
31 | #endif | ||
32 | |||
33 | #ifndef __GNUC__ | ||
34 | #define __FUNCTION__ "" | ||
35 | #endif | ||
36 | |||
37 | #define journal_oom_retry 1 | ||
38 | |||
39 | #ifdef __STDC__ | ||
40 | #ifdef __CONFIG_JBD_DEBUG__E2FS | ||
41 | /* | ||
42 | * Define JBD_EXPENSIVE_CHECKING to enable more expensive internal | ||
43 | * consistency checks. By default we don't do this unless | ||
44 | * __CONFIG_JBD_DEBUG__E2FS is on. | ||
45 | */ | ||
46 | #define JBD_EXPENSIVE_CHECKING | ||
47 | extern int journal_enable_debug; | ||
48 | |||
49 | #define jbd_debug(n, f, a...) \ | ||
50 | do { \ | ||
51 | if ((n) <= journal_enable_debug) { \ | ||
52 | printk (KERN_DEBUG "(%s, %d): %s: ", \ | ||
53 | __FILE__, __LINE__, __FUNCTION__); \ | ||
54 | printk (f, ## a); \ | ||
55 | } \ | ||
56 | } while (0) | ||
57 | #else | ||
58 | #ifdef __GNUC__ | ||
59 | #define jbd_debug(f, a...) /**/ | ||
60 | #else | ||
61 | #define jbd_debug(f, ...) /**/ | ||
62 | #endif | ||
63 | #endif | ||
64 | #else | ||
65 | #define jbd_debug(x) /* AIX doesn't do STDC */ | ||
66 | #endif | ||
67 | |||
68 | extern void * __jbd_kmalloc (char *where, size_t size, int flags, int retry); | ||
69 | #define jbd_kmalloc(size, flags) \ | ||
70 | __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry) | ||
71 | #define jbd_rep_kmalloc(size, flags) \ | ||
72 | __jbd_kmalloc(__FUNCTION__, (size), (flags), 1) | ||
73 | |||
74 | #define JFS_MIN_JOURNAL_BLOCKS 1024 | ||
75 | |||
76 | #ifdef __KERNEL__ | ||
77 | typedef struct handle_s handle_t; /* Atomic operation type */ | ||
78 | typedef struct journal_s journal_t; /* Journal control structure */ | ||
79 | #endif | ||
80 | |||
81 | /* | ||
82 | * Internal structures used by the logging mechanism: | ||
83 | */ | ||
84 | |||
85 | #define JFS_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */ | ||
86 | |||
87 | /* | ||
88 | * On-disk structures | ||
89 | */ | ||
90 | |||
91 | /* | ||
92 | * Descriptor block types: | ||
93 | */ | ||
94 | |||
95 | #define JFS_DESCRIPTOR_BLOCK 1 | ||
96 | #define JFS_COMMIT_BLOCK 2 | ||
97 | #define JFS_SUPERBLOCK_V1 3 | ||
98 | #define JFS_SUPERBLOCK_V2 4 | ||
99 | #define JFS_REVOKE_BLOCK 5 | ||
100 | 22 | ||
101 | /* | 23 | /* |
102 | * Standard header for all descriptor blocks: | 24 | * Standard header for all descriptor blocks: |
103 | */ | 25 | */ |
26 | |||
104 | typedef struct journal_header_s | 27 | typedef struct journal_header_s |
105 | { | 28 | { |
106 | __u32 h_magic; | 29 | __u32 h_magic; |
@@ -108,32 +31,17 @@ typedef struct journal_header_s | |||
108 | __u32 h_sequence; | 31 | __u32 h_sequence; |
109 | } journal_header_t; | 32 | } journal_header_t; |
110 | 33 | ||
111 | |||
112 | /* | ||
113 | * The block tag: used to describe a single buffer in the journal | ||
114 | */ | ||
115 | typedef struct journal_block_tag_s | ||
116 | { | ||
117 | __u32 t_blocknr; /* The on-disk block number */ | ||
118 | __u32 t_flags; /* See below */ | ||
119 | } journal_block_tag_t; | ||
120 | |||
121 | /* | 34 | /* |
122 | * The revoke descriptor: used on disk to describe a series of blocks to | 35 | * This is the global e2fsck structure. |
123 | * be revoked from the log | ||
124 | */ | 36 | */ |
125 | typedef struct journal_revoke_header_s | 37 | typedef struct e2fsck_struct *e2fsck_t; |
126 | { | ||
127 | journal_header_t r_header; | ||
128 | int r_count; /* Count of bytes used in the block */ | ||
129 | } journal_revoke_header_t; | ||
130 | 38 | ||
131 | 39 | ||
132 | /* Definitions for the journal tag flags word: */ | 40 | struct inode { |
133 | #define JFS_FLAG_ESCAPE 1 /* on-disk block is escaped */ | 41 | e2fsck_t i_ctx; |
134 | #define JFS_FLAG_SAME_UUID 2 /* block has same uuid as previous */ | 42 | ext2_ino_t i_ino; |
135 | #define JFS_FLAG_DELETED 4 /* block deleted by this transaction */ | 43 | struct ext2_inode i_ext2; |
136 | #define JFS_FLAG_LAST_TAG 8 /* last tag in this descriptor block */ | 44 | }; |
137 | 45 | ||
138 | 46 | ||
139 | /* | 47 | /* |
@@ -184,6 +92,58 @@ typedef struct journal_superblock_s | |||
184 | /* 0x0400 */ | 92 | /* 0x0400 */ |
185 | } journal_superblock_t; | 93 | } journal_superblock_t; |
186 | 94 | ||
95 | |||
96 | extern int journal_blocks_per_page(struct inode *inode); | ||
97 | extern int jbd_blocks_per_page(struct inode *inode); | ||
98 | |||
99 | #define JFS_MIN_JOURNAL_BLOCKS 1024 | ||
100 | |||
101 | |||
102 | /* | ||
103 | * Internal structures used by the logging mechanism: | ||
104 | */ | ||
105 | |||
106 | #define JFS_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */ | ||
107 | |||
108 | /* | ||
109 | * Descriptor block types: | ||
110 | */ | ||
111 | |||
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 | ||
117 | |||
118 | /* | ||
119 | * The block tag: used to describe a single buffer in the journal | ||
120 | */ | ||
121 | typedef struct journal_block_tag_s | ||
122 | { | ||
123 | __u32 t_blocknr; /* The on-disk block number */ | ||
124 | __u32 t_flags; /* See below */ | ||
125 | } journal_block_tag_t; | ||
126 | |||
127 | /* | ||
128 | * The revoke descriptor: used on disk to describe a series of blocks to | ||
129 | * be revoked from the log | ||
130 | */ | ||
131 | typedef struct journal_revoke_header_s | ||
132 | { | ||
133 | journal_header_t r_header; | ||
134 | int r_count; /* Count of bytes used in the block */ | ||
135 | } journal_revoke_header_t; | ||
136 | |||
137 | |||
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 */ | ||
143 | |||
144 | |||
145 | |||
146 | |||
187 | #define JFS_HAS_COMPAT_FEATURE(j,mask) \ | 147 | #define JFS_HAS_COMPAT_FEATURE(j,mask) \ |
188 | ((j)->j_format_version >= 2 && \ | 148 | ((j)->j_format_version >= 2 && \ |
189 | ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask)))) | 149 | ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask)))) |
@@ -201,581 +161,59 @@ typedef struct journal_superblock_s | |||
201 | #define JFS_KNOWN_ROCOMPAT_FEATURES 0 | 161 | #define JFS_KNOWN_ROCOMPAT_FEATURES 0 |
202 | #define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE | 162 | #define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE |
203 | 163 | ||
204 | #ifdef __KERNEL__ | 164 | /* Comparison functions for transaction IDs: perform comparisons using |
205 | 165 | * modulo arithmetic so that they work over sequence number wraps. */ | |
206 | #include <linux/fs.h> | ||
207 | #include <linux/sched.h> | ||
208 | |||
209 | #define JBD_ASSERTIONS | ||
210 | #ifdef JBD_ASSERTIONS | ||
211 | #define J_ASSERT(assert) \ | ||
212 | do { \ | ||
213 | if (!(assert)) { \ | ||
214 | printk (KERN_EMERG \ | ||
215 | "Assertion failure in %s() at %s:%d: \"%s\"\n", \ | ||
216 | __FUNCTION__, __FILE__, __LINE__, # assert); \ | ||
217 | BUG(); \ | ||
218 | } \ | ||
219 | } while (0) | ||
220 | |||
221 | #if defined(CONFIG_BUFFER_DEBUG) | ||
222 | void buffer_assertion_failure(struct buffer_head *bh); | ||
223 | #define J_ASSERT_BH(bh, expr) \ | ||
224 | do { \ | ||
225 | if (!(expr)) \ | ||
226 | buffer_assertion_failure(bh); \ | ||
227 | J_ASSERT(expr); \ | ||
228 | } while (0) | ||
229 | #define J_ASSERT_JH(jh, expr) J_ASSERT_BH(jh2bh(jh), expr) | ||
230 | #else | ||
231 | #define J_ASSERT_BH(bh, expr) J_ASSERT(expr) | ||
232 | #define J_ASSERT_JH(jh, expr) J_ASSERT(expr) | ||
233 | #endif | ||
234 | |||
235 | #else | ||
236 | #define J_ASSERT(assert) | ||
237 | #endif /* JBD_ASSERTIONS */ | ||
238 | |||
239 | enum jbd_state_bits { | ||
240 | BH_JWrite | ||
241 | = BH_PrivateStart, /* 1 if being written to log (@@@ DEBUGGING) */ | ||
242 | BH_Freed, /* 1 if buffer has been freed (truncated) */ | ||
243 | BH_Revoked, /* 1 if buffer has been revoked from the log */ | ||
244 | BH_RevokeValid, /* 1 if buffer revoked flag is valid */ | ||
245 | BH_JBDDirty, /* 1 if buffer is dirty but journaled */ | ||
246 | }; | ||
247 | |||
248 | /* Return true if the buffer is one which JBD is managing */ | ||
249 | static inline int buffer_jbd(struct buffer_head *bh) | ||
250 | { | ||
251 | return __buffer_state(bh, JBD); | ||
252 | } | ||
253 | |||
254 | static inline struct buffer_head *jh2bh(struct journal_head *jh) | ||
255 | { | ||
256 | return jh->b_bh; | ||
257 | } | ||
258 | |||
259 | static inline struct journal_head *bh2jh(struct buffer_head *bh) | ||
260 | { | ||
261 | return bh->b_private; | ||
262 | } | ||
263 | |||
264 | struct jbd_revoke_table_s; | ||
265 | |||
266 | /* The handle_t type represents a single atomic update being performed | ||
267 | * by some process. All filesystem modifications made by the process go | ||
268 | * through this handle. Recursive operations (such as quota operations) | ||
269 | * are gathered into a single update. | ||
270 | * | ||
271 | * The buffer credits field is used to account for journaled buffers | ||
272 | * being modified by the running process. To ensure that there is | ||
273 | * enough log space for all outstanding operations, we need to limit the | ||
274 | * number of outstanding buffers possible at any time. When the | ||
275 | * operation completes, any buffer credits not used are credited back to | ||
276 | * the transaction, so that at all times we know how many buffers the | ||
277 | * outstanding updates on a transaction might possibly touch. */ | ||
278 | |||
279 | struct handle_s | ||
280 | { | ||
281 | /* Which compound transaction is this update a part of? */ | ||
282 | transaction_t * h_transaction; | ||
283 | |||
284 | /* Number of remaining buffers we are allowed to dirty: */ | ||
285 | int h_buffer_credits; | ||
286 | |||
287 | /* Reference count on this handle */ | ||
288 | int h_ref; | ||
289 | 166 | ||
290 | /* Field for caller's use to track errors through large fs | ||
291 | operations */ | ||
292 | int h_err; | ||
293 | 167 | ||
294 | /* Flags */ | 168 | /* |
295 | unsigned int h_sync: 1; /* sync-on-close */ | 169 | * Definitions which augment the buffer_head layer |
296 | unsigned int h_jdata: 1; /* force data journaling */ | 170 | */ |
297 | unsigned int h_aborted: 1; /* fatal error on handle */ | ||
298 | }; | ||
299 | 171 | ||
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 | ||
300 | 183 | ||
301 | /* The transaction_t type is the guts of the journaling mechanism. It | ||
302 | * tracks a compound transaction through its various states: | ||
303 | * | ||
304 | * RUNNING: accepting new updates | ||
305 | * LOCKED: Updates still running but we don't accept new ones | ||
306 | * RUNDOWN: Updates are tidying up but have finished requesting | ||
307 | * new buffers to modify (state not used for now) | ||
308 | * FLUSH: All updates complete, but we are still writing to disk | ||
309 | * COMMIT: All data on disk, writing commit record | ||
310 | * FINISHED: We still have to keep the transaction for checkpointing. | ||
311 | * | ||
312 | * The transaction keeps track of all of the buffers modified by a | ||
313 | * running transaction, and all of the buffers committed but not yet | ||
314 | * flushed to home for finished transactions. | ||
315 | */ | ||
316 | 184 | ||
317 | struct transaction_s | 185 | struct kdev_s { |
318 | { | 186 | e2fsck_t k_ctx; |
319 | /* Pointer to the journal for this transaction. */ | 187 | int k_dev; |
320 | journal_t * t_journal; | ||
321 | |||
322 | /* Sequence number for this transaction */ | ||
323 | tid_t t_tid; | ||
324 | |||
325 | /* Transaction's current state */ | ||
326 | enum { | ||
327 | T_RUNNING, | ||
328 | T_LOCKED, | ||
329 | T_RUNDOWN, | ||
330 | T_FLUSH, | ||
331 | T_COMMIT, | ||
332 | T_FINISHED | ||
333 | } t_state; | ||
334 | |||
335 | /* Where in the log does this transaction's commit start? */ | ||
336 | unsigned long t_log_start; | ||
337 | |||
338 | /* Doubly-linked circular list of all inodes owned by this | ||
339 | transaction */ /* AKPM: unused */ | ||
340 | struct inode * t_ilist; | ||
341 | |||
342 | /* Number of buffers on the t_buffers list */ | ||
343 | int t_nr_buffers; | ||
344 | |||
345 | /* Doubly-linked circular list of all buffers reserved but not | ||
346 | yet modified by this transaction */ | ||
347 | struct journal_head * t_reserved_list; | ||
348 | |||
349 | /* Doubly-linked circular list of all metadata buffers owned by this | ||
350 | transaction */ | ||
351 | struct journal_head * t_buffers; | ||
352 | |||
353 | /* | ||
354 | * Doubly-linked circular list of all data buffers still to be | ||
355 | * flushed before this transaction can be committed. | ||
356 | * Protected by journal_datalist_lock. | ||
357 | */ | ||
358 | struct journal_head * t_sync_datalist; | ||
359 | |||
360 | /* | ||
361 | * Doubly-linked circular list of all writepage data buffers | ||
362 | * still to be written before this transaction can be committed. | ||
363 | * Protected by journal_datalist_lock. | ||
364 | */ | ||
365 | struct journal_head * t_async_datalist; | ||
366 | |||
367 | /* Doubly-linked circular list of all forget buffers (superceded | ||
368 | buffers which we can un-checkpoint once this transaction | ||
369 | commits) */ | ||
370 | struct journal_head * t_forget; | ||
371 | |||
372 | /* | ||
373 | * Doubly-linked circular list of all buffers still to be | ||
374 | * flushed before this transaction can be checkpointed. | ||
375 | */ | ||
376 | /* Protected by journal_datalist_lock */ | ||
377 | struct journal_head * t_checkpoint_list; | ||
378 | |||
379 | /* Doubly-linked circular list of temporary buffers currently | ||
380 | undergoing IO in the log */ | ||
381 | struct journal_head * t_iobuf_list; | ||
382 | |||
383 | /* Doubly-linked circular list of metadata buffers being | ||
384 | shadowed by log IO. The IO buffers on the iobuf list and the | ||
385 | shadow buffers on this list match each other one for one at | ||
386 | all times. */ | ||
387 | struct journal_head * t_shadow_list; | ||
388 | |||
389 | /* Doubly-linked circular list of control buffers being written | ||
390 | to the log. */ | ||
391 | struct journal_head * t_log_list; | ||
392 | |||
393 | /* Number of outstanding updates running on this transaction */ | ||
394 | int t_updates; | ||
395 | |||
396 | /* Number of buffers reserved for use by all handles in this | ||
397 | * transaction handle but not yet modified. */ | ||
398 | int t_outstanding_credits; | ||
399 | |||
400 | /* | ||
401 | * Forward and backward links for the circular list of all | ||
402 | * transactions awaiting checkpoint. | ||
403 | */ | ||
404 | /* Protected by journal_datalist_lock */ | ||
405 | transaction_t *t_cpnext, *t_cpprev; | ||
406 | |||
407 | /* When will the transaction expire (become due for commit), in | ||
408 | * jiffies ? */ | ||
409 | unsigned long t_expires; | ||
410 | |||
411 | /* How many handles used this transaction? */ | ||
412 | int t_handle_count; | ||
413 | }; | 188 | }; |
414 | 189 | ||
415 | 190 | typedef struct kdev_s *kdev_t; | |
416 | /* The journal_t maintains all of the journaling state information for a | 191 | typedef unsigned int tid_t; |
417 | * single filesystem. It is linked to from the fs superblock structure. | ||
418 | * | ||
419 | * We use the journal_t to keep track of all outstanding transaction | ||
420 | * activity on the filesystem, and to manage the state of the log | ||
421 | * writing process. */ | ||
422 | 192 | ||
423 | struct journal_s | 193 | struct journal_s |
424 | { | 194 | { |
425 | /* General journaling state flags */ | ||
426 | unsigned long j_flags; | 195 | unsigned long j_flags; |
427 | |||
428 | /* Is there an outstanding uncleared error on the journal (from | ||
429 | * a prior abort)? */ | ||
430 | int j_errno; | 196 | int j_errno; |
431 | |||
432 | /* The superblock buffer */ | ||
433 | struct buffer_head * j_sb_buffer; | 197 | struct buffer_head * j_sb_buffer; |
434 | journal_superblock_t * j_superblock; | 198 | struct journal_superblock_s *j_superblock; |
435 | |||
436 | /* Version of the superblock format */ | ||
437 | int j_format_version; | 199 | int j_format_version; |
438 | |||
439 | /* Number of processes waiting to create a barrier lock */ | ||
440 | int j_barrier_count; | ||
441 | |||
442 | /* The barrier lock itself */ | ||
443 | struct semaphore j_barrier; | ||
444 | |||
445 | /* Transactions: The current running transaction... */ | ||
446 | transaction_t * j_running_transaction; | ||
447 | |||
448 | /* ... the transaction we are pushing to disk ... */ | ||
449 | transaction_t * j_committing_transaction; | ||
450 | |||
451 | /* ... and a linked circular list of all transactions waiting | ||
452 | * for checkpointing. */ | ||
453 | /* Protected by journal_datalist_lock */ | ||
454 | transaction_t * j_checkpoint_transactions; | ||
455 | |||
456 | /* Wait queue for waiting for a locked transaction to start | ||
457 | committing, or for a barrier lock to be released */ | ||
458 | wait_queue_head_t j_wait_transaction_locked; | ||
459 | |||
460 | /* Wait queue for waiting for checkpointing to complete */ | ||
461 | wait_queue_head_t j_wait_logspace; | ||
462 | |||
463 | /* Wait queue for waiting for commit to complete */ | ||
464 | wait_queue_head_t j_wait_done_commit; | ||
465 | |||
466 | /* Wait queue to trigger checkpointing */ | ||
467 | wait_queue_head_t j_wait_checkpoint; | ||
468 | |||
469 | /* Wait queue to trigger commit */ | ||
470 | wait_queue_head_t j_wait_commit; | ||
471 | |||
472 | /* Wait queue to wait for updates to complete */ | ||
473 | wait_queue_head_t j_wait_updates; | ||
474 | |||
475 | /* Semaphore for locking against concurrent checkpoints */ | ||
476 | struct semaphore j_checkpoint_sem; | ||
477 | |||
478 | /* The main journal lock, used by lock_journal() */ | ||
479 | struct semaphore j_sem; | ||
480 | |||
481 | /* Journal head: identifies the first unused block in the journal. */ | ||
482 | unsigned long j_head; | 200 | unsigned long j_head; |
483 | |||
484 | /* Journal tail: identifies the oldest still-used block in the | ||
485 | * journal. */ | ||
486 | unsigned long j_tail; | 201 | unsigned long j_tail; |
487 | |||
488 | /* Journal free: how many free blocks are there in the journal? */ | ||
489 | unsigned long j_free; | 202 | unsigned long j_free; |
490 | |||
491 | /* Journal start and end: the block numbers of the first usable | ||
492 | * block and one beyond the last usable block in the journal. */ | ||
493 | unsigned long j_first, j_last; | 203 | unsigned long j_first, j_last; |
494 | |||
495 | /* Device, blocksize and starting block offset for the location | ||
496 | * where we store the journal. */ | ||
497 | kdev_t j_dev; | 204 | kdev_t j_dev; |
205 | kdev_t j_fs_dev; | ||
498 | int j_blocksize; | 206 | int j_blocksize; |
499 | unsigned int j_blk_offset; | 207 | unsigned int j_blk_offset; |
500 | |||
501 | /* Device which holds the client fs. For internal journal this | ||
502 | * will be equal to j_dev. */ | ||
503 | kdev_t j_fs_dev; | ||
504 | |||
505 | /* Total maximum capacity of the journal region on disk. */ | ||
506 | unsigned int j_maxlen; | 208 | unsigned int j_maxlen; |
507 | |||
508 | /* Optional inode where we store the journal. If present, all | ||
509 | * journal block numbers are mapped into this inode via | ||
510 | * bmap(). */ | ||
511 | struct inode * j_inode; | 209 | struct inode * j_inode; |
512 | |||
513 | /* Sequence number of the oldest transaction in the log */ | ||
514 | tid_t j_tail_sequence; | 210 | tid_t j_tail_sequence; |
515 | /* Sequence number of the next transaction to grant */ | ||
516 | tid_t j_transaction_sequence; | 211 | tid_t j_transaction_sequence; |
517 | /* Sequence number of the most recently committed transaction */ | ||
518 | tid_t j_commit_sequence; | ||
519 | /* Sequence number of the most recent transaction wanting commit */ | ||
520 | tid_t j_commit_request; | ||
521 | |||
522 | /* Journal uuid: identifies the object (filesystem, LVM volume | ||
523 | * etc) backed by this journal. This will eventually be | ||
524 | * replaced by an array of uuids, allowing us to index multiple | ||
525 | * devices within a single journal and to perform atomic updates | ||
526 | * across them. */ | ||
527 | |||
528 | __u8 j_uuid[16]; | 212 | __u8 j_uuid[16]; |
529 | |||
530 | /* Pointer to the current commit thread for this journal */ | ||
531 | struct task_struct * j_task; | ||
532 | |||
533 | /* Maximum number of metadata buffers to allow in a single | ||
534 | * compound commit transaction */ | ||
535 | int j_max_transaction_buffers; | ||
536 | |||
537 | /* What is the maximum transaction lifetime before we begin a | ||
538 | * commit? */ | ||
539 | unsigned long j_commit_interval; | ||
540 | |||
541 | /* The timer used to wakeup the commit thread: */ | ||
542 | struct timer_list * j_commit_timer; | ||
543 | int j_commit_timer_active; | ||
544 | |||
545 | /* Link all journals together - system-wide */ | ||
546 | struct list_head j_all_journals; | ||
547 | |||
548 | /* The revoke table: maintains the list of revoked blocks in the | ||
549 | current transaction. */ | ||
550 | struct jbd_revoke_table_s *j_revoke; | 213 | struct jbd_revoke_table_s *j_revoke; |
551 | }; | 214 | }; |
552 | 215 | ||
553 | /* | 216 | typedef struct journal_s journal_t; |
554 | * Journal flag definitions | ||
555 | */ | ||
556 | #define JFS_UNMOUNT 0x001 /* Journal thread is being destroyed */ | ||
557 | #define JFS_ABORT 0x002 /* Journaling has been aborted for errors. */ | ||
558 | #define JFS_ACK_ERR 0x004 /* The errno in the sb has been acked */ | ||
559 | #define JFS_FLUSHED 0x008 /* The journal superblock has been flushed */ | ||
560 | #define JFS_LOADED 0x010 /* The journal superblock has been loaded */ | ||
561 | |||
562 | /* | ||
563 | * Function declarations for the journaling transaction and buffer | ||
564 | * management | ||
565 | */ | ||
566 | |||
567 | /* Filing buffers */ | ||
568 | extern void __journal_unfile_buffer(struct journal_head *); | ||
569 | extern void journal_unfile_buffer(struct journal_head *); | ||
570 | extern void __journal_refile_buffer(struct journal_head *); | ||
571 | extern void journal_refile_buffer(struct journal_head *); | ||
572 | extern void __journal_file_buffer(struct journal_head *, transaction_t *, int); | ||
573 | extern void __journal_free_buffer(struct journal_head *bh); | ||
574 | extern void journal_file_buffer(struct journal_head *, transaction_t *, int); | ||
575 | extern void __journal_clean_data_list(transaction_t *transaction); | ||
576 | |||
577 | /* Log buffer allocation */ | ||
578 | extern struct journal_head * journal_get_descriptor_buffer(journal_t *); | ||
579 | extern unsigned long journal_next_log_block(journal_t *); | ||
580 | |||
581 | /* Commit management */ | ||
582 | extern void journal_commit_transaction(journal_t *); | ||
583 | |||
584 | /* Checkpoint list management */ | ||
585 | int __journal_clean_checkpoint_list(journal_t *journal); | ||
586 | extern void journal_remove_checkpoint(struct journal_head *); | ||
587 | extern void __journal_remove_checkpoint(struct journal_head *); | ||
588 | extern void journal_insert_checkpoint(struct journal_head *, transaction_t *); | ||
589 | extern void __journal_insert_checkpoint(struct journal_head *,transaction_t *); | ||
590 | |||
591 | /* Buffer IO */ | ||
592 | extern int | ||
593 | journal_write_metadata_buffer(transaction_t *transaction, | ||
594 | struct journal_head *jh_in, | ||
595 | struct journal_head **jh_out, | ||
596 | int blocknr); | ||
597 | |||
598 | /* Transaction locking */ | ||
599 | extern void __wait_on_journal (journal_t *); | ||
600 | |||
601 | /* | ||
602 | * Journal locking. | ||
603 | * | ||
604 | * We need to lock the journal during transaction state changes so that | ||
605 | * nobody ever tries to take a handle on the running transaction while | ||
606 | * we are in the middle of moving it to the commit phase. | ||
607 | * | ||
608 | * Note that the locking is completely interrupt unsafe. We never touch | ||
609 | * journal structures from interrupts. | ||
610 | * | ||
611 | * In 2.2, the BKL was required for lock_journal. This is no longer | ||
612 | * the case. | ||
613 | */ | ||
614 | |||
615 | static inline void lock_journal(journal_t *journal) | ||
616 | { | ||
617 | down(&journal->j_sem); | ||
618 | } | ||
619 | |||
620 | /* This returns zero if we acquired the semaphore */ | ||
621 | static inline int try_lock_journal(journal_t * journal) | ||
622 | { | ||
623 | return down_trylock(&journal->j_sem); | ||
624 | } | ||
625 | |||
626 | static inline void unlock_journal(journal_t * journal) | ||
627 | { | ||
628 | up(&journal->j_sem); | ||
629 | } | ||
630 | |||
631 | |||
632 | static inline handle_t *journal_current_handle(void) | ||
633 | { | ||
634 | return current->journal_info; | ||
635 | } | ||
636 | |||
637 | /* The journaling code user interface: | ||
638 | * | ||
639 | * Create and destroy handles | ||
640 | * Register buffer modifications against the current transaction. | ||
641 | */ | ||
642 | |||
643 | extern handle_t *journal_start(journal_t *, int nblocks); | ||
644 | extern handle_t *journal_try_start(journal_t *, int nblocks); | ||
645 | extern int journal_restart (handle_t *, int nblocks); | ||
646 | extern int journal_extend (handle_t *, int nblocks); | ||
647 | extern int journal_get_write_access (handle_t *, struct buffer_head *); | ||
648 | extern int journal_get_create_access (handle_t *, struct buffer_head *); | ||
649 | extern int journal_get_undo_access (handle_t *, struct buffer_head *); | ||
650 | extern int journal_dirty_data (handle_t *, | ||
651 | struct buffer_head *, int async); | ||
652 | extern int journal_dirty_metadata (handle_t *, struct buffer_head *); | ||
653 | extern void journal_release_buffer (handle_t *, struct buffer_head *); | ||
654 | extern void journal_forget (handle_t *, struct buffer_head *); | ||
655 | extern void journal_sync_buffer (struct buffer_head *); | ||
656 | extern int journal_flushpage(journal_t *, struct page *, unsigned long); | ||
657 | extern int journal_try_to_free_buffers(journal_t *, struct page *, int); | ||
658 | extern int journal_stop(handle_t *); | ||
659 | extern int journal_flush (journal_t *); | ||
660 | |||
661 | extern void journal_lock_updates (journal_t *); | ||
662 | extern void journal_unlock_updates (journal_t *); | ||
663 | |||
664 | extern journal_t * journal_init_dev(kdev_t dev, kdev_t fs_dev, | ||
665 | int start, int len, int bsize); | ||
666 | extern journal_t * journal_init_inode (struct inode *); | ||
667 | extern int journal_update_format (journal_t *); | ||
668 | extern int journal_check_used_features | ||
669 | (journal_t *, unsigned long, unsigned long, unsigned long); | ||
670 | extern int journal_check_available_features | ||
671 | (journal_t *, unsigned long, unsigned long, unsigned long); | ||
672 | extern int journal_set_features | ||
673 | (journal_t *, unsigned long, unsigned long, unsigned long); | ||
674 | extern int journal_create (journal_t *); | ||
675 | extern int journal_load (journal_t *journal); | ||
676 | extern void journal_destroy (journal_t *); | ||
677 | extern int journal_recover (journal_t *journal); | ||
678 | extern int journal_wipe (journal_t *, int); | ||
679 | extern int journal_skip_recovery (journal_t *); | ||
680 | extern void journal_update_superblock (journal_t *, int); | ||
681 | extern void __journal_abort (journal_t *); | ||
682 | extern void journal_abort (journal_t *, int); | ||
683 | extern int journal_errno (journal_t *); | ||
684 | extern void journal_ack_err (journal_t *); | ||
685 | extern int journal_clear_err (journal_t *); | ||
686 | extern unsigned long journal_bmap(journal_t *journal, unsigned long blocknr); | ||
687 | extern int journal_force_commit(journal_t *journal); | ||
688 | |||
689 | /* | ||
690 | * journal_head management | ||
691 | */ | ||
692 | extern struct journal_head | ||
693 | *journal_add_journal_head(struct buffer_head *bh); | ||
694 | extern void journal_remove_journal_head(struct buffer_head *bh); | ||
695 | extern void __journal_remove_journal_head(struct buffer_head *bh); | ||
696 | extern void journal_unlock_journal_head(struct journal_head *jh); | ||
697 | |||
698 | /* Primary revoke support */ | ||
699 | #define JOURNAL_REVOKE_DEFAULT_HASH 256 | ||
700 | extern int journal_init_revoke(journal_t *, int); | ||
701 | extern void journal_destroy_revoke_caches(void); | ||
702 | extern int journal_init_revoke_caches(void); | ||
703 | |||
704 | extern void journal_destroy_revoke(journal_t *); | ||
705 | extern int journal_revoke (handle_t *, | ||
706 | unsigned long, struct buffer_head *); | ||
707 | extern int journal_cancel_revoke(handle_t *, struct journal_head *); | ||
708 | extern void journal_write_revoke_records(journal_t *, transaction_t *); | ||
709 | |||
710 | /* Recovery revoke support */ | ||
711 | extern int journal_set_revoke(journal_t *, unsigned long, tid_t); | ||
712 | extern int journal_test_revoke(journal_t *, unsigned long, tid_t); | ||
713 | extern void journal_clear_revoke(journal_t *); | ||
714 | extern void journal_brelse_array(struct buffer_head *b[], int n); | ||
715 | |||
716 | /* The log thread user interface: | ||
717 | * | ||
718 | * Request space in the current transaction, and force transaction commit | ||
719 | * transitions on demand. | ||
720 | */ | ||
721 | |||
722 | extern int log_space_left (journal_t *); /* Called with journal locked */ | ||
723 | extern tid_t log_start_commit (journal_t *, transaction_t *); | ||
724 | extern void log_wait_commit (journal_t *, tid_t); | ||
725 | extern int log_do_checkpoint (journal_t *, int); | ||
726 | |||
727 | extern void log_wait_for_space(journal_t *, int nblocks); | ||
728 | extern void __journal_drop_transaction(journal_t *, transaction_t *); | ||
729 | extern int cleanup_journal_tail(journal_t *); | ||
730 | |||
731 | /* Reduce journal memory usage by flushing */ | ||
732 | extern void shrink_journal_memory(void); | ||
733 | |||
734 | /* Debugging code only: */ | ||
735 | |||
736 | #define jbd_ENOSYS() \ | ||
737 | do { \ | ||
738 | printk (KERN_ERR "JBD unimplemented function " __FUNCTION__); \ | ||
739 | current->state = TASK_UNINTERRUPTIBLE; \ | ||
740 | schedule(); \ | ||
741 | } while (1) | ||
742 | |||
743 | /* | ||
744 | * is_journal_abort | ||
745 | * | ||
746 | * Simple test wrapper function to test the JFS_ABORT state flag. This | ||
747 | * bit, when set, indicates that we have had a fatal error somewhere, | ||
748 | * either inside the journaling layer or indicated to us by the client | ||
749 | * (eg. ext3), and that we and should not commit any further | ||
750 | * transactions. | ||
751 | */ | ||
752 | |||
753 | static inline int is_journal_aborted(journal_t *journal) | ||
754 | { | ||
755 | return journal->j_flags & JFS_ABORT; | ||
756 | } | ||
757 | |||
758 | static inline int is_handle_aborted(handle_t *handle) | ||
759 | { | ||
760 | if (handle->h_aborted) | ||
761 | return 1; | ||
762 | return is_journal_aborted(handle->h_transaction->t_journal); | ||
763 | } | ||
764 | |||
765 | static inline void journal_abort_handle(handle_t *handle) | ||
766 | { | ||
767 | handle->h_aborted = 1; | ||
768 | } | ||
769 | |||
770 | /* Not all architectures define BUG() */ | ||
771 | #ifndef BUG | ||
772 | #define BUG() do { \ | ||
773 | printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ | ||
774 | * ((char *) 0) = 0; \ | ||
775 | } while (0) | ||
776 | #endif /* BUG */ | ||
777 | |||
778 | #else | ||
779 | 217 | ||
780 | extern int journal_recover (journal_t *journal); | 218 | extern int journal_recover (journal_t *journal); |
781 | extern int journal_skip_recovery (journal_t *); | 219 | extern int journal_skip_recovery (journal_t *); |
@@ -792,119 +230,6 @@ extern void journal_clear_revoke(journal_t *); | |||
792 | extern void journal_brelse_array(struct buffer_head *b[], int n); | 230 | extern void journal_brelse_array(struct buffer_head *b[], int n); |
793 | 231 | ||
794 | extern void journal_destroy_revoke(journal_t *); | 232 | extern void journal_destroy_revoke(journal_t *); |
795 | #endif /* __KERNEL__ */ | ||
796 | |||
797 | /* Comparison functions for transaction IDs: perform comparisons using | ||
798 | * modulo arithmetic so that they work over sequence number wraps. */ | ||
799 | |||
800 | static inline int tid_gt(tid_t x, tid_t y) | ||
801 | { | ||
802 | int difference = (x - y); | ||
803 | return (difference > 0); | ||
804 | } | ||
805 | |||
806 | static inline int tid_geq(tid_t x, tid_t y) | ||
807 | { | ||
808 | int difference = (x - y); | ||
809 | return (difference >= 0); | ||
810 | } | ||
811 | |||
812 | extern int journal_blocks_per_page(struct inode *inode); | ||
813 | |||
814 | /* | ||
815 | * Definitions which augment the buffer_head layer | ||
816 | */ | ||
817 | |||
818 | /* journaling buffer types */ | ||
819 | #define BJ_None 0 /* Not journaled */ | ||
820 | #define BJ_SyncData 1 /* Normal data: flush before commit */ | ||
821 | #define BJ_AsyncData 2 /* writepage data: wait on it before commit */ | ||
822 | #define BJ_Metadata 3 /* Normal journaled metadata */ | ||
823 | #define BJ_Forget 4 /* Buffer superceded by this transaction */ | ||
824 | #define BJ_IO 5 /* Buffer is for temporary IO use */ | ||
825 | #define BJ_Shadow 6 /* Buffer contents being shadowed to the log */ | ||
826 | #define BJ_LogCtl 7 /* Buffer contains log descriptors */ | ||
827 | #define BJ_Reserved 8 /* Buffer is reserved for access by journal */ | ||
828 | #define BJ_Types 9 | ||
829 | |||
830 | extern int jbd_blocks_per_page(struct inode *inode); | ||
831 | |||
832 | #ifdef __KERNEL__ | ||
833 | |||
834 | extern spinlock_t jh_splice_lock; | ||
835 | /* | ||
836 | * Once `expr1' has been found true, take jh_splice_lock | ||
837 | * and then reevaluate everything. | ||
838 | */ | ||
839 | #define SPLICE_LOCK(expr1, expr2) \ | ||
840 | ({ \ | ||
841 | int ret = (expr1); \ | ||
842 | if (ret) { \ | ||
843 | spin_lock(&jh_splice_lock); \ | ||
844 | ret = (expr1) && (expr2); \ | ||
845 | spin_unlock(&jh_splice_lock); \ | ||
846 | } \ | ||
847 | ret; \ | ||
848 | }) | ||
849 | |||
850 | /* | ||
851 | * A number of buffer state predicates. They test for | ||
852 | * buffer_jbd() because they are used in core kernel code. | ||
853 | * | ||
854 | * These will be racy on SMP unless we're *sure* that the | ||
855 | * buffer won't be detached from the journalling system | ||
856 | * in parallel. | ||
857 | */ | ||
858 | |||
859 | /* Return true if the buffer is on journal list `list' */ | ||
860 | static inline int buffer_jlist_eq(struct buffer_head *bh, int list) | ||
861 | { | ||
862 | return SPLICE_LOCK(buffer_jbd(bh), bh2jh(bh)->b_jlist == list); | ||
863 | } | ||
864 | |||
865 | /* Return true if this bufer is dirty wrt the journal */ | ||
866 | static inline int buffer_jdirty(struct buffer_head *bh) | ||
867 | { | ||
868 | return buffer_jbd(bh) && __buffer_state(bh, JBDDirty); | ||
869 | } | ||
870 | |||
871 | /* Return true if it's a data buffer which journalling is managing */ | ||
872 | static inline int buffer_jbd_data(struct buffer_head *bh) | ||
873 | { | ||
874 | return SPLICE_LOCK(buffer_jbd(bh), | ||
875 | bh2jh(bh)->b_jlist == BJ_SyncData || | ||
876 | bh2jh(bh)->b_jlist == BJ_AsyncData); | ||
877 | } | ||
878 | |||
879 | #ifdef CONFIG_SMP | ||
880 | #define assert_spin_locked(lock) J_ASSERT(spin_is_locked(lock)) | ||
881 | #else | ||
882 | #define assert_spin_locked(lock) do {} while(0) | ||
883 | #endif | ||
884 | |||
885 | #define buffer_trace_init(bh) do {} while (0) | ||
886 | #define print_buffer_fields(bh) do {} while (0) | ||
887 | #define print_buffer_trace(bh) do {} while (0) | ||
888 | #define BUFFER_TRACE(bh, info) do {} while (0) | ||
889 | #define BUFFER_TRACE2(bh, bh2, info) do {} while (0) | ||
890 | #define JBUFFER_TRACE(jh, info) do {} while (0) | ||
891 | |||
892 | #endif /* __KERNEL__ */ | ||
893 | |||
894 | #endif /* CONFIG_JBD || CONFIG_JBD_MODULE || !__KERNEL__ */ | ||
895 | |||
896 | /* | ||
897 | * Compatibility no-ops which allow the kernel to compile without CONFIG_JBD | ||
898 | * go here. | ||
899 | */ | ||
900 | |||
901 | #if defined(__KERNEL__) && !(defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE)) | ||
902 | 233 | ||
903 | #define J_ASSERT(expr) do {} while (0) | ||
904 | #define J_ASSERT_BH(bh, expr) do {} while (0) | ||
905 | #define buffer_jbd(bh) 0 | ||
906 | #define buffer_jlist_eq(bh, val) 0 | ||
907 | #define journal_buffer_journal_lru(bh) 0 | ||
908 | 234 | ||
909 | #endif /* defined(__KERNEL__) && !defined(CONFIG_JBD) */ | ||
910 | #endif /* _LINUX_JBD_H */ | 235 | #endif /* _LINUX_JBD_H */ |
diff --git a/e2fsprogs/ext2fs/mkjournal.c b/e2fsprogs/ext2fs/mkjournal.c index 0a9ae7a4d..47a459055 100644 --- a/e2fsprogs/ext2fs/mkjournal.c +++ b/e2fsprogs/ext2fs/mkjournal.c | |||
@@ -34,8 +34,9 @@ | |||
34 | 34 | ||
35 | #include "ext2_fs.h" | 35 | #include "ext2_fs.h" |
36 | #include "../e2p/e2p.h" | 36 | #include "../e2p/e2p.h" |
37 | #include "../e2fsck.h" | ||
37 | #include "ext2fs.h" | 38 | #include "ext2fs.h" |
38 | #include "jfs_user.h" | 39 | #include "kernel-jbd.h" |
39 | 40 | ||
40 | /* | 41 | /* |
41 | * This function automatically sets up the journal superblock and | 42 | * This function automatically sets up the journal superblock and |
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index 2bd9a65ae..65ff445e7 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "ext2fs/ext2fs.h" | 39 | #include "ext2fs/ext2fs.h" |
40 | #include "uuid/uuid.h" | 40 | #include "uuid/uuid.h" |
41 | #include "e2p/e2p.h" | 41 | #include "e2p/e2p.h" |
42 | #include "ext2fs/jfs_user.h" | 42 | #include "ext2fs/kernel-jbd.h" |
43 | #include "util.h" | 43 | #include "util.h" |
44 | #include "blkid/blkid.h" | 44 | #include "blkid/blkid.h" |
45 | 45 | ||