mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
The runtime stores each volume in one content-named layout on the filer: immutable chunks, segments and roots are ordinary filer files, and one HEAD entry per volume carries every conditional commit. A holder claims HEAD under its granted epoch and claim id, cuts in its own session, commits by HEAD generation and position, and is fenced when its identity moves. Catalog, restore, snapshot, retention, cleaning, verify and volume delete run through the layout kernel; the master mints the layout identity, reads HEAD proofs and holds the delete reservation and lease barrier. The legacy store, its intents and its compatibility paths are removed; existing stores are recreated, not converted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
74 lines
2.4 KiB
Go
74 lines
2.4 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore"
|
|
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
|
"github.com/seaweedfs/seaweed-block/core/lifecycle"
|
|
)
|
|
|
|
// layoutVolumeCreator writes only the master's initial VOLUME and unclaimed
|
|
// HEAD. layout.CreateVolume performs exclusive writes and heals a replay
|
|
// stopped between them without minting another identity.
|
|
func layoutVolumeCreator(cat *chunkstore.BCatalog) func(context.Context, lifecycle.VolumeSpec) error {
|
|
return func(ctx context.Context, spec lifecycle.VolumeSpec) error {
|
|
if cat == nil {
|
|
return fmt.Errorf("master: layout catalog is unavailable")
|
|
}
|
|
id, err := layout.ParseVolumeID(spec.LayoutID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = cat.CreateVolume(ctx, chunkstore.VolumeRef{Name: spec.VolumeID, ID: id}, layout.Geometry{
|
|
SizeBytes: spec.SizeBytes, BlockSize: spec.BlockSize, ChunkBytes: spec.ChunkBytes,
|
|
})
|
|
return err
|
|
}
|
|
}
|
|
|
|
func layoutVolumeReader(cat *chunkstore.BCatalog) func(context.Context, lifecycle.VolumeSpec) (layout.Volume, error) {
|
|
return func(ctx context.Context, spec lifecycle.VolumeSpec) (layout.Volume, error) {
|
|
id, err := layout.ParseVolumeID(spec.LayoutID)
|
|
if err != nil {
|
|
return layout.Volume{}, err
|
|
}
|
|
return cat.ReadVolume(ctx, chunkstore.VolumeRef{Name: spec.VolumeID, ID: id})
|
|
}
|
|
}
|
|
|
|
func layoutHeadReader(cat *chunkstore.BCatalog) func(context.Context, lifecycle.VolumeSpec) (layout.Head, error) {
|
|
return func(ctx context.Context, spec lifecycle.VolumeSpec) (layout.Head, error) {
|
|
id, err := layout.ParseVolumeID(spec.LayoutID)
|
|
if err != nil {
|
|
return layout.Head{}, err
|
|
}
|
|
h, found, err := cat.ReadHead(ctx, chunkstore.VolumeRef{Name: spec.VolumeID, ID: id})
|
|
if err != nil {
|
|
return layout.Head{}, err
|
|
}
|
|
if !found {
|
|
return layout.Head{}, layout.ErrHeadAbsent
|
|
}
|
|
return h, nil
|
|
}
|
|
}
|
|
|
|
func layoutTargetCreator(cat *chunkstore.BCatalog) func(context.Context, lifecycle.VolumeSpec, lifecycle.VolumeSpec, string) error {
|
|
return func(ctx context.Context, source, target lifecycle.VolumeSpec, snapshot string) error {
|
|
sid, err := layout.ParseVolumeID(source.LayoutID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
tid, err := layout.ParseVolumeID(target.LayoutID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = cat.Restore(ctx,
|
|
chunkstore.VolumeRef{Name: source.VolumeID, ID: sid}, snapshot,
|
|
chunkstore.VolumeRef{Name: target.VolumeID, ID: tid})
|
|
return err
|
|
}
|
|
}
|