diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-03 11:21:53 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-05 19:48:17 -0700 |
commit | d696784667e8dd01fee62145d031fd56285d48ae (patch) | |
tree | 9bb269f4643ad34015443f7ec3b79b57675a79dd /lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go | |
parent | df62eb5d4c92756914ce57a1b6219b39876331f6 (diff) |
rebuildnodes: Track inode flags, to avoid later i/o
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go')
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go index 63a0d16..fbbda26 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go @@ -911,27 +911,28 @@ func (o *rebuilder) wantCSum(ctx context.Context, reason string, inodeTree, inod o.enqueueRetry() return } - inodeBody, ok := o.rebuilt.Tree(inodeCtx, inodeKey.TreeID).ReadItem(inodeCtx, inodeKey.Key) + inodePtr, ok := o.rebuilt.Tree(inodeCtx, inodeKey.TreeID).Items(inodeCtx).Load(inodeKey.Key) if !ok { - o.ioErr(inodeCtx, fmt.Errorf("could not read previously read item: %v", inodeKey)) + panic(fmt.Errorf("should not happen: could not load key: %v", inodeKey)) } - switch inodeBody := inodeBody.(type) { - case btrfsitem.Inode: - if inodeBody.Flags.Has(btrfsitem.INODE_NODATASUM) { - return - } - beg = roundDown(beg, btrfssum.BlockSize) - end = roundUp(end, btrfssum.BlockSize) - const treeID = btrfsprim.CSUM_TREE_OBJECTID - o._wantRange(ctx, treeID, btrfsprim.EXTENT_CSUM_OBJECTID, btrfsprim.EXTENT_CSUM_KEY, - uint64(beg), uint64(end)) - case btrfsitem.Error: - o.fsErr(inodeCtx, fmt.Errorf("error decoding item: %v: %w", inodeKey, inodeBody.Err)) - default: - // This is a panic because the item decoder should not emit INODE_ITEM items as anything but - // btrfsitem.Inode or btrfsitem.Error without this code also being updated. - panic(fmt.Errorf("should not happen: INODE_ITEM item has unexpected type: %T", inodeBody)) + inodeFlags, ok := o.keyIO.Flags[inodePtr] + if !ok { + panic(fmt.Errorf("should not happen: INODE_ITEM did not have flags recorded")) + } + if inodeFlags.Err != nil { + o.fsErr(inodeCtx, inodeFlags.Err) + return } + + if inodeFlags.NoDataSum { + return + } + + beg = roundDown(beg, btrfssum.BlockSize) + end = roundUp(end, btrfssum.BlockSize) + const treeID = btrfsprim.CSUM_TREE_OBJECTID + o._wantRange(ctx, treeID, btrfsprim.EXTENT_CSUM_OBJECTID, btrfsprim.EXTENT_CSUM_KEY, + uint64(beg), uint64(end)) } // wantFileExt implements rebuildCallbacks. |