summaryrefslogtreecommitdiff
path: root/lib/btrfsprogs/btrfsinspect/rebuildnodes/bak_rebuildnodes.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-12-20 20:06:15 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2022-12-20 20:06:15 -0700
commit8ff81c1ed6a50179166ffc4cfb60bef85394265e (patch)
treef2395593d4d4cfd12b26ba2030bb94930fe4ba56 /lib/btrfsprogs/btrfsinspect/rebuildnodes/bak_rebuildnodes.go
parent7315c38414b3a6840d71f254b7c8192640b41d7c (diff)
parent94a86a763157327ac969c98e19d7770db477a6a3 (diff)
Merge branch 'lukeshu/rebuild-nodes-take2'
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/bak_rebuildnodes.go')
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/bak_rebuildnodes.go102
1 files changed, 0 insertions, 102 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/bak_rebuildnodes.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/bak_rebuildnodes.go
deleted file mode 100644
index 1a9f487..0000000
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/bak_rebuildnodes.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
-//
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-package rebuildnodes
-
-/*
-import (
- "context"
- "errors"
-
- "git.lukeshu.com/btrfs-progs-ng/lib/btrfs"
- "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsprim"
- "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfstree"
- "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
- "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect"
- "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsutil"
- "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
-)
-
-func RebuildNodes(ctx context.Context, fs *btrfs.FS, nodeScanResults btrfsinspect.ScanDevicesResult) (map[btrfsvol.LogicalAddr]*RebuiltNode, error) {
- uuidMap, err := buildUUIDMap(ctx, fs, nodeScanResults)
- if err != nil {
- return nil, err
- }
-
- nfs := &RebuiltTrees{
- inner: fs,
- uuidMap: uuidMap,
- }
-
- orphanedNodes, badNodes, treeAncestors, err := classifyNodes(ctx, nfs, nodeScanResults)
- if err != nil {
- return nil, err
- }
-
- uuidMap.considerAncestors(ctx, treeAncestors)
-
- rebuiltNodes, err := reInitBrokenNodes(ctx, nfs, badNodes)
- if err != nil {
- return nil, err
- }
-
- if err := reAttachNodes(ctx, nfs, orphanedNodes, rebuiltNodes); err != nil {
- return nil, err
- }
-
- return rebuiltNodes, nil
-}
-
-func spanOfTreePath(fs _FS, path btrfstree.TreePath) (btrfsprim.Key, btrfsprim.Key) {
- // tree root error
- if len(path) == 0 {
- return btrfsprim.Key{}, maxKey
- }
-
- // item error
- if path.Node(-1).ToNodeAddr == 0 {
- // If we got an item error, then the node is readable
- node, _ := fs.ReadNode(path.Parent())
- key := node.Data.BodyLeaf[path.Node(-1).FromItemIdx].Key
- return key, key
- }
-
- // node error
- //
- // assume that path.Node(-1).ToNodeAddr is not readable, but that path.Node(-2).ToNodeAddr is.
- if len(path) == 1 {
- return btrfsprim.Key{}, maxKey
- }
- parentNode, _ := fs.ReadNode(path.Parent())
- low := parentNode.Data.BodyInternal[path.Node(-1).FromItemIdx].Key
- var high btrfsprim.Key
- if path.Node(-1).FromItemIdx+1 < len(parentNode.Data.BodyInternal) {
- high = keyMm(parentNode.Data.BodyInternal[path.Node(-1).FromItemIdx+1].Key)
- } else {
- parentPath := path.Parent().DeepCopy()
- _, high = spanOfTreePath(fs, parentPath)
- }
- return low, high
-}
-
-func getChunkTreeUUID(ctx context.Context, fs _FS) (btrfsprim.UUID, bool) {
- ctx, cancel := context.WithCancel(ctx)
- var ret btrfsprim.UUID
- var retOK bool
- btrfsutil.WalkAllTrees(ctx, fs, btrfsutil.WalkAllTreesHandler{
- TreeWalkHandler: btrfstree.TreeWalkHandler{
- Node: func(path btrfstree.TreePath, node *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.Node]) error {
- ret = node.Data.Head.ChunkTreeUUID
- retOK = true
- cancel()
- return nil
- },
- },
- Err: func(err *btrfsutil.WalkError) {
- // do nothing
- },
- })
- return ret, retOK
-}
-*/