add patch remove-unneeded-test-of-ret-variable
[ext4-patch-queue.git] / dont-hold-j_state_lock-during-wake_up
blobedec3b654992937cd530938ff7dd603528d4f28e
1 jbd2: don't hold j_state_lock while calling wake_up()
3 The j_state_lock is one of the hottest locks in the jbd2 layer and
4 thus one of its scalability bottlenecks.
6 We don't need to be holding the j_state_lock while we are calling
7 wake_up(&journal->j_wait_commit), so release the lock a little bit
8 earlier.
10 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
11 diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
12 index 244b6f6..67b8e30 100644
13 --- a/fs/jbd2/journal.c
14 +++ b/fs/jbd2/journal.c
15 @@ -302,8 +302,8 @@ static void journal_kill_thread(journal_t *journal)
16         journal->j_flags |= JBD2_UNMOUNT;
18         while (journal->j_task) {
19 -               wake_up(&journal->j_wait_commit);
20                 write_unlock(&journal->j_state_lock);
21 +               wake_up(&journal->j_wait_commit);
22                 wait_event(journal->j_wait_done_commit, journal->j_task == NULL);
23                 write_lock(&journal->j_state_lock);
24         }
25 @@ -710,8 +710,8 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
26         while (tid_gt(tid, journal->j_commit_sequence)) {
27                 jbd_debug(1, "JBD2: want %d, j_commit_sequence=%d\n",
28                                   tid, journal->j_commit_sequence);
29 -               wake_up(&journal->j_wait_commit);
30                 read_unlock(&journal->j_state_lock);
31 +               wake_up(&journal->j_wait_commit);
32                 wait_event(journal->j_wait_done_commit,
33                                 !tid_gt(tid, journal->j_commit_sequence));
34                 read_lock(&journal->j_state_lock);