sched: Remove proliferation of wait_on_bit() action functions
[deliverable/linux.git] / fs / jbd2 / transaction.c
index 60bb365f54a52efb8ff859ff746ac1af201bb7d2..5f09370c90a8199647a87ef7cb6a5cfdba113d2b 100644 (file)
@@ -763,12 +763,6 @@ static void warn_dirty_buffer(struct buffer_head *bh)
               bdevname(bh->b_bdev, b), (unsigned long long)bh->b_blocknr);
 }
 
-static int sleep_on_shadow_bh(void *word)
-{
-       io_schedule();
-       return 0;
-}
-
 /*
  * If the buffer is already part of the current transaction, then there
  * is nothing we need to do.  If it is already part of a prior
@@ -906,8 +900,8 @@ repeat:
                if (buffer_shadow(bh)) {
                        JBUFFER_TRACE(jh, "on shadow: sleep");
                        jbd_unlock_bh_state(bh);
-                       wait_on_bit(&bh->b_state, BH_Shadow,
-                                   sleep_on_shadow_bh, TASK_UNINTERRUPTIBLE);
+                       wait_on_bit_io(&bh->b_state, BH_Shadow,
+                                      TASK_UNINTERRUPTIBLE);
                        goto repeat;
                }
 
@@ -1073,7 +1067,6 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
         * reused here.
         */
        jbd_lock_bh_state(bh);
-       spin_lock(&journal->j_list_lock);
        J_ASSERT_JH(jh, (jh->b_transaction == transaction ||
                jh->b_transaction == NULL ||
                (jh->b_transaction == journal->j_committing_transaction &&
@@ -1096,12 +1089,14 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
                jh->b_modified = 0;
 
                JBUFFER_TRACE(jh, "file as BJ_Reserved");
+               spin_lock(&journal->j_list_lock);
                __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved);
        } else if (jh->b_transaction == journal->j_committing_transaction) {
                /* first access by this transaction */
                jh->b_modified = 0;
 
                JBUFFER_TRACE(jh, "set next transaction");
+               spin_lock(&journal->j_list_lock);
                jh->b_next_transaction = transaction;
        }
        spin_unlock(&journal->j_list_lock);
@@ -1312,7 +1307,7 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
                             journal->j_running_transaction)) {
                        printk(KERN_ERR "JBD2: %s: "
                               "jh->b_transaction (%llu, %p, %u) != "
-                              "journal->j_running_transaction (%p, %u)",
+                              "journal->j_running_transaction (%p, %u)\n",
                               journal->j_devname,
                               (unsigned long long) bh->b_blocknr,
                               jh->b_transaction,
@@ -1335,30 +1330,25 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
         */
        if (jh->b_transaction != transaction) {
                JBUFFER_TRACE(jh, "already on other transaction");
-               if (unlikely(jh->b_transaction !=
-                            journal->j_committing_transaction)) {
-                       printk(KERN_ERR "JBD2: %s: "
-                              "jh->b_transaction (%llu, %p, %u) != "
-                              "journal->j_committing_transaction (%p, %u)",
+               if (unlikely(((jh->b_transaction !=
+                              journal->j_committing_transaction)) ||
+                            (jh->b_next_transaction != transaction))) {
+                       printk(KERN_ERR "jbd2_journal_dirty_metadata: %s: "
+                              "bad jh for block %llu: "
+                              "transaction (%p, %u), "
+                              "jh->b_transaction (%p, %u), "
+                              "jh->b_next_transaction (%p, %u), jlist %u\n",
                               journal->j_devname,
                               (unsigned long long) bh->b_blocknr,
+                              transaction, transaction->t_tid,
                               jh->b_transaction,
-                              jh->b_transaction ? jh->b_transaction->t_tid : 0,
-                              journal->j_committing_transaction,
-                              journal->j_committing_transaction ?
-                              journal->j_committing_transaction->t_tid : 0);
-                       ret = -EINVAL;
-               }
-               if (unlikely(jh->b_next_transaction != transaction)) {
-                       printk(KERN_ERR "JBD2: %s: "
-                              "jh->b_next_transaction (%llu, %p, %u) != "
-                              "transaction (%p, %u)",
-                              journal->j_devname,
-                              (unsigned long long) bh->b_blocknr,
+                              jh->b_transaction ?
+                              jh->b_transaction->t_tid : 0,
                               jh->b_next_transaction,
                               jh->b_next_transaction ?
                               jh->b_next_transaction->t_tid : 0,
-                              transaction, transaction->t_tid);
+                              jh->b_jlist);
+                       WARN_ON(1);
                        ret = -EINVAL;
                }
                /* And this case is illegal: we can't reuse another
@@ -1415,7 +1405,6 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
        BUFFER_TRACE(bh, "entry");
 
        jbd_lock_bh_state(bh);
-       spin_lock(&journal->j_list_lock);
 
        if (!buffer_jbd(bh))
                goto not_jbd;
@@ -1468,6 +1457,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
                 * we know to remove the checkpoint after we commit.
                 */
 
+               spin_lock(&journal->j_list_lock);
                if (jh->b_cp_transaction) {
                        __jbd2_journal_temp_unlink_buffer(jh);
                        __jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
@@ -1480,6 +1470,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
                                goto drop;
                        }
                }
+               spin_unlock(&journal->j_list_lock);
        } else if (jh->b_transaction) {
                J_ASSERT_JH(jh, (jh->b_transaction ==
                                 journal->j_committing_transaction));
@@ -1491,7 +1482,9 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
 
                if (jh->b_next_transaction) {
                        J_ASSERT(jh->b_next_transaction == transaction);
+                       spin_lock(&journal->j_list_lock);
                        jh->b_next_transaction = NULL;
+                       spin_unlock(&journal->j_list_lock);
 
                        /*
                         * only drop a reference if this transaction modified
@@ -1503,7 +1496,6 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
        }
 
 not_jbd:
-       spin_unlock(&journal->j_list_lock);
        jbd_unlock_bh_state(bh);
        __brelse(bh);
 drop:
@@ -1590,9 +1582,12 @@ int jbd2_journal_stop(handle_t *handle)
         * to perform a synchronous write.  We do this to detect the
         * case where a single process is doing a stream of sync
         * writes.  No point in waiting for joiners in that case.
+        *
+        * Setting max_batch_time to 0 disables this completely.
         */
        pid = current->pid;
-       if (handle->h_sync && journal->j_last_sync_writer != pid) {
+       if (handle->h_sync && journal->j_last_sync_writer != pid &&
+           journal->j_max_batch_time) {
                u64 commit_time, trans_time;
 
                journal->j_last_sync_writer = pid;
@@ -1821,11 +1816,11 @@ __journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh)
        if (buffer_locked(bh) || buffer_dirty(bh))
                goto out;
 
-       if (jh->b_next_transaction != NULL)
+       if (jh->b_next_transaction != NULL || jh->b_transaction != NULL)
                goto out;
 
        spin_lock(&journal->j_list_lock);
-       if (jh->b_cp_transaction != NULL && jh->b_transaction == NULL) {
+       if (jh->b_cp_transaction != NULL) {
                /* written-back checkpointed metadata buffer */
                JBUFFER_TRACE(jh, "remove from checkpoint list");
                __jbd2_journal_remove_checkpoint(jh);
This page took 0.027129 seconds and 5 git commands to generate.