]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/jbd2/transaction.c
jbd2: move lockdep instrumentation for jbd2 handles
[mirror_ubuntu-bionic-kernel.git] / fs / jbd2 / transaction.c
index 67c103867bf8d5d27e84a4eb2ad2c8a09b22d328..41249538c0472f6ab4cd3afa3ec4c17c9836f2fa 100644 (file)
@@ -543,7 +543,7 @@ EXPORT_SYMBOL(jbd2_journal_start_reserved);
  *
  * Some transactions, such as large extends and truncates, can be done
  * atomically all at once or in several stages.  The operation requests
- * a credit for a number of buffer modications in advance, but can
+ * a credit for a number of buffer modifications in advance, but can
  * extend its credit if it needs more.
  *
  * jbd2_journal_extend tries to give the running handle more buffer credits.
@@ -627,7 +627,7 @@ error_out:
  * If the jbd2_journal_extend() call above fails to grant new buffer credits
  * to a running handle, a call to jbd2_journal_restart will commit the
  * handle's transaction so far and reattach the handle to a new
- * transaction capabable of guaranteeing the requested number of
+ * transaction capable of guaranteeing the requested number of
  * credits. We preserve reserved handle if there's any attached to the
  * passed in handle.
  */
@@ -1586,7 +1586,7 @@ drop:
 
 /**
  * int jbd2_journal_stop() - complete a transaction
- * @handle: tranaction to complete.
+ * @handle: transaction to complete.
  *
  * All done for a particular handle.
  *
@@ -1750,11 +1750,11 @@ int jbd2_journal_stop(handle_t *handle)
                        wake_up(&journal->j_wait_transaction_locked);
        }
 
+       lock_map_release(&handle->h_lockdep_map);
+
        if (wait_for_commit)
                err = jbd2_log_wait_commit(journal, tid);
 
-       lock_map_release(&handle->h_lockdep_map);
-
        if (handle->h_rsv_handle)
                jbd2_journal_free_reserved(handle->h_rsv_handle);
 free_and_exit:
@@ -2462,7 +2462,8 @@ void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh)
 /*
  * File inode in the inode list of the handle's transaction
  */
-int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode)
+static int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode,
+                                  unsigned long flags)
 {
        transaction_t *transaction = handle->h_transaction;
        journal_t *journal;
@@ -2487,12 +2488,14 @@ int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode)
         * and if jinode->i_next_transaction == transaction, commit code
         * will only file the inode where we want it.
         */
-       if (jinode->i_transaction == transaction ||
-           jinode->i_next_transaction == transaction)
+       if ((jinode->i_transaction == transaction ||
+           jinode->i_next_transaction == transaction) &&
+           (jinode->i_flags & flags) == flags)
                return 0;
 
        spin_lock(&journal->j_list_lock);
-
+       jinode->i_flags |= flags;
+       /* Is inode already attached where we need it? */
        if (jinode->i_transaction == transaction ||
            jinode->i_next_transaction == transaction)
                goto done;
@@ -2523,6 +2526,17 @@ done:
        return 0;
 }
 
+int jbd2_journal_inode_add_write(handle_t *handle, struct jbd2_inode *jinode)
+{
+       return jbd2_journal_file_inode(handle, jinode,
+                                      JI_WRITE_DATA | JI_WAIT_DATA);
+}
+
+int jbd2_journal_inode_add_wait(handle_t *handle, struct jbd2_inode *jinode)
+{
+       return jbd2_journal_file_inode(handle, jinode, JI_WAIT_DATA);
+}
+
 /*
  * File truncate and transaction commit interact with each other in a
  * non-trivial way.  If a transaction writing data block A is