diff options
Diffstat (limited to 'lib/btrfs')
-rw-r--r-- | lib/btrfs/btrfsvol/lvm.go | 36 | ||||
-rw-r--r-- | lib/btrfs/internal/misc.go | 8 | ||||
-rw-r--r-- | lib/btrfs/io4_fs.go | 3 |
3 files changed, 24 insertions, 23 deletions
diff --git a/lib/btrfs/btrfsvol/lvm.go b/lib/btrfs/btrfsvol/lvm.go index 351cbe5..62ca6d7 100644 --- a/lib/btrfs/btrfsvol/lvm.go +++ b/lib/btrfs/btrfsvol/lvm.go @@ -19,8 +19,8 @@ type LogicalVolume[PhysicalVolume util.File[PhysicalAddr]] struct { id2pv map[DeviceID]PhysicalVolume - logical2physical *containers.RBTree[util.NativeOrdered[LogicalAddr], chunkMapping] - physical2logical map[DeviceID]*containers.RBTree[util.NativeOrdered[PhysicalAddr], devextMapping] + logical2physical *containers.RBTree[containers.NativeOrdered[LogicalAddr], chunkMapping] + physical2logical map[DeviceID]*containers.RBTree[containers.NativeOrdered[PhysicalAddr], devextMapping] } var _ util.File[LogicalAddr] = (*LogicalVolume[util.File[PhysicalAddr]])(nil) @@ -30,20 +30,20 @@ func (lv *LogicalVolume[PhysicalVolume]) init() { lv.id2pv = make(map[DeviceID]PhysicalVolume) } if lv.logical2physical == nil { - lv.logical2physical = &containers.RBTree[util.NativeOrdered[LogicalAddr], chunkMapping]{ - KeyFn: func(chunk chunkMapping) util.NativeOrdered[LogicalAddr] { - return util.NativeOrdered[LogicalAddr]{Val: chunk.LAddr} + lv.logical2physical = &containers.RBTree[containers.NativeOrdered[LogicalAddr], chunkMapping]{ + KeyFn: func(chunk chunkMapping) containers.NativeOrdered[LogicalAddr] { + return containers.NativeOrdered[LogicalAddr]{Val: chunk.LAddr} }, } } if lv.physical2logical == nil { - lv.physical2logical = make(map[DeviceID]*containers.RBTree[util.NativeOrdered[PhysicalAddr], devextMapping], len(lv.id2pv)) + lv.physical2logical = make(map[DeviceID]*containers.RBTree[containers.NativeOrdered[PhysicalAddr], devextMapping], len(lv.id2pv)) } for devid := range lv.id2pv { if _, ok := lv.physical2logical[devid]; !ok { - lv.physical2logical[devid] = &containers.RBTree[util.NativeOrdered[PhysicalAddr], devextMapping]{ - KeyFn: func(ext devextMapping) util.NativeOrdered[PhysicalAddr] { - return util.NativeOrdered[PhysicalAddr]{Val: ext.PAddr} + lv.physical2logical[devid] = &containers.RBTree[containers.NativeOrdered[PhysicalAddr], devextMapping]{ + KeyFn: func(ext devextMapping) containers.NativeOrdered[PhysicalAddr] { + return containers.NativeOrdered[PhysicalAddr]{Val: ext.PAddr} }, } } @@ -74,9 +74,9 @@ func (lv *LogicalVolume[PhysicalVolume]) AddPhysicalVolume(id DeviceID, dev Phys lv, dev.Name(), other.Name(), id) } lv.id2pv[id] = dev - lv.physical2logical[id] = &containers.RBTree[util.NativeOrdered[PhysicalAddr], devextMapping]{ - KeyFn: func(ext devextMapping) util.NativeOrdered[PhysicalAddr] { - return util.NativeOrdered[PhysicalAddr]{Val: ext.PAddr} + lv.physical2logical[id] = &containers.RBTree[containers.NativeOrdered[PhysicalAddr], devextMapping]{ + KeyFn: func(ext devextMapping) containers.NativeOrdered[PhysicalAddr] { + return containers.NativeOrdered[PhysicalAddr]{Val: ext.PAddr} }, } return nil @@ -148,13 +148,13 @@ func (lv *LogicalVolume[PhysicalVolume]) AddMapping(m Mapping) error { // logical2physical for _, chunk := range logicalOverlaps { - lv.logical2physical.Delete(util.NativeOrdered[LogicalAddr]{Val: chunk.LAddr}) + lv.logical2physical.Delete(containers.NativeOrdered[LogicalAddr]{Val: chunk.LAddr}) } lv.logical2physical.Insert(newChunk) // physical2logical for _, ext := range physicalOverlaps { - lv.physical2logical[m.PAddr.Dev].Delete(util.NativeOrdered[PhysicalAddr]{Val: ext.PAddr}) + lv.physical2logical[m.PAddr.Dev].Delete(containers.NativeOrdered[PhysicalAddr]{Val: ext.PAddr}) } lv.physical2logical[m.PAddr.Dev].Insert(newExt) @@ -173,7 +173,7 @@ func (lv *LogicalVolume[PhysicalVolume]) AddMapping(m Mapping) error { } func (lv *LogicalVolume[PhysicalVolume]) fsck() error { - physical2logical := make(map[DeviceID]*containers.RBTree[util.NativeOrdered[PhysicalAddr], devextMapping]) + physical2logical := make(map[DeviceID]*containers.RBTree[containers.NativeOrdered[PhysicalAddr], devextMapping]) if err := lv.logical2physical.Walk(func(node *containers.RBNode[chunkMapping]) error { chunk := node.Value for _, stripe := range chunk.PAddrs { @@ -182,9 +182,9 @@ func (lv *LogicalVolume[PhysicalVolume]) fsck() error { lv, stripe.Dev) } if _, exists := physical2logical[stripe.Dev]; !exists { - physical2logical[stripe.Dev] = &containers.RBTree[util.NativeOrdered[PhysicalAddr], devextMapping]{ - KeyFn: func(ext devextMapping) util.NativeOrdered[PhysicalAddr] { - return util.NativeOrdered[PhysicalAddr]{Val: ext.PAddr} + physical2logical[stripe.Dev] = &containers.RBTree[containers.NativeOrdered[PhysicalAddr], devextMapping]{ + KeyFn: func(ext devextMapping) containers.NativeOrdered[PhysicalAddr] { + return containers.NativeOrdered[PhysicalAddr]{Val: ext.PAddr} }, } } diff --git a/lib/btrfs/internal/misc.go b/lib/btrfs/internal/misc.go index 49fe2bd..eb5c287 100644 --- a/lib/btrfs/internal/misc.go +++ b/lib/btrfs/internal/misc.go @@ -9,7 +9,7 @@ import ( "time" "git.lukeshu.com/btrfs-progs-ng/lib/binstruct" - "git.lukeshu.com/btrfs-progs-ng/lib/util" + "git.lukeshu.com/btrfs-progs-ng/lib/containers" ) type Generation uint64 @@ -26,13 +26,13 @@ func (k Key) String() string { } func (a Key) Cmp(b Key) int { - if d := util.CmpUint(a.ObjectID, b.ObjectID); d != 0 { + if d := containers.CmpUint(a.ObjectID, b.ObjectID); d != 0 { return d } - if d := util.CmpUint(a.ItemType, b.ItemType); d != 0 { + if d := containers.CmpUint(a.ItemType, b.ItemType); d != 0 { return d } - return util.CmpUint(a.Offset, b.Offset) + return containers.CmpUint(a.Offset, b.Offset) } type Time struct { diff --git a/lib/btrfs/io4_fs.go b/lib/btrfs/io4_fs.go index 07e52bb..eaa83f7 100644 --- a/lib/btrfs/io4_fs.go +++ b/lib/btrfs/io4_fs.go @@ -16,6 +16,7 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol" + "git.lukeshu.com/btrfs-progs-ng/lib/containers" "git.lukeshu.com/btrfs-progs-ng/lib/util" ) @@ -133,7 +134,7 @@ func (sv *Subvolume) LoadFullInode(inode ObjID) (*FullInode, error) { }, } items, err := sv.FS.TreeSearchAll(sv.TreeID, func(key Key) int { - return util.CmpUint(inode, key.ObjectID) + return containers.CmpUint(inode, key.ObjectID) }) if err != nil { val.Errs = append(val.Errs, err) |