md/raid5: correct degraded calculation in raid5_error
authorbingjingc <bingjingc@synology.com>
Fri, 17 Nov 2017 02:57:44 +0000 (10:57 +0800)
committerShaohua Li <shli@fb.com>
Fri, 1 Dec 2017 19:27:32 +0000 (11:27 -0800)
commitaff69d89bdebc39235cddb4445371eb979b49685
tree9cf208c4b30fb844b3fe8a1c1f1dd2121976d53a
parenta0651c7fa2c088a605f63792279859608ed7f2c8
md/raid5: correct degraded calculation in raid5_error

When disk failure occurs on new disks for reshape, mddev->degraded
is not calculated correctly. Faulty bit of the failure device is not
set before raid5_calc_degraded(conf).

mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/loop[012]
mdadm /dev/md0 -a /dev/loop3
mdadm /dev/md0 --grow -n4
mdadm /dev/md0 -f /dev/loop3 # simulating disk failure

cat /sys/block/md0/md/degraded # it outputs 0, but it should be 1.

However, mdadm -D /dev/md0 will show that it is degraded. It's a bug.
It can be fixed by moving the resources raid5_calc_degraded() depends
on before it.

Reported-by: Roy Chung <roychung@synology.com>
Reviewed-by: Alex Wu <alexwu@synology.com>
Signed-off-by: BingJing Chang <bingjingc@synology.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid5.c