diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-12 22:36:30 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-12 22:36:30 -0600 |
commit | ec6929e40ca17cacb6a4ba23508d2b724b9201c1 (patch) | |
tree | df5180c4880fe88cfd5c18996da327af07d17900 /lib/btrfs | |
parent | d250398e68fae70bd765a7f90389b58a4eeb4ee2 (diff) |
Don't have .Superblock() return a reference
Diffstat (limited to 'lib/btrfs')
-rw-r--r-- | lib/btrfs/io1_pv.go | 8 | ||||
-rw-r--r-- | lib/btrfs/io2_lv.go | 20 | ||||
-rw-r--r-- | lib/btrfs/io3_btree.go | 24 | ||||
-rw-r--r-- | lib/btrfs/types_node.go | 2 |
4 files changed, 27 insertions, 27 deletions
diff --git a/lib/btrfs/io1_pv.go b/lib/btrfs/io1_pv.go index 4a69e12..44a8d76 100644 --- a/lib/btrfs/io1_pv.go +++ b/lib/btrfs/io1_pv.go @@ -17,7 +17,7 @@ type Device struct { *os.File cacheSuperblocks []*util.Ref[btrfsvol.PhysicalAddr, Superblock] - cacheSuperblock *util.Ref[btrfsvol.PhysicalAddr, Superblock] + cacheSuperblock *Superblock } var _ util.File[btrfsvol.PhysicalAddr] = (*Device)(nil) @@ -75,7 +75,7 @@ func (dev *Device) Superblocks() ([]*util.Ref[btrfsvol.PhysicalAddr, Superblock] return ret, nil } -func (dev *Device) Superblock() (*util.Ref[btrfsvol.PhysicalAddr, Superblock], error) { +func (dev *Device) Superblock() (*Superblock, error) { if dev.cacheSuperblock != nil { return dev.cacheSuperblock, nil } @@ -95,6 +95,6 @@ func (dev *Device) Superblock() (*util.Ref[btrfsvol.PhysicalAddr, Superblock], e } } - dev.cacheSuperblock = sbs[0] - return sbs[0], nil + dev.cacheSuperblock = &sbs[0].Data + return &sbs[0].Data, nil } diff --git a/lib/btrfs/io2_lv.go b/lib/btrfs/io2_lv.go index b36796b..eee58d5 100644 --- a/lib/btrfs/io2_lv.go +++ b/lib/btrfs/io2_lv.go @@ -23,7 +23,7 @@ type FS struct { LV btrfsvol.LogicalVolume[*Device] cacheSuperblocks []*util.Ref[btrfsvol.PhysicalAddr, Superblock] - cacheSuperblock *util.Ref[btrfsvol.PhysicalAddr, Superblock] + cacheSuperblock *Superblock } var _ util.File[btrfsvol.LogicalAddr] = (*FS)(nil) @@ -33,12 +33,12 @@ func (fs *FS) AddDevice(ctx context.Context, dev *Device) error { if err != nil { return err } - if err := fs.LV.AddPhysicalVolume(sb.Data.DevItem.DevID, dev); err != nil { + if err := fs.LV.AddPhysicalVolume(sb.DevItem.DevID, dev); err != nil { return err } fs.cacheSuperblocks = nil fs.cacheSuperblock = nil - if err := fs.initDev(sb); err != nil { + if err := fs.initDev(*sb); err != nil { dlog.Errorf(ctx, "error: AddDevice: %q: %v", dev.Name(), err) } return nil @@ -52,7 +52,7 @@ func (fs *FS) Name() string { if err != nil { return fmt.Sprintf("fs_uuid=%v", "(unreadable)") } - name := fmt.Sprintf("fs_uuid=%v", sb.Data.FSUUID) + name := fmt.Sprintf("fs_uuid=%v", sb.FSUUID) fs.LV.SetName(name) return name } @@ -92,7 +92,7 @@ func (fs *FS) Superblocks() ([]*util.Ref[btrfsvol.PhysicalAddr, Superblock], err return ret, nil } -func (fs *FS) Superblock() (*util.Ref[btrfsvol.PhysicalAddr, Superblock], error) { +func (fs *FS) Superblock() (*Superblock, error) { if fs.cacheSuperblock != nil { return fs.cacheSuperblock, nil } @@ -129,8 +129,8 @@ func (fs *FS) Superblock() (*util.Ref[btrfsvol.PhysicalAddr, Superblock], error) } } - fs.cacheSuperblock = sbs[0] - return sbs[0], nil + fs.cacheSuperblock = &sbs[0].Data + return &sbs[0].Data, nil } func (fs *FS) ReInit() error { @@ -140,15 +140,15 @@ func (fs *FS) ReInit() error { if err != nil { return fmt.Errorf("file %q: %w", dev.Name(), err) } - if err := fs.initDev(sb); err != nil { + if err := fs.initDev(*sb); err != nil { return fmt.Errorf("file %q: %w", dev.Name(), err) } } return nil } -func (fs *FS) initDev(sb *util.Ref[btrfsvol.PhysicalAddr, Superblock]) error { - syschunks, err := sb.Data.ParseSysChunkArray() +func (fs *FS) initDev(sb Superblock) error { + syschunks, err := sb.ParseSysChunkArray() if err != nil { return err } diff --git a/lib/btrfs/io3_btree.go b/lib/btrfs/io3_btree.go index a02a857..4d2e556 100644 --- a/lib/btrfs/io3_btree.go +++ b/lib/btrfs/io3_btree.go @@ -146,30 +146,30 @@ func (fs *FS) lookupTree(treeID ObjID) (*treeRoot, error) { case ROOT_TREE_OBJECTID: return &treeRoot{ TreeID: treeID, - RootNode: sb.Data.RootTree, - Level: sb.Data.RootLevel, - Generation: sb.Data.Generation, // XXX: same generation as LOG_TREE? + RootNode: sb.RootTree, + Level: sb.RootLevel, + Generation: sb.Generation, // XXX: same generation as LOG_TREE? }, nil case CHUNK_TREE_OBJECTID: return &treeRoot{ TreeID: treeID, - RootNode: sb.Data.ChunkTree, - Level: sb.Data.ChunkLevel, - Generation: sb.Data.ChunkRootGeneration, + RootNode: sb.ChunkTree, + Level: sb.ChunkLevel, + Generation: sb.ChunkRootGeneration, }, nil case TREE_LOG_OBJECTID: return &treeRoot{ TreeID: treeID, - RootNode: sb.Data.LogTree, - Level: sb.Data.LogLevel, - Generation: sb.Data.Generation, // XXX: same generation as ROOT_TREE? + RootNode: sb.LogTree, + Level: sb.LogLevel, + Generation: sb.Generation, // XXX: same generation as ROOT_TREE? }, nil case BLOCK_GROUP_TREE_OBJECTID: return &treeRoot{ TreeID: treeID, - RootNode: sb.Data.BlockGroupRoot, - Level: sb.Data.BlockGroupRootLevel, - Generation: sb.Data.BlockGroupRootGeneration, + RootNode: sb.BlockGroupRoot, + Level: sb.BlockGroupRootLevel, + Generation: sb.BlockGroupRootGeneration, }, nil default: rootItem, err := fs.TreeSearch(ROOT_TREE_OBJECTID, func(key Key) int { diff --git a/lib/btrfs/types_node.go b/lib/btrfs/types_node.go index 34151c9..fc12a00 100644 --- a/lib/btrfs/types_node.go +++ b/lib/btrfs/types_node.go @@ -406,7 +406,7 @@ func (fs *FS) ReadNode(addr btrfsvol.LogicalAddr) (*util.Ref[btrfsvol.LogicalAdd return nil, fmt.Errorf("btrfs.FS.ReadNode: %w", err) } - return ReadNode[btrfsvol.LogicalAddr](fs, sb.Data, addr, func(claimAddr btrfsvol.LogicalAddr) error { + return ReadNode[btrfsvol.LogicalAddr](fs, *sb, addr, func(claimAddr btrfsvol.LogicalAddr) error { if claimAddr != addr { return fmt.Errorf("read from laddr=%v but claims to be at laddr=%v", addr, claimAddr) |