-
Notifications
You must be signed in to change notification settings - Fork 349
DAOS-19207 control: check redundancy factor early #18522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3dd9d25
0ede7a6
6edfafd
ff85801
0dc5c08
1ec4d05
3a2d4f2
6611003
bbe5169
a193121
9827187
d9e5b70
d01d07d
1f528f3
3baa4de
eb2637f
b401b8b
d423047
8a92998
b4ef189
a65865d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -785,6 +785,60 @@ func (m *Membership) CompressedFaultDomainTree(ranks ...uint32) ([]uint32, error | |||||||||||||
| return append([]uint32{md}, compressTree(subtree)...), nil | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // FaultDomainLevel returns the fault domain level of the domain tree. | ||||||||||||||
| // It assumes the tree is balanced and that the rank level is present. | ||||||||||||||
| // So, the fault domain level is the second to last level of the tree. | ||||||||||||||
| func (m *Membership) FaultDomainLevel() (int, error) { | ||||||||||||||
| tree := m.db.FaultDomainTree() | ||||||||||||||
| if tree == nil { | ||||||||||||||
| return 0, errors.New("uninitialized fault domain tree") | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| depth := tree.Depth() | ||||||||||||||
| // The depth includes the rank level but it does NOT include the root level. | ||||||||||||||
| // So, the tree needs to have more than one level to have a fault domain level. | ||||||||||||||
| if depth <= 1 { | ||||||||||||||
| return 0, errors.New("domain tree has no fault domain level") | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return depth - 1, nil | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // domainNrAtLevel returns the number of domains in the tree at the given level. | ||||||||||||||
| // It traverses the tree recursively to reach the specified level. | ||||||||||||||
| func domainNrAtLevel(tree *FaultDomainTree, level int) int { | ||||||||||||||
| if level == 0 { | ||||||||||||||
| return 1 | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+810
to
+812
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can a tree be unbalanced?
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it cannot. Regarding your suggestion, please note this is exactly what is the for-loop below for.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I know, but it is not needed to call each tree leaf only to confirm that it is a leaf and return 1. |
||||||||||||||
|
|
||||||||||||||
| count := 0 | ||||||||||||||
| for _, child := range tree.Children { | ||||||||||||||
| count += domainNrAtLevel(child, level-1) | ||||||||||||||
| } | ||||||||||||||
| return count | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // DomainNr returns the number of domains in the subtree of the domain tree | ||||||||||||||
| // specified by the given ranks at the given level. | ||||||||||||||
| // If no ranks are provided, the entire tree is considered. | ||||||||||||||
| func (m *Membership) DomainNr(level int, ranks ...uint32) (int, error) { | ||||||||||||||
|
grom72 marked this conversation as resolved.
|
||||||||||||||
| tree := m.db.FaultDomainTree() | ||||||||||||||
| if tree == nil { | ||||||||||||||
| return 0, errors.New("uninitialized fault domain tree") | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| subtree, err := getFaultDomainSubtree(tree, ranks...) | ||||||||||||||
| if err != nil { | ||||||||||||||
| return 0, err | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if level >= subtree.Depth() { | ||||||||||||||
| return 0, errors.Errorf("level %d >= subtree depth %d", level, subtree.Depth()) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return domainNrAtLevel(subtree, level), nil | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| const ( | ||||||||||||||
| DomTreeMetadataHasFaultDom uint32 = (1 << iota) | ||||||||||||||
| DomTreeMetadataHasPerfDom | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.