fix(mdstat): parse (W), (J) and (R) component device flags#842
Open
sueun-dev wants to merge 1 commit into
Open
fix(mdstat): parse (W), (J) and (R) component device flags#842sueun-dev wants to merge 1 commit into
sueun-dev wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
evalComponentDevicesfills the WriteMostly/Journal/Replacement fields frommatch[3], butcomponentDeviceREonly 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 forsde1[4](W)(F)the old group matches nothing and evenFaultyis lost.The kernel emits
(W),(J),(F),(S),(R)one group per flag (the md.c lines already linked inevalComponentDevices), so the group now captures a run of them:((?:\([FJRSW]\))+)?.Added
TestEvalComponentDevicesFlagscovering each flag plus the(W)(F)combination — it fails before this change (WriteMostly/Journal/Replacementstay false, andFaultyis false in the combined case) and passes after. This covers the WriteMostly/Journal/Replacement entries of the TODO at the top ofmdstat_test.go.Checked:
go test ./...,go vet ./...,gofmt -l(the unrelatedTestFileDescriptorsLenfails on this non-Linux machine with and without the change).