add patch create-function-to-read-journal-inode
[ext4-patch-queue.git] / commit-as-soon-as-possible-after-log_start_commit
blob46b310bf892fb9c97cc1c933eea7a35b89a76828
1 jbd2: commit as soon as possible after log_start_commit
3 Once a transaction has been requested to be committed, don't let any
4 other handles start under that transaction, and don't allow any
5 pending transactions to be extended (i.e., in the case of
6 unlink/ftruncate).
8 The idea is once the transaction has had log_start_commit() called on
9 it, at least one thread is blocked waiting for that transaction to
10 commit, and over time, more and more threads will end up getting
11 blocked.  In order to avoid high variability in file system operations
12 getting blocked behind the a blocked start_this_handle(), we should
13 try to get the commit started as soon as possible.
15 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
16 ---
17  fs/jbd2/transaction.c | 4 ++--
18  1 file changed, 2 insertions(+), 2 deletions(-)
20 diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
21 index 7aa9a32..e1c0b4a 100644
22 --- a/fs/jbd2/transaction.c
23 +++ b/fs/jbd2/transaction.c
24 @@ -186,7 +186,7 @@ static int add_transaction_credits(journal_t *journal, int blocks,
25          * If the current transaction is locked down for commit, wait
26          * for the lock to be released.
27          */
28 -       if (t->t_state == T_LOCKED) {
29 +       if (t->t_state == T_LOCKED || t->t_requested) {
30                 wait_transaction_locked(journal);
31                 return 1;
32         }
33 @@ -559,7 +559,7 @@ int jbd2_journal_extend(handle_t *handle, int nblocks)
34         read_lock(&journal->j_state_lock);
36         /* Don't extend a locked-down transaction! */
37 -       if (transaction->t_state != T_RUNNING) {
38 +       if (transaction->t_state != T_RUNNING || transaction->t_requested) {
39                 jbd_debug(3, "denied handle %p %d blocks: "
40                           "transaction not running\n", handle, nblocks);
41                 goto error_out;