Re: [PATCH v3] mdadm/Detail: show correct state for cluster-md array
From: Jes Sorensen <hidden>
Date: 2020-08-07 13:39:44
On 7/28/20 11:48 PM, Zhao Heming wrote:
quoted hunk ↗ jump to hunk
After kernel md module commit 480523feae581, in md-cluster env, mddev->in_sync always zero, it will make array.state never set up MD_SB_CLEAN. it causes "mdadm -D /dev/mdX" show state 'active' all the time. bitmap.c: add a new API IsBitmapDirty() to support inquiry bitmap dirty or clean. Signed-off-by: Zhao Heming <redacted> --- v3: - Detail.c: fix error logic: v2 code didn't check bitmap when dv is null. v2: - Detail.c: change to read only one device. - bitmap.c: modify IsBitmapDirty() to check all bitmap on the selected device. --- Detail.c | 20 +++++++++++++++++++- bitmap.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ mdadm.h | 1 + 3 files changed, 75 insertions(+), 1 deletion(-)diff --git a/Detail.c b/Detail.c index 24eeba0..a69e5ac 100644 --- a/Detail.c +++ b/Detail.c@@ -495,8 +495,26 @@ int Detail(char *dev, struct context *c) sra->array_state); else arrayst = "clean"; - } else + } else { arrayst = "active"; + if (array.state & (1<<MD_SB_CLUSTERED)) { + for (d = 0; d < max_disks * 2; d++) { + char *dv; + mdu_disk_info_t disk = disks[d]; + + if (d >= array.raid_disks * 2 && + disk.major == 0 && disk.minor == 0) + continue; + if ((d & 1) && disk.major == 0 && disk.minor == 0) + continue; + dv = map_dev_preferred(disk.major, disk.minor, 0, + c->prefer); + if (!dv) continue;
Minor nit here, never ever put if() < bleh on the same line. Thanks, Jes