[PATCH] md/raid1: remove unnecessary null checking

Gou Hao posted 1 patch 2 years, 1 month ago
drivers/md/raid1.c | 2 --
1 file changed, 2 deletions(-)
[PATCH] md/raid1: remove unnecessary null checking
Posted by Gou Hao 2 years, 1 month ago
If %__GFP_DIRECT_RECLAIM is set then bio_alloc_bioset will always
be able to allocate a bio. See comment of bio_alloc_bioset.

Signed-off-by: Gou Hao <gouhao@uniontech.com>
---
 drivers/md/raid1.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 35d12948e0a9..e77dc95d4a75 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1126,8 +1126,6 @@ static void alloc_behind_master_bio(struct r1bio *r1_bio,
 
 	behind_bio = bio_alloc_bioset(NULL, vcnt, 0, GFP_NOIO,
 				      &r1_bio->mddev->bio_set);
-	if (!behind_bio)
-		return;
 
 	/* discard op, we don't support writezero/writesame yet */
 	if (!bio_has_data(bio)) {
-- 
2.34.1
Re: [PATCH] md/raid1: remove unnecessary null checking
Posted by Song Liu 2 years, 1 month ago
On Thu, Dec 14, 2023 at 7:15 AM Gou Hao <gouhao@uniontech.com> wrote:
>
> If %__GFP_DIRECT_RECLAIM is set then bio_alloc_bioset will always
> be able to allocate a bio. See comment of bio_alloc_bioset.
>
> Signed-off-by: Gou Hao <gouhao@uniontech.com>

Applied to md-next. Thanks!

Song

> ---
>  drivers/md/raid1.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index 35d12948e0a9..e77dc95d4a75 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -1126,8 +1126,6 @@ static void alloc_behind_master_bio(struct r1bio *r1_bio,
>
>         behind_bio = bio_alloc_bioset(NULL, vcnt, 0, GFP_NOIO,
>                                       &r1_bio->mddev->bio_set);
> -       if (!behind_bio)
> -               return;
>
>         /* discard op, we don't support writezero/writesame yet */
>         if (!bio_has_data(bio)) {
> --
> 2.34.1
>
>