Skip to content

fix(mdstat): parse (W), (J) and (R) component device flags#842

Open
sueun-dev wants to merge 1 commit into
prometheus:masterfrom
sueun-dev:fix-mdstat-component-flags
Open

fix(mdstat): parse (W), (J) and (R) component device flags#842
sueun-dev wants to merge 1 commit into
prometheus:masterfrom
sueun-dev:fix-mdstat-component-flags

Conversation

@sueun-dev

Copy link
Copy Markdown

evalComponentDevices fills the WriteMostly/Journal/Replacement fields from match[3], but componentDeviceRE only captures (\([SF]+\))?, so (W), (J) and (R) never match and those fields are always false. Combined flags break too: the kernel prints each flag as its own parenthesis group and (F) can follow (W), so for sde1[4](W)(F) the old group matches nothing and even Faulty is lost.

The kernel emits (W), (J), (F), (S), (R) one group per flag (the md.c lines already linked in evalComponentDevices), so the group now captures a run of them: ((?:\([FJRSW]\))+)?.

Added TestEvalComponentDevicesFlags covering each flag plus the (W)(F) combination — it fails before this change (WriteMostly/Journal/Replacement stay false, and Faulty is false in the combined case) and passes after. This covers the WriteMostly/Journal/Replacement entries of the TODO at the top of mdstat_test.go.

Checked: go test ./..., go vet ./..., gofmt -l (the unrelated TestFileDescriptorsLen fails on this non-Linux machine with and without the change).

componentDeviceRE only captured ([SF]+), so the WriteMostly, Journal
and Replacement fields read from match[3] were always false, and a
flag following another one was dropped entirely - for sde1[4](W)(F)
the group matched nothing, losing Faulty as well. The kernel prints
each flag as its own parenthesis group, so capture a run of them.

Signed-off-by: Sueun Cho <sueun.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant