diff options
author | Josef Bacik <jbacik@redhat.com> | 2008-04-17 10:38:59 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-04-17 10:38:59 -0400 |
commit | 1dfc3220d963385a317264b11154c462a83596ed (patch) | |
tree | 8c35f3233c3d10110b3b48d8f476ddf9404d7192 /fs/jbd2/commit.c | |
parent | 9fc7c63a1d6e9920038ced782390a54888ed70a6 (diff) |
jbd2: fix possible journal overflow issues
There are several cases where the running transaction can get buffers
added to its BJ_Metadata list which it never dirtied, which makes its
t_nr_buffers counter end up larger than its t_outstanding_credits
counter.
This will cause issues when starting new transactions as while we are
logging buffers we decrement t_outstanding_buffers, so when
t_outstanding_buffers goes negative, we will report that we need less
space in the journal than we actually need, so transactions will be
started even though there may not be enough room for them. In the worst
case scenario (which admittedly is almost impossible to reproduce) this
will result in the journal running out of space.
The fix is to only refile buffers from the committing transaction to the
running transactions BJ_Modified list when b_modified is set on that
journal, which is the only way to be sure if the running transaction has
modified that buffer.
This patch also fixes an accounting error in journal_forget, it is
possible that we can call journal_forget on a buffer without having
modified it, only gotten write access to it, so instead of freeing a
credit, we only do so if the buffer was modified. The assert will help
catch if this problem occurs. Without these two patches I could hit
this assert within minutes of running postmark, with them this issue no
longer arises.
Cc: <linux-ext4@vger.kernel.org>
Cc: Jan Kara <jack@ucw.cz>
Signed-off-by: Josef Bacik <jbacik@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2/commit.c')
-rw-r--r-- | fs/jbd2/commit.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 988fbec1143c..e0139786f717 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c | |||
@@ -568,6 +568,9 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
568 | stats.u.run.rs_blocks = commit_transaction->t_outstanding_credits; | 568 | stats.u.run.rs_blocks = commit_transaction->t_outstanding_credits; |
569 | stats.u.run.rs_blocks_logged = 0; | 569 | stats.u.run.rs_blocks_logged = 0; |
570 | 570 | ||
571 | J_ASSERT(commit_transaction->t_nr_buffers <= | ||
572 | commit_transaction->t_outstanding_credits); | ||
573 | |||
571 | descriptor = NULL; | 574 | descriptor = NULL; |
572 | bufs = 0; | 575 | bufs = 0; |
573 | while (commit_transaction->t_buffers) { | 576 | while (commit_transaction->t_buffers) { |