]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/jbd/checkpoint.c
Merge git://git.infradead.org/mtd-2.6
[linux-2.6-omap-h63xx.git] / fs / jbd / checkpoint.c
index e29293501d42717b581fb57be952b77ae65e0ee2..1bd8d4acc6f2124a7574001d454a25b971fd9852 100644 (file)
@@ -94,7 +94,7 @@ static int __try_to_free_cp_buf(struct journal_head *jh)
        struct buffer_head *bh = jh2bh(jh);
 
        if (jh->b_jlist == BJ_None && !buffer_locked(bh) &&
-           !buffer_dirty(bh) && buffer_uptodate(bh)) {
+           !buffer_dirty(bh) && !buffer_write_io_error(bh)) {
                JBUFFER_TRACE(jh, "remove from checkpoint list");
                ret = __journal_remove_checkpoint(jh) + 1;
                jbd_unlock_bh_state(bh);
@@ -127,14 +127,29 @@ void __log_wait_for_space(journal_t *journal)
 
                /*
                 * Test again, another process may have checkpointed while we
-                * were waiting for the checkpoint lock
+                * 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.
                 */
                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;
+
+                       spin_unlock(&journal->j_list_lock);
                        spin_unlock(&journal->j_state_lock);
-                       log_do_checkpoint(journal);
+                       if (chkpt) {
+                               log_do_checkpoint(journal);
+                       } else {
+                               printk(KERN_ERR "%s: no transactions\n",
+                                      __func__);
+                               journal_abort(journal, 0);
+                       }
+
                        spin_lock(&journal->j_state_lock);
+               } else {
+                       spin_unlock(&journal->j_list_lock);
                }
                mutex_unlock(&journal->j_checkpoint_mutex);
        }
@@ -199,7 +214,7 @@ restart:
                        spin_lock(&journal->j_list_lock);
                        goto restart;
                }
-               if (unlikely(!buffer_uptodate(bh)))
+               if (unlikely(buffer_write_io_error(bh)))
                        ret = -EIO;
 
                /*
@@ -268,7 +283,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
                ret = 1;
        } else if (!buffer_dirty(bh)) {
                ret = 1;
-               if (unlikely(!buffer_uptodate(bh)))
+               if (unlikely(buffer_write_io_error(bh)))
                        ret = -EIO;
                J_ASSERT_JH(jh, !buffer_jbddirty(bh));
                BUFFER_TRACE(bh, "remove from checkpoint");