diff options
author | Jan Kara <jack@suse.cz> | 2011-05-24 11:59:18 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-05-24 11:59:18 -0400 |
commit | bbd2be36910728f485ac78ea36e0f4f5a38e691e (patch) | |
tree | 6a45da5a6ef8bafe9614de5fac68cce1fe4e13ec /fs/jbd2/journal.c | |
parent | 81be12c8179c1c397d3f179cdd9b3f7146cf47f1 (diff) |
jbd2: Add function jbd2_trans_will_send_data_barrier()
Provide a function which returns whether a transaction with given tid
will send a flush to the filesystem device. The function will be used
by ext4 to detect whether fsync needs to send a separate flush or not.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2/journal.c')
-rw-r--r-- | fs/jbd2/journal.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index cd2d341f602e..9a7826990304 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -588,6 +588,47 @@ int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid) | |||
588 | } | 588 | } |
589 | 589 | ||
590 | /* | 590 | /* |
591 | * Return 1 if a given transaction has not yet sent barrier request | ||
592 | * connected with a transaction commit. If 0 is returned, transaction | ||
593 | * may or may not have sent the barrier. Used to avoid sending barrier | ||
594 | * twice in common cases. | ||
595 | */ | ||
596 | int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid) | ||
597 | { | ||
598 | int ret = 0; | ||
599 | transaction_t *commit_trans; | ||
600 | |||
601 | if (!(journal->j_flags & JBD2_BARRIER)) | ||
602 | return 0; | ||
603 | read_lock(&journal->j_state_lock); | ||
604 | /* Transaction already committed? */ | ||
605 | if (tid_geq(journal->j_commit_sequence, tid)) | ||
606 | goto out; | ||
607 | commit_trans = journal->j_committing_transaction; | ||
608 | if (!commit_trans || commit_trans->t_tid != tid) { | ||
609 | ret = 1; | ||
610 | goto out; | ||
611 | } | ||
612 | /* | ||
613 | * Transaction is being committed and we already proceeded to | ||
614 | * submitting a flush to fs partition? | ||
615 | */ | ||
616 | if (journal->j_fs_dev != journal->j_dev) { | ||
617 | if (!commit_trans->t_need_data_flush || | ||
618 | commit_trans->t_state >= T_COMMIT_DFLUSH) | ||
619 | goto out; | ||
620 | } else { | ||
621 | if (commit_trans->t_state >= T_COMMIT_JFLUSH) | ||
622 | goto out; | ||
623 | } | ||
624 | ret = 1; | ||
625 | out: | ||
626 | read_unlock(&journal->j_state_lock); | ||
627 | return ret; | ||
628 | } | ||
629 | EXPORT_SYMBOL(jbd2_trans_will_send_data_barrier); | ||
630 | |||
631 | /* | ||
591 | * Wait for a specified commit to complete. | 632 | * Wait for a specified commit to complete. |
592 | * The caller may not hold the journal lock. | 633 | * The caller may not hold the journal lock. |
593 | */ | 634 | */ |