summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-04-03 15:06:31 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-04-04 14:08:38 -0600
commit83886d4925e3d1d9c2c5d9cca4dd165597e54864 (patch)
treec1e3c66d8a2ea34ffa2ac17263db439dd7db2dbd
parentb7e24934c062017fd50fff5d3416b2729c99bc4e (diff)
btrfsutil: Rename unexported types to be clearer about which system they belong to
- nodeInfo → oldRebuiltNodeInfo (old_rebuilt_forrest.go) - itemStats → rebuiltItemStats (rebuilt_tree.go) - rootStats → rebuiltRootStats (rebuilt_tree.go) - nodeScanner → nodeLister (listnodes.go) - nodeStats → nodeListStats (listnodes.go) - scanStats → devScanStats (scan.go)
-rw-r--r--lib/btrfsutil/listnodes.go24
-rw-r--r--lib/btrfsutil/old_rebuilt_forrest.go10
-rw-r--r--lib/btrfsutil/rebuilt_tree.go16
-rw-r--r--lib/btrfsutil/scan.go8
4 files changed, 29 insertions, 29 deletions
diff --git a/lib/btrfsutil/listnodes.go b/lib/btrfsutil/listnodes.go
index 70b647c..d4572bd 100644
--- a/lib/btrfsutil/listnodes.go
+++ b/lib/btrfsutil/listnodes.go
@@ -15,45 +15,45 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/textui"
)
-type nodeScanner struct {
+type nodeLister struct {
nodes containers.Set[btrfsvol.LogicalAddr]
}
-type nodeStats struct {
+type nodeListStats struct {
numNodes int
}
-func (s nodeStats) String() string {
+func (s nodeListStats) String() string {
return textui.Sprintf("found: %d nodes", s.numNodes)
}
-var _ DeviceScanner[nodeStats, containers.Set[btrfsvol.LogicalAddr]] = (*nodeScanner)(nil)
+var _ DeviceScanner[nodeListStats, containers.Set[btrfsvol.LogicalAddr]] = (*nodeLister)(nil)
-func newNodeScanner(context.Context, btrfstree.Superblock, btrfsvol.PhysicalAddr, int) DeviceScanner[nodeStats, containers.Set[btrfsvol.LogicalAddr]] {
- s := new(nodeScanner)
+func newNodeLister(context.Context, btrfstree.Superblock, btrfsvol.PhysicalAddr, int) DeviceScanner[nodeListStats, containers.Set[btrfsvol.LogicalAddr]] {
+ s := new(nodeLister)
s.nodes = make(containers.Set[btrfsvol.LogicalAddr])
return s
}
-func (s *nodeScanner) ScanStats() nodeStats {
- return nodeStats{numNodes: len(s.nodes)}
+func (s *nodeLister) ScanStats() nodeListStats {
+ return nodeListStats{numNodes: len(s.nodes)}
}
-func (*nodeScanner) ScanSector(context.Context, *btrfs.Device, btrfsvol.PhysicalAddr) error {
+func (*nodeLister) ScanSector(context.Context, *btrfs.Device, btrfsvol.PhysicalAddr) error {
return nil
}
-func (s *nodeScanner) ScanNode(_ context.Context, _ btrfsvol.PhysicalAddr, node *btrfstree.Node) error {
+func (s *nodeLister) ScanNode(_ context.Context, _ btrfsvol.PhysicalAddr, node *btrfstree.Node) error {
s.nodes.Insert(node.Head.Addr)
return nil
}
-func (s *nodeScanner) ScanDone(_ context.Context) (containers.Set[btrfsvol.LogicalAddr], error) {
+func (s *nodeLister) ScanDone(_ context.Context) (containers.Set[btrfsvol.LogicalAddr], error) {
return s.nodes, nil
}
func ListNodes(ctx context.Context, fs *btrfs.FS) ([]btrfsvol.LogicalAddr, error) {
- perDev, err := ScanDevices[nodeStats, containers.Set[btrfsvol.LogicalAddr]](ctx, fs, newNodeScanner)
+ perDev, err := ScanDevices[nodeListStats, containers.Set[btrfsvol.LogicalAddr]](ctx, fs, newNodeLister)
if err != nil {
return nil, err
}
diff --git a/lib/btrfsutil/old_rebuilt_forrest.go b/lib/btrfsutil/old_rebuilt_forrest.go
index c451fb8..0a3106d 100644
--- a/lib/btrfsutil/old_rebuilt_forrest.go
+++ b/lib/btrfsutil/old_rebuilt_forrest.go
@@ -53,11 +53,11 @@ type oldRebuiltTreeValue struct {
Key btrfsprim.Key
ItemSize uint32
- Node nodeInfo
+ Node oldRebuiltNodeInfo
Slot int
}
-type nodeInfo struct {
+type oldRebuiltNodeInfo struct {
LAddr btrfsvol.LogicalAddr
Level uint8
Generation btrfsprim.Generation
@@ -187,7 +187,7 @@ func (bt *OldRebuiltForrest) rawTreeWalk(ctx context.Context, treeID btrfsprim.O
cacheEntry.ParentUUID = root.ParentUUID
cacheEntry.ParentGen = root.ParentGen
- var curNode nodeInfo
+ var curNode oldRebuiltNodeInfo
cbs := btrfstree.TreeWalkHandler{
BadNode: func(path btrfstree.Path, node *btrfstree.Node, err error) bool {
nodeAddr, nodeExp, _ := path.NodeExpectations(ctx, false)
@@ -200,7 +200,7 @@ func (bt *OldRebuiltForrest) rawTreeWalk(ctx context.Context, treeID btrfsprim.O
return false
},
Node: func(path btrfstree.Path, node *btrfstree.Node) {
- curNode = nodeInfo{
+ curNode = oldRebuiltNodeInfo{
LAddr: node.Head.Addr,
Level: node.Head.Level,
Generation: node.Head.Generation,
@@ -247,7 +247,7 @@ func (tree oldRebuiltTree) addErrs(fn func(btrfsprim.Key, uint32) int, err error
return errs
}
-func (bt *OldRebuiltForrest) readNode(ctx context.Context, nodeInfo nodeInfo) *btrfstree.Node {
+func (bt *OldRebuiltForrest) readNode(ctx context.Context, nodeInfo oldRebuiltNodeInfo) *btrfstree.Node {
node, err := bt.AcquireNode(ctx, nodeInfo.LAddr, btrfstree.NodeExpectations{
LAddr: containers.OptionalValue(nodeInfo.LAddr),
Level: containers.OptionalValue(nodeInfo.Level),
diff --git a/lib/btrfsutil/rebuilt_tree.go b/lib/btrfsutil/rebuilt_tree.go
index 8e6e32d..ffb2e5f 100644
--- a/lib/btrfsutil/rebuilt_tree.go
+++ b/lib/btrfsutil/rebuilt_tree.go
@@ -210,13 +210,13 @@ func (tree *RebuiltTree) uncachedExcItems(ctx context.Context) containers.Sorted
return tree.items(ctx, false)
}
-type itemStats struct {
+type rebuiltItemStats struct {
Leafs textui.Portion[int]
NumItems int
NumDups int
}
-func (s itemStats) String() string {
+func (s rebuiltItemStats) String() string {
return textui.Sprintf("%v (%v items, %v dups)",
s.Leafs, s.NumItems, s.NumDups)
}
@@ -234,9 +234,9 @@ func (tree *RebuiltTree) items(ctx context.Context, inc bool) containers.SortedM
tree.releaseLeafToRoots()
slices.Sort(leafs)
- var stats itemStats
+ var stats rebuiltItemStats
stats.Leafs.D = len(leafs)
- progressWriter := textui.NewProgress[itemStats](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second))
+ progressWriter := textui.NewProgress[rebuiltItemStats](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second))
var index containers.SortedMap[btrfsprim.Key, ItemPtr]
for i, leaf := range leafs {
@@ -302,13 +302,13 @@ func (tree *RebuiltTree) RebuiltShouldReplace(oldNode, newNode btrfsvol.LogicalA
}
}
-type rootStats struct {
+type rebuiltRootStats struct {
Leafs textui.Portion[int]
AddedLeafs int
AddedItems int
}
-func (s rootStats) String() string {
+func (s rebuiltRootStats) String() string {
return textui.Sprintf("%v (added %v leafs, added %v items)",
s.Leafs, s.AddedLeafs, s.AddedItems)
}
@@ -322,10 +322,10 @@ func (tree *RebuiltTree) RebuiltAddRoot(ctx context.Context, rootNode btrfsvol.L
ctx = dlog.WithField(ctx, "btrfs.util.rebuilt-tree.add-root", fmt.Sprintf("tree=%v rootNode=%v", tree.ID, rootNode))
dlog.Info(ctx, "adding root...")
- var stats rootStats
+ var stats rebuiltRootStats
leafToRoots := tree.acquireLeafToRoots(ctx)
stats.Leafs.D = len(leafToRoots)
- progressWriter := textui.NewProgress[rootStats](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second))
+ progressWriter := textui.NewProgress[rebuiltRootStats](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second))
for i, leaf := range maps.SortedKeys(leafToRoots) {
stats.Leafs.N = i
progressWriter.Set(stats)
diff --git a/lib/btrfsutil/scan.go b/lib/btrfsutil/scan.go
index 0e268e5..bf848ee 100644
--- a/lib/btrfsutil/scan.go
+++ b/lib/btrfsutil/scan.go
@@ -33,12 +33,12 @@ type DeviceScanner[Stats comparable, Result any] interface {
ScanDone(ctx context.Context) (Result, error)
}
-type scanStats[T comparable] struct {
+type devScanStats[T comparable] struct {
portion textui.Portion[btrfsvol.PhysicalAddr]
stats T
}
-func (s scanStats[T]) String() string {
+func (s devScanStats[T]) String() string {
return textui.Sprintf("scanned %v (%v)",
s.portion, s.stats)
}
@@ -91,8 +91,8 @@ func ScanOneDevice[Stats comparable, Result any](ctx context.Context, dev *btrfs
scanner := newScanner(ctx, *sb, numBytes, numSectors)
- progressWriter := textui.NewProgress[scanStats[Stats]](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second))
- var stats scanStats[Stats]
+ progressWriter := textui.NewProgress[devScanStats[Stats]](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second))
+ var stats devScanStats[Stats]
stats.portion.D = numBytes
var minNextNode btrfsvol.PhysicalAddr