summaryrefslogtreecommitdiff
path: root/lib/btrfs/io2_lv.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/btrfs/io2_lv.go')
-rw-r--r--lib/btrfs/io2_lv.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/btrfs/io2_lv.go b/lib/btrfs/io2_lv.go
index 5580285..3f82cd0 100644
--- a/lib/btrfs/io2_lv.go
+++ b/lib/btrfs/io2_lv.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
@@ -171,10 +171,20 @@ func (fs *FS) initDev(ctx context.Context, sb btrfstree.Superblock) error {
if item.Key.ItemType != btrfsitem.CHUNK_ITEM_KEY {
return nil
}
- for _, mapping := range item.Body.(btrfsitem.Chunk).Mappings(item.Key) {
- if err := fs.LV.AddMapping(mapping); err != nil {
- return err
+ switch itemBody := item.Body.(type) {
+ case btrfsitem.Chunk:
+ for _, mapping := range itemBody.Mappings(item.Key) {
+ if err := fs.LV.AddMapping(mapping); err != nil {
+ return err
+ }
}
+ case btrfsitem.Error:
+ // do nothing
+ default:
+ // This is a panic because the item decoder should not emit CHUNK_ITEM items as
+ // anything but btrfsitem.Chunk or btrfsitem.Error without this code also being
+ // updated.
+ panic(fmt.Errorf("should not happen: CHUNK_ITEM has unexpected item type: %T", itemBody))
}
return nil
},