diff options
Diffstat (limited to 'pkg/btrfs/btrfsvol/chunk.go')
-rw-r--r-- | pkg/btrfs/btrfsvol/chunk.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/pkg/btrfs/btrfsvol/chunk.go b/pkg/btrfs/btrfsvol/chunk.go index e53265f..146193d 100644 --- a/pkg/btrfs/btrfsvol/chunk.go +++ b/pkg/btrfs/btrfsvol/chunk.go @@ -9,12 +9,15 @@ import ( // logical => []physical type chunkMapping struct { - LAddr LogicalAddr - PAddrs []QualifiedPhysicalAddr - Size AddrDelta - Flags *BlockGroupFlags + LAddr LogicalAddr + PAddrs []QualifiedPhysicalAddr + Size AddrDelta + SizeLocked bool + Flags *BlockGroupFlags } +type ChunkMapping = chunkMapping + // return -1 if 'a' is wholly to the left of 'b' // return 0 if there is some overlap between 'a' and 'b' // return 1 if 'a is wholly to the right of 'b' @@ -51,6 +54,15 @@ func (a chunkMapping) union(rest ...chunkMapping) (chunkMapping, error) { LAddr: beg, Size: end.Sub(beg), } + for _, chunk := range chunks { + if chunk.SizeLocked { + ret.SizeLocked = true + if ret.Size != chunk.Size { + return chunkMapping{}, fmt.Errorf("member chunk has locked size=%v, but union would have size=%v", + chunk.Size, ret.Size) + } + } + } // figure out the physical stripes (.PAddrs) paddrs := make(map[QualifiedPhysicalAddr]struct{}) for _, chunk := range chunks { |