diff mbox series

[1/2] md/raid10: a simple cleanup for fix_recovery_read_error

Message ID 20230627034127.4000994-2-linan666@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series md/raid10: handle replacement if recovery read error | expand

Commit Message

Li Nan June 27, 2023, 3:41 a.m. UTC
From: Li Nan <linan122@huawei.com>

There is no need to use a new variable 'rdev2' for write device since
'rdev' is not used again later. Use 'rdev' directly. Assigning return
value to 'ok' is also unnecessary. Clean it up.

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

Comments

Song Liu July 7, 2023, 8:27 a.m. UTC | #1
On Tue, Jun 27, 2023 at 11:42 AM <linan666@huaweicloud.com> wrote:
>
> From: Li Nan <linan122@huawei.com>
>
> There is no need to use a new variable 'rdev2' for write device since
> 'rdev' is not used again later. Use 'rdev' directly. Assigning return
> value to 'ok' is also unnecessary. Clean it up.

I actually think rdev2 here makes the code easier to read. And the
'ok' variable doesn't hurt the code readability either.

Thanks,
Song

>
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>  drivers/md/raid10.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 4fcfcb350d2b..5105273f60e9 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -2590,10 +2590,9 @@ static void fix_recovery_read_error(struct r10bio *r10_bio)
>
>                         if (rdev != conf->mirrors[dw].rdev) {
>                                 /* need bad block on destination too */
> -                               struct md_rdev *rdev2 = conf->mirrors[dw].rdev;
> +                               rdev = conf->mirrors[dw].rdev;
>                                 addr = r10_bio->devs[1].addr + sect;
> -                               ok = rdev_set_badblocks(rdev2, addr, s, 0);
> -                               if (!ok) {
> +                               if (!rdev_set_badblocks(rdev, addr, s, 0)) {
>                                         /* just abort the recovery */
>                                         pr_notice("md/raid10:%s: recovery aborted due to read error\n",
>                                                   mdname(mddev));
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 4fcfcb350d2b..5105273f60e9 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2590,10 +2590,9 @@  static void fix_recovery_read_error(struct r10bio *r10_bio)
 
 			if (rdev != conf->mirrors[dw].rdev) {
 				/* need bad block on destination too */
-				struct md_rdev *rdev2 = conf->mirrors[dw].rdev;
+				rdev = conf->mirrors[dw].rdev;
 				addr = r10_bio->devs[1].addr + sect;
-				ok = rdev_set_badblocks(rdev2, addr, s, 0);
-				if (!ok) {
+				if (!rdev_set_badblocks(rdev, addr, s, 0)) {
 					/* just abort the recovery */
 					pr_notice("md/raid10:%s: recovery aborted due to read error\n",
 						  mdname(mddev));