mdadm: fix bitmap check#255
Open
bkucman wants to merge 1 commit into
Open
Conversation
Commit e97c4e1 ("mdadm: ask user if bitmap is not set") adds a prompt to the user regarding bitmap enabling during creation. However, the case of creating a container, where the bitmap is not meaningful, was omitted. This may mislead the user, as attempting to enable bitmap ends with a container creation error: "mdadm: bitmaps not meaningful with level container" At the stage where this check is performed, the level holds the UnSet value, LEVEL_CONTAINER is set at a later stage in Create. The fix adds a check if the level is UnSet and set bitmap to BitmapNone, because this is the only acceptable value for the container. This check also covers the case when the level is not given during volume creation, as it makes no sense to ask for a bitmap without knowledge about level. Signed-off-by: Blazej Kucman <blazej.kucman@graidtech.com>
mwilck
approved these changes
Mar 11, 2026
| if (s.level == UnSet) | ||
| s.btype = BitmapNone; | ||
| else if (c.runstop != 1 && s.level >= 1 && | ||
| ask("To optimize recovery speed, it is recommended to enable write-intent bitmap, do you want to enable it now?")) |
Collaborator
Author
Member
case O(BUILD,'l'): /* set raid level*/
if (s.level != UnSet) {
pr_err("raid level may only be set once. Second value is %s.\n", optarg);
exit(2);
}
s.level = map_name(pers, optarg);
if (s.level == UnSet) {
pr_err("invalid raid level: %s\n",
optarg);
exit(2);Could you please share the scenario it was discovered? is it regular: If you will add --level=container to the command what will happen? Did you considered something like: Just asking, I don't remember exactly the flows. Anyway, I think that discovering container is right way to fix this rather than workarounding the cmdline. |
Merged
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.

Commit e97c4e1 ("mdadm: ask user if bitmap is not set") adds a prompt to the user regarding bitmap enabling during creation. However, the case of creating a container, where the bitmap is not meaningful, was omitted.
This may mislead the user, as attempting to enable bitmap ends with a container creation error: "mdadm: bitmaps not meaningful with level container"
At the stage where this check is performed, the level holds the UnSet value, LEVEL_CONTAINER is set at a later stage in Create.
The fix adds a check if the level is UnSet and set bitmap to BitmapNone, because this is the only acceptable value for the container. This check also covers the case when the level is not given during volume creation, as it makes no sense to ask for a bitmap without knowledge about level.