diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-17 21:46:53 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-17 21:46:53 -0600 |
commit | 72c0d02ebf69b12ab434a5243978f05a65c43e3b (patch) | |
tree | c37fbbb12d79b2d5c87a96f0e2770d22934eab91 /lib/btrfsutil/rebuilt_callbacks.go | |
parent | 4efa228eb104145bb0750fb68c0d9493dc5854d5 (diff) | |
parent | 7bd942c1e5f8d4a18f7e1ac866191d8f1aa31d30 (diff) |
Merge branch 'lukeshu/rebuilt-v2-pt3-errs'
Diffstat (limited to 'lib/btrfsutil/rebuilt_callbacks.go')
-rw-r--r-- | lib/btrfsutil/rebuilt_callbacks.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/btrfsutil/rebuilt_callbacks.go b/lib/btrfsutil/rebuilt_callbacks.go index 0b51d08..b5fbc91 100644 --- a/lib/btrfsutil/rebuilt_callbacks.go +++ b/lib/btrfsutil/rebuilt_callbacks.go @@ -16,8 +16,8 @@ import ( type RebuiltForrestCallbacks interface { AddedRoot(ctx context.Context, tree btrfsprim.ObjID, root btrfsvol.LogicalAddr) - LookupRoot(ctx context.Context, tree btrfsprim.ObjID) (offset btrfsprim.Generation, item btrfsitem.Root, ok bool) - LookupUUID(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, ok bool) + LookupRoot(ctx context.Context, tree btrfsprim.ObjID) (offset btrfsprim.Generation, item btrfsitem.Root, err error) + LookupUUID(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, err error) } type RebuiltForrestExtendedCallbacks interface { @@ -32,21 +32,21 @@ type noopRebuiltForrestCallbacks struct { func (noopRebuiltForrestCallbacks) AddedRoot(context.Context, btrfsprim.ObjID, btrfsvol.LogicalAddr) { } -func (cb noopRebuiltForrestCallbacks) LookupRoot(ctx context.Context, tree btrfsprim.ObjID) (offset btrfsprim.Generation, _item btrfsitem.Root, ok bool) { +func (cb noopRebuiltForrestCallbacks) LookupRoot(ctx context.Context, tree btrfsprim.ObjID) (offset btrfsprim.Generation, _item btrfsitem.Root, err error) { rootTree, err := cb.forrest.ForrestLookup(ctx, btrfsprim.ROOT_TREE_OBJECTID) if err != nil { - return 0, btrfsitem.Root{}, false + return 0, btrfsitem.Root{}, err } item, err := rootTree.TreeSearch(ctx, btrfstree.SearchRootItem(tree)) if err != nil { - return 0, btrfsitem.Root{}, false + return 0, btrfsitem.Root{}, err } defer item.Body.Free() switch itemBody := item.Body.(type) { case *btrfsitem.Root: - return btrfsprim.Generation(item.Key.Offset), *itemBody, true + return btrfsprim.Generation(item.Key.Offset), *itemBody, nil case *btrfsitem.Error: - return 0, btrfsitem.Root{}, false + return 0, btrfsitem.Root{}, itemBody.Err default: // This is a panic because the item decoder should not emit ROOT_ITEM items as anything but // btrfsitem.Root or btrfsitem.Error without this code also being updated. @@ -54,22 +54,22 @@ func (cb noopRebuiltForrestCallbacks) LookupRoot(ctx context.Context, tree btrfs } } -func (cb noopRebuiltForrestCallbacks) LookupUUID(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, ok bool) { +func (cb noopRebuiltForrestCallbacks) LookupUUID(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, err error) { uuidTree, err := cb.forrest.ForrestLookup(ctx, btrfsprim.UUID_TREE_OBJECTID) if err != nil { - return 0, false + return 0, err } tgt := btrfsitem.UUIDToKey(uuid) item, err := uuidTree.TreeLookup(ctx, tgt) if err != nil { - return 0, false + return 0, err } defer item.Body.Free() switch itemBody := item.Body.(type) { case *btrfsitem.UUIDMap: - return itemBody.ObjID, true + return itemBody.ObjID, nil case *btrfsitem.Error: - return 0, false + return 0, itemBody.Err default: // This is a panic because the item decoder should not emit UUID_SUBVOL items as anything but // btrfsitem.UUIDMap or btrfsitem.Error without this code also being updated. |