Skip to contentSkip to conversation

md/raid5: Fix bio retry on interrupted reshape

PATCH In review Nigel Croxon 2 participants 3 messages Apr 29 – Apr 30 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md/raid5: Fix bio retry on interrupted reshape

When a bio encounters LOC_INSIDE_RESHAPE during a reshape that is interrupted (stopped or unable to progress), the code sets bi->bi_status = BLK_STS_RESOURCE to signal the block layer for retry. However, bio_endio() is never called, so the block layer never receives the completion notification and the retry never happens.

This causes I/O to hang when a filesystem is layered over RAID5 and reshape gets stuck.

Fix this by calling bio_endio(bi) before md_free_cloned_bio(bi) so the block layer is properly notified of the BLK_STS_RESOURCE status and can retry the request.

Tested stripes and stripe size conversions under load comparing files multiple times during each conversion (i.e. MD reshape) on ext4 after dropping caches degrading the RaidLV each time and no data corruption.

---
 drivers/md/raid5.c | 1 +

 1 file changed, 1 insertion(+)
drivers/md/raid5.c +0 -0
index 6e79829c5acb..9a3475429ef4 100644
@@ -6217,6 +6217,7 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
 

     mempool_free(ctx, conf->ctx_pool);
     if (res == STRIPE_WAIT_RESHAPE) {
+        bio_endio(bi);
         md_free_cloned_bio(bi);
         return false;
     }

Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw

Dear Nigel,

Thank you for your patch.

Am 29.04.26 um 13:10 schrieb Nigel Croxon:

Quoted 9 lines

When a bio encounters LOC_INSIDE_RESHAPE during a reshape that is interrupted (stopped or unable to progress), the code sets bi->bi_status = BLK_STS_RESOURCE to signal the block layer for retry. However, bio_endio() is never called, so the block layer never receives the completion notification and the retry never happens.

This causes I/O to hang when a filesystem is layered over RAID5 and reshape gets stuck.

Quoted 7 lines

Fix this by calling bio_endio(bi) before md_free_cloned_bio(bi) so the block layer is properly notified of the BLK_STS_RESOURCE status and can retry the request.

Tested stripes and stripe size conversions under load comparing files multiple times during each conversion (i.e. MD reshape) on ext4 after dropping caches degrading the RaidLV each time and

I thought RaidLV misspelled Raid V (Raid 5), so should you resend, maybe write it as RAID LV.

Quoted 3 lines

no data corruption.

Which paragraph/comment exactly?

Quoted 17 lines
---
  drivers/md/raid5.c | 1 +
  1 file changed, 1 insertion(+)
drivers/md/raid5.c +1 -0
index 6e79829c5acb..9a3475429ef4 100644
@@ -6217,6 +6217,7 @@ static bool raid5_make_request(struct mddev 
 *mddev, struct bio * bi)
 
      mempool_free(ctx, conf->ctx_pool);
      if (res == STRIPE_WAIT_RESHAPE) {
+         bio_endio(bi);
          md_free_cloned_bio(bi);
          return false;
Quoted 1 line

     }

Kind regards,

Paul

#2 lore raw

Looks like this was just fixed by Benjamin Marzinski's

commit 418b3e64e4459 md/raid5: Fix UAF on IO across the reshape position

So my patch is not needed anymore.

-Nigel

Quoted 57 lines · Paul Menzel

Dear Nigel,

Thank you for your patch.

Am 29.04.26 um 13:10 schrieb Nigel Croxon:

Quoted 9 lines

When a bio encounters LOC_INSIDE_RESHAPE during a reshape that is interrupted (stopped or unable to progress), the code sets bi->bi_status = BLK_STS_RESOURCE to signal the block layer for retry. However, bio_endio() is never called, so the block layer never receives the completion notification and the retry never happens.

This causes I/O to hang when a filesystem is layered over RAID5 and reshape gets stuck.

Quoted 7 lines

Fix this by calling bio_endio(bi) before md_free_cloned_bio(bi) so the block layer is properly notified of the BLK_STS_RESOURCE status and can retry the request.

Tested stripes and stripe size conversions under load comparing files multiple times during each conversion (i.e. MD reshape) on ext4 after dropping caches degrading the RaidLV each time and

I thought RaidLV misspelled Raid V (Raid 5), so should you resend, maybe write it as RAID LV.

Quoted 3 lines

no data corruption.

Which paragraph/comment exactly?

Quoted 17 lines

---
  drivers/md/raid5.c | 1 +

  1 file changed, 1 insertion(+)
drivers/md/raid5.c +1 -0
index 6e79829c5acb..9a3475429ef4 100644
@@ -6217,6 +6217,7 @@ static bool raid5_make_request(struct mddev 
 *mddev, struct bio * bi)
 
       mempool_free(ctx, conf->ctx_pool);
       if (res == STRIPE_WAIT_RESHAPE) {
+         bio_endio(bi);
           md_free_cloned_bio(bi);
           return false;
Quoted 1 line

      }

Kind regards,

Paul