From db7047c394edbcc713accda2a15f201a5b400ef7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 13 Jul 2022 20:16:46 -0600 Subject: Misc tidy up --- lib/btrfs/internal/misc.go | 8 +++++--- lib/btrfs/internal/objid.go | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'lib/btrfs/internal') diff --git a/lib/btrfs/internal/misc.go b/lib/btrfs/internal/misc.go index eb5c287..3bc5402 100644 --- a/lib/btrfs/internal/misc.go +++ b/lib/btrfs/internal/misc.go @@ -26,15 +26,17 @@ func (k Key) String() string { } func (a Key) Cmp(b Key) int { - if d := containers.CmpUint(a.ObjectID, b.ObjectID); d != 0 { + if d := containers.NativeCmp(a.ObjectID, b.ObjectID); d != 0 { return d } - if d := containers.CmpUint(a.ItemType, b.ItemType); d != 0 { + if d := containers.NativeCmp(a.ItemType, b.ItemType); d != 0 { return d } - return containers.CmpUint(a.Offset, b.Offset) + return containers.NativeCmp(a.Offset, b.Offset) } +var _ containers.Ordered[Key] = Key{} + type Time struct { Sec int64 `bin:"off=0x0, siz=0x8"` // Number of seconds since 1970-01-01T00:00:00Z. NSec uint32 `bin:"off=0x8, siz=0x4"` // Number of nanoseconds since the beginning of the second. diff --git a/lib/btrfs/internal/objid.go b/lib/btrfs/internal/objid.go index f1d2a2a..fa9eb4d 100644 --- a/lib/btrfs/internal/objid.go +++ b/lib/btrfs/internal/objid.go @@ -6,12 +6,12 @@ package internal import ( "fmt" - - "git.lukeshu.com/btrfs-progs-ng/lib/util" ) type ObjID uint64 +const maxUint64pp = 0x1_00000000_00000000 + const ( // The IDs of the various trees ROOT_TREE_OBJECTID = ObjID(1) // holds pointers to all of the tree roots @@ -30,21 +30,21 @@ const ( DEV_STATS_OBJECTID = ObjID(0) // device stats in the device tree // ??? - BALANCE_OBJECTID = ObjID(util.MaxUint64pp - 4) // for storing balance parameters in the root tree - ORPHAN_OBJECTID = ObjID(util.MaxUint64pp - 5) // orphan objectid for tracking unlinked/truncated files - TREE_LOG_OBJECTID = ObjID(util.MaxUint64pp - 6) // does write ahead logging to speed up fsyncs - TREE_LOG_FIXUP_OBJECTID = ObjID(util.MaxUint64pp - 7) - TREE_RELOC_OBJECTID = ObjID(util.MaxUint64pp - 8) // space balancing - DATA_RELOC_TREE_OBJECTID = ObjID(util.MaxUint64pp - 9) - EXTENT_CSUM_OBJECTID = ObjID(util.MaxUint64pp - 10) // extent checksums all have this objectid - FREE_SPACE_OBJECTID = ObjID(util.MaxUint64pp - 11) // For storing free space cache - FREE_INO_OBJECTID = ObjID(util.MaxUint64pp - 12) // stores the inode number for the free-ino cache - - MULTIPLE_OBJECTIDS = ObjID(util.MaxUint64pp - 255) // dummy objectid represents multiple objectids + BALANCE_OBJECTID = ObjID(maxUint64pp - 4) // for storing balance parameters in the root tree + ORPHAN_OBJECTID = ObjID(maxUint64pp - 5) // orphan objectid for tracking unlinked/truncated files + TREE_LOG_OBJECTID = ObjID(maxUint64pp - 6) // does write ahead logging to speed up fsyncs + TREE_LOG_FIXUP_OBJECTID = ObjID(maxUint64pp - 7) + TREE_RELOC_OBJECTID = ObjID(maxUint64pp - 8) // space balancing + DATA_RELOC_TREE_OBJECTID = ObjID(maxUint64pp - 9) + EXTENT_CSUM_OBJECTID = ObjID(maxUint64pp - 10) // extent checksums all have this objectid + FREE_SPACE_OBJECTID = ObjID(maxUint64pp - 11) // For storing free space cache + FREE_INO_OBJECTID = ObjID(maxUint64pp - 12) // stores the inode number for the free-ino cache + + MULTIPLE_OBJECTIDS = ObjID(maxUint64pp - 255) // dummy objectid represents multiple objectids // All files have objectids in this range. FIRST_FREE_OBJECTID = ObjID(256) - LAST_FREE_OBJECTID = ObjID(util.MaxUint64pp - 256) + LAST_FREE_OBJECTID = ObjID(maxUint64pp - 256) FIRST_CHUNK_TREE_OBJECTID = ObjID(256) -- cgit v1.2.3-2-g168b