int barrier_done = 0;
if (is_journal_aborted(journal))
-@@ -119,21 +124,34 @@ static int journal_write_commit_record(j
+@@ -119,21 +124,35 @@ static int journal_write_commit_record(j
bh = jh2bh(descriptor);
- JBUFFER_TRACE(descriptor, "write commit block");
+ JBUFFER_TRACE(descriptor, "submit commit block");
+ lock_buffer(bh);
++ get_bh(bh);
+
set_buffer_dirty(bh);
- if (journal->j_flags & JFS_BARRIER) {
+ 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
-@@ -154,12 +172,70 @@ static int journal_write_commit_record(j
+@@ -154,12 +173,70 @@ static int journal_write_commit_record(j
clear_buffer_ordered(bh);
set_buffer_uptodate(bh);
set_buffer_dirty(bh);
}
void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
-@@ -273,6 +349,20 @@ write_out_data:
+@@ -273,6 +350,20 @@ write_out_data:
journal_do_submit_data(wbuf, bufs);
}
+ char *addr;
+ __u32 checksum;
+
-+ addr = kmap(page);
++ addr = kmap_atomic(page, KM_USER0);
+ checksum = crc32_be(crc32_sum,
+ (void *)(addr + offset_in_page(bh->b_data)),
+ bh->b_size);
-+ kunmap(page);
++ kunmap_atomic(addr, KM_USER0);
+ return checksum;
+}
+
/*
* journal_commit_transaction
*
-@@ -296,6 +386,8 @@ void journal_commit_transaction(journal_
+@@ -296,6 +387,8 @@ void journal_commit_transaction(journal_
int first_tag = 0;
int tag_flag;
int i;
/*
* First job: lock down the current transaction and wait for
-@@ -439,38 +531,14 @@ void journal_commit_transaction(journal_
+@@ -439,39 +532,14 @@ void journal_commit_transaction(journal_
journal_submit_data_buffers(journal, commit_transaction);
/*
- 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)
-@@ -643,6 +711,16 @@ void journal_commit_transaction(journal_
+@@ -643,6 +712,16 @@ void journal_commit_transaction(journal_
start_journal_io:
for (i = 0; i < bufs; i++) {
struct buffer_head *bh = wbuf[i];
lock_buffer(bh);
clear_buffer_dirty(bh);
set_buffer_uptodate(bh);
-@@ -659,6 +737,23 @@ start_journal_io:
+@@ -659,6 +738,23 @@ start_journal_io:
}
}
/* 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
-@@ -757,9 +852,15 @@ wait_for_iobuf:
+@@ -757,9 +853,15 @@ wait_for_iobuf:
}
jbd_debug(3, "JBD: commit phase 6\n");
+#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
++#define JFS_KNOWN_INCOMPAT_FEATURES (JFS_FEATURE_INCOMPAT_REVOKE | \
++ JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)
#ifdef __KERNEL__
#endif
/*
-@@ -307,6 +308,37 @@ int journal_skip_recovery(journal_t *jou
+@@ -307,6 +308,38 @@ int journal_skip_recovery(journal_t *jou
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
+@@ -318,6 +351,7 @@ static int do_one_pass(journal_t *journa
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
+@@ -409,9 +443,24 @@ static int do_one_pass(journal_t *journa
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
+@@ -506,9 +555,97 @@ static int do_one_pass(journal_t *journa
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
+@@ -544,9 +681,10 @@ static int do_one_pass(journal_t *journa
* transaction marks the end of the valid log.
*/