summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-07-12 17:01:13 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-07-12 17:01:13 -0600
commitbba3428e8f034802b4b5ceb772bde1285a65ee50 (patch)
tree7b56b8241385c4474c232ccb584bf07089e47e92
parent54ba669b644f13c158fcbbde76943543eaf66e0a (diff)
Don't include the offset and size in btrfs.Item
-rw-r--r--cmd/btrfs-fsck/pass1.go22
-rw-r--r--cmd/btrfs-rec/inspect_lsfiles.go12
-rw-r--r--cmd/btrfs-rec/inspect_lstrees.go2
-rw-r--r--lib/btrfs/io2_lv.go4
-rw-r--r--lib/btrfs/io3_btree.go6
-rw-r--r--lib/btrfs/io4_fs.go20
-rw-r--r--lib/btrfs/types_node.go28
-rw-r--r--lib/btrfsprogs/btrfsinspect/print_tree.go38
-rw-r--r--lib/btrfsprogs/btrfsinspect/recoverchunks.go8
-rw-r--r--lib/btrfsprogs/btrfsutil/walk.go6
10 files changed, 76 insertions, 70 deletions
diff --git a/cmd/btrfs-fsck/pass1.go b/cmd/btrfs-fsck/pass1.go
index c75e066..e8398f9 100644
--- a/cmd/btrfs-fsck/pass1.go
+++ b/cmd/btrfs-fsck/pass1.go
@@ -92,12 +92,10 @@ func pass1WriteReconstructedChunks(fs *btrfs.FS) {
for _, dev := range fs.LV.PhysicalVolumes() {
superblock, _ := dev.Superblock()
reconstructedNode.Data.BodyLeaf = append(reconstructedNode.Data.BodyLeaf, btrfs.Item{
- Head: btrfs.ItemHeader{
- Key: btrfs.Key{
- ObjectID: btrfs.DEV_ITEMS_OBJECTID,
- ItemType: btrfsitem.DEV_ITEM_KEY,
- Offset: uint64(superblock.Data.DevItem.DevID),
- },
+ Key: btrfs.Key{
+ ObjectID: btrfs.DEV_ITEMS_OBJECTID,
+ ItemType: btrfsitem.DEV_ITEM_KEY,
+ Offset: uint64(superblock.Data.DevItem.DevID),
},
Body: superblock.Data.DevItem,
})
@@ -105,14 +103,12 @@ func pass1WriteReconstructedChunks(fs *btrfs.FS) {
for _, mapping := range fs.LV.Mappings() {
chunkIdx := len(reconstructedNode.Data.BodyLeaf) - 1
- if len(reconstructedNode.Data.BodyLeaf) == 0 || reconstructedNode.Data.BodyLeaf[chunkIdx].Head.Key.Offset != uint64(mapping.LAddr) {
+ if len(reconstructedNode.Data.BodyLeaf) == 0 || reconstructedNode.Data.BodyLeaf[chunkIdx].Key.Offset != uint64(mapping.LAddr) {
reconstructedNode.Data.BodyLeaf = append(reconstructedNode.Data.BodyLeaf, btrfs.Item{
- Head: btrfs.ItemHeader{
- Key: btrfs.Key{
- ObjectID: btrfs.FIRST_CHUNK_TREE_OBJECTID,
- ItemType: btrfsitem.CHUNK_ITEM_KEY,
- Offset: uint64(mapping.LAddr),
- },
+ Key: btrfs.Key{
+ ObjectID: btrfs.FIRST_CHUNK_TREE_OBJECTID,
+ ItemType: btrfsitem.CHUNK_ITEM_KEY,
+ Offset: uint64(mapping.LAddr),
},
Body: btrfsitem.Chunk{
Head: btrfsitem.ChunkHeader{
diff --git a/cmd/btrfs-rec/inspect_lsfiles.go b/cmd/btrfs-rec/inspect_lsfiles.go
index 2da31aa..a859be3 100644
--- a/cmd/btrfs-rec/inspect_lsfiles.go
+++ b/cmd/btrfs-rec/inspect_lsfiles.go
@@ -51,7 +51,7 @@ func printSubvol(fs *btrfs.FS, prefix0, prefix1, name string, key btrfs.Key) {
}
rootBody := root.Body.(btrfsitem.Root)
- printDir(fs, root.Head.Key.ObjectID, prefix0, prefix1, name, rootBody.RootDirID)
+ printDir(fs, root.Key.ObjectID, prefix0, prefix1, name, rootBody.RootDirID)
}
func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string, dirInode btrfs.ObjID) {
@@ -67,7 +67,7 @@ func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string
membersByIndex := make(map[uint64]btrfsitem.DirEntry)
membersByNameHash := make(map[uint64]btrfsitem.DirEntry)
for _, item := range items {
- switch item.Head.Key.ItemType {
+ switch item.Key.ItemType {
case btrfsitem.INODE_ITEM_KEY:
if dirInodeDatOK {
if !reflect.DeepEqual(dirInodeDat, item.Body.(btrfsitem.Inode)) {
@@ -82,9 +82,9 @@ func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string
case btrfsitem.DIR_ITEM_KEY:
entry := item.Body.(btrfsitem.DirEntry)
namehash := btrfsitem.NameHash(entry.Name)
- if namehash != item.Head.Key.Offset {
+ if namehash != item.Key.Offset {
errs = append(errs, fmt.Errorf("read dir: direntry crc32c mismatch: key=%#x crc32c(%q)=%#x",
- item.Head.Key.Offset, entry.Name, namehash))
+ item.Key.Offset, entry.Name, namehash))
continue
}
if other, exists := membersByNameHash[namehash]; exists {
@@ -101,7 +101,7 @@ func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string
}
membersByNameHash[btrfsitem.NameHash(entry.Name)] = entry
case btrfsitem.DIR_INDEX_KEY:
- index := item.Head.Key.Offset
+ index := item.Key.Offset
entry := item.Body.(btrfsitem.DirEntry)
if other, exists := membersByIndex[index]; exists {
if !reflect.DeepEqual(entry, other) {
@@ -112,7 +112,7 @@ func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string
membersByIndex[index] = entry
//case btrfsitem.XATTR_ITEM_KEY:
default:
- errs = append(errs, fmt.Errorf("TODO: handle item type %v", item.Head.Key.ItemType))
+ errs = append(errs, fmt.Errorf("TODO: handle item type %v", item.Key.ItemType))
}
}
fmt.Printf("%s%q\t[ino=%d",
diff --git a/cmd/btrfs-rec/inspect_lstrees.go b/cmd/btrfs-rec/inspect_lstrees.go
index e308b20..b55acf0 100644
--- a/cmd/btrfs-rec/inspect_lstrees.go
+++ b/cmd/btrfs-rec/inspect_lstrees.go
@@ -40,7 +40,7 @@ func init() {
},
TreeWalkHandler: btrfs.TreeWalkHandler{
Item: func(_ btrfs.TreePath, item btrfs.Item) error {
- typ := item.Head.Key.ItemType
+ typ := item.Key.ItemType
treeItemCnt[typ] = treeItemCnt[typ] + 1
return nil
},
diff --git a/lib/btrfs/io2_lv.go b/lib/btrfs/io2_lv.go
index aac902b..b36796b 100644
--- a/lib/btrfs/io2_lv.go
+++ b/lib/btrfs/io2_lv.go
@@ -166,10 +166,10 @@ func (fs *FS) initDev(sb *util.Ref[btrfsvol.PhysicalAddr, Superblock]) error {
},
TreeWalkHandler{
Item: func(_ TreePath, item Item) error {
- if item.Head.Key.ItemType != btrfsitem.CHUNK_ITEM_KEY {
+ if item.Key.ItemType != btrfsitem.CHUNK_ITEM_KEY {
return nil
}
- for _, mapping := range item.Body.(btrfsitem.Chunk).Mappings(item.Head.Key) {
+ for _, mapping := range item.Body.(btrfsitem.Chunk).Mappings(item.Key) {
if err := fs.LV.AddMapping(mapping); err != nil {
return err
}
diff --git a/lib/btrfs/io3_btree.go b/lib/btrfs/io3_btree.go
index 14419fe..759e378 100644
--- a/lib/btrfs/io3_btree.go
+++ b/lib/btrfs/io3_btree.go
@@ -367,7 +367,7 @@ func (fs *FS) treeSearch(treeRoot treeRoot, fn func(Key) int) (TreePath, *util.R
end := len(node.Data.BodyLeaf)
for beg < end {
midpoint := (beg + end) / 2
- direction := fn(node.Data.BodyLeaf[midpoint].Head.Key)
+ direction := fn(node.Data.BodyLeaf[midpoint].Key)
switch {
case direction < 0:
end = midpoint
@@ -551,7 +551,7 @@ func (fs *FS) TreeSearchAll(treeID ObjID, fn func(Key) int) ([]Item, error) {
break
}
prevItem := prevNode.Data.BodyLeaf[prevPath.Nodes[len(prevPath.Nodes)-1].ItemIdx]
- if fn(prevItem.Head.Key) != 0 {
+ if fn(prevItem.Key) != 0 {
break
}
ret = append(ret, prevItem)
@@ -567,7 +567,7 @@ func (fs *FS) TreeSearchAll(treeID ObjID, fn func(Key) int) ([]Item, error) {
break
}
nextItem := nextNode.Data.BodyLeaf[nextPath.Nodes[len(nextPath.Nodes)-1].ItemIdx]
- if fn(nextItem.Head.Key) != 0 {
+ if fn(nextItem.Key) != 0 {
break
}
ret = append(ret, nextItem)
diff --git a/lib/btrfs/io4_fs.go b/lib/btrfs/io4_fs.go
index 3099aca..02f1969 100644
--- a/lib/btrfs/io4_fs.go
+++ b/lib/btrfs/io4_fs.go
@@ -142,7 +142,7 @@ func (sv *Subvolume) LoadFullInode(inode ObjID) (*FullInode, error) {
}
}
for _, item := range items {
- switch item.Head.Key.ItemType {
+ switch item.Key.ItemType {
case btrfsitem.INODE_ITEM_KEY:
itemBody := item.Body.(btrfsitem.Inode)
if val.InodeItem != nil {
@@ -187,10 +187,10 @@ func (ret *Dir) populate() {
ret.ChildrenByName = make(map[string]btrfsitem.DirEntry)
ret.ChildrenByIndex = make(map[uint64]btrfsitem.DirEntry)
for _, item := range ret.OtherItems {
- switch item.Head.Key.ItemType {
+ switch item.Key.ItemType {
case btrfsitem.INODE_REF_KEY:
ref := InodeRef{
- Inode: ObjID(item.Head.Key.Offset),
+ Inode: ObjID(item.Key.Offset),
InodeRef: item.Body.(btrfsitem.InodeRef),
}
if ret.DotDot != nil {
@@ -203,9 +203,9 @@ func (ret *Dir) populate() {
case btrfsitem.DIR_ITEM_KEY:
entry := item.Body.(btrfsitem.DirEntry)
namehash := btrfsitem.NameHash(entry.Name)
- if namehash != item.Head.Key.Offset {
+ if namehash != item.Key.Offset {
ret.Errs = append(ret.Errs, fmt.Errorf("direntry crc32c mismatch: key=%#x crc32c(%q)=%#x",
- item.Head.Key.Offset, entry.Name, namehash))
+ item.Key.Offset, entry.Name, namehash))
continue
}
if other, exists := ret.ChildrenByName[string(entry.Name)]; exists {
@@ -216,7 +216,7 @@ func (ret *Dir) populate() {
}
ret.ChildrenByName[string(entry.Name)] = entry
case btrfsitem.DIR_INDEX_KEY:
- index := item.Head.Key.Offset
+ index := item.Key.Offset
entry := item.Body.(btrfsitem.DirEntry)
if other, exists := ret.ChildrenByIndex[index]; exists {
if !reflect.DeepEqual(entry, other) {
@@ -227,7 +227,7 @@ func (ret *Dir) populate() {
ret.ChildrenByIndex[index] = entry
//case btrfsitem.XATTR_ITEM_KEY:
default:
- panic(fmt.Errorf("TODO: handle item type %v", item.Head.Key.ItemType))
+ panic(fmt.Errorf("TODO: handle item type %v", item.Key.ItemType))
}
}
entriesWithIndexes := make(map[string]struct{})
@@ -297,16 +297,16 @@ func (sv *Subvolume) LoadFile(inode ObjID) (*File, error) {
func (ret *File) populate() {
for _, item := range ret.OtherItems {
- switch item.Head.Key.ItemType {
+ switch item.Key.ItemType {
case btrfsitem.INODE_REF_KEY:
// TODO
case btrfsitem.EXTENT_DATA_KEY:
ret.Extents = append(ret.Extents, FileExtent{
- OffsetWithinFile: int64(item.Head.Key.Offset),
+ OffsetWithinFile: int64(item.Key.Offset),
FileExtent: item.Body.(btrfsitem.FileExtent),
})
default:
- panic(fmt.Errorf("TODO: handle item type %v", item.Head.Key.ItemType))
+ panic(fmt.Errorf("TODO: handle item type %v", item.Key.ItemType))
}
}
diff --git a/lib/btrfs/types_node.go b/lib/btrfs/types_node.go
index f425460..34151c9 100644
--- a/lib/btrfs/types_node.go
+++ b/lib/btrfs/types_node.go
@@ -246,7 +246,7 @@ func (node *Node) marshalInternalTo(bodyBuf []byte) error {
// Node: "leaf" ////////////////////////////////////////////////////////////////////////////////////
type Item struct {
- Head ItemHeader
+ Key Key
Body btrfsitem.Item
}
@@ -261,9 +261,8 @@ func (node *Node) unmarshalLeaf(bodyBuf []byte) (int, error) {
head := 0
tail := len(bodyBuf)
for i := uint32(0); i < node.Head.NumItems; i++ {
- var item Item
-
- n, err := binstruct.Unmarshal(bodyBuf[head:], &item.Head)
+ var itemHead ItemHeader
+ n, err := binstruct.Unmarshal(bodyBuf[head:], &itemHead)
head += n
if err != nil {
return 0, fmt.Errorf("item %v: head: %w", i, err)
@@ -273,21 +272,23 @@ func (node *Node) unmarshalLeaf(bodyBuf []byte) (int, error) {
i, head, tail)
}
- dataOff := int(item.Head.DataOffset)
+ dataOff := int(itemHead.DataOffset)
if dataOff < head {
return 0, fmt.Errorf("item %v: body: beg_offset=%#x is in the head section (offset<%#x)",
i, dataOff, head)
}
- dataSize := int(item.Head.DataSize)
+ dataSize := int(itemHead.DataSize)
if dataOff+dataSize != tail {
return 0, fmt.Errorf("item %v: body: end_offset=%#x is not cur_tail=%#x)",
i, dataOff+dataSize, tail)
}
tail = dataOff
dataBuf := bodyBuf[dataOff : dataOff+dataSize]
- item.Body = btrfsitem.UnmarshalItem(item.Head.Key, node.ChecksumType, dataBuf)
- node.BodyLeaf = append(node.BodyLeaf, item)
+ node.BodyLeaf = append(node.BodyLeaf, Item{
+ Key: itemHead.Key,
+ Body: btrfsitem.UnmarshalItem(itemHead.Key, node.ChecksumType, dataBuf),
+ })
}
node.Padding = bodyBuf[head:tail]
@@ -302,9 +303,11 @@ func (node *Node) marshalLeafTo(bodyBuf []byte) error {
if err != nil {
return fmt.Errorf("item %v: body: %w", i, err)
}
- item.Head.DataSize = uint32(len(itemBodyBuf))
- item.Head.DataOffset = uint32(tail - len(itemBodyBuf))
- itemHeadBuf, err := binstruct.Marshal(item.Head)
+ itemHeadBuf, err := binstruct.Marshal(ItemHeader{
+ Key: item.Key,
+ DataSize: uint32(len(itemBodyBuf)),
+ DataOffset: uint32(tail - len(itemBodyBuf)),
+ })
if err != nil {
return fmt.Errorf("item %v: head: %w", i, err)
}
@@ -334,7 +337,8 @@ func (node *Node) LeafFreeSpace() uint32 {
freeSpace -= uint32(binstruct.StaticSize(NodeHeader{}))
for _, item := range node.BodyLeaf {
freeSpace -= uint32(binstruct.StaticSize(ItemHeader{}))
- freeSpace -= item.Head.DataSize
+ bs, _ := binstruct.Marshal(item.Body)
+ freeSpace -= uint32(len(bs))
}
return freeSpace
}
diff --git a/lib/btrfsprogs/btrfsinspect/print_tree.go b/lib/btrfsprogs/btrfsinspect/print_tree.go
index 2bb6762..78a9df6 100644
--- a/lib/btrfsprogs/btrfsinspect/print_tree.go
+++ b/lib/btrfsprogs/btrfsinspect/print_tree.go
@@ -12,6 +12,7 @@ import (
"github.com/datawire/dlib/dlog"
+ "git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfssum"
@@ -49,7 +50,7 @@ func DumpTrees(ctx context.Context, out io.Writer, fs *btrfs.FS) {
},
btrfs.TreeWalkHandler{
Item: func(_ btrfs.TreePath, item btrfs.Item) error {
- if item.Head.Key.ItemType != btrfsitem.ROOT_ITEM_KEY {
+ if item.Key.ItemType != btrfsitem.ROOT_ITEM_KEY {
return nil
}
treeName, ok := map[btrfs.ObjID]string{
@@ -71,12 +72,12 @@ func DumpTrees(ctx context.Context, out io.Writer, fs *btrfs.FS) {
btrfs.FREE_SPACE_TREE_OBJECTID: "free space",
btrfs.MULTIPLE_OBJECTIDS: "multiple",
btrfs.BLOCK_GROUP_TREE_OBJECTID: "block group",
- }[item.Head.Key.ObjectID]
+ }[item.Key.ObjectID]
if !ok {
treeName = "file"
}
- fmt.Fprintf(out, "%v tree %v \n", treeName, fmtKey(item.Head.Key))
- printTree(ctx, out, fs, item.Head.Key.ObjectID)
+ fmt.Fprintf(out, "%v tree %v \n", treeName, fmtKey(item.Key))
+ printTree(ctx, out, fs, item.Key.ObjectID)
return nil
},
},
@@ -90,6 +91,7 @@ func DumpTrees(ctx context.Context, out io.Writer, fs *btrfs.FS) {
// kernel-shared/print-tree.c:btrfs_print_tree() and
// kernel-shared/print-tree.c:btrfs_print_leaf()
func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.ObjID) {
+ var itemOffset uint32
fs.TreeWalk(
treeID,
func(err *btrfs.TreeError) {
@@ -98,6 +100,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.Ob
btrfs.TreeWalkHandler{
Node: func(path btrfs.TreePath, nodeRef *util.Ref[btrfsvol.LogicalAddr, btrfs.Node]) error {
printHeaderInfo(out, nodeRef.Data)
+ itemOffset = nodeRef.Data.Size - uint32(binstruct.StaticSize(btrfs.NodeHeader{}))
return nil
},
PreKeyPointer: func(_ btrfs.TreePath, item btrfs.KeyPointer) error {
@@ -109,11 +112,14 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.Ob
},
Item: func(path btrfs.TreePath, item btrfs.Item) error {
i := path.Nodes[len(path.Nodes)-1].ItemIdx
+ bs, _ := binstruct.Marshal(item.Body)
+ itemSize := uint32(len(bs))
+ itemOffset -= itemSize
fmt.Fprintf(out, "\titem %v %v itemoff %v itemsize %v\n",
i,
- fmtKey(item.Head.Key),
- item.Head.DataOffset,
- item.Head.DataSize)
+ fmtKey(item.Key),
+ itemOffset,
+ itemSize)
switch body := item.Body.(type) {
case btrfsitem.FreeSpaceHeader:
fmt.Fprintf(out, "\t\tlocation %v\n", fmtKey(body.Location))
@@ -169,13 +175,13 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.Ob
}
case btrfsitem.RootRef:
var tag string
- switch item.Head.Key.ItemType {
+ switch item.Key.ItemType {
case btrfsitem.ROOT_REF_KEY:
tag = "ref"
case btrfsitem.ROOT_BACKREF_KEY:
tag = "backref"
default:
- tag = fmt.Sprintf("(error: unhandled RootRef item type: %v)", item.Head.Key.ItemType)
+ tag = fmt.Sprintf("(error: unhandled RootRef item type: %v)", item.Key.ItemType)
}
fmt.Fprintf(out, "\t\troot %v key dirid %v sequence %v name %s\n",
tag, body.DirID, body.Sequence, body.Name)
@@ -190,7 +196,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.Ob
case btrfsitem.Metadata:
fmt.Fprintf(out, "\t\trefs %v gen %v flags %v\n",
body.Head.Refs, body.Head.Generation, body.Head.Flags)
- fmt.Fprintf(out, "\t\ttree block skinny level %v\n", item.Head.Key.Offset)
+ fmt.Fprintf(out, "\t\ttree block skinny level %v\n", item.Key.Offset)
printExtentInlineRefs(out, body.Refs)
//case btrfsitem.EXTENT_DATA_REF_KEY:
// // TODO
@@ -200,7 +206,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.Ob
sb, _ := fs.Superblock()
sectorSize := btrfsvol.AddrDelta(sb.Data.SectorSize)
- start := btrfsvol.LogicalAddr(item.Head.Key.Offset)
+ start := btrfsvol.LogicalAddr(item.Key.Offset)
itemSize := btrfsvol.AddrDelta(len(body.Sums)) * sectorSize
fmt.Fprintf(out, "\t\trange start %d end %d length %d",
start, start.Add(itemSize), itemSize)
@@ -298,8 +304,8 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.Ob
// // TODO
case btrfsitem.DevStats:
fmt.Fprintf(out, "\t\tpersistent item objectid %v offset %v\n",
- item.Head.Key.ObjectID.Format(item.Head.Key.ItemType), item.Head.Key.Offset)
- switch item.Head.Key.ObjectID {
+ item.Key.ObjectID.Format(item.Key.ItemType), item.Key.Offset)
+ switch item.Key.ObjectID {
case btrfs.DEV_STATS_OBJECTID:
fmt.Fprintf(out, "\t\tdevice stats\n")
fmt.Fprintf(out, "\t\twrite_errs %v read_errs %v flush_errs %v corruption_errs %v generation %v\n",
@@ -309,12 +315,12 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.Ob
body.Values[btrfsitem.DEV_STAT_CORRUPTION_ERRS],
body.Values[btrfsitem.DEV_STAT_GENERATION_ERRS])
default:
- fmt.Fprintf(out, "\t\tunknown persistent item objectid %v\n", item.Head.Key.ObjectID)
+ fmt.Fprintf(out, "\t\tunknown persistent item objectid %v\n", item.Key.ObjectID)
}
//case btrfsitem.TEMPORARY_ITEM_KEY:
// // TODO
case btrfsitem.Empty:
- switch item.Head.Key.ItemType {
+ switch item.Key.ItemType {
case btrfsitem.ORPHAN_ITEM_KEY: // 48
fmt.Fprintf(out, "\t\torphan item\n")
case btrfsitem.TREE_BLOCK_REF_KEY: // 176
@@ -330,7 +336,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.Ob
//case btrfsitem.CSUM_ITEM_KEY:
// fmt.Fprintf(out, "\t\tcsum item\n")
default:
- fmt.Fprintf(out, "\t\t(error) unhandled empty item type: %v\n", item.Head.Key.ItemType)
+ fmt.Fprintf(out, "\t\t(error) unhandled empty item type: %v\n", item.Key.ItemType)
}
case btrfsitem.Error:
fmt.Fprintf(out, "\t\t(error) error item: %v\n", body.Err)
diff --git a/lib/btrfsprogs/btrfsinspect/recoverchunks.go b/lib/btrfsprogs/btrfsinspect/recoverchunks.go
index 354328e..aae46b0 100644
--- a/lib/btrfsprogs/btrfsinspect/recoverchunks.go
+++ b/lib/btrfsprogs/btrfsinspect/recoverchunks.go
@@ -164,7 +164,7 @@ func ScanOneDev(ctx context.Context, dev *btrfs.Device, superblock btrfs.Superbl
}
result.FoundNodes[nodeRef.Data.Head.Addr] = append(result.FoundNodes[nodeRef.Data.Head.Addr], nodeRef.Addr)
for i, item := range nodeRef.Data.BodyLeaf {
- switch item.Head.Key.ItemType {
+ switch item.Key.ItemType {
case btrfsitem.CHUNK_ITEM_KEY:
chunk, ok := item.Body.(btrfsitem.Chunk)
if !ok {
@@ -175,7 +175,7 @@ func ScanOneDev(ctx context.Context, dev *btrfs.Device, superblock btrfs.Superbl
//dlog.Tracef(ctx, "... dev[%q] node@%v: item %v: found chunk",
// dev.Name(), nodeRef.Addr, i)
result.FoundChunks = append(result.FoundChunks, btrfs.SysChunk{
- Key: item.Head.Key,
+ Key: item.Key,
Chunk: chunk,
})
case btrfsitem.BLOCK_GROUP_ITEM_KEY:
@@ -188,7 +188,7 @@ func ScanOneDev(ctx context.Context, dev *btrfs.Device, superblock btrfs.Superbl
//dlog.Tracef(ctx, "... dev[%q] node@%v: item %v: found block group",
// dev.Name(), nodeRef.Addr, i)
result.FoundBlockGroups = append(result.FoundBlockGroups, SysBlockGroup{
- Key: item.Head.Key,
+ Key: item.Key,
BG: bg,
})
case btrfsitem.DEV_EXTENT_KEY:
@@ -201,7 +201,7 @@ func ScanOneDev(ctx context.Context, dev *btrfs.Device, superblock btrfs.Superbl
//dlog.Tracef(ctx, "... dev[%q] node@%v: item %v: found dev extent",
// dev.Name(), nodeRef.Addr, i)
result.FoundDevExtents = append(result.FoundDevExtents, SysDevExtent{
- Key: item.Head.Key,
+ Key: item.Key,
DevExt: devext,
})
}
diff --git a/lib/btrfsprogs/btrfsutil/walk.go b/lib/btrfsprogs/btrfsutil/walk.go
index d2322b2..d2b6367 100644
--- a/lib/btrfsprogs/btrfsutil/walk.go
+++ b/lib/btrfsprogs/btrfsutil/walk.go
@@ -60,14 +60,14 @@ func WalkAllTrees(fs *btrfs.FS, cbs WalkAllTreesHandler) {
}
origItem := cbs.Item
cbs.Item = func(path btrfs.TreePath, item btrfs.Item) error {
- if item.Head.Key.ItemType == btrfsitem.ROOT_ITEM_KEY {
+ if item.Key.ItemType == btrfsitem.ROOT_ITEM_KEY {
trees = append(trees, struct {
Name string
ID btrfs.ObjID
}{
Name: fmt.Sprintf("tree %v (via %v %v)",
- item.Head.Key.ObjectID.Format(0), treeName, path),
- ID: item.Head.Key.ObjectID,
+ item.Key.ObjectID.Format(0), treeName, path),
+ ID: item.Key.ObjectID,
})
}
if origItem != nil {