2023-06-27 04:15:16

by Li Nan

[permalink] [raw]
Subject: [PATCH 1/2] md/raid10: a simple cleanup for fix_recovery_read_error

From: Li Nan <[email protected]>

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 <[email protected]>
---
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



2023-07-07 08:35:47

by Song Liu

[permalink] [raw]
Subject: Re: [PATCH 1/2] md/raid10: a simple cleanup for fix_recovery_read_error

On Tue, Jun 27, 2023 at 11:42 AM <[email protected]> wrote:
>
> From: Li Nan <[email protected]>
>
> 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 <[email protected]>
> ---
> 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
>