Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bfea811 authored by Theodore Ts'o's avatar Theodore Ts'o
Browse files

jbd2: minimize region locked by j_list_lock in jbd2_journal_forget()



It's not needed until we start trying to modifying fields in the
journal_head which are protected by j_list_lock.

Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 6e4862a5
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -1416,7 +1416,6 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
	BUFFER_TRACE(bh, "entry");
	BUFFER_TRACE(bh, "entry");


	jbd_lock_bh_state(bh);
	jbd_lock_bh_state(bh);
	spin_lock(&journal->j_list_lock);


	if (!buffer_jbd(bh))
	if (!buffer_jbd(bh))
		goto not_jbd;
		goto not_jbd;
@@ -1469,6 +1468,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
		 * we know to remove the checkpoint after we commit.
		 * we know to remove the checkpoint after we commit.
		 */
		 */


		spin_lock(&journal->j_list_lock);
		if (jh->b_cp_transaction) {
		if (jh->b_cp_transaction) {
			__jbd2_journal_temp_unlink_buffer(jh);
			__jbd2_journal_temp_unlink_buffer(jh);
			__jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
			__jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
@@ -1481,6 +1481,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
				goto drop;
				goto drop;
			}
			}
		}
		}
		spin_unlock(&journal->j_list_lock);
	} else if (jh->b_transaction) {
	} else if (jh->b_transaction) {
		J_ASSERT_JH(jh, (jh->b_transaction ==
		J_ASSERT_JH(jh, (jh->b_transaction ==
				 journal->j_committing_transaction));
				 journal->j_committing_transaction));
@@ -1492,7 +1493,9 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)


		if (jh->b_next_transaction) {
		if (jh->b_next_transaction) {
			J_ASSERT(jh->b_next_transaction == transaction);
			J_ASSERT(jh->b_next_transaction == transaction);
			spin_lock(&journal->j_list_lock);
			jh->b_next_transaction = NULL;
			jh->b_next_transaction = NULL;
			spin_unlock(&journal->j_list_lock);


			/*
			/*
			 * only drop a reference if this transaction modified
			 * only drop a reference if this transaction modified
@@ -1504,7 +1507,6 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
	}
	}


not_jbd:
not_jbd:
	spin_unlock(&journal->j_list_lock);
	jbd_unlock_bh_state(bh);
	jbd_unlock_bh_state(bh);
	__brelse(bh);
	__brelse(bh);
drop:
drop: