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