From e46cbc7ee7f3a2b93bd1bdf02e1eb95b98100f57 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 28 Feb 2023 13:10:16 -0700 Subject: misc: btrfsutil: Shrink the size of GraphNode --- lib/btrfsutil/rebuilt_readitem.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/btrfsutil/rebuilt_readitem.go') diff --git a/lib/btrfsutil/rebuilt_readitem.go b/lib/btrfsutil/rebuilt_readitem.go index 57440cf..a508d99 100644 --- a/lib/btrfsutil/rebuilt_readitem.go +++ b/lib/btrfsutil/rebuilt_readitem.go @@ -141,8 +141,8 @@ func (o *KeyIO) readNode(ctx context.Context, laddr btrfsvol.LogicalAddr) *diski } return nil }, - MinItem: containers.Optional[btrfsprim.Key]{OK: true, Val: graphInfo.MinItem}, - MaxItem: containers.Optional[btrfsprim.Key]{OK: true, Val: graphInfo.MaxItem}, + MinItem: containers.Optional[btrfsprim.Key]{OK: true, Val: graphInfo.MinItem()}, + MaxItem: containers.Optional[btrfsprim.Key]{OK: true, Val: graphInfo.MaxItem()}, }) if err != nil { panic(fmt.Errorf("should not happen: i/o error: %w", err)) -- cgit v1.2.3-2-g168b From 2c2d616b8650dd01818bd29e11e7b06ae2de5891 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 4 Mar 2023 09:51:34 -0700 Subject: tree-wide: Refer to item "slots" rather than "indexes" --- lib/btrfsutil/rebuilt_readitem.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/btrfsutil/rebuilt_readitem.go') diff --git a/lib/btrfsutil/rebuilt_readitem.go b/lib/btrfsutil/rebuilt_readitem.go index a508d99..016299c 100644 --- a/lib/btrfsutil/rebuilt_readitem.go +++ b/lib/btrfsutil/rebuilt_readitem.go @@ -22,11 +22,11 @@ import ( type ItemPtr struct { Node btrfsvol.LogicalAddr - Idx int + Slot int } func (ptr ItemPtr) String() string { - return fmt.Sprintf("node@%v[%v]", ptr.Node, ptr.Idx) + return fmt.Sprintf("node@%v[%v]", ptr.Node, ptr.Slot) } type SizeAndErr struct { @@ -74,7 +74,7 @@ func (o *KeyIO) InsertNode(nodeRef *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.N for i, item := range nodeRef.Data.BodyLeaf { ptr := ItemPtr{ Node: nodeRef.Addr, - Idx: i, + Slot: i, } switch itemBody := item.Body.(type) { case *btrfsitem.Inode: @@ -159,13 +159,13 @@ func (o *KeyIO) ReadItem(ctx context.Context, ptr ItemPtr) btrfsitem.Item { if o.graph.Nodes[ptr.Node].Level != 0 { panic(fmt.Errorf("should not happen: btrfsutil.KeyIO.ReadItem called for non-leaf node@%v", ptr.Node)) } - if ptr.Idx < 0 { - panic(fmt.Errorf("should not happen: btrfsutil.KeyIO.ReadItem called for negative item index: %v", ptr.Idx)) + if ptr.Slot < 0 { + panic(fmt.Errorf("should not happen: btrfsutil.KeyIO.ReadItem called for negative item slot: %v", ptr.Slot)) } items := o.readNode(ctx, ptr.Node).Data.BodyLeaf - if ptr.Idx >= len(items) { - panic(fmt.Errorf("should not happen: btrfsutil.KeyIO.ReadItem called for out-of-bounds item index: index=%v len=%v", - ptr.Idx, len(items))) + if ptr.Slot >= len(items) { + panic(fmt.Errorf("should not happen: btrfsutil.KeyIO.ReadItem called for out-of-bounds item slot: slot=%v len=%v", + ptr.Slot, len(items))) } - return items[ptr.Idx].Body.CloneItem() + return items[ptr.Slot].Body.CloneItem() } -- cgit v1.2.3-2-g168b