diff options
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect')
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/print_tree.go | 52 | ||||
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildnodes/graph/graph.go | 6 | ||||
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go | 10 | ||||
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go | 10 | ||||
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild_graph.go | 54 | ||||
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/scandevices.go | 24 |
6 files changed, 78 insertions, 78 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/print_tree.go b/lib/btrfsprogs/btrfsinspect/print_tree.go index 3807df5..409ce0c 100644 --- a/lib/btrfsprogs/btrfsinspect/print_tree.go +++ b/lib/btrfsprogs/btrfsinspect/print_tree.go @@ -121,11 +121,11 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri itemOffset, itemSize) switch body := item.Body.(type) { - case btrfsitem.FreeSpaceHeader: + case *btrfsitem.FreeSpaceHeader: textui.Fprintf(out, "\t\tlocation %v\n", fmtKey(body.Location)) textui.Fprintf(out, "\t\tcache generation %v entries %v bitmaps %v\n", body.Generation, body.NumEntries, body.NumBitmaps) - case btrfsitem.Inode: + case *btrfsitem.Inode: textui.Fprintf(out, ""+ "\t\tgeneration %v transid %v size %v nbytes %v\n"+ "\t\tblock group %v mode %o links %v uid %v gid %v rdev %v\n"+ @@ -137,14 +137,14 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri textui.Fprintf(out, "\t\tctime %v\n", fmtTime(body.CTime)) textui.Fprintf(out, "\t\tmtime %v\n", fmtTime(body.MTime)) textui.Fprintf(out, "\t\totime %v\n", fmtTime(body.OTime)) - case btrfsitem.InodeRefs: - for _, ref := range body { + case *btrfsitem.InodeRefs: + for _, ref := range body.Refs { textui.Fprintf(out, "\t\tindex %v namelen %v name: %s\n", ref.Index, ref.NameLen, ref.Name) } // case btrfsitem.INODE_EXTREF_KEY: // // TODO - case btrfsitem.DirEntry: + case *btrfsitem.DirEntry: textui.Fprintf(out, "\t\tlocation %v type %v\n", fmtKey(body.Location), body.Type) textui.Fprintf(out, "\t\ttransid %v data_len %v name_len %v\n", @@ -155,7 +155,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri } // case btrfsitem.DIR_LOG_INDEX_KEY, btrfsitem.DIR_LOG_ITEM_KEY: // // TODO - case btrfsitem.Root: + case *btrfsitem.Root: textui.Fprintf(out, "\t\tgeneration %v root_dirid %v bytenr %d byte_limit %v bytes_used %v\n", body.Generation, body.RootDirID, body.ByteNr, body.ByteLimit, body.BytesUsed) textui.Fprintf(out, "\t\tlast_snapshot %v flags %v refs %v\n", @@ -175,7 +175,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri textui.Fprintf(out, "\t\tstime %v\n", fmtTime(body.STime)) textui.Fprintf(out, "\t\trtime %v\n", fmtTime(body.RTime)) } - case btrfsitem.RootRef: + case *btrfsitem.RootRef: var tag string switch item.Key.ItemType { case btrfsitem.ROOT_REF_KEY: @@ -187,7 +187,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri } textui.Fprintf(out, "\t\troot %v key dirid %v sequence %v name %s\n", tag, body.DirID, body.Sequence, body.Name) - case btrfsitem.Extent: + case *btrfsitem.Extent: textui.Fprintf(out, "\t\trefs %v gen %v flags %v\n", body.Head.Refs, body.Head.Generation, body.Head.Flags) if body.Head.Flags.Has(btrfsitem.EXTENT_FLAG_TREE_BLOCK) { @@ -195,7 +195,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri fmtKey(body.Info.Key), body.Info.Level) } printExtentInlineRefs(out, body.Refs) - case btrfsitem.Metadata: + case *btrfsitem.Metadata: textui.Fprintf(out, "\t\trefs %v gen %v flags %v\n", body.Head.Refs, body.Head.Generation, body.Head.Flags) textui.Fprintf(out, "\t\ttree block skinny level %v\n", item.Key.Offset) @@ -204,7 +204,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri // // TODO // case btrfsitem.SHARED_DATA_REF_KEY: // // TODO - case btrfsitem.ExtentCSum: + case *btrfsitem.ExtentCSum: start := btrfsvol.LogicalAddr(item.Key.Offset) textui.Fprintf(out, "\t\trange start %d end %d length %d", start, start.Add(body.Size()), body.Size()) @@ -222,7 +222,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri return nil }) textui.Fprintf(out, "\n") - case btrfsitem.FileExtent: + case *btrfsitem.FileExtent: textui.Fprintf(out, "\t\tgeneration %v type %v\n", body.Generation, body.Type) switch body.Type { @@ -249,15 +249,15 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri default: textui.Fprintf(out, "\t\t(error) unknown file extent type %v", body.Type) } - case btrfsitem.BlockGroup: + case *btrfsitem.BlockGroup: textui.Fprintf(out, "\t\tblock group used %v chunk_objectid %v flags %v\n", body.Used, body.ChunkObjectID, body.Flags) - case btrfsitem.FreeSpaceInfo: + case *btrfsitem.FreeSpaceInfo: textui.Fprintf(out, "\t\tfree space info extent count %v flags %d\n", body.ExtentCount, body.Flags) - case btrfsitem.FreeSpaceBitmap: + case *btrfsitem.FreeSpaceBitmap: textui.Fprintf(out, "\t\tfree space bitmap\n") - case btrfsitem.Chunk: + case *btrfsitem.Chunk: textui.Fprintf(out, "\t\tlength %d owner %d stripe_len %v type %v\n", body.Head.Size, body.Head.Owner, body.Head.StripeLen, body.Head.Type) textui.Fprintf(out, "\t\tio_align %v io_width %v sector_size %v\n", @@ -270,7 +270,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri textui.Fprintf(out, "\t\t\tdev_uuid %v\n", stripe.DeviceUUID) } - case btrfsitem.Dev: + case *btrfsitem.Dev: textui.Fprintf(out, ""+ "\t\tdevid %d total_bytes %v bytes_used %v\n"+ "\t\tio_align %v io_width %v sector_size %v type %v\n"+ @@ -284,18 +284,18 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri body.SeekSpeed, body.Bandwidth, body.DevUUID, body.FSUUID) - case btrfsitem.DevExtent: + case *btrfsitem.DevExtent: textui.Fprintf(out, ""+ "\t\tdev extent chunk_tree %d\n"+ "\t\tchunk_objectid %v chunk_offset %d length %d\n"+ "\t\tchunk_tree_uuid %v\n", body.ChunkTree, body.ChunkObjectID, body.ChunkOffset, body.Length, body.ChunkTreeUUID) - case btrfsitem.QGroupStatus: + case *btrfsitem.QGroupStatus: textui.Fprintf(out, ""+ "\t\tversion %v generation %v flags %v scan %d\n", body.Version, body.Generation, body.Flags, body.RescanProgress) - case btrfsitem.QGroupInfo: + case *btrfsitem.QGroupInfo: textui.Fprintf(out, ""+ "\t\tgeneration %v\n"+ "\t\treferenced %d referenced_compressed %d\n"+ @@ -303,7 +303,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri body.Generation, body.ReferencedBytes, body.ReferencedBytesCompressed, body.ExclusiveBytes, body.ExclusiveBytesCompressed) - case btrfsitem.QGroupLimit: + case *btrfsitem.QGroupLimit: textui.Fprintf(out, ""+ "\t\tflags %x\n"+ "\t\tmax_referenced %d max_exclusive %d\n"+ @@ -311,11 +311,11 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri uint64(body.Flags), body.MaxReferenced, body.MaxExclusive, body.RsvReferenced, body.RsvExclusive) - case btrfsitem.UUIDMap: + case *btrfsitem.UUIDMap: textui.Fprintf(out, "\t\tsubvol_id %d\n", body.ObjID) // case btrfsitem.STRING_ITEM_KEY: // // TODO - case btrfsitem.DevStats: + case *btrfsitem.DevStats: textui.Fprintf(out, "\t\tpersistent item objectid %v offset %v\n", item.Key.ObjectID.Format(item.Key.ItemType), item.Key.Offset) switch item.Key.ObjectID { @@ -332,7 +332,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri } // case btrfsitem.TEMPORARY_ITEM_KEY: // // TODO - case btrfsitem.Empty: + case *btrfsitem.Empty: switch item.Key.ItemType { case btrfsitem.ORPHAN_ITEM_KEY: // 48 textui.Fprintf(out, "\t\torphan item\n") @@ -351,7 +351,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri default: textui.Fprintf(out, "\t\t(error) unhandled empty item type: %v\n", item.Key.ItemType) } - case btrfsitem.Error: + case *btrfsitem.Error: textui.Fprintf(out, "\t\t(error) error item: %v\n", body.Err) default: textui.Fprintf(out, "\t\t(error) unhandled item type: %T\n", body) @@ -423,10 +423,10 @@ func printExtentInlineRefs(out io.Writer, refs []btrfsitem.ExtentInlineRef) { default: textui.Fprintf(out, "\t\t(error) unexpected empty sub-item type: %v\n", ref.Type) } - case btrfsitem.ExtentDataRef: + case *btrfsitem.ExtentDataRef: textui.Fprintf(out, "\t\textent data backref root %v objectid %v offset %v count %v\n", subitem.Root, subitem.ObjectID, subitem.Offset, subitem.Count) - case btrfsitem.SharedDataRef: + case *btrfsitem.SharedDataRef: textui.Fprintf(out, "\t\tshared data backref parent %v count %v\n", ref.Offset, subitem.Count) default: diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/graph/graph.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/graph/graph.go index cf86d74..c04fec0 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/graph/graph.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/graph/graph.go @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com> // // SPDX-License-Identifier: GPL-2.0-or-later @@ -151,7 +151,7 @@ func (g Graph) InsertNode(nodeRef *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.No if nodeRef.Data.Head.Level == 0 { cnt := 0 for _, item := range nodeRef.Data.BodyLeaf { - if _, ok := item.Body.(btrfsitem.Root); ok { + if _, ok := item.Body.(*btrfsitem.Root); ok { cnt++ } } @@ -161,7 +161,7 @@ func (g Graph) InsertNode(nodeRef *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.No g.Nodes[nodeRef.Addr] = nodeData for i, item := range nodeRef.Data.BodyLeaf { keys[i] = item.Key - if itemBody, ok := item.Body.(btrfsitem.Root); ok { + if itemBody, ok := item.Body.(*btrfsitem.Root); ok { kps = append(kps, Edge{ FromRoot: nodeRef.Addr, FromItem: i, diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go index a85b78e..149706d 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go @@ -73,27 +73,27 @@ func (o *Handle) InsertNode(nodeRef *diskio.Ref[btrfsvol.LogicalAddr, btrfstree. Idx: i, } switch itemBody := item.Body.(type) { - case btrfsitem.Inode: + case *btrfsitem.Inode: o.Flags[ptr] = FlagsAndErr{ NoDataSum: itemBody.Flags.Has(btrfsitem.INODE_NODATASUM), Err: nil, } - case btrfsitem.DirEntry: + case *btrfsitem.DirEntry: if item.Key.ItemType == btrfsprim.DIR_INDEX_KEY { o.Names[ptr] = append([]byte(nil), itemBody.Name...) } - case btrfsitem.ExtentCSum: + case *btrfsitem.ExtentCSum: o.Sizes[ptr] = SizeAndErr{ Size: uint64(itemBody.Size()), Err: nil, } - case btrfsitem.FileExtent: + case *btrfsitem.FileExtent: size, err := itemBody.Size() o.Sizes[ptr] = SizeAndErr{ Size: uint64(size), Err: err, } - case btrfsitem.Error: + case *btrfsitem.Error: switch item.Key.ItemType { case btrfsprim.INODE_ITEM_KEY: o.Flags[ptr] = FlagsAndErr{ diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go index bd29278..624441f 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go @@ -290,9 +290,9 @@ func (o *rebuilder) cbLookupRoot(ctx context.Context, tree btrfsprim.ObjID) (off o.ioErr(ctx, fmt.Errorf("could not read previously read item: %v", key)) } switch itemBody := itemBody.(type) { - case btrfsitem.Root: - return btrfsprim.Generation(key.Offset), itemBody, true - case btrfsitem.Error: + case *btrfsitem.Root: + return btrfsprim.Generation(key.Offset), *itemBody, true + case *btrfsitem.Error: o.fsErr(ctx, fmt.Errorf("error decoding item: %v: %w", key, itemBody.Err)) return 0, btrfsitem.Root{}, false default: @@ -315,9 +315,9 @@ func (o *rebuilder) cbLookupUUID(ctx context.Context, uuid btrfsprim.UUID) (id b o.ioErr(ctx, fmt.Errorf("could not read previously read item: %v", key)) } switch itemBody := itemBody.(type) { - case btrfsitem.UUIDMap: + case *btrfsitem.UUIDMap: return itemBody.ObjID, true - case btrfsitem.Error: + case *btrfsitem.Error: o.fsErr(ctx, fmt.Errorf("error decoding item: %v: %w", key, itemBody.Err)) return 0, false default: diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild_graph.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild_graph.go index 9e40465..710030c 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild_graph.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild_graph.go @@ -50,7 +50,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, // https://btrfs.wiki.kernel.org/index.php/File:References.png (from the page // https://btrfs.wiki.kernel.org/index.php/Data_Structures ) switch body := item.Body.(type) { - case btrfsitem.BlockGroup: + case *btrfsitem.BlockGroup: o.want(ctx, "Chunk", btrfsprim.CHUNK_TREE_OBJECTID, body.ChunkObjectID, @@ -60,22 +60,22 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, item.Key.ObjectID, btrfsitem.FREE_SPACE_INFO_KEY, item.Key.Offset) - case btrfsitem.Chunk: + case *btrfsitem.Chunk: o.want(ctx, "owning Root", btrfsprim.ROOT_TREE_OBJECTID, body.Head.Owner, btrfsitem.ROOT_ITEM_KEY) - case btrfsitem.Dev: + case *btrfsitem.Dev: // nothing - case btrfsitem.DevExtent: + case *btrfsitem.DevExtent: o.wantOff(ctx, "Chunk", body.ChunkTree, body.ChunkObjectID, btrfsitem.CHUNK_ITEM_KEY, uint64(body.ChunkOffset)) - case btrfsitem.DevStats: + case *btrfsitem.DevStats: // nothing - case btrfsitem.DirEntry: + case *btrfsitem.DirEntry: // containing-directory o.wantOff(ctx, "containing dir inode", treeID, @@ -126,9 +126,9 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, o.fsErr(ctx, fmt.Errorf("DirEntry: unexpected .Location.ItemType=%v", body.Location.ItemType)) } } - case btrfsitem.Empty: + case *btrfsitem.Empty: // nothing - case btrfsitem.Extent: + case *btrfsitem.Extent: // if body.Head.Flags.Has(btrfsitem.EXTENT_FLAG_TREE_BLOCK) { // // Supposedly this flag indicates that // // body.Info.Key identifies a node by the @@ -140,7 +140,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, switch refBody := ref.Body.(type) { case nil: // nothing - case btrfsitem.ExtentDataRef: + case *btrfsitem.ExtentDataRef: o.wantOff(ctx, "referencing Inode", refBody.Root, refBody.ObjectID, @@ -151,7 +151,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, refBody.ObjectID, btrfsitem.EXTENT_DATA_KEY, uint64(refBody.Offset)) - case btrfsitem.SharedDataRef: + case *btrfsitem.SharedDataRef: // nothing default: // This is a panic because the item decoder should not emit a new @@ -159,9 +159,9 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, panic(fmt.Errorf("should not happen: Extent: unexpected .Refs[%d].Body type %T", i, refBody)) } } - case btrfsitem.ExtentCSum: + case *btrfsitem.ExtentCSum: // nothing - case btrfsitem.ExtentDataRef: + case *btrfsitem.ExtentDataRef: o.want(ctx, "Extent being referenced", btrfsprim.EXTENT_TREE_OBJECTID, item.Key.ObjectID, @@ -176,7 +176,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, body.ObjectID, btrfsitem.EXTENT_DATA_KEY, uint64(body.Offset)) - case btrfsitem.FileExtent: + case *btrfsitem.FileExtent: o.wantOff(ctx, "containing Inode", treeID, item.Key.ObjectID, @@ -194,19 +194,19 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, default: o.fsErr(ctx, fmt.Errorf("FileExtent: unexpected body.Type=%v", body.Type)) } - case btrfsitem.FreeSpaceBitmap: + case *btrfsitem.FreeSpaceBitmap: o.wantOff(ctx, "FreeSpaceInfo", treeID, item.Key.ObjectID, btrfsitem.FREE_SPACE_INFO_KEY, item.Key.Offset) - case btrfsitem.FreeSpaceHeader: + case *btrfsitem.FreeSpaceHeader: o.wantOff(ctx, ".Location", treeID, body.Location.ObjectID, body.Location.ItemType, body.Location.Offset) - case btrfsitem.FreeSpaceInfo: + case *btrfsitem.FreeSpaceInfo: if body.Flags.Has(btrfsitem.FREE_SPACE_USING_BITMAPS) { o.wantOff(ctx, "FreeSpaceBitmap", treeID, @@ -214,7 +214,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, btrfsitem.FREE_SPACE_BITMAP_KEY, item.Key.Offset) } - case btrfsitem.Inode: + case *btrfsitem.Inode: o.want(ctx, "backrefs", treeID, // TODO: validate the number of these against body.NLink item.Key.ObjectID, @@ -227,7 +227,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, body.BlockGroup, btrfsitem.BLOCK_GROUP_ITEM_KEY) } - case btrfsitem.InodeRefs: + case *btrfsitem.InodeRefs: o.wantOff(ctx, "child Inode", treeID, item.Key.ObjectID, @@ -238,7 +238,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, btrfsprim.ObjID(item.Key.Offset), btrfsitem.INODE_ITEM_KEY, 0) - for _, ref := range body { + for _, ref := range body.Refs { o.wantOff(ctx, "DIR_ITEM", treeID, btrfsprim.ObjID(item.Key.Offset), @@ -250,12 +250,12 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, btrfsitem.DIR_INDEX_KEY, uint64(ref.Index)) } - case btrfsitem.Metadata: + case *btrfsitem.Metadata: for i, ref := range body.Refs { switch refBody := ref.Body.(type) { case nil: // nothing - case btrfsitem.ExtentDataRef: + case *btrfsitem.ExtentDataRef: o.wantOff(ctx, "referencing INode", refBody.Root, refBody.ObjectID, @@ -266,7 +266,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, refBody.ObjectID, btrfsitem.EXTENT_DATA_KEY, uint64(refBody.Offset)) - case btrfsitem.SharedDataRef: + case *btrfsitem.SharedDataRef: // nothing default: // This is a panic because the item decoder should not emit a new @@ -274,7 +274,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, panic(fmt.Errorf("should not happen: Metadata: unexpected .Refs[%d].Body type %T", i, refBody)) } } - case btrfsitem.Root: + case *btrfsitem.Root: if body.RootDirID != 0 { o.wantOff(ctx, "root directory", item.Key.ObjectID, @@ -298,7 +298,7 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, key.ItemType, key.Offset) } - case btrfsitem.RootRef: + case *btrfsitem.RootRef: var otherType btrfsprim.ItemType var parent, child btrfsprim.ObjID switch item.Key.ItemType { @@ -347,17 +347,17 @@ func handleItem(o rebuildCallbacks, ctx context.Context, treeID btrfsprim.ObjID, treeID, child, btrfsitem.ROOT_ITEM_KEY) - case btrfsitem.SharedDataRef: + case *btrfsitem.SharedDataRef: o.want(ctx, "Extent", btrfsprim.EXTENT_TREE_OBJECTID, item.Key.ObjectID, btrfsitem.EXTENT_ITEM_KEY) - case btrfsitem.UUIDMap: + case *btrfsitem.UUIDMap: o.want(ctx, "subvolume Root", btrfsprim.ROOT_TREE_OBJECTID, body.ObjID, btrfsitem.ROOT_ITEM_KEY) - case btrfsitem.Error: + case *btrfsitem.Error: o.fsErr(ctx, fmt.Errorf("error decoding item: %w", body.Err)) default: // This is a panic because the item decoder should not emit new types without this diff --git a/lib/btrfsprogs/btrfsinspect/scandevices.go b/lib/btrfsprogs/btrfsinspect/scandevices.go index 9b8360c..91b5136 100644 --- a/lib/btrfsprogs/btrfsinspect/scandevices.go +++ b/lib/btrfsprogs/btrfsinspect/scandevices.go @@ -183,14 +183,14 @@ func ScanOneDevice(ctx context.Context, dev *btrfs.Device, sb btrfstree.Superblo switch item.Key.ItemType { case btrfsitem.CHUNK_ITEM_KEY: switch itemBody := item.Body.(type) { - case btrfsitem.Chunk: + case *btrfsitem.Chunk: dlog.Tracef(ctx, "node@%v: item %v: found chunk", nodeRef.Addr, i) result.FoundChunks = append(result.FoundChunks, btrfstree.SysChunk{ Key: item.Key, - Chunk: itemBody, + Chunk: *itemBody, }) - case btrfsitem.Error: + case *btrfsitem.Error: dlog.Errorf(ctx, "node@%v: item %v: error: malformed CHUNK_ITEM: %v", nodeRef.Addr, i, itemBody.Err) default: @@ -198,14 +198,14 @@ func ScanOneDevice(ctx context.Context, dev *btrfs.Device, sb btrfstree.Superblo } case btrfsitem.BLOCK_GROUP_ITEM_KEY: switch itemBody := item.Body.(type) { - case btrfsitem.BlockGroup: + case *btrfsitem.BlockGroup: dlog.Tracef(ctx, "node@%v: item %v: found block group", nodeRef.Addr, i) result.FoundBlockGroups = append(result.FoundBlockGroups, SysBlockGroup{ Key: item.Key, - BG: itemBody, + BG: *itemBody, }) - case btrfsitem.Error: + case *btrfsitem.Error: dlog.Errorf(ctx, "node@%v: item %v: error: malformed BLOCK_GROUP_ITEM: %v", nodeRef.Addr, i, itemBody.Err) default: @@ -213,14 +213,14 @@ func ScanOneDevice(ctx context.Context, dev *btrfs.Device, sb btrfstree.Superblo } case btrfsitem.DEV_EXTENT_KEY: switch itemBody := item.Body.(type) { - case btrfsitem.DevExtent: + case *btrfsitem.DevExtent: dlog.Tracef(ctx, "node@%v: item %v: found dev extent", nodeRef.Addr, i) result.FoundDevExtents = append(result.FoundDevExtents, SysDevExtent{ Key: item.Key, - DevExt: itemBody, + DevExt: *itemBody, }) - case btrfsitem.Error: + case *btrfsitem.Error: dlog.Errorf(ctx, "node@%v: item %v: error: malformed DEV_EXTENT: %v", nodeRef.Addr, i, itemBody.Err) default: @@ -228,14 +228,14 @@ func ScanOneDevice(ctx context.Context, dev *btrfs.Device, sb btrfstree.Superblo } case btrfsitem.EXTENT_CSUM_KEY: switch itemBody := item.Body.(type) { - case btrfsitem.ExtentCSum: + case *btrfsitem.ExtentCSum: dlog.Tracef(ctx, "node@%v: item %v: found csums", nodeRef.Addr, i) result.FoundExtentCSums = append(result.FoundExtentCSums, SysExtentCSum{ Generation: nodeRef.Data.Head.Generation, - Sums: itemBody, + Sums: *itemBody, }) - case btrfsitem.Error: + case *btrfsitem.Error: dlog.Errorf(ctx, "node@%v: item %v: error: malformed is EXTENT_CSUM: %v", nodeRef.Addr, i, itemBody.Err) default: |