diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-10-17 00:31:38 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-12-20 20:02:11 -0700 |
commit | 6c03becc595c9938644e767c852a2627d4a265d3 (patch) | |
tree | f5003fe1b9b22f7c97b98fa9b888606869bc2031 /lib/btrfsprogs/btrfsinspect/rebuildnodes/util.go | |
parent | 580189ee3e43d5595a8700ee21b8900b0dd5389d (diff) |
rebuildnodes: wip: New rebuild-nodes implementation
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/util.go')
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildnodes/util.go | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/util.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/util.go index f1033e6..bdaa0c4 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/util.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/util.go @@ -7,6 +7,8 @@ package rebuildnodes import ( "fmt" + "golang.org/x/exp/constraints" + "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect" ) @@ -18,26 +20,6 @@ func maybeSet[K, V comparable](name string, m map[K]V, k K, v V) error { return nil } -/* -var maxKey = btrfsprim.Key{ - ObjectID: math.MaxUint64, - ItemType: math.MaxUint8, - Offset: math.MaxUint64, -} - -func keyMm(key btrfsprim.Key) btrfsprim.Key { - switch { - case key.Offset > 0: - key.Offset-- - case key.ItemType > 0: - key.ItemType-- - case key.ObjectID > 0: - key.ObjectID-- - } - return key -} -*/ - func countNodes(nodeScanResults btrfsinspect.ScanDevicesResult) int { var cnt int for _, devResults := range nodeScanResults { @@ -45,3 +27,11 @@ func countNodes(nodeScanResults btrfsinspect.ScanDevicesResult) int { } return cnt } + +func roundDown[T constraints.Integer](n, d T) T { + return (n / d) * d +} + +func roundUp[T constraints.Integer](n, d T) T { + return ((n + d - 1) / d) * d +} |