Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 118560
b: refs/heads/master
c: 8c3f25d
h: refs/heads/master
v: v3
  • Loading branch information
Theodore Ts'o committed Nov 7, 2008
1 parent 5fa41af commit b4bf446
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e219cca082f52e7dfea41f3be264b7b5eb204227
refs/heads/master: 8c3f25d8950c3e9fe6c9849f88679b3f2a071550
32 changes: 25 additions & 7 deletions trunk/fs/jbd2/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static int __try_to_free_cp_buf(struct journal_head *jh)
*/
void __jbd2_log_wait_for_space(journal_t *journal)
{
int nblocks;
int nblocks, space_left;
assert_spin_locked(&journal->j_state_lock);

nblocks = jbd_space_needed(journal);
Expand All @@ -129,25 +129,43 @@ void __jbd2_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 (__jbd2_log_space_left(journal) < nblocks) {
space_left = __jbd2_log_space_left(journal);
if (space_left < nblocks) {
int chkpt = journal->j_checkpoint_transactions != NULL;
tid_t 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) {
jbd2_log_do_checkpoint(journal);
} else if (jbd2_cleanup_journal_tail(journal) == 0) {
/* We were able to recover space; yay! */
;
} else if (tid) {
jbd2_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, space_left);
printk(KERN_ERR "%s: no way to get more "
"journal space in %s\n", __func__,
journal->j_devname);
WARN_ON(1);
jbd2_journal_abort(journal, 0);
}

spin_lock(&journal->j_state_lock);
} else {
spin_unlock(&journal->j_list_lock);
Expand Down

0 comments on commit b4bf446

Please sign in to comment.