aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2/journal.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jbd2/journal.c')
-rw-r--r--fs/jbd2/journal.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index ed10991ab006..886ec2faa9b4 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -710,6 +710,37 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
710} 710}
711 711
712/* 712/*
713 * When this function returns the transaction corresponding to tid
714 * will be completed. If the transaction has currently running, start
715 * committing that transaction before waiting for it to complete. If
716 * the transaction id is stale, it is by definition already completed,
717 * so just return SUCCESS.
718 */
719int jbd2_complete_transaction(journal_t *journal, tid_t tid)
720{
721 int need_to_wait = 1;
722
723 read_lock(&journal->j_state_lock);
724 if (journal->j_running_transaction &&
725 journal->j_running_transaction->t_tid == tid) {
726 if (journal->j_commit_request != tid) {
727 /* transaction not yet started, so request it */
728 read_unlock(&journal->j_state_lock);
729 jbd2_log_start_commit(journal, tid);
730 goto wait_commit;
731 }
732 } else if (!(journal->j_committing_transaction &&
733 journal->j_committing_transaction->t_tid == tid))
734 need_to_wait = 0;
735 read_unlock(&journal->j_state_lock);
736 if (!need_to_wait)
737 return 0;
738wait_commit:
739 return jbd2_log_wait_commit(journal, tid);
740}
741EXPORT_SYMBOL(jbd2_complete_transaction);
742
743/*
713 * Log buffer allocation routines: 744 * Log buffer allocation routines:
714 */ 745 */
715 746