add jbd2 speedup patches
[ext4-patch-queue.git] / jbd2-minimize-j_list_lock-in-journal_get_create_access
blob27c92f6df3d1934459f4ffc8a4b25f8ac8e09b84
1 jbd2: minimize region locked by j_list_lock in journal_get_create_access()
3 It's not needed until we start trying to modifying fields in the
4 journal_head which are protected by j_list_lock.
6 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
7 ---
8  fs/jbd2/transaction.c | 3 ++-
9  1 file changed, 2 insertions(+), 1 deletion(-)
11 diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
12 index 78900a1..357f3dc 100644
13 --- a/fs/jbd2/transaction.c
14 +++ b/fs/jbd2/transaction.c
15 @@ -1073,7 +1073,6 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
16          * reused here.
17          */
18         jbd_lock_bh_state(bh);
19 -       spin_lock(&journal->j_list_lock);
20         J_ASSERT_JH(jh, (jh->b_transaction == transaction ||
21                 jh->b_transaction == NULL ||
22                 (jh->b_transaction == journal->j_committing_transaction &&
23 @@ -1096,12 +1095,14 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
24                 jh->b_modified = 0;
26                 JBUFFER_TRACE(jh, "file as BJ_Reserved");
27 +               spin_lock(&journal->j_list_lock);
28                 __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved);
29         } else if (jh->b_transaction == journal->j_committing_transaction) {
30                 /* first access by this transaction */
31                 jh->b_modified = 0;
33                 JBUFFER_TRACE(jh, "set next transaction");
34 +               spin_lock(&journal->j_list_lock);
35                 jh->b_next_transaction = transaction;
36         }
37         spin_unlock(&journal->j_list_lock);