diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-13 20:16:46 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-13 21:52:30 -0600 |
commit | db7047c394edbcc713accda2a15f201a5b400ef7 (patch) | |
tree | 0b8fb9c1b4176af762422197cca721145cda91a6 /lib/btrfs | |
parent | 166e51d3a6f81834cc89aec36015f05f350be31e (diff) |
Misc tidy up
Diffstat (limited to 'lib/btrfs')
-rw-r--r-- | lib/btrfs/internal/misc.go | 8 | ||||
-rw-r--r-- | lib/btrfs/internal/objid.go | 28 | ||||
-rw-r--r-- | lib/btrfs/io4_fs.go | 2 |
3 files changed, 20 insertions, 18 deletions
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) diff --git a/lib/btrfs/io4_fs.go b/lib/btrfs/io4_fs.go index 701230e..b2a2ee1 100644 --- a/lib/btrfs/io4_fs.go +++ b/lib/btrfs/io4_fs.go @@ -135,7 +135,7 @@ func (sv *Subvolume) LoadFullInode(inode ObjID) (*FullInode, error) { }, } items, err := sv.FS.TreeSearchAll(sv.TreeID, func(key Key) int { - return containers.CmpUint(inode, key.ObjectID) + return containers.NativeCmp(inode, key.ObjectID) }) if err != nil { val.Errs = append(val.Errs, err) |