diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-12 02:44:35 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-12 02:44:35 -0700 |
commit | 128e4d9aa876e14a1203ce98bfaa7ad399ad97c7 (patch) | |
tree | 039c3c549414c21b15d58c3d695ee87c3feb1402 /lib/btrfs/btrfsvol/devext.go | |
parent | 53d7fbb73869eb5defa1ca5c52b26abd346b13b9 (diff) | |
parent | 696a7d192e5eefa53230168a4b200ec0560c8a10 (diff) |
Merge branch 'lukeshu/containers'
Diffstat (limited to 'lib/btrfs/btrfsvol/devext.go')
-rw-r--r-- | lib/btrfs/btrfsvol/devext.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/btrfs/btrfsvol/devext.go b/lib/btrfs/btrfsvol/devext.go index e8e5446..3324476 100644 --- a/lib/btrfs/btrfsvol/devext.go +++ b/lib/btrfs/btrfsvol/devext.go @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com> // // SPDX-License-Identifier: GPL-2.0-or-later @@ -20,10 +20,15 @@ type devextMapping struct { Flags containers.Optional[BlockGroupFlags] } +// Compare implements containers.Ordered. +func (a devextMapping) Compare(b devextMapping) int { + return containers.NativeCompare(a.PAddr, b.PAddr) +} + // return -1 if 'a' is wholly to the left of 'b' // return 0 if there is some overlap between 'a' and 'b' // return 1 if 'a is wholly to the right of 'b' -func (a devextMapping) cmpRange(b devextMapping) int { +func (a devextMapping) compareRange(b devextMapping) int { switch { case a.PAddr.Add(a.Size) <= b.PAddr: // 'a' is wholly to the left of 'b'. @@ -40,7 +45,7 @@ func (a devextMapping) cmpRange(b devextMapping) int { func (a devextMapping) union(rest ...devextMapping) (devextMapping, error) { // sanity check for _, ext := range rest { - if a.cmpRange(ext) != 0 { + if a.compareRange(ext) != 0 { return devextMapping{}, fmt.Errorf("devexts don't overlap") } } |