2022-04-21 16:25:34

by Logan Gunthorpe

[permalink] [raw]
Subject: [PATCH v2 08/12] md/raid5: Refactor for loop in raid5_make_request() into while loop

The for loop with retry label can be more cleanly expressed as a while
loop by moving the logical_sector increment into the success path.

No functional changes intended.

Signed-off-by: Logan Gunthorpe <[email protected]>
---
drivers/md/raid5.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 1bce9075e165..0c250cc3bfff 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5971,20 +5971,21 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
}
md_account_bio(mddev, &bi);
prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
- for (; logical_sector < last_sector; logical_sector += RAID5_STRIPE_SECTORS(conf)) {
- retry:
+ while (logical_sector < last_sector) {
res = make_stripe_request(mddev, conf, &ctx, logical_sector,
bi);
if (res == STRIPE_FAIL) {
break;
} else if (res == STRIPE_RETRY) {
- goto retry;
+ continue;
} else if (res == STRIPE_SCHEDULE_AND_RETRY) {
schedule();
prepare_to_wait(&conf->wait_for_overlap, &w,
TASK_UNINTERRUPTIBLE);
- goto retry;
+ continue;
}
+
+ logical_sector += RAID5_STRIPE_SECTORS(conf);
}

finish_wait(&conf->wait_for_overlap, &w);
--
2.30.2


2022-04-22 20:40:09

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 08/12] md/raid5: Refactor for loop in raid5_make_request() into while loop

On Wed, Apr 20, 2022 at 01:54:21PM -0600, Logan Gunthorpe wrote:
> prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
> - for (; logical_sector < last_sector; logical_sector += RAID5_STRIPE_SECTORS(conf)) {
> - retry:
> + while (logical_sector < last_sector) {
> res = make_stripe_request(mddev, conf, &ctx, logical_sector,
> bi);
> if (res == STRIPE_FAIL) {
> break;
> } else if (res == STRIPE_RETRY) {
> - goto retry;
> + continue;
> } else if (res == STRIPE_SCHEDULE_AND_RETRY) {
> schedule();
> prepare_to_wait(&conf->wait_for_overlap, &w,
> TASK_UNINTERRUPTIBLE);
> - goto retry;
> + continue;
> }

All the else statements here aren't needed (this is really a
comment for the earlier patch adding them).

Otherwise looks good:

Reviewed-by: Christoph Hellwig <[email protected]>