sealing: Use FinalizeSector in snap abort for cleanup
This commit is contained in:
parent
7512f82a8d
commit
0bba2bd1ba
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||||
)
|
)
|
||||||
|
|
||||||
var MinRetryTime = 1 * time.Minute
|
var MinRetryTime = 1 * time.Minute
|
||||||
@ -430,19 +431,12 @@ func (m *Sealing) handleAbortUpgrade(ctx statemachine.Context, sector SectorInfo
|
|||||||
return xerrors.Errorf("removing CC update files from sector storage")
|
return xerrors.Errorf("removing CC update files from sector storage")
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := m.getConfig()
|
// This removes the unsealed file from all storage, and makes sure sealed/unsealed files only exist in long-term-storage
|
||||||
if err != nil {
|
// note: we're not keeping anything unsealed because we're reverting to CC
|
||||||
return xerrors.Errorf("getting sealing config: %w", err)
|
if err := m.sealer.FinalizeSector(ctx.Context(), m.minerSector(sector.SectorType, sector.SectorNumber), []storiface.Range{}); err != nil {
|
||||||
}
|
|
||||||
|
|
||||||
// This removes the unsealed file from all storage
|
|
||||||
// TODO: Pass full sector range
|
|
||||||
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)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove sealed/cache copies
|
|
||||||
|
|
||||||
return ctx.Send(SectorRevertUpgradeToProving{})
|
return ctx.Send(SectorRevertUpgradeToProving{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,6 +621,15 @@ func (m *Manager) FinalizeSector(ctx context.Context, sector storiface.SectorRef
|
|||||||
return xerrors.Errorf("acquiring sector lock: %w", err)
|
return xerrors.Errorf("acquiring sector lock: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
We want to:
|
||||||
|
* Trim cache
|
||||||
|
* (partially) free unsealed data
|
||||||
|
* Move stuff to long-term storage
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
// first check if the unsealed file exists anywhere; If it doesn't ignore it
|
// first check if the unsealed file exists anywhere; If it doesn't ignore it
|
||||||
unsealed := storiface.FTUnsealed
|
unsealed := storiface.FTUnsealed
|
||||||
{
|
{
|
||||||
@ -631,21 +640,34 @@ func (m *Manager) FinalizeSector(ctx context.Context, sector storiface.SectorRef
|
|||||||
|
|
||||||
if len(unsealedStores) == 0 { // Is some edge-cases unsealed sector may not exist already, that's fine
|
if len(unsealedStores) == 0 { // Is some edge-cases unsealed sector may not exist already, that's fine
|
||||||
unsealed = storiface.FTNone
|
unsealed = storiface.FTNone
|
||||||
|
} else {
|
||||||
|
// remove redundant copies if there are any
|
||||||
|
if err := m.storage.RemoveCopies(ctx, sector.ID, storiface.FTUnsealed); err != nil {
|
||||||
|
return xerrors.Errorf("remove copies (unsealed): %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that the sealed file is still in sealing storage; In case it already
|
// remove redundant copies if there are any
|
||||||
// isn't, we want to do finalize in long-term storage
|
if err := m.storage.RemoveCopies(ctx, sector.ID, storiface.FTSealed); err != nil {
|
||||||
pathType := storiface.PathStorage
|
return xerrors.Errorf("remove copies (sealed): %w", err)
|
||||||
|
}
|
||||||
|
if err := m.storage.RemoveCopies(ctx, sector.ID, storiface.FTCache); err != nil {
|
||||||
|
return xerrors.Errorf("remove copies (cache): %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that the cache files are still in sealing storage; In case not,
|
||||||
|
// we want to do finalize in long-term storage
|
||||||
|
cachePathType := storiface.PathStorage
|
||||||
{
|
{
|
||||||
sealedStores, err := m.index.StorageFindSector(ctx, sector.ID, storiface.FTSealed, 0, false)
|
sealedStores, err := m.index.StorageFindSector(ctx, sector.ID, storiface.FTCache, 0, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("finding sealed sector: %w", err)
|
return xerrors.Errorf("finding sealed sector: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, store := range sealedStores {
|
for _, store := range sealedStores {
|
||||||
if store.CanSeal {
|
if store.CanSeal {
|
||||||
pathType = storiface.PathSealing
|
cachePathType = storiface.PathSealing
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,7 +678,7 @@ func (m *Manager) FinalizeSector(ctx context.Context, sector storiface.SectorRef
|
|||||||
selector := newExistingSelector(m.index, sector.ID, storiface.FTCache, false)
|
selector := newExistingSelector(m.index, sector.ID, storiface.FTCache, false)
|
||||||
|
|
||||||
err := m.sched.Schedule(ctx, sector, sealtasks.TTFinalize, selector,
|
err := m.sched.Schedule(ctx, sector, sealtasks.TTFinalize, selector,
|
||||||
m.schedFetch(sector, storiface.FTCache|unsealed, pathType, storiface.AcquireMove),
|
m.schedFetch(sector, storiface.FTCache|unsealed, cachePathType, storiface.AcquireMove),
|
||||||
func(ctx context.Context, w Worker) error {
|
func(ctx context.Context, w Worker) error {
|
||||||
_, err := m.waitSimpleCall(ctx)(w.FinalizeSector(ctx, sector, keepUnsealed))
|
_, err := m.waitSimpleCall(ctx)(w.FinalizeSector(ctx, sector, keepUnsealed))
|
||||||
return err
|
return err
|
||||||
|
@ -83,7 +83,7 @@ func (t SectorFileType) String() string {
|
|||||||
case FTUpdateCache:
|
case FTUpdateCache:
|
||||||
return "update-cache"
|
return "update-cache"
|
||||||
default:
|
default:
|
||||||
return fmt.Sprintf("<unknown %d>", t)
|
return fmt.Sprintf("<unknown %d %v>", t, (t & ((1 << FileTypes) - 1)).Strings())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user