Skip to content

Commit 1d24d4c

Browse files
bmarzinsYu Kuai
authored andcommitted
dm-raid: only requeue bios when dm is suspending
Returning DM_MAPIO_REQUEUE from the target map() function only requeues the bio during noflush suspends. During regular operations or during flushing suspends, it fails the bio. Failing the bio during flushing suspends is the correct behavior here. The bio cannot be handled, and dm-raid cannot suspend while it is outstanding. But during normal operations, dm-raid should not push the bio back to dm. Instead, wait for the reshape to be resumed. Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Reviewed-by: Xiao Ni <xiao@kernel.org> Link: https://patch.msgid.link/20260428232010.2785514-1-bmarzins@redhat.com Signed-off-by: Yu Kuai <yukuai@fygo.io>
1 parent e99e15f commit 1d24d4c

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

drivers/md/dm-raid.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,6 +3831,7 @@ static void raid_presuspend(struct dm_target *ti)
38313831
* resume, raid_postsuspend() is too late.
38323832
*/
38333833
set_bit(RT_FLAG_RS_FROZEN, &rs->runtime_flags);
3834+
set_bit(MD_DM_SUSPENDING, &mddev->flags);
38343835

38353836
if (!reshape_interrupted(mddev))
38363837
return;
@@ -3847,13 +3848,16 @@ static void raid_presuspend(struct dm_target *ti)
38473848
static void raid_presuspend_undo(struct dm_target *ti)
38483849
{
38493850
struct raid_set *rs = ti->private;
3851+
struct mddev *mddev = &rs->md;
38503852

3853+
clear_bit(MD_DM_SUSPENDING, &mddev->flags);
38513854
clear_bit(RT_FLAG_RS_FROZEN, &rs->runtime_flags);
38523855
}
38533856

38543857
static void raid_postsuspend(struct dm_target *ti)
38553858
{
38563859
struct raid_set *rs = ti->private;
3860+
struct mddev *mddev = &rs->md;
38573861

38583862
if (!test_and_set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags)) {
38593863
/*
@@ -3864,6 +3868,8 @@ static void raid_postsuspend(struct dm_target *ti)
38643868
mddev_suspend(&rs->md, false);
38653869
rs->md.ro = MD_RDONLY;
38663870
}
3871+
clear_bit(MD_DM_SUSPENDING, &mddev->flags);
3872+
38673873
}
38683874

38693875
static void attempt_restore_of_faulty_devices(struct raid_set *rs)

drivers/md/md.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ struct md_cluster_operations;
346346
* @MD_HAS_SUPERBLOCK: There is persistence sb in member disks.
347347
* @MD_FAILLAST_DEV: Allow last rdev to be removed.
348348
* @MD_SERIALIZE_POLICY: Enforce write IO is not reordered, just used by raid1.
349+
* @MD_DM_SUSPENDING: This DM raid device is suspending.
349350
*
350351
* change UNSUPPORTED_MDDEV_FLAGS for each array type if new flag is added
351352
*/
@@ -365,6 +366,7 @@ enum mddev_flags {
365366
MD_HAS_SUPERBLOCK,
366367
MD_FAILLAST_DEV,
367368
MD_SERIALIZE_POLICY,
369+
MD_DM_SUSPENDING,
368370
};
369371

370372
enum mddev_sb_flags {

drivers/md/raid5.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6042,8 +6042,11 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
60426042
raid5_release_stripe(sh);
60436043
out:
60446044
if (ret == STRIPE_SCHEDULE_AND_RETRY && reshape_interrupted(mddev)) {
6045-
bi->bi_status = BLK_STS_RESOURCE;
6046-
ret = STRIPE_WAIT_RESHAPE;
6045+
if (!mddev_is_dm(mddev) ||
6046+
test_bit(MD_DM_SUSPENDING, &mddev->flags)) {
6047+
bi->bi_status = BLK_STS_RESOURCE;
6048+
ret = STRIPE_WAIT_RESHAPE;
6049+
}
60476050
pr_err_ratelimited("dm-raid456: io across reshape position while reshape can't make progress");
60486051
}
60496052
return ret;

0 commit comments

Comments
 (0)