Add patch SR-ext4-resize-mark-new-group-EXT_BG_INODE_ZEROED.patch
[ext4-patch-queue/an.git] / aneesh-6-call-journal-commit-without-holding-j_list_lock
blob8ecaaabe57b0156d3b5499182db306adb76f8f57
1 jbd2: Call journal commit callback without holding j_list_lock
3 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
5 Avoid freeing the transaction in __jbd2_journal_drop_transaction() so
6 the journal commit callback can run without holding j_list_lock, to
7 avoid lock contention on this spinlock.
9 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
10 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
11 ---
12  fs/jbd2/checkpoint.c |    2 +-
13  fs/jbd2/commit.c     |   13 ++++++++-----
14  include/linux/jbd2.h |    4 ++--
15  3 files changed, 11 insertions(+), 8 deletions(-)
17 diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
18 index 1c10ce5..ad1d2d9 100644
19 --- a/fs/jbd2/checkpoint.c
20 +++ b/fs/jbd2/checkpoint.c
21 @@ -682,6 +682,7 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
22            safely remove this transaction from the log */
24         __jbd2_journal_drop_transaction(journal, transaction);
25 +       kfree(transaction);
27         /* Just in case anybody was waiting for more transactions to be
28             checkpointed... */
29 @@ -756,5 +757,4 @@ void __jbd2_journal_drop_transaction(journal_t *journal, transaction_t *transact
30         J_ASSERT(journal->j_running_transaction != transaction);
32         jbd_debug(1, "Dropping transaction %d, all done\n", transaction->t_tid);
33 -       kfree(transaction);
34  }
35 diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
36 index b3bcb26..5befb2d 100644
37 --- a/fs/jbd2/commit.c
38 +++ b/fs/jbd2/commit.c
39 @@ -340,7 +340,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
40         int space_left = 0;
41         int first_tag = 0;
42         int tag_flag;
43 -       int i;
44 +       int i, to_free = 0;
45         int tag_bytes = journal_tag_bytes(journal);
46         struct buffer_head *cbh = NULL; /* For transactional checksums */
47         __u32 crc32_sum = ~0;
48 @@ -988,12 +988,10 @@ void jbd2_journal_commit_transaction(journal_t *journal)
49                 journal->j_average_commit_time = commit_time;
50         spin_unlock(&journal->j_state_lock);
52 -       if (journal->j_commit_callback)
53 -               journal->j_commit_callback(journal, commit_transaction);
55         if (commit_transaction->t_checkpoint_list == NULL &&
56             commit_transaction->t_checkpoint_io_list == NULL) {
57                 __jbd2_journal_drop_transaction(journal, commit_transaction);
58 +               to_free = 1;
59         } else {
60                 if (journal->j_checkpoint_transactions == NULL) {
61                         journal->j_checkpoint_transactions = commit_transaction;
62 @@ -1012,11 +1010,16 @@ void jbd2_journal_commit_transaction(journal_t *journal)
63         }
64         spin_unlock(&journal->j_list_lock);
66 +       if (journal->j_commit_callback)
67 +               journal->j_commit_callback(journal, commit_transaction);
69         trace_mark(jbd2_end_commit, "dev %s transaction %d head %d",
70 -                  journal->j_devname, journal->j_commit_sequence,
71 +                  journal->j_devname, commit_transaction->t_tid,
72                    journal->j_tail_sequence);
73         jbd_debug(1, "JBD: commit %d complete, head %d\n",
74                   journal->j_commit_sequence, journal->j_tail_sequence);
75 +       if (to_free)
76 +               kfree(commit_transaction);
78         wake_up(&journal->j_wait_done_commit);
79  }
80 diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
81 index fdbd0bf..4932b34 100644
82 --- a/include/linux/jbd2.h
83 +++ b/include/linux/jbd2.h
84 @@ -1170,8 +1170,8 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
85  int jbd2_log_do_checkpoint(journal_t *journal);
87  void __jbd2_log_wait_for_space(journal_t *journal);
88 -extern void    __jbd2_journal_drop_transaction(journal_t *, transaction_t *);
89 -extern int     jbd2_cleanup_journal_tail(journal_t *);
90 +extern void __jbd2_journal_drop_transaction(journal_t *, transaction_t *);
91 +extern int jbd2_cleanup_journal_tail(journal_t *);
93  /* Debugging code only: */
95 -- 
96 1.6.0.3.514.g2f91b
99 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
100 the body of a message to majordomo@vger.kernel.org
101 More majordomo info at  http://vger.kernel.org/majordomo-info.html