diff mbox series

[2/3] md: remove redundant check in fix_read_error()

Message ID 20230623173236.2513554-3-linan666@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series md/raid10: optimize and fix read error | expand

Commit Message

Li Nan June 23, 2023, 5:32 p.m. UTC
From: Li Nan <linan122@huawei.com>

In fix_read_error(), 'success' will be checked immediately after assigning
it, if it is set to 1 then the loop will break. Checking it again in
condition of loop is redundant. Clean it up.

Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/raid1.c  | 2 +-
 drivers/md/raid10.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Yu Kuai June 26, 2023, 2:31 a.m. UTC | #1
在 2023/06/24 1:32, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
> 
> In fix_read_error(), 'success' will be checked immediately after assigning
> it, if it is set to 1 then the loop will break. Checking it again in
> condition of loop is redundant. Clean it up.

LGTM
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
> 
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/md/raid1.c  | 2 +-
>   drivers/md/raid10.c | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> :
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index 3570da63969b..0391c2d0c109 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -2318,7 +2318,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
>   			d++;
>   			if (d == conf->raid_disks * 2)
>   				d = 0;
> -		} while (!success && d != read_disk);
> +		} while (d != read_disk);
>   
>   		if (!success) {
>   			/* Cannot read from anywhere - mark it bad */
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 94ae294c8a3c..a36e53fce21f 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -2790,7 +2790,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
>   			sl++;
>   			if (sl == conf->copies)
>   				sl = 0;
> -		} while (!success && sl != slot);
> +		} while (sl != slot);
>   		rcu_read_unlock();
>   
>   		if (!success) {
>
diff mbox series

Patch

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 3570da63969b..0391c2d0c109 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2318,7 +2318,7 @@  static void fix_read_error(struct r1conf *conf, int read_disk,
 			d++;
 			if (d == conf->raid_disks * 2)
 				d = 0;
-		} while (!success && d != read_disk);
+		} while (d != read_disk);
 
 		if (!success) {
 			/* Cannot read from anywhere - mark it bad */
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 94ae294c8a3c..a36e53fce21f 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2790,7 +2790,7 @@  static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 			sl++;
 			if (sl == conf->copies)
 				sl = 0;
-		} while (!success && sl != slot);
+		} while (sl != slot);
 		rcu_read_unlock();
 
 		if (!success) {