1 jbd2: minimize region locked by j_list_lock in jbd2_journal_forget()
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>
9 fs/jbd2/transaction.c | 6 ++++--
10 1 file changed, 4 insertions(+), 2 deletions(-)
12 diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
13 index 357f3dc..d999b1f 100644
14 --- a/fs/jbd2/transaction.c
15 +++ b/fs/jbd2/transaction.c
16 @@ -1416,7 +1416,6 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
17 BUFFER_TRACE(bh, "entry");
19 jbd_lock_bh_state(bh);
20 - spin_lock(&journal->j_list_lock);
24 @@ -1469,6 +1468,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
25 * we know to remove the checkpoint after we commit.
28 + spin_lock(&journal->j_list_lock);
29 if (jh->b_cp_transaction) {
30 __jbd2_journal_temp_unlink_buffer(jh);
31 __jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
32 @@ -1481,6 +1481,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
36 + spin_unlock(&journal->j_list_lock);
37 } else if (jh->b_transaction) {
38 J_ASSERT_JH(jh, (jh->b_transaction ==
39 journal->j_committing_transaction));
40 @@ -1492,7 +1493,9 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
42 if (jh->b_next_transaction) {
43 J_ASSERT(jh->b_next_transaction == transaction);
44 + spin_lock(&journal->j_list_lock);
45 jh->b_next_transaction = NULL;
46 + spin_unlock(&journal->j_list_lock);
49 * only drop a reference if this transaction modified
50 @@ -1504,7 +1507,6 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
54 - spin_unlock(&journal->j_list_lock);
55 jbd_unlock_bh_state(bh);