diff mbox series

[9/9] jbd2: remove unnecessary "should_sleep" in kjournald2

Message ID 20240506141801.1165315-10-shikemeng@huaweicloud.com
State Superseded
Headers show
Series A fix and some cleanups to jbd2 | expand

Commit Message

Kemeng Shi May 6, 2024, 2:18 p.m. UTC
We only need to sleep if no running transaction is expired. Simply remove
unnecessary "should_sleep".

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 fs/jbd2/journal.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Zhang Yi May 9, 2024, 12:09 p.m. UTC | #1
On 2024/5/6 22:18, Kemeng Shi wrote:
> We only need to sleep if no running transaction is expired. Simply remove
> unnecessary "should_sleep".
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

It looks much clearer now.

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

> ---
>  fs/jbd2/journal.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index ce9004f40ffb..65c6cfce9d92 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -220,15 +220,12 @@ static int kjournald2(void *arg)
>  		 * so we don't sleep
>  		 */
>  		DEFINE_WAIT(wait);
> -		int should_sleep = 1;
>  
>  		prepare_to_wait(&journal->j_wait_commit, &wait,
>  				TASK_INTERRUPTIBLE);
>  		transaction = journal->j_running_transaction;
> -		if (transaction && time_after_eq(jiffies,
> -						transaction->t_expires))
> -			should_sleep = 0;
> -		if (should_sleep) {
> +		if (transaction == NULL ||
> +		    time_before(jiffies, transaction->t_expires)) {
>  			write_unlock(&journal->j_state_lock);
>  			schedule();
>  			write_lock(&journal->j_state_lock);
>
Jan Kara May 12, 2024, 11:26 a.m. UTC | #2
On Mon 06-05-24 22:18:01, Kemeng Shi wrote:
> We only need to sleep if no running transaction is expired. Simply remove
> unnecessary "should_sleep".
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

Nice! Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/jbd2/journal.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index ce9004f40ffb..65c6cfce9d92 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -220,15 +220,12 @@ static int kjournald2(void *arg)
>  		 * so we don't sleep
>  		 */
>  		DEFINE_WAIT(wait);
> -		int should_sleep = 1;
>  
>  		prepare_to_wait(&journal->j_wait_commit, &wait,
>  				TASK_INTERRUPTIBLE);
>  		transaction = journal->j_running_transaction;
> -		if (transaction && time_after_eq(jiffies,
> -						transaction->t_expires))
> -			should_sleep = 0;
> -		if (should_sleep) {
> +		if (transaction == NULL ||
> +		    time_before(jiffies, transaction->t_expires)) {
>  			write_unlock(&journal->j_state_lock);
>  			schedule();
>  			write_lock(&journal->j_state_lock);
> -- 
> 2.30.0
>
diff mbox series

Patch

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index ce9004f40ffb..65c6cfce9d92 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -220,15 +220,12 @@  static int kjournald2(void *arg)
 		 * so we don't sleep
 		 */
 		DEFINE_WAIT(wait);
-		int should_sleep = 1;
 
 		prepare_to_wait(&journal->j_wait_commit, &wait,
 				TASK_INTERRUPTIBLE);
 		transaction = journal->j_running_transaction;
-		if (transaction && time_after_eq(jiffies,
-						transaction->t_expires))
-			should_sleep = 0;
-		if (should_sleep) {
+		if (transaction == NULL ||
+		    time_before(jiffies, transaction->t_expires)) {
 			write_unlock(&journal->j_state_lock);
 			schedule();
 			write_lock(&journal->j_state_lock);