diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-09-11 09:30:12 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-09-11 09:30:12 -0400 |
commit | 0e3d2a6313d03413d93327202a60256d1d726fdc (patch) | |
tree | 3b4165751568e4332edad89a82e76bc6708c8ccd /fs/jbd2/commit.c | |
parent | 71290b368ad5e1e0b0b300c9d5638490a9fd1a2d (diff) |
ext4: Fix async commit mode to be safe by using a barrier
Previously the journal_async_commit mount option was equivalent to
using barrier=0 (and just as unsafe). This patch fixes it so that we
eliminate the barrier before the commit block (by not using ordered
mode), and explicitly issuing an empty barrier bio after writing the
commit block. Because of the journal checksum, it is safe to do this;
if the journal blocks are not all written before a power failure, the
checksum in the commit block will prevent the last transaction from
being replayed.
Using the fs_mark benchmark, using journal_async_commit shows a 50%
improvement:
FSUse% Count Size Files/sec App Overhead
8 1000 10240 30.5 28242
vs.
FSUse% Count Size Files/sec App Overhead
8 1000 10240 45.8 28620
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2/commit.c')
-rw-r--r-- | fs/jbd2/commit.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 0df600e9162d..26d991ddc1e6 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/writeback.h> | 25 | #include <linux/writeback.h> |
26 | #include <linux/backing-dev.h> | 26 | #include <linux/backing-dev.h> |
27 | #include <linux/bio.h> | 27 | #include <linux/bio.h> |
28 | #include <linux/blkdev.h> | ||
28 | #include <trace/events/jbd2.h> | 29 | #include <trace/events/jbd2.h> |
29 | 30 | ||
30 | /* | 31 | /* |
@@ -133,8 +134,8 @@ static int journal_submit_commit_record(journal_t *journal, | |||
133 | bh->b_end_io = journal_end_buffer_io_sync; | 134 | bh->b_end_io = journal_end_buffer_io_sync; |
134 | 135 | ||
135 | if (journal->j_flags & JBD2_BARRIER && | 136 | if (journal->j_flags & JBD2_BARRIER && |
136 | !JBD2_HAS_INCOMPAT_FEATURE(journal, | 137 | !JBD2_HAS_INCOMPAT_FEATURE(journal, |
137 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { | 138 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { |
138 | set_buffer_ordered(bh); | 139 | set_buffer_ordered(bh); |
139 | barrier_done = 1; | 140 | barrier_done = 1; |
140 | } | 141 | } |
@@ -706,11 +707,13 @@ start_journal_io: | |||
706 | /* Done it all: now write the commit record asynchronously. */ | 707 | /* Done it all: now write the commit record asynchronously. */ |
707 | 708 | ||
708 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, | 709 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, |
709 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { | 710 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { |
710 | err = journal_submit_commit_record(journal, commit_transaction, | 711 | err = journal_submit_commit_record(journal, commit_transaction, |
711 | &cbh, crc32_sum); | 712 | &cbh, crc32_sum); |
712 | if (err) | 713 | if (err) |
713 | __jbd2_journal_abort_hard(journal); | 714 | __jbd2_journal_abort_hard(journal); |
715 | if (journal->j_flags & JBD2_BARRIER) | ||
716 | blkdev_issue_flush(journal->j_dev, NULL); | ||
714 | } | 717 | } |
715 | 718 | ||
716 | /* | 719 | /* |
@@ -833,7 +836,7 @@ wait_for_iobuf: | |||
833 | jbd_debug(3, "JBD: commit phase 5\n"); | 836 | jbd_debug(3, "JBD: commit phase 5\n"); |
834 | 837 | ||
835 | if (!JBD2_HAS_INCOMPAT_FEATURE(journal, | 838 | if (!JBD2_HAS_INCOMPAT_FEATURE(journal, |
836 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { | 839 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { |
837 | err = journal_submit_commit_record(journal, commit_transaction, | 840 | err = journal_submit_commit_record(journal, commit_transaction, |
838 | &cbh, crc32_sum); | 841 | &cbh, crc32_sum); |
839 | if (err) | 842 | if (err) |