* [PATCH] md/raid5: correct degraded calculation in raid5_error
@ 2017-11-17 2:57 bingjingc
2017-11-17 18:44 ` Shaohua Li
0 siblings, 1 reply; 2+ messages in thread
From: bingjingc @ 2017-11-17 2:57 UTC (permalink / raw)
To: linux-raid
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>
---
drivers/md/raid5.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 31dc25e..98ce427 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2677,13 +2677,13 @@ static void raid5_error(struct mddev *mddev,
struct md_rdev *rdev)
pr_debug("raid456: error called\n");
spin_lock_irqsave(&conf->device_lock, flags);
+ set_bit(Faulty, &rdev->flags);
clear_bit(In_sync, &rdev->flags);
mddev->degraded = raid5_calc_degraded(conf);
spin_unlock_irqrestore(&conf->device_lock, flags);
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
set_bit(Blocked, &rdev->flags);
- set_bit(Faulty, &rdev->flags);
set_mask_bits(&mddev->sb_flags, 0,
BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
pr_crit("md/raid:%s: Disk failure on %s, disabling device.\n"
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] md/raid5: correct degraded calculation in raid5_error
2017-11-17 2:57 [PATCH] md/raid5: correct degraded calculation in raid5_error bingjingc
@ 2017-11-17 18:44 ` Shaohua Li
0 siblings, 0 replies; 2+ messages in thread
From: Shaohua Li @ 2017-11-17 18:44 UTC (permalink / raw)
To: bingjingc; +Cc: linux-raid
On Fri, Nov 17, 2017 at 10:57:44AM +0800, bingjingc wrote:
> 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>
Applied, thanks!
> ---
> drivers/md/raid5.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 31dc25e..98ce427 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -2677,13 +2677,13 @@ static void raid5_error(struct mddev *mddev, struct
> md_rdev *rdev)
> pr_debug("raid456: error called\n");
>
> spin_lock_irqsave(&conf->device_lock, flags);
> + set_bit(Faulty, &rdev->flags);
> clear_bit(In_sync, &rdev->flags);
> mddev->degraded = raid5_calc_degraded(conf);
> spin_unlock_irqrestore(&conf->device_lock, flags);
> set_bit(MD_RECOVERY_INTR, &mddev->recovery);
>
> set_bit(Blocked, &rdev->flags);
> - set_bit(Faulty, &rdev->flags);
> set_mask_bits(&mddev->sb_flags, 0,
> BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
> pr_crit("md/raid:%s: Disk failure on %s, disabling device.\n"
> --
> 2.7.4
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-17 18:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-17 2:57 [PATCH] md/raid5: correct degraded calculation in raid5_error bingjingc
2017-11-17 18:44 ` Shaohua Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).