fix: sealing: Release unsealed sector files after snapdeals abort
This commit is contained in:
parent
e1ef1b759e
commit
68f3e4483f
18
extern/sector-storage/manager.go
vendored
18
extern/sector-storage/manager.go
vendored
@ -701,7 +701,23 @@ func (m *Manager) FinalizeReplicaUpdate(ctx context.Context, sector storage.Sect
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) ReleaseUnsealed(ctx context.Context, sector storage.SectorRef, safeToFree []storage.Range) error {
|
func (m *Manager) ReleaseUnsealed(ctx context.Context, sector storage.SectorRef, safeToFree []storage.Range) error {
|
||||||
return nil
|
ssize, err := sector.ProofType.SectorSize()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(safeToFree) != 0 || safeToFree[0].Offset != 0 || safeToFree[0].Size.Padded() != abi.PaddedPieceSize(ssize) {
|
||||||
|
// todo support partial free
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
if err := m.index.StorageLock(ctx, sector.ID, storiface.FTNone, storiface.FTUnsealed); err != nil {
|
||||||
|
return xerrors.Errorf("acquiring sector lock: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return m.storage.Remove(ctx, sector.ID, storiface.FTUnsealed, true, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) ReleaseSectorKey(ctx context.Context, sector storage.SectorRef) error {
|
func (m *Manager) ReleaseSectorKey(ctx context.Context, sector storage.SectorRef) error {
|
||||||
|
10
extern/storage-sealing/states_failed.go
vendored
10
extern/storage-sealing/states_failed.go
vendored
@ -417,6 +417,16 @@ func (m *Sealing) handleAbortUpgrade(ctx statemachine.Context, sector SectorInfo
|
|||||||
if err := m.sealer.ReleaseReplicaUpgrade(ctx.Context(), m.minerSector(sector.SectorType, sector.SectorNumber)); err != nil {
|
if err := m.sealer.ReleaseReplicaUpgrade(ctx.Context(), m.minerSector(sector.SectorType, sector.SectorNumber)); err != nil {
|
||||||
return xerrors.Errorf("removing CC update files from sector storage")
|
return xerrors.Errorf("removing CC update files from sector storage")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg, err := m.getConfig()
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting sealing config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.sealer.ReleaseUnsealed(ctx.Context(), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(sector.CCPieces, true, cfg.AlwaysKeepUnsealedCopy)); err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
return ctx.Send(SectorRevertUpgradeToProving{})
|
return ctx.Send(SectorRevertUpgradeToProving{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
extern/storage-sealing/states_proving.go
vendored
9
extern/storage-sealing/states_proving.go
vendored
@ -135,15 +135,6 @@ func (m *Sealing) handleProvingSector(ctx statemachine.Context, sector SectorInf
|
|||||||
delete(m.available, m.minerSectorID(sector.SectorNumber))
|
delete(m.available, m.minerSectorID(sector.SectorNumber))
|
||||||
m.inputLk.Unlock()
|
m.inputLk.Unlock()
|
||||||
|
|
||||||
cfg, err := m.getConfig()
|
|
||||||
if err != nil {
|
|
||||||
return xerrors.Errorf("getting sealing config: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := m.sealer.ReleaseUnsealed(ctx.Context(), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(true, cfg.AlwaysKeepUnsealedCopy)); err != nil {
|
|
||||||
log.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Watch termination
|
// TODO: Watch termination
|
||||||
// TODO: Auto-extend if set
|
// TODO: Auto-extend if set
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ func (m *Sealing) handleFinalizeReplicaUpdate(ctx statemachine.Context, sector S
|
|||||||
return xerrors.Errorf("getting sealing config: %w", err)
|
return xerrors.Errorf("getting sealing config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.sealer.FinalizeReplicaUpdate(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(false, cfg.AlwaysKeepUnsealedCopy)); err != nil {
|
if err := m.sealer.FinalizeReplicaUpdate(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(sector.Pieces, false, cfg.AlwaysKeepUnsealedCopy)); err != nil {
|
||||||
return ctx.Send(SectorFinalizeFailed{xerrors.Errorf("finalize sector: %w", err)})
|
return ctx.Send(SectorFinalizeFailed{xerrors.Errorf("finalize sector: %w", err)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
extern/storage-sealing/states_sealing.go
vendored
2
extern/storage-sealing/states_sealing.go
vendored
@ -763,7 +763,7 @@ func (m *Sealing) handleFinalizeSector(ctx statemachine.Context, sector SectorIn
|
|||||||
return xerrors.Errorf("getting sealing config: %w", err)
|
return xerrors.Errorf("getting sealing config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.sealer.FinalizeSector(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(false, cfg.AlwaysKeepUnsealedCopy)); err != nil {
|
if err := m.sealer.FinalizeSector(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(sector.Pieces, false, cfg.AlwaysKeepUnsealedCopy)); err != nil {
|
||||||
return ctx.Send(SectorFinalizeFailed{xerrors.Errorf("finalize sector: %w", err)})
|
return ctx.Send(SectorFinalizeFailed{xerrors.Errorf("finalize sector: %w", err)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
extern/storage-sealing/types.go
vendored
4
extern/storage-sealing/types.go
vendored
@ -165,11 +165,11 @@ func (t *SectorInfo) sealingCtx(ctx context.Context) context.Context {
|
|||||||
|
|
||||||
// Returns list of offset/length tuples of sector data ranges which clients
|
// Returns list of offset/length tuples of sector data ranges which clients
|
||||||
// requested to keep unsealed
|
// requested to keep unsealed
|
||||||
func (t *SectorInfo) keepUnsealedRanges(invert, alwaysKeep bool) []storage.Range {
|
func (t *SectorInfo) keepUnsealedRanges(pieces []Piece, invert, alwaysKeep bool) []storage.Range {
|
||||||
var out []storage.Range
|
var out []storage.Range
|
||||||
|
|
||||||
var at abi.UnpaddedPieceSize
|
var at abi.UnpaddedPieceSize
|
||||||
for _, piece := range t.Pieces {
|
for _, piece := range pieces {
|
||||||
psize := piece.Piece.Size.Unpadded()
|
psize := piece.Piece.Size.Unpadded()
|
||||||
at += psize
|
at += psize
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user