summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-04 09:42:44 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-04-15 12:01:29 -0600
commitb302df6a761fda3ba1ba60c6866eb39dbb36527a (patch)
treed144566198f604d91d83196788bca588d99e74db /cmd
parentc2c6fa42233cd3911b81bb9449329816f645cec5 (diff)
Clean-up made possible by btrfsutil.RebuiltForrest implementing btrfs.ReadableFS
- rebuildtrees: Use .ForrestLookup instead of .RebuiltTree where possible - btrfsutil: noopRebuiltForrestCallbacks: Use only the generic btrfstree.Forrest API - btrfsutil: RebuiltForrest, RebuiltTree: Avoid unnecessarily reaching into forrest.inner - btrfsutil: RebuiltTree: Drop the .ReadItem() method; it duplicates .TreeLookup without benefit.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go4
-rw-r--r--cmd/btrfs-rec/inspect/rebuildtrees/rebuild_treecb.go14
2 files changed, 9 insertions, 9 deletions
diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go b/cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go
index 7e2e49f..77d56ae 100644
--- a/cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go
+++ b/cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go
@@ -159,7 +159,7 @@ func (o *rebuilder) processTreeQueue(ctx context.Context) error {
}
// This will call o.AddedItem as nescessary, which
// inserts to o.addedItemQueue.
- _, _ = o.rebuilt.RebuiltTree(ctx, o.curKey.TreeID)
+ _, _ = o.rebuilt.ForrestLookup(ctx, o.curKey.TreeID)
}
return nil
@@ -415,7 +415,7 @@ func (o *rebuilder) processSettledItemQueue(ctx context.Context) error {
ctx := dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.process.item", key)
item := keyAndBody{
itemToVisit: key,
- Body: discardErr(o.rebuilt.RebuiltTree(ctx, key.TreeID)).ReadItem(ctx, key.Key),
+ Body: discardErr(discardErr(o.rebuilt.RebuiltTree(ctx, key.TreeID)).TreeLookup(ctx, key.Key)).Body,
}
if key.TreeID == btrfsprim.EXTENT_TREE_OBJECTID &&
(key.ItemType == btrfsprim.EXTENT_ITEM_KEY || key.ItemType == btrfsprim.METADATA_ITEM_KEY) {
diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/rebuild_treecb.go b/cmd/btrfs-rec/inspect/rebuildtrees/rebuild_treecb.go
index e227cc7..15ad42c 100644
--- a/cmd/btrfs-rec/inspect/rebuildtrees/rebuild_treecb.go
+++ b/cmd/btrfs-rec/inspect/rebuildtrees/rebuild_treecb.go
@@ -36,7 +36,7 @@ func (o forrestCallbacks) AddedRoot(_ context.Context, tree btrfsprim.ObjID, _ b
}
// LookupRoot implements btrfsutil.RebuiltForrestCallbacks.
-func (o forrestCallbacks) LookupRoot(ctx context.Context, tree btrfsprim.ObjID) (offset btrfsprim.Generation, item btrfsitem.Root, ok bool) {
+func (o forrestCallbacks) LookupRoot(ctx context.Context, tree btrfsprim.ObjID) (offset btrfsprim.Generation, _item btrfsitem.Root, ok bool) {
wantKey := wantWithTree{
TreeID: btrfsprim.ROOT_TREE_OBJECTID,
Key: want{
@@ -51,9 +51,9 @@ func (o forrestCallbacks) LookupRoot(ctx context.Context, tree btrfsprim.ObjID)
o.enqueueRetry(btrfsprim.ROOT_TREE_OBJECTID)
return 0, btrfsitem.Root{}, false
}
- itemBody := discardErr(o.rebuilt.RebuiltTree(ctx, wantKey.TreeID)).ReadItem(ctx, foundKey)
- defer itemBody.Free()
- switch itemBody := itemBody.(type) {
+ item, _ := discardErr(o.rebuilt.RebuiltTree(ctx, wantKey.TreeID)).TreeLookup(ctx, foundKey)
+ defer item.Body.Free()
+ switch itemBody := item.Body.(type) {
case *btrfsitem.Root:
return btrfsprim.Generation(foundKey.Offset), *itemBody, true
case *btrfsitem.Error:
@@ -77,9 +77,9 @@ func (o forrestCallbacks) LookupUUID(ctx context.Context, uuid btrfsprim.UUID) (
o.enqueueRetry(btrfsprim.UUID_TREE_OBJECTID)
return 0, false
}
- itemBody := discardErr(o.rebuilt.RebuiltTree(ctx, wantKey.TreeID)).ReadItem(ctx, wantKey.Key.Key())
- defer itemBody.Free()
- switch itemBody := itemBody.(type) {
+ item, _ := discardErr(o.rebuilt.RebuiltTree(ctx, wantKey.TreeID)).TreeLookup(ctx, wantKey.Key.Key())
+ defer item.Body.Free()
+ switch itemBody := item.Body.(type) {
case *btrfsitem.UUIDMap:
return itemBody.ObjID, true
case *btrfsitem.Error: