summaryrefslogtreecommitdiff
path: root/lib/btrfs/btrfsprim
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-10-06 01:26:27 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-10-06 09:11:18 -0600
commitfc06704c55e82818b652210dde3b7b6902fac10a (patch)
tree1a9d65d95d78e797a1ffbbb43522208fed1c7538 /lib/btrfs/btrfsprim
parentf0a73ec8d2742da62c09c824cf4b001f05e4a717 (diff)
let skinny paths get evicted
Diffstat (limited to 'lib/btrfs/btrfsprim')
-rw-r--r--lib/btrfs/btrfsprim/misc.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/btrfs/btrfsprim/misc.go b/lib/btrfs/btrfsprim/misc.go
index 0ebbe19..9b3a6f8 100644
--- a/lib/btrfs/btrfsprim/misc.go
+++ b/lib/btrfs/btrfsprim/misc.go
@@ -6,6 +6,7 @@ package btrfsprim
import (
"fmt"
+ "math"
"time"
"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
@@ -25,6 +26,24 @@ func (k Key) String() string {
return fmt.Sprintf("{%v %v %v}", k.ObjectID, k.ItemType, k.Offset)
}
+var MaxKey = Key{
+ ObjectID: math.MaxUint64,
+ ItemType: math.MaxUint8,
+ Offset: math.MaxUint64,
+}
+
+func (key Key) Mm() Key {
+ switch {
+ case key.Offset > 0:
+ key.Offset--
+ case key.ItemType > 0:
+ key.ItemType--
+ case key.ObjectID > 0:
+ key.ObjectID--
+ }
+ return key
+}
+
func (a Key) Cmp(b Key) int {
if d := containers.NativeCmp(a.ObjectID, b.ObjectID); d != 0 {
return d