-Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
+Index: linux-2.6.18-128.1.6/fs/jbd/commit.c
===================================================================
---- linux-2.6.18-8.1.8.orig/fs/jbd/commit.c
-+++ linux-2.6.18-8.1.8/fs/jbd/commit.c
-@@ -21,6 +21,7 @@
+--- linux-2.6.18-128.1.6.orig/fs/jbd/commit.c 2009-06-02 23:24:00.000000000 -0600
++++ linux-2.6.18-128.1.6/fs/jbd/commit.c 2009-06-02 23:26:07.000000000 -0600
+@@ -22,6 +22,7 @@
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/smp_lock.h>
+#include <linux/crc32.h>
+
/*
- * Default IO end handler for temporary BJ_IO buffer_heads.
-@@ -93,19 +94,23 @@ static int inverted_lock(journal_t *jour
+@@ -95,19 +96,23 @@
return 1;
}
int barrier_done = 0;
if (is_journal_aborted(journal))
-@@ -117,21 +122,34 @@ static int journal_write_commit_record(j
+@@ -119,21 +124,34 @@
bh = jh2bh(descriptor);
+ bh->b_end_io = journal_end_buffer_io_sync;
+
+ if (journal->j_flags & JFS_BARRIER &&
-+ !JFS_HAS_COMPAT_FEATURE(journal,
++ !JFS_HAS_INCOMPAT_FEATURE(journal,
+ JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)) {
+
set_buffer_ordered(bh);
/* is it possible for another commit to fail at roughly
* the same time as this one? If so, we don't want to
* trust the barrier flag in the super, but instead want
-@@ -152,14 +170,72 @@ static int journal_write_commit_record(j
+@@ -154,12 +172,70 @@
clear_buffer_ordered(bh);
set_buffer_uptodate(bh);
set_buffer_dirty(bh);
+ *cbh = bh;
+ return ret;
+}
-
-- return (ret == -EIO);
++
+/*
+ * This function along with journal_submit_commit_record
+ * allows to write the commit record asynchronously.
+ journal_put_journal_head(bh2jh(bh));
+
+ return ret;
- }
-
++}
++
+/*
+ * Wait for all submitted IO to complete.
+ */
+{
+ int ret = 0;
+ struct journal_head *jh;
-+
+
+- return (ret == -EIO);
+ while (commit_transaction->t_locked_list) {
+ struct buffer_head *bh;
+
+ cond_resched_lock(&journal->j_list_lock);
+ }
+ return ret;
+ }
+
+ void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
+@@ -282,6 +358,20 @@
+ return err;
+ }
+
++static inline __u32 jbd_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
++{
++ struct page *page = bh->b_page;
++ char *addr;
++ __u32 checksum;
++
++ addr = kmap_atomic(page, KM_USER0);
++ checksum = crc32_be(crc32_sum,
++ (void *)(addr + offset_in_page(bh->b_data)),
++ bh->b_size);
++ kunmap_atomic(addr, KM_USER0);
++ return checksum;
+}
+
- void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
- {
- int i;
-@@ -293,6 +369,8 @@ void journal_commit_transaction(journal_
+ /*
+ * journal_commit_transaction
+ *
+@@ -305,6 +395,8 @@
int first_tag = 0;
int tag_flag;
int i;
/*
* First job: lock down the current transaction and wait for
-@@ -428,38 +506,14 @@ void journal_commit_transaction(journal_
- journal_submit_data_buffers(journal, commit_transaction);
+@@ -431,39 +523,14 @@
+ err = journal_submit_data_buffers(journal, commit_transaction);
/*
- * Wait for all previously submitted IO to complete.
- if (buffer_locked(bh)) {
- spin_unlock(&journal->j_list_lock);
- wait_on_buffer(bh);
-- if (unlikely(!buffer_uptodate(bh)))
-- err = -EIO;
- spin_lock(&journal->j_list_lock);
- }
+- if (unlikely(!buffer_uptodate(bh)))
+- err = -EIO;
+-
- if (!inverted_lock(journal, bh)) {
- put_bh(bh);
- spin_lock(&journal->j_list_lock);
spin_unlock(&journal->j_list_lock);
if (err)
-@@ -627,6 +681,16 @@ void journal_commit_transaction(journal_
+@@ -642,6 +709,16 @@
start_journal_io:
for (i = 0; i < bufs; i++) {
struct buffer_head *bh = wbuf[i];
+ */
+ if (JFS_HAS_COMPAT_FEATURE(journal,
+ JFS_FEATURE_COMPAT_CHECKSUM)) {
-+ crc32_sum = crc32_be(crc32_sum,
-+ (void *)bh->b_data,
-+ bh->b_size);
++ crc32_sum =
++ jbd_checksum_data(crc32_sum,
++ bh);
+ }
+
lock_buffer(bh);
clear_buffer_dirty(bh);
set_buffer_uptodate(bh);
-@@ -642,6 +706,23 @@ start_journal_io:
+@@ -658,6 +735,23 @@
}
}
/* Lo and behold: we have just managed to send a transaction to
the log. Before we can commit it, wait for the IO so far to
complete. Control buffers being written are on the
-@@ -740,9 +821,15 @@ wait_for_iobuf:
- }
+@@ -759,9 +853,15 @@
+ journal_abort(journal, err);
jbd_debug(3, "JBD: commit phase 6\n");
-
+ err = journal_wait_on_commit_record(cbh);
if (err)
- __journal_abort_hard(journal);
-Index: linux-2.6.18-8.1.8/include/linux/jbd.h
+ journal_abort(journal, err);
+Index: linux-2.6.18-128.1.6/fs/jbd/recovery.c
===================================================================
---- linux-2.6.18-8.1.8.orig/include/linux/jbd.h
-+++ linux-2.6.18-8.1.8/include/linux/jbd.h
-@@ -148,6 +148,29 @@ typedef struct journal_header_s
- __be32 h_sequence;
- } journal_header_t;
-
-+/*
-+ * Checksum types.
-+ */
-+#define JFS_CRC32_CHKSUM 1
-+#define JFS_MD5_CHKSUM 2
-+#define JFS_SHA1_CHKSUM 3
-+
-+#define JFS_CRC32_CHKSUM_SIZE 4
-+
-+#define JFS_CHECKSUM_BYTES (32 / sizeof(u32))
-+/*
-+ * Commit block header for storing transactional checksums:
-+ */
-+struct commit_header
-+{
-+ __be32 h_magic;
-+ __be32 h_blocktype;
-+ __be32 h_sequence;
-+ unsigned char h_chksum_type;
-+ unsigned char h_chksum_size;
-+ unsigned char h_padding[2];
-+ __be32 h_chksum[JFS_CHECKSUM_BYTES];
-+};
-
- /*
- * The block tag: used to describe a single buffer in the journal
-@@ -234,12 +257,16 @@ typedef struct journal_superblock_s
- ((j)->j_format_version >= 2 && \
- ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
-
--#define JFS_FEATURE_INCOMPAT_REVOKE 0x00000001
-+#define JFS_FEATURE_COMPAT_CHECKSUM 0x00000001
-+
-+#define JFS_FEATURE_INCOMPAT_REVOKE 0x00000001
-+#define JFS_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
-
- /* Features known to this kernel version: */
--#define JFS_KNOWN_COMPAT_FEATURES 0
-+#define JFS_KNOWN_COMPAT_FEATURES JFS_FEATURE_COMPAT_CHECKSUM
- #define JFS_KNOWN_ROCOMPAT_FEATURES 0
--#define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE
-+#define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE | \
-+ JFS_FEATURE_INCOMPAT_ASYNC_COMMIT
-
- #ifdef __KERNEL__
-
-@@ -967,6 +994,8 @@ extern int journal_check_available_fe
- (journal_t *, unsigned long, unsigned long, unsigned long);
- extern int journal_set_features
- (journal_t *, unsigned long, unsigned long, unsigned long);
-+extern int journal_clear_features
-+ (journal_t *, unsigned long, unsigned long, unsigned long);
- extern int journal_create (journal_t *);
- extern int journal_load (journal_t *journal);
- extern void journal_destroy (journal_t *);
-Index: linux-2.6.18-8.1.8/fs/jbd/recovery.c
-===================================================================
---- linux-2.6.18-8.1.8.orig/fs/jbd/recovery.c
-+++ linux-2.6.18-8.1.8/fs/jbd/recovery.c
+--- linux-2.6.18-128.1.6.orig/fs/jbd/recovery.c 2009-04-14 21:05:39.000000000 -0600
++++ linux-2.6.18-128.1.6/fs/jbd/recovery.c 2009-06-02 23:26:07.000000000 -0600
@@ -21,6 +21,7 @@
#include <linux/jbd.h>
#include <linux/errno.h>
#endif
/*
-@@ -307,6 +308,37 @@ int journal_skip_recovery(journal_t *jou
+@@ -310,6 +311,38 @@
return err;
}
+ unsigned long *next_log_block, __u32 *crc32_sum)
+{
+ int i, num_blks, err;
-+ unsigned io_block;
++ unsigned long io_block;
+ struct buffer_head *obh;
+
+ num_blks = count_tags(bh, journal->j_blocksize);
+ err = jread(&obh, journal, io_block);
+ if (err) {
+ printk(KERN_ERR "JBD: IO error %d recovering block "
-+ "%u in log\n", err, io_block);
++ "%lu in log\n", err, io_block);
+ return 1;
+ } else {
+ *crc32_sum = crc32_be(*crc32_sum, (void *)obh->b_data,
+ obh->b_size);
+ }
++ put_bh(obh);
+ }
+ return 0;
+}
static int do_one_pass(journal_t *journal,
struct recovery_info *info, enum passtype pass)
{
-@@ -318,6 +350,7 @@ static int do_one_pass(journal_t *journa
+@@ -321,6 +354,7 @@
struct buffer_head * bh;
unsigned int sequence;
int blocktype;
/* Precompute the maximum metadata descriptors in a descriptor block */
int MAX_BLOCKS_PER_DESC;
-@@ -409,9 +442,24 @@ static int do_one_pass(journal_t *journa
+@@ -412,9 +446,24 @@
switch(blocktype) {
case JFS_DESCRIPTOR_BLOCK:
/* If it is a valid descriptor block, replay it
+ if (calc_chksums(journal, bh,
+ &next_log_block,
+ &crc32_sum)) {
-+ brelse(bh);
++ put_bh(bh);
+ break;
+ }
-+ brelse(bh);
++ put_bh(bh);
+ continue;
+ }
+
next_log_block +=
count_tags(bh, journal->j_blocksize);
wrap(journal, next_log_block);
-@@ -506,9 +554,97 @@ static int do_one_pass(journal_t *journa
+@@ -509,9 +558,97 @@
continue;
case JFS_COMMIT_BLOCK:
+ if (chksum_err) {
+ info->end_transaction = next_commit_ID;
+
-+ if (!JFS_HAS_COMPAT_FEATURE(journal,
++ if (!JFS_HAS_INCOMPAT_FEATURE(journal,
+ JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)){
+ printk(KERN_ERR
+ "JBD: Transaction %u "
brelse(bh);
next_commit_ID++;
continue;
-@@ -544,9 +680,10 @@ static int do_one_pass(journal_t *journa
+@@ -547,9 +684,10 @@
* transaction marks the end of the valid log.
*/
/* It's really bad news if different passes end up at
* different places (but possible due to IO errors). */
if (info->end_transaction != next_commit_ID) {
-Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
+Index: linux-2.6.18-128.1.6/fs/jbd/journal.c
===================================================================
---- linux-2.6.18-8.1.8.orig/fs/jbd/journal.c
-+++ linux-2.6.18-8.1.8/fs/jbd/journal.c
-@@ -66,6 +66,7 @@ EXPORT_SYMBOL(journal_update_format);
+--- linux-2.6.18-128.1.6.orig/fs/jbd/journal.c 2009-06-02 23:24:00.000000000 -0600
++++ linux-2.6.18-128.1.6/fs/jbd/journal.c 2009-06-02 23:26:07.000000000 -0600
+@@ -67,6 +67,7 @@
EXPORT_SYMBOL(journal_check_used_features);
EXPORT_SYMBOL(journal_check_available_features);
EXPORT_SYMBOL(journal_set_features);
EXPORT_SYMBOL(journal_create);
EXPORT_SYMBOL(journal_load);
EXPORT_SYMBOL(journal_destroy);
-@@ -1271,6 +1272,33 @@ int journal_set_features (journal_t *jou
+@@ -1583,6 +1584,33 @@
return 1;
}
/**
* int journal_update_format () - Update on-disk journal structure.
-Index: linux-2.6.18-8.1.8/fs/Kconfig
+Index: linux-2.6.18-128.1.6/fs/Kconfig
===================================================================
---- linux-2.6.18-8.1.8.orig/fs/Kconfig
-+++ linux-2.6.18-8.1.8/fs/Kconfig
-@@ -140,6 +140,7 @@ config EXT3_FS_SECURITY
+--- linux-2.6.18-128.1.6.orig/fs/Kconfig 2009-04-14 21:05:39.000000000 -0600
++++ linux-2.6.18-128.1.6/fs/Kconfig 2009-06-02 23:26:07.000000000 -0600
+@@ -206,6 +206,7 @@
config JBD
tristate
help
This is a generic journaling layer for block devices. It is
currently used by the ext3 and OCFS2 file systems, but it could
-Index: linux-2.6.18-8.1.8/Documentation/filesystems/ext3.txt
+Index: linux-2.6.18-128.1.6/include/linux/jbd.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/include/linux/jbd.h 2009-06-02 23:24:00.000000000 -0600
++++ linux-2.6.18-128.1.6/include/linux/jbd.h 2009-06-02 23:26:07.000000000 -0600
+@@ -148,6 +148,29 @@
+ __be32 h_sequence;
+ } journal_header_t;
+
++/*
++ * Checksum types.
++ */
++#define JFS_CRC32_CHKSUM 1
++#define JFS_MD5_CHKSUM 2
++#define JFS_SHA1_CHKSUM 3
++
++#define JFS_CRC32_CHKSUM_SIZE 4
++
++#define JFS_CHECKSUM_BYTES (32 / sizeof(u32))
++/*
++ * Commit block header for storing transactional checksums:
++ */
++struct commit_header
++{
++ __be32 h_magic;
++ __be32 h_blocktype;
++ __be32 h_sequence;
++ unsigned char h_chksum_type;
++ unsigned char h_chksum_size;
++ unsigned char h_padding[2];
++ __be32 h_chksum[JFS_CHECKSUM_BYTES];
++};
+
+ /*
+ * The block tag: used to describe a single buffer in the journal
+@@ -234,12 +257,16 @@
+ ((j)->j_format_version >= 2 && \
+ ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
+
+-#define JFS_FEATURE_INCOMPAT_REVOKE 0x00000001
++#define JFS_FEATURE_COMPAT_CHECKSUM 0x00000001
++
++#define JFS_FEATURE_INCOMPAT_REVOKE 0x00000001
++#define JFS_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
+
+ /* Features known to this kernel version: */
+-#define JFS_KNOWN_COMPAT_FEATURES 0
++#define JFS_KNOWN_COMPAT_FEATURES JFS_FEATURE_COMPAT_CHECKSUM
+ #define JFS_KNOWN_ROCOMPAT_FEATURES 0
+-#define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE
++#define JFS_KNOWN_INCOMPAT_FEATURES (JFS_FEATURE_INCOMPAT_REVOKE | \
++ JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)
+
+ #ifdef __KERNEL__
+
+@@ -1053,6 +1080,8 @@
+ (journal_t *, unsigned long, unsigned long, unsigned long);
+ extern int journal_set_features
+ (journal_t *, unsigned long, unsigned long, unsigned long);
++extern int journal_clear_features
++ (journal_t *, unsigned long, unsigned long, unsigned long);
+ extern int journal_create (journal_t *);
+ extern int journal_load (journal_t *journal);
+ #ifndef __GENKSYMS__
+Index: linux-2.6.18-128.1.6/Documentation/filesystems/ext3.txt
===================================================================
---- linux-2.6.18-8.1.8.orig/Documentation/filesystems/ext3.txt
-+++ linux-2.6.18-8.1.8/Documentation/filesystems/ext3.txt
-@@ -14,6 +14,16 @@ Options
+--- linux-2.6.18-128.1.6.orig/Documentation/filesystems/ext3.txt 2006-09-19 21:42:06.000000000 -0600
++++ linux-2.6.18-128.1.6/Documentation/filesystems/ext3.txt 2009-06-02 23:26:07.000000000 -0600
+@@ -14,6 +14,16 @@
When mounting an ext3 filesystem, the following option are accepted:
(*) == default