On 2019/9/2 15:16, Yufen Yu wrote:
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 24638ccedce4..350e1f152e97 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1092,7 +1092,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
{
char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
mdp_super_t *sb;
- int ret;
+ int ret = 0;
/*
* Calculate the position of the superblock (512byte sectors),
@@ -1160,10 +1160,13 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
}
ev1 = md_event(sb);
ev2 = md_event(refsb);
- if (ev1 > ev2)
- ret = 1;
- else
- ret = 0;
+
+ /* Insist on good event counter while assembling, except
+ * for spares (which don't need an event count) */
+ if (sb->disks[rdev->desc_nr].state & (
+ (1<<MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE)))
+ if (ev1 > ev2)
+ ret = 1;
}
rdev->sectors = rdev->sb_start;
super_90_load will set 'ret = -EINVAL' before checking event count, as
follow:
ret = read_disk_sb(rdev, MD_SB_BYTES);
if (ret)
return ret;
ret = -EINVAL;
So, we cannot write 'if' statement like that, which will lead to
super_90_load
return '-EINVAL' for spare disks. Then, test cases in mdadm , such as
00linear, 00raid0,
will report failed.
I will resend the fixed version.
Thanks,
Yufen