Whamcloud - gitweb
JBD: Fix NULL pointer bh->b_data on NUMA box with journal checksumming.
[fs/lustre-release.git] / lustre / kernel_patches / patches / jbd-journal-chksum-2.6.18-vanilla.patch
1 Index: linux-2.6.18.8/fs/jbd/commit.c
2 ===================================================================
3 --- linux-2.6.18.8.orig/fs/jbd/commit.c
4 +++ linux-2.6.18.8/fs/jbd/commit.c
5 @@ -22,6 +22,7 @@
6  #include <linux/mm.h>
7  #include <linux/pagemap.h>
8  #include <linux/smp_lock.h>
9 +#include <linux/crc32.h>
10  
11  
12  /*
13 @@ -95,19 +96,23 @@ static int inverted_lock(journal_t *jour
14         return 1;
15  }
16  
17 -/* Done it all: now write the commit record.  We should have
18 +/*
19 + * Done it all: now submit the commit record.  We should have
20   * cleaned up our previous buffers by now, so if we are in abort
21   * mode we can now just skip the rest of the journal write
22   * entirely.
23   *
24   * Returns 1 if the journal needs to be aborted or 0 on success
25   */
26 -static int journal_write_commit_record(journal_t *journal,
27 -                                       transaction_t *commit_transaction)
28 +static int journal_submit_commit_record(journal_t *journal,
29 +                                       transaction_t *commit_transaction,
30 +                                       struct buffer_head **cbh,
31 +                                       __u32 crc32_sum)
32  {
33         struct journal_head *descriptor;
34 +       struct commit_header *tmp;
35         struct buffer_head *bh;
36 -       int i, ret;
37 +       int ret;
38         int barrier_done = 0;
39  
40         if (is_journal_aborted(journal))
41 @@ -119,21 +124,34 @@ static int journal_write_commit_record(j
42  
43         bh = jh2bh(descriptor);
44  
45 -       /* AKPM: buglet - add `i' to tmp! */
46 -       for (i = 0; i < bh->b_size; i += 512) {
47 -               journal_header_t *tmp = (journal_header_t*)bh->b_data;
48 -               tmp->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER);
49 -               tmp->h_blocktype = cpu_to_be32(JFS_COMMIT_BLOCK);
50 -               tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid);
51 +       tmp = (struct commit_header *)bh->b_data;
52 +       tmp->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER);
53 +       tmp->h_blocktype = cpu_to_be32(JFS_COMMIT_BLOCK);
54 +       tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid);
55 +                               
56 +       if (JFS_HAS_COMPAT_FEATURE(journal,
57 +                               JFS_FEATURE_COMPAT_CHECKSUM)) {
58 +               tmp->h_chksum_type      = JFS_CRC32_CHKSUM;
59 +               tmp->h_chksum_size      = JFS_CRC32_CHKSUM_SIZE;
60 +               tmp->h_chksum[0]        = cpu_to_be32(crc32_sum);
61         }
62  
63 -       JBUFFER_TRACE(descriptor, "write commit block");
64 +       JBUFFER_TRACE(descriptor, "submit commit block");
65 +       lock_buffer(bh);
66 +
67         set_buffer_dirty(bh);
68 -       if (journal->j_flags & JFS_BARRIER) {
69 +       set_buffer_uptodate(bh);
70 +       bh->b_end_io = journal_end_buffer_io_sync;
71 +
72 +       if (journal->j_flags & JFS_BARRIER &&
73 +               !JFS_HAS_COMPAT_FEATURE(journal,
74 +                                        JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)) {
75 +
76                 set_buffer_ordered(bh);
77                 barrier_done = 1;
78         }
79 -       ret = sync_dirty_buffer(bh);
80 +       ret = submit_bh(WRITE, bh);
81 +
82         /* is it possible for another commit to fail at roughly
83          * the same time as this one?  If so, we don't want to
84          * trust the barrier flag in the super, but instead want
85 @@ -154,12 +172,70 @@ static int journal_write_commit_record(j
86                 clear_buffer_ordered(bh);
87                 set_buffer_uptodate(bh);
88                 set_buffer_dirty(bh);
89 -               ret = sync_dirty_buffer(bh);
90 +               ret = submit_bh(WRITE, bh);
91         }
92 -       put_bh(bh);             /* One for getblk() */
93 -       journal_put_journal_head(descriptor);
94 +       *cbh = bh;
95 +       return ret;
96 +}
97 +
98 +/*
99 + * This function along with journal_submit_commit_record
100 + * allows to write the commit record asynchronously.
101 + */
102 +static int journal_wait_on_commit_record(struct buffer_head *bh)
103 +{
104 +       int ret = 0;
105 +
106 +       clear_buffer_dirty(bh);
107 +       wait_on_buffer(bh);
108 +       
109 +       if (unlikely(!buffer_uptodate(bh)))
110 +               ret = -EIO;
111 +       put_bh(bh);            /* One for getblk() */
112 +       journal_put_journal_head(bh2jh(bh));
113 +       
114 +       return ret;
115 +}
116 +
117 +/*
118 + * Wait for all submitted IO to complete.
119 + */
120 +static int journal_wait_on_locked_list(journal_t *journal,
121 +                                      transaction_t *commit_transaction)
122 +{
123 +       int ret = 0;
124 +       struct journal_head *jh;
125  
126 -       return (ret == -EIO);
127 +       while (commit_transaction->t_locked_list) {
128 +               struct buffer_head *bh;
129 +
130 +               jh = commit_transaction->t_locked_list->b_tprev;
131 +               bh = jh2bh(jh);
132 +               get_bh(bh);
133 +               if (buffer_locked(bh)) {
134 +                       spin_unlock(&journal->j_list_lock);
135 +                       wait_on_buffer(bh);
136 +                       if (unlikely(!buffer_uptodate(bh)))
137 +                               ret = -EIO;
138 +                       spin_lock(&journal->j_list_lock);
139 +               }
140 +               if (!inverted_lock(journal, bh)) {
141 +                       put_bh(bh);
142 +                       spin_lock(&journal->j_list_lock);
143 +                       continue;
144 +               }
145 +               if (buffer_jbd(bh) && jh->b_jlist == BJ_Locked) {
146 +                       __journal_unfile_buffer(jh);
147 +                       jbd_unlock_bh_state(bh);
148 +                       journal_remove_journal_head(bh);
149 +                       put_bh(bh);
150 +               } else {
151 +                       jbd_unlock_bh_state(bh);
152 +               }
153 +               put_bh(bh);
154 +               cond_resched_lock(&journal->j_list_lock);
155 +       }
156 +       return ret;
157  }
158  
159  void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
160 @@ -273,6 +349,20 @@ write_out_data:
161         journal_do_submit_data(wbuf, bufs);
162  }
163  
164 +static inline __u32 jbd_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
165 +{
166 +       struct page *page = bh->b_page;
167 +       char *addr;
168 +       __u32 checksum;
169 +
170 +       addr = kmap(page);
171 +       checksum = crc32_be(crc32_sum,
172 +                           (void *)(addr + offset_in_page(bh->b_data)),
173 +                           bh->b_size);
174 +       kunmap(page);
175 +       return checksum;
176 +}
177 +
178  /*
179   * journal_commit_transaction
180   *
181 @@ -296,6 +386,8 @@ void journal_commit_transaction(journal_
182         int first_tag = 0;
183         int tag_flag;
184         int i;
185 +       struct buffer_head *cbh = NULL; /* For transactional checksums */
186 +       __u32 crc32_sum = ~0;
187  
188         /*
189          * First job: lock down the current transaction and wait for
190 @@ -439,38 +531,14 @@ void journal_commit_transaction(journal_
191         journal_submit_data_buffers(journal, commit_transaction);
192  
193         /*
194 -        * Wait for all previously submitted IO to complete.
195 +        * Wait for all previously submitted IO to complete if commit
196 +        * record is to be written synchronously.
197          */
198         spin_lock(&journal->j_list_lock);
199 -       while (commit_transaction->t_locked_list) {
200 -               struct buffer_head *bh;
201 -
202 -               jh = commit_transaction->t_locked_list->b_tprev;
203 -               bh = jh2bh(jh);
204 -               get_bh(bh);
205 -               if (buffer_locked(bh)) {
206 -                       spin_unlock(&journal->j_list_lock);
207 -                       wait_on_buffer(bh);
208 -                       if (unlikely(!buffer_uptodate(bh)))
209 -                               err = -EIO;
210 -                       spin_lock(&journal->j_list_lock);
211 -               }
212 -               if (!inverted_lock(journal, bh)) {
213 -                       put_bh(bh);
214 -                       spin_lock(&journal->j_list_lock);
215 -                       continue;
216 -               }
217 -               if (buffer_jbd(bh) && jh->b_jlist == BJ_Locked) {
218 -                       __journal_unfile_buffer(jh);
219 -                       jbd_unlock_bh_state(bh);
220 -                       journal_remove_journal_head(bh);
221 -                       put_bh(bh);
222 -               } else {
223 -                       jbd_unlock_bh_state(bh);
224 -               }
225 -               put_bh(bh);
226 -               cond_resched_lock(&journal->j_list_lock);
227 -       }
228 +       if (!JFS_HAS_INCOMPAT_FEATURE(journal,
229 +               JFS_FEATURE_INCOMPAT_ASYNC_COMMIT))
230 +               err = journal_wait_on_locked_list(journal,
231 +                                                 commit_transaction);
232         spin_unlock(&journal->j_list_lock);
233  
234         if (err)
235 @@ -643,6 +711,16 @@ void journal_commit_transaction(journal_
236  start_journal_io:
237                         for (i = 0; i < bufs; i++) {
238                                 struct buffer_head *bh = wbuf[i];
239 +                               /*
240 +                                * Compute checksum.
241 +                                */
242 +                               if (JFS_HAS_COMPAT_FEATURE(journal,
243 +                                       JFS_FEATURE_COMPAT_CHECKSUM)) {
244 +                                       crc32_sum =
245 +                                               jbd_checksum_data(crc32_sum,
246 +                                                                  bh);
247 +                               }
248 +
249                                 lock_buffer(bh);
250                                 clear_buffer_dirty(bh);
251                                 set_buffer_uptodate(bh);
252 @@ -659,6 +737,23 @@ start_journal_io:
253                 }
254         }
255  
256 +       /* Done it all: now write the commit record asynchronously. */
257 +
258 +       if (JFS_HAS_INCOMPAT_FEATURE(journal,
259 +               JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)) {
260 +               err = journal_submit_commit_record(journal, commit_transaction,
261 +                                                &cbh, crc32_sum);
262 +               if (err)
263 +                       __journal_abort_hard(journal);
264 +
265 +               spin_lock(&journal->j_list_lock);
266 +               err = journal_wait_on_locked_list(journal,
267 +                                               commit_transaction);
268 +               spin_unlock(&journal->j_list_lock);
269 +               if (err)
270 +                       __journal_abort_hard(journal);
271 +       }
272 +
273         /* Lo and behold: we have just managed to send a transaction to
274             the log.  Before we can commit it, wait for the IO so far to
275             complete.  Control buffers being written are on the
276 @@ -757,9 +852,15 @@ wait_for_iobuf:
277         }
278  
279         jbd_debug(3, "JBD: commit phase 6\n");
280 -
281 -       if (journal_write_commit_record(journal, commit_transaction))
282 -               err = -EIO;
283 +               
284 +       if (!JFS_HAS_INCOMPAT_FEATURE(journal,
285 +               JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)) {
286 +               err = journal_submit_commit_record(journal, commit_transaction,
287 +                                               &cbh, crc32_sum);
288 +               if (err)
289 +                       __journal_abort_hard(journal);
290 +       }
291 +       err = journal_wait_on_commit_record(cbh);
292  
293         if (err)
294                 __journal_abort_hard(journal);
295 Index: linux-2.6.18.8/include/linux/jbd.h
296 ===================================================================
297 --- linux-2.6.18.8.orig/include/linux/jbd.h
298 +++ linux-2.6.18.8/include/linux/jbd.h
299 @@ -148,6 +148,29 @@ typedef struct journal_header_s
300         __be32          h_sequence;
301  } journal_header_t;
302  
303 +/*
304 + * Checksum types.
305 + */
306 +#define JFS_CRC32_CHKSUM   1
307 +#define JFS_MD5_CHKSUM     2
308 +#define JFS_SHA1_CHKSUM    3
309 +
310 +#define JFS_CRC32_CHKSUM_SIZE 4
311 +
312 +#define JFS_CHECKSUM_BYTES (32 / sizeof(u32))
313 +/*
314 + * Commit block header for storing transactional checksums:
315 + */
316 +struct commit_header
317 +{
318 +       __be32          h_magic;
319 +       __be32          h_blocktype;
320 +       __be32          h_sequence;
321 +       unsigned char   h_chksum_type;
322 +       unsigned char   h_chksum_size;
323 +       unsigned char   h_padding[2];
324 +       __be32          h_chksum[JFS_CHECKSUM_BYTES];
325 +};
326  
327  /* 
328   * The block tag: used to describe a single buffer in the journal 
329 @@ -234,12 +257,16 @@ typedef struct journal_superblock_s
330         ((j)->j_format_version >= 2 &&                                  \
331          ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
332  
333 -#define JFS_FEATURE_INCOMPAT_REVOKE    0x00000001
334 +#define JFS_FEATURE_COMPAT_CHECKSUM    0x00000001
335 +
336 +#define JFS_FEATURE_INCOMPAT_REVOKE            0x00000001
337 +#define JFS_FEATURE_INCOMPAT_ASYNC_COMMIT      0x00000004
338  
339  /* Features known to this kernel version: */
340 -#define JFS_KNOWN_COMPAT_FEATURES      0
341 +#define JFS_KNOWN_COMPAT_FEATURES      JFS_FEATURE_COMPAT_CHECKSUM
342  #define JFS_KNOWN_ROCOMPAT_FEATURES    0
343 -#define JFS_KNOWN_INCOMPAT_FEATURES    JFS_FEATURE_INCOMPAT_REVOKE
344 +#define JFS_KNOWN_INCOMPAT_FEATURES    JFS_FEATURE_INCOMPAT_REVOKE | \
345 +                                       JFS_FEATURE_INCOMPAT_ASYNC_COMMIT
346  
347  #ifdef __KERNEL__
348  
349 @@ -1053,6 +1080,8 @@ extern int           journal_check_available_fe
350                    (journal_t *, unsigned long, unsigned long, unsigned long);
351  extern int        journal_set_features 
352                    (journal_t *, unsigned long, unsigned long, unsigned long);
353 +extern int        journal_clear_features
354 +                  (journal_t *, unsigned long, unsigned long, unsigned long);
355  extern int        journal_create     (journal_t *);
356  extern int        journal_load       (journal_t *journal);
357  extern void       journal_destroy    (journal_t *);
358 Index: linux-2.6.18.8/fs/jbd/recovery.c
359 ===================================================================
360 --- linux-2.6.18.8.orig/fs/jbd/recovery.c
361 +++ linux-2.6.18.8/fs/jbd/recovery.c
362 @@ -21,6 +21,7 @@
363  #include <linux/jbd.h>
364  #include <linux/errno.h>
365  #include <linux/slab.h>
366 +#include <linux/crc32.h>
367  #endif
368  
369  /*
370 @@ -307,6 +308,37 @@ int journal_skip_recovery(journal_t *jou
371         return err;
372  }
373  
374 +/*
375 + * calc_chksums calculates the checksums for the blocks described in the
376 + * descriptor block.
377 + */
378 +static int calc_chksums(journal_t *journal, struct buffer_head *bh,
379 +                      unsigned long *next_log_block, __u32 *crc32_sum)
380 +{
381 +       int i, num_blks, err;
382 +       unsigned io_block;
383 +       struct buffer_head *obh;
384 +
385 +       num_blks = count_tags(bh, journal->j_blocksize);
386 +       /* Calculate checksum of the descriptor block. */
387 +       *crc32_sum = crc32_be(*crc32_sum, (void *)bh->b_data, bh->b_size);
388 +
389 +       for (i = 0; i < num_blks; i++) {
390 +               io_block = (*next_log_block)++;
391 +               wrap(journal, *next_log_block);
392 +               err = jread(&obh, journal, io_block);
393 +               if (err) {
394 +                       printk(KERN_ERR "JBD: IO error %d recovering block "
395 +                               "%u in log\n", err, io_block);
396 +                       return 1;
397 +               } else {
398 +                       *crc32_sum = crc32_be(*crc32_sum, (void *)obh->b_data,
399 +                                    obh->b_size);
400 +               }
401 +       }
402 +       return 0;
403 +}
404 +
405  static int do_one_pass(journal_t *journal,
406                         struct recovery_info *info, enum passtype pass)
407  {
408 @@ -318,6 +350,7 @@ static int do_one_pass(journal_t *journa
409         struct buffer_head *    bh;
410         unsigned int            sequence;
411         int                     blocktype;
412 +       __u32                   crc32_sum = ~0; /* Transactional Checksums */
413  
414         /* Precompute the maximum metadata descriptors in a descriptor block */
415         int                     MAX_BLOCKS_PER_DESC;
416 @@ -409,9 +442,24 @@ static int do_one_pass(journal_t *journa
417                 switch(blocktype) {
418                 case JFS_DESCRIPTOR_BLOCK:
419                         /* If it is a valid descriptor block, replay it
420 -                        * in pass REPLAY; otherwise, just skip over the
421 -                        * blocks it describes. */
422 +                        * in pass REPLAY; if journal_checksums enabled, then
423 +                        * calculate checksums in PASS_SCAN, otherwise,
424 +                        * just skip over the blocks it describes. */
425                         if (pass != PASS_REPLAY) {
426 +                               if (pass == PASS_SCAN &&
427 +                                   JFS_HAS_COMPAT_FEATURE(journal,
428 +                                           JFS_FEATURE_COMPAT_CHECKSUM) &&
429 +                                   !info->end_transaction) {
430 +                                       if (calc_chksums(journal, bh,
431 +                                                       &next_log_block,
432 +                                                       &crc32_sum)) {
433 +                                               brelse(bh);
434 +                                               break;
435 +                                       }
436 +                                       brelse(bh);
437 +                                       continue;
438 +                               }
439 +
440                                 next_log_block +=
441                                         count_tags(bh, journal->j_blocksize);
442                                 wrap(journal, next_log_block);
443 @@ -506,9 +554,97 @@ static int do_one_pass(journal_t *journa
444                         continue;
445  
446                 case JFS_COMMIT_BLOCK:
447 -                       /* Found an expected commit block: not much to
448 -                        * do other than move on to the next sequence
449 +                       /*     How to differentiate between interrupted commit
450 +                        *               and journal corruption ?
451 +                        *
452 +                        * {nth transaction}
453 +                        *        Checksum Verification Failed
454 +                        *                       |
455 +                        *               ____________________
456 +                        *              |                    |
457 +                        *      async_commit             sync_commit
458 +                        *              |                    |
459 +                        *              | GO TO NEXT    "Journal Corruption"
460 +                        *              | TRANSACTION
461 +                        *              |
462 +                        * {(n+1)th transanction}
463 +                        *              |
464 +                        *       _______|______________
465 +                        *      |                     |
466 +                        * Commit block found   Commit block not found
467 +                        *      |                     |
468 +                        * "Journal Corruption"       |
469 +                        *               _____________|__________
470 +                        *              |                       |
471 +                        *      nth trans corrupt       OR   nth trans
472 +                        *      and (n+1)th interrupted     interrupted 
473 +                        *      before commit block
474 +                        *      could reach the disk.
475 +                        *      (Cannot find the difference in above
476 +                        *       mentioned conditions. Hence assume
477 +                        *       "Interrupted Commit".)
478 +                        */
479 +
480 +                       /* Found an expected commit block: if checksums
481 +                        * are present verify them in PASS_SCAN; else not
482 +                        * much to do other than move on to the next sequence
483                          * number. */
484 +                       if (pass == PASS_SCAN &&
485 +                           JFS_HAS_COMPAT_FEATURE(journal,
486 +                                   JFS_FEATURE_COMPAT_CHECKSUM)) {
487 +                               int chksum_err, chksum_seen;
488 +                               struct commit_header *cbh =
489 +                                       (struct commit_header *)bh->b_data;
490 +                               unsigned found_chksum =
491 +                                               be32_to_cpu(cbh->h_chksum[0]);
492 +
493 +                               chksum_err = chksum_seen = 0;
494 +
495 +                               if (info->end_transaction) {
496 +                                       printk(KERN_ERR "JBD: Transaction %u "
497 +                                               "found to be corrupt.\n",
498 +                                               next_commit_ID - 1);
499 +                                       brelse(bh);
500 +                                       break;
501 +                               }
502 +
503 +                               if (crc32_sum == found_chksum &&
504 +                                   cbh->h_chksum_type == JFS_CRC32_CHKSUM &&
505 +                                   cbh->h_chksum_size ==
506 +                                               JFS_CRC32_CHKSUM_SIZE) {
507 +                                      chksum_seen = 1;
508 +                               } else if (!(cbh->h_chksum_type == 0 &&
509 +                                            cbh->h_chksum_size == 0 &&
510 +                                            found_chksum == 0 &&
511 +                                            !chksum_seen)) {
512 +                               /*
513 +                                * If fs is mounted using an old kernel and then
514 +                                * kernel with journal_chksum is used then we
515 +                                * get a situation where the journal flag has
516 +                                * checksum flag set but checksums are not
517 +                                * present i.e chksum = 0, in the individual
518 +                                * commit blocks.
519 +                                * Hence to avoid checksum failures, in this
520 +                                * situation, this extra check is added.
521 +                                */
522 +                                               chksum_err = 1;
523 +                               }
524 +
525 +                               if (chksum_err) {
526 +                                       info->end_transaction = next_commit_ID;
527 +
528 +                                       if (!JFS_HAS_COMPAT_FEATURE(journal,
529 +                                           JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)){
530 +                                               printk(KERN_ERR
531 +                                                      "JBD: Transaction %u "
532 +                                                      "found to be corrupt.\n",
533 +                                                      next_commit_ID);
534 +                                               brelse(bh);
535 +                                               break;
536 +                                       }
537 +                               }
538 +                               crc32_sum = ~0;
539 +                       }
540                         brelse(bh);
541                         next_commit_ID++;
542                         continue;
543 @@ -544,9 +680,10 @@ static int do_one_pass(journal_t *journa
544          * transaction marks the end of the valid log.
545          */
546  
547 -       if (pass == PASS_SCAN)
548 -               info->end_transaction = next_commit_ID;
549 -       else {
550 +       if (pass == PASS_SCAN) {
551 +               if (!info->end_transaction)
552 +                       info->end_transaction = next_commit_ID;
553 +       } else {
554                 /* It's really bad news if different passes end up at
555                  * different places (but possible due to IO errors). */
556                 if (info->end_transaction != next_commit_ID) {
557 Index: linux-2.6.18.8/fs/jbd/journal.c
558 ===================================================================
559 --- linux-2.6.18.8.orig/fs/jbd/journal.c
560 +++ linux-2.6.18.8/fs/jbd/journal.c
561 @@ -67,6 +67,7 @@ EXPORT_SYMBOL(journal_update_format);
562  EXPORT_SYMBOL(journal_check_used_features);
563  EXPORT_SYMBOL(journal_check_available_features);
564  EXPORT_SYMBOL(journal_set_features);
565 +EXPORT_SYMBOL(journal_clear_features);
566  EXPORT_SYMBOL(journal_create);
567  EXPORT_SYMBOL(journal_load);
568  EXPORT_SYMBOL(journal_destroy);
569 @@ -1573,6 +1574,33 @@ int journal_set_features (journal_t *jou
570         return 1;
571  }
572  
573 +/**
574 + * int journal_clear_features () - Clear a given journal feature in the superblock
575 + * @journal: Journal to act on.
576 + * @compat: bitmask of compatible features
577 + * @ro: bitmask of features that force read-only mount
578 + * @incompat: bitmask of incompatible features
579 + *
580 + * Clear a given journal feature as present on the
581 + * superblock.  Returns true if the requested features could be reset.
582 + *
583 + */
584 +int journal_clear_features (journal_t *journal, unsigned long compat,
585 +                         unsigned long ro, unsigned long incompat)
586 +{
587 +       journal_superblock_t *sb;
588 +
589 +       jbd_debug(1, "Clear features 0x%lx/0x%lx/0x%lx\n",
590 +                 compat, ro, incompat);
591 +
592 +       sb = journal->j_superblock;
593 +
594 +       sb->s_feature_compat    &= ~cpu_to_be32(compat);
595 +       sb->s_feature_ro_compat &= ~cpu_to_be32(ro);
596 +       sb->s_feature_incompat  &= ~cpu_to_be32(incompat);
597 +
598 +       return 1;
599 +}
600  
601  /**
602   * int journal_update_format () - Update on-disk journal structure.
603 Index: linux-2.6.18.8/fs/Kconfig
604 ===================================================================
605 --- linux-2.6.18.8.orig/fs/Kconfig
606 +++ linux-2.6.18.8/fs/Kconfig
607 @@ -140,6 +140,7 @@ config EXT3_FS_SECURITY
608  
609  config JBD
610         tristate
611 +       select CRC32
612         help
613           This is a generic journaling layer for block devices.  It is
614           currently used by the ext3 and OCFS2 file systems, but it could
615 Index: linux-2.6.18.8/Documentation/filesystems/ext3.txt
616 ===================================================================
617 --- linux-2.6.18.8.orig/Documentation/filesystems/ext3.txt
618 +++ linux-2.6.18.8/Documentation/filesystems/ext3.txt
619 @@ -14,6 +14,16 @@ Options
620  When mounting an ext3 filesystem, the following option are accepted:
621  (*) == default
622  
623 +journal_checksum       Enable checksumming of the journal transactions.
624 +                       This will allow the recovery code in e2fsck and the
625 +                       kernel to detect corruption in the kernel.  It is a
626 +                       compatible change and will be ignored by older kernels.
627 +
628 +journal_async_commit   Commit block can be written to disk without waiting
629 +                       for descriptor blocks. If enabled older kernels cannot
630 +                       mount the device. This will enable 'journal_checksum'
631 +                       internally.
632 +
633  journal=update         Update the ext3 file system's journal to the current
634                         format.
635