vserver 1.9.5.x5
[linux-2.6.git] / fs / jbd / commit.c
index f8a1dea..aa5f224 100644 (file)
@@ -262,7 +262,7 @@ write_out_data:
                        __journal_file_buffer(jh, commit_transaction,
                                                BJ_Locked);
                        jbd_unlock_bh_state(bh);
-                       if (need_resched()) {
+                       if (lock_need_resched(&journal->j_list_lock)) {
                                spin_unlock(&journal->j_list_lock);
                                goto write_out_data;
                        }
@@ -288,7 +288,7 @@ write_out_data:
                                jbd_unlock_bh_state(bh);
                                journal_remove_journal_head(bh);
                                put_bh(bh);
-                               if (need_resched()) {
+                               if (lock_need_resched(&journal->j_list_lock)) {
                                        spin_unlock(&journal->j_list_lock);
                                        goto write_out_data;
                                }
@@ -333,14 +333,13 @@ write_out_data:
                        jbd_unlock_bh_state(bh);
                }
                put_bh(bh);
-               if (need_resched()) {
-                       spin_unlock(&journal->j_list_lock);
-                       cond_resched();
-                       spin_lock(&journal->j_list_lock);
-               }
+               cond_resched_lock(&journal->j_list_lock);
        }
        spin_unlock(&journal->j_list_lock);
 
+       if (err)
+               __journal_abort_hard(journal);
+
        journal_write_revoke_records(journal, commit_transaction);
 
        jbd_debug(3, "JBD: commit phase 2\n");
@@ -545,6 +544,8 @@ wait_for_iobuf:
                        wait_on_buffer(bh);
                        goto wait_for_iobuf;
                }
+               if (cond_resched())
+                       goto wait_for_iobuf;
 
                if (unlikely(!buffer_uptodate(bh)))
                        err = -EIO;
@@ -579,7 +580,7 @@ wait_for_iobuf:
                journal_file_buffer(jh, commit_transaction, BJ_Forget);
                /* Wake up any transactions which were waiting for this
                   IO to complete */
-               wake_up_buffer(bh);
+               wake_up_bit(&bh->b_state, BH_Unshadow);
                JBUFFER_TRACE(jh, "brelse shadowed buffer");
                __brelse(bh);
        }
@@ -599,6 +600,8 @@ wait_for_iobuf:
                        wait_on_buffer(bh);
                        goto wait_for_ctlbuf;
                }
+               if (cond_resched())
+                       goto wait_for_ctlbuf;
 
                if (unlikely(!buffer_uptodate(bh)))
                        err = -EIO;
@@ -686,30 +689,6 @@ skip_commit: /* The journal should be unlocked by now. */
        if (err)
                __journal_abort_hard(journal);
 
-       /*
-        * Call any callbacks that had been registered for handles in this
-        * transaction.  It is up to the callback to free any allocated
-        * memory.
-        *
-        * The spinlocking (t_jcb_lock) here is surely unnecessary...
-        */
-       spin_lock(&commit_transaction->t_jcb_lock);
-       if (!list_empty(&commit_transaction->t_jcb)) {
-               struct list_head *p, *n;
-               int error = is_journal_aborted(journal);
-
-               list_for_each_safe(p, n, &commit_transaction->t_jcb) {
-                       struct journal_callback *jcb;
-
-                       jcb = list_entry(p, struct journal_callback, jcb_list);
-                       list_del(p);
-                       spin_unlock(&commit_transaction->t_jcb_lock);
-                       jcb->jcb_func(jcb, error);
-                       spin_lock(&commit_transaction->t_jcb_lock);
-               }
-       }
-       spin_unlock(&commit_transaction->t_jcb_lock);
-
        jbd_debug(3, "JBD: commit phase 7\n");
 
        J_ASSERT(commit_transaction->t_sync_datalist == NULL);
@@ -719,6 +698,7 @@ skip_commit: /* The journal should be unlocked by now. */
        J_ASSERT(commit_transaction->t_shadow_list == NULL);
        J_ASSERT(commit_transaction->t_log_list == NULL);
 
+restart_loop:
        while (commit_transaction->t_forget) {
                transaction_t *cp_transaction;
                struct buffer_head *bh;
@@ -792,6 +772,8 @@ skip_commit: /* The journal should be unlocked by now. */
                        release_buffer_page(bh);
                }
                spin_unlock(&journal->j_list_lock);
+               if (cond_resched())
+                       goto restart_loop;
        }
 
        /* Done with this transaction! */