From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>, Duane Griffin <duaneg@dghda.com>,
Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com>
Subject: [PATCH] jbd: don't give up looking for space so easily in __log_wait_for_space
Date: Wed, 5 Nov 2008 09:05:07 -0500 [thread overview]
Message-ID: <1225893908-2086-1-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <20081105135349.GA22998@mit.edu>
Commit be07c4ed introducd a regression because it assumed that if
there were no transactions ready to be checkpointed, that no progress
could be made on making space available in the journal, and so the
journal should be aborted. This assumption is false; it could be the
case that simply calling cleanup_journal_tail() will recover the
necessary space, or, for small journals, the currently committing
transaction could be responsible for chewing up the required space in
the log, so we need to wait for the currently committing transaction
to finish before trying to force a checkpoint operation.
This patch fixes the bug reported by Meelis Roos at:
http://bugzilla.kernel.org/show_bug.cgi?id=11937
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Duane Griffin <duaneg@dghda.com>
Cc: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com>
---
fs/jbd/checkpoint.c | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c
index 1bd8d4a..5e856de 100644
--- a/fs/jbd/checkpoint.c
+++ b/fs/jbd/checkpoint.c
@@ -128,25 +128,42 @@ void __log_wait_for_space(journal_t *journal)
/*
* Test again, another process may have checkpointed while we
* were waiting for the checkpoint lock. If there are no
- * outstanding transactions there is nothing to checkpoint and
- * we can't make progress. Abort the journal in this case.
+ * transactions ready to be checkpointed, try to recover
+ * journal space by calling cleanup_journal_tail(), and if
+ * that doesn't work, by waiting for the currently committing
+ * transaction to complete. If there is absolutely no way
+ * to make progress, this is either a BUG or corrupted
+ * filesystem, so abort the journal and leave a stack
+ * trace for forensic evidence.
*/
spin_lock(&journal->j_state_lock);
spin_lock(&journal->j_list_lock);
nblocks = jbd_space_needed(journal);
if (__log_space_left(journal) < nblocks) {
int chkpt = journal->j_checkpoint_transactions != NULL;
+ int tid = 0;
+ if (journal->j_committing_transaction)
+ tid = journal->j_committing_transaction->t_tid;
spin_unlock(&journal->j_list_lock);
spin_unlock(&journal->j_state_lock);
if (chkpt) {
log_do_checkpoint(journal);
+ } else if (cleanup_journal_tail(journal) == 0) {
+ /* We were able to recover space; yay! */
+ ;
+ } else if (tid) {
+ log_wait_commit(journal, tid);
} else {
- printk(KERN_ERR "%s: no transactions\n",
- __func__);
+ printk(KERN_ERR "%s: needed %d blocks and "
+ "only had %d space available\n",
+ __func__, nblocks,
+ __log_space_left(journal));
+ printk(KERN_ERR "%s: no way to get more "
+ "journal space\n", __func__);
+ WARN_ON(1);
journal_abort(journal, 0);
}
next prev parent reply other threads:[~2008-11-05 14:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-17 13:37 [RFC][PATCH] JBD: release checkpoint journal heads through try_to_release_page when the memory is exhausted Toshiyuki Okajima
2008-10-20 23:02 ` Andrew Morton
2008-10-21 2:49 ` Toshiyuki Okajima
2008-10-23 8:41 ` Toshiyuki Okajima
2008-10-27 21:26 ` Andrew Morton
2008-10-28 2:46 ` Toshiyuki Okajima
2008-11-05 4:11 ` [PATCH][BUG] jbd: fix the root cause of "no transactions" error in __log_wait_for_space() Toshiyuki Okajima
2008-11-05 13:53 ` Theodore Tso
2008-11-05 14:05 ` Theodore Ts'o [this message]
2008-11-05 14:05 ` [PATCH] jbd2: don't give up looking for space so easily in __jbd2_log_wait_for_space Theodore Ts'o
2008-11-07 3:17 ` [PATCH][BUG] jbd: fix the root cause of "no transactions" error in __log_wait_for_space() Toshiyuki Okajima
2008-11-12 7:49 ` [PATCH 0/3][RFC] release block-device-mapping buffer_heads which have the filesystem private data for avoiding oom-killer Toshiyuki Okajima
2008-11-12 7:51 ` [PATCH 1/3][RFC] vfs: " Toshiyuki Okajima
2008-11-12 7:53 ` [PATCH 2/3][RFC] ext3: " Toshiyuki Okajima
2008-11-12 7:55 ` [PATCH 3/3][RFC] ext4: " Toshiyuki Okajima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1225893908-2086-1-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=duaneg@dghda.com \
--cc=linux-ext4@vger.kernel.org \
--cc=toshi.okajima@jp.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).