Message ID | 20240506141801.1165315-8-shikemeng@huaweicloud.com |
---|---|
State | Superseded |
Headers | show |
Series | A fix and some cleanups to jbd2 | expand |
On 2024/5/6 22:17, Kemeng Shi wrote: > In kjournald2, two equality checks of j_commit_[sequence/request] are > under the same j_state_lock. As j_commit_[sequence/request] are updated > concurrently with j_state_lock held during runtime, the second check is > unnecessary. > The j_commit_sequence is only updated concurrently in > jbd2_journal_commit_transaction with j_state_lock held. > The j_commit_request is only updated concurrently in > __jbd2_log_start_commit with j_state_lock held. > Also see comment in struct journal_s about lock rule of j_commit_sequence > and j_commit_request. > > Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Looks reasonable to me. Reviewed-by: Zhang Yi <yi.zhang@huawei.com> > --- > fs/jbd2/journal.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c > index 01e33b643e4d..e8f592fbd6e1 100644 > --- a/fs/jbd2/journal.c > +++ b/fs/jbd2/journal.c > @@ -224,8 +224,6 @@ static int kjournald2(void *arg) > > prepare_to_wait(&journal->j_wait_commit, &wait, > TASK_INTERRUPTIBLE); > - if (journal->j_commit_sequence != journal->j_commit_request) > - should_sleep = 0; > transaction = journal->j_running_transaction; > if (transaction && time_after_eq(jiffies, > transaction->t_expires)) >
On Mon 06-05-24 22:17:59, Kemeng Shi wrote: > In kjournald2, two equality checks of j_commit_[sequence/request] are > under the same j_state_lock. As j_commit_[sequence/request] are updated > concurrently with j_state_lock held during runtime, the second check is > unnecessary. > The j_commit_sequence is only updated concurrently in > jbd2_journal_commit_transaction with j_state_lock held. > The j_commit_request is only updated concurrently in > __jbd2_log_start_commit with j_state_lock held. > Also see comment in struct journal_s about lock rule of j_commit_sequence > and j_commit_request. > > Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Looks good. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > fs/jbd2/journal.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c > index 01e33b643e4d..e8f592fbd6e1 100644 > --- a/fs/jbd2/journal.c > +++ b/fs/jbd2/journal.c > @@ -224,8 +224,6 @@ static int kjournald2(void *arg) > > prepare_to_wait(&journal->j_wait_commit, &wait, > TASK_INTERRUPTIBLE); > - if (journal->j_commit_sequence != journal->j_commit_request) > - should_sleep = 0; > transaction = journal->j_running_transaction; > if (transaction && time_after_eq(jiffies, > transaction->t_expires)) > -- > 2.30.0 >
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 01e33b643e4d..e8f592fbd6e1 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -224,8 +224,6 @@ static int kjournald2(void *arg) prepare_to_wait(&journal->j_wait_commit, &wait, TASK_INTERRUPTIBLE); - if (journal->j_commit_sequence != journal->j_commit_request) - should_sleep = 0; transaction = journal->j_running_transaction; if (transaction && time_after_eq(jiffies, transaction->t_expires))
In kjournald2, two equality checks of j_commit_[sequence/request] are under the same j_state_lock. As j_commit_[sequence/request] are updated concurrently with j_state_lock held during runtime, the second check is unnecessary. The j_commit_sequence is only updated concurrently in jbd2_journal_commit_transaction with j_state_lock held. The j_commit_request is only updated concurrently in __jbd2_log_start_commit with j_state_lock held. Also see comment in struct journal_s about lock rule of j_commit_sequence and j_commit_request. Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> --- fs/jbd2/journal.c | 2 -- 1 file changed, 2 deletions(-)