Skip to content

Commit 6995f0b

Browse files
committed
md: takeover should clear unrelated bits
When we change level from raid1 to raid5, the MD_FAILFAST_SUPPORTED bit will be accidentally set, but raid5 doesn't support it. The same is true for the MD_HAS_JOURNAL bit. Fix: 46533ff (md: Use REQ_FAILFAST_* on metadata writes where appropriate) Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent 3c6edc6 commit 6995f0b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

drivers/md/raid0.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,11 @@ static void *raid0_takeover_raid45(struct mddev *mddev)
539539
mddev->delta_disks = -1;
540540
/* make sure it will be not marked as dirty */
541541
mddev->recovery_cp = MaxSector;
542+
clear_bit(MD_HAS_JOURNAL, &mddev->flags);
543+
clear_bit(MD_JOURNAL_CLEAN, &mddev->flags);
542544

543545
create_strip_zones(mddev, &priv_conf);
546+
544547
return priv_conf;
545548
}
546549

@@ -580,6 +583,7 @@ static void *raid0_takeover_raid10(struct mddev *mddev)
580583
mddev->degraded = 0;
581584
/* make sure it will be not marked as dirty */
582585
mddev->recovery_cp = MaxSector;
586+
clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags);
583587

584588
create_strip_zones(mddev, &priv_conf);
585589
return priv_conf;
@@ -622,6 +626,7 @@ static void *raid0_takeover_raid1(struct mddev *mddev)
622626
mddev->raid_disks = 1;
623627
/* make sure it will be not marked as dirty */
624628
mddev->recovery_cp = MaxSector;
629+
clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags);
625630

626631
create_strip_zones(mddev, &priv_conf);
627632
return priv_conf;

drivers/md/raid1.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3243,9 +3243,12 @@ static void *raid1_takeover(struct mddev *mddev)
32433243
mddev->new_layout = 0;
32443244
mddev->new_chunk_sectors = 0;
32453245
conf = setup_conf(mddev);
3246-
if (!IS_ERR(conf))
3246+
if (!IS_ERR(conf)) {
32473247
/* Array must appear to be quiesced */
32483248
conf->array_frozen = 1;
3249+
clear_bit(MD_HAS_JOURNAL, &mddev->flags);
3250+
clear_bit(MD_JOURNAL_CLEAN, &mddev->flags);
3251+
}
32493252
return conf;
32503253
}
32513254
return ERR_PTR(-EINVAL);

drivers/md/raid5.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7811,6 +7811,7 @@ static void *raid45_takeover_raid0(struct mddev *mddev, int level)
78117811
static void *raid5_takeover_raid1(struct mddev *mddev)
78127812
{
78137813
int chunksect;
7814+
void *ret;
78147815

78157816
if (mddev->raid_disks != 2 ||
78167817
mddev->degraded > 1)
@@ -7832,7 +7833,10 @@ static void *raid5_takeover_raid1(struct mddev *mddev)
78327833
mddev->new_layout = ALGORITHM_LEFT_SYMMETRIC;
78337834
mddev->new_chunk_sectors = chunksect;
78347835

7835-
return setup_conf(mddev);
7836+
ret = setup_conf(mddev);
7837+
if (!IS_ERR_VALUE(ret))
7838+
clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags);
7839+
return ret;
78367840
}
78377841

78387842
static void *raid5_takeover_raid6(struct mddev *mddev)

0 commit comments

Comments
 (0)