2023-07-06 07:26:27

by Yu Kuai

[permalink] [raw]
Subject: [PATCH -next 2/3] md/dm-raid: cleanup multiple equivalent goto tags from raid_ctr()

From: Yu Kuai <[email protected]>

There are four equivalent goto tags in raid_ctr(), clean them up to use
just one, there are no functional change and prepare to fix that
md_stop() is not protected.

Signed-off-by: Yu Kuai <[email protected]>
---
drivers/md/dm-raid.c | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 4c819d5f93fd..33742f5e7ee5 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -3251,8 +3251,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
r = md_start(&rs->md);
if (r) {
ti->error = "Failed to start raid array";
- mddev_unlock(&rs->md);
- goto bad_md_start;
+ goto bad_unlock;
}

/* If raid4/5/6 journal mode explicitly requested (only possible with journal dev) -> set it */
@@ -3260,8 +3259,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
r = r5c_journal_mode_set(&rs->md, rs->journal_dev.mode);
if (r) {
ti->error = "Failed to set raid4/5/6 journal mode";
- mddev_unlock(&rs->md);
- goto bad_journal_mode_set;
+ goto bad_unlock;
}
}

@@ -3271,19 +3269,15 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
/* Try to adjust the raid4/5/6 stripe cache size to the stripe size */
if (rs_is_raid456(rs)) {
r = rs_set_raid456_stripe_cache(rs);
- if (r) {
- mddev_unlock(&rs->md);
- goto bad_stripe_cache;
- }
+ if (r)
+ goto bad_unlock;
}

/* Now do an early reshape check */
if (test_bit(RT_FLAG_RESHAPE_RS, &rs->runtime_flags)) {
r = rs_check_reshape(rs);
- if (r) {
- mddev_unlock(&rs->md);
- goto bad_check_reshape;
- }
+ if (r)
+ goto bad_unlock;

/* Restore new, ctr requested layout to perform check */
rs_config_restore(rs, &rs_layout);
@@ -3292,8 +3286,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
r = rs->md.pers->check_reshape(&rs->md);
if (r) {
ti->error = "Reshape check failed";
- mddev_unlock(&rs->md);
- goto bad_check_reshape;
+ goto bad_unlock;
}
}
}
@@ -3304,10 +3297,8 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
mddev_unlock(&rs->md);
return 0;

-bad_md_start:
-bad_journal_mode_set:
-bad_stripe_cache:
-bad_check_reshape:
+bad_unlock:
+ mddev_unlock(&rs->md);
md_stop(&rs->md);
bad:
raid_set_free(rs);
--
2.39.2



2023-07-06 13:24:29

by Paul Menzel

[permalink] [raw]
Subject: Re: [PATCH -next 2/3] md/dm-raid: cleanup multiple equivalent goto tags from raid_ctr()

Dear Yu,


Thank you for your patch. Some minor nits, if you are interested.

Am 06.07.23 um 09:16 schrieb Yu Kuai:
> From: Yu Kuai <[email protected]>
>
> There are four equivalent goto tags in raid_ctr(), clean them up to use
> just one, there are no functional change and prepare to fix that

Maybe:

There *is* no functional change, and is a preparation to fix an
unprotected `md_stop()`.

> md_stop() is not protected.

In the commit message summary/title, I’d spell the verb with a space:

Clean up four equivalent goto tags in raid_ctr()

> Signed-off-by: Yu Kuai <[email protected]>
> ---
> drivers/md/dm-raid.c | 27 +++++++++------------------
> 1 file changed, 9 insertions(+), 18 deletions(-)

[…]


Kind regards,

Paul

2023-07-07 01:58:49

by Yu Kuai

[permalink] [raw]
Subject: Re: [PATCH -next 2/3] md/dm-raid: cleanup multiple equivalent goto tags from raid_ctr()

Hi,

在 2023/07/06 21:01, Paul Menzel 写道:
> Dear Yu,
>
>
> Thank you for your patch. Some minor nits, if you are interested.
>
> Am 06.07.23 um 09:16 schrieb Yu Kuai:
>> From: Yu Kuai <[email protected]>
>>
>> There are four equivalent goto tags in raid_ctr(), clean them up to use
>> just one, there are no functional change and prepare to fix that
>
> Maybe:
>
> There *is* no functional change, and is a preparation to fix an
> unprotected `md_stop()`.
>
>> md_stop() is not protected.
>
> In the commit message summary/title, I’d spell the verb with a space:
>
>     Clean up four equivalent goto tags in raid_ctr()
>

Thanks for the suggestions, I'll update them in the next version.

Thanks,
Kuai
>> Signed-off-by: Yu Kuai <[email protected]>
>> ---
>>   drivers/md/dm-raid.c | 27 +++++++++------------------
>>   1 file changed, 9 insertions(+), 18 deletions(-)
>
> […]
>
>
> Kind regards,
>
> Paul
>
> .
>