[PATCH 2/7] jbd2: remove dead check in journal_alloc_journal_head

Kemeng Shi posted 7 patches 1 year, 6 months ago
There is a newer version of this series
[PATCH 2/7] jbd2: remove dead check in journal_alloc_journal_head
Posted by Kemeng Shi 1 year, 6 months ago
We will alloc journal_head with __GFP_NOFAIL anyway, test for failure
is pointless.

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

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index da5a56d700f1..b5d02de1ffff 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2866,8 +2866,7 @@ static struct journal_head *journal_alloc_journal_head(void)
 		ret = kmem_cache_zalloc(jbd2_journal_head_cache,
 				GFP_NOFS | __GFP_NOFAIL);
 	}
-	if (ret)
-		spin_lock_init(&ret->b_state_lock);
+	spin_lock_init(&ret->b_state_lock);
 	return ret;
 }
 
-- 
2.30.0
Re: [PATCH 2/7] jbd2: remove dead check in journal_alloc_journal_head
Posted by Zhang Yi 1 year, 6 months ago
On 2024/7/30 19:33, Kemeng Shi wrote:
> We will alloc journal_head with __GFP_NOFAIL anyway, test for failure
> is pointless.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

A nice cleanup.

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

> ---
>  fs/jbd2/journal.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index da5a56d700f1..b5d02de1ffff 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -2866,8 +2866,7 @@ static struct journal_head *journal_alloc_journal_head(void)
>  		ret = kmem_cache_zalloc(jbd2_journal_head_cache,
>  				GFP_NOFS | __GFP_NOFAIL);
>  	}
> -	if (ret)
> -		spin_lock_init(&ret->b_state_lock);
> +	spin_lock_init(&ret->b_state_lock);
>  	return ret;
>  }
>  
>
Re: [PATCH 2/7] jbd2: remove dead check in journal_alloc_journal_head
Posted by Jan Kara 1 year, 6 months ago
On Tue 30-07-24 19:33:30, Kemeng Shi wrote:
> We will alloc journal_head with __GFP_NOFAIL anyway, test for failure
> is pointless.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

Why not. Feel free to add:

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

								Honza

> ---
>  fs/jbd2/journal.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index da5a56d700f1..b5d02de1ffff 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -2866,8 +2866,7 @@ static struct journal_head *journal_alloc_journal_head(void)
>  		ret = kmem_cache_zalloc(jbd2_journal_head_cache,
>  				GFP_NOFS | __GFP_NOFAIL);
>  	}
> -	if (ret)
> -		spin_lock_init(&ret->b_state_lock);
> +	spin_lock_init(&ret->b_state_lock);
>  	return ret;
>  }
>  
> -- 
> 2.30.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR