diff --git a/extern/sector-storage/ffiwrapper/sealer_cgo.go b/extern/sector-storage/ffiwrapper/sealer_cgo.go index 21d14a4d9e6..a17a82eefd5 100644 --- a/extern/sector-storage/ffiwrapper/sealer_cgo.go +++ b/extern/sector-storage/ffiwrapper/sealer_cgo.go @@ -244,12 +244,12 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector storage.SectorRef, off maxPieceSize := abi.PaddedPieceSize(ssize) // try finding existing - unsealedPath, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage) + unsealedPath, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTUnsealed, storiface.FTNone, storiface.PathStoragePrefer) var pf *partialfile.PartialFile switch { case xerrors.Is(err, storiface.ErrSectorNotFound): - unsealedPath, done, err = sb.sectors.AcquireSector(ctx, sector, storiface.FTNone, storiface.FTUnsealed, storiface.PathStorage) + unsealedPath, done, err = sb.sectors.AcquireSector(ctx, sector, storiface.FTNone, storiface.FTUnsealed, storiface.PathStoragePrefer) if err != nil { return xerrors.Errorf("acquire unsealed sector path (allocate): %w", err) } @@ -286,7 +286,7 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector storage.SectorRef, off return nil } - srcPaths, srcDone, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTCache|storiface.FTSealed, storiface.FTNone, storiface.PathStorage) + srcPaths, srcDone, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTCache|storiface.FTSealed, storiface.FTNone, storiface.PathStoragePrefer) if err != nil { return xerrors.Errorf("acquire sealed sector paths: %w", err) } diff --git a/extern/sector-storage/manager.go b/extern/sector-storage/manager.go index 3bf0ac19e63..ef9c4b867da 100644 --- a/extern/sector-storage/manager.go +++ b/extern/sector-storage/manager.go @@ -237,7 +237,7 @@ func (m *Manager) SectorsUnsealPiece(ctx context.Context, sector storage.SectorR return xerrors.Errorf("getting sector size: %w", err) } - selector := newExistingSelector(m.index, sector.ID, storiface.FTSealed|storiface.FTCache, false) + selector := newExistingSelector(m.index, sector.ID, storiface.FTSealed|storiface.FTCache, true) log.Debugf("schedule unseal for sector %d", sector.ID) err = m.sched.Schedule(ctx, sector, sealtasks.TTUnseal, selector, unsealFetch, func(ctx context.Context, w Worker) error { diff --git a/extern/sector-storage/piece_provider.go b/extern/sector-storage/piece_provider.go index 008c06e63a0..30510395708 100644 --- a/extern/sector-storage/piece_provider.go +++ b/extern/sector-storage/piece_provider.go @@ -67,6 +67,9 @@ func (p *pieceProvider) ReadPiece(ctx context.Context, sector storage.SectorRef, } r, unlock, err := p.tryReadUnsealedPiece(ctx, sector, offset, size) + if xerrors.Is(err, storiface.ErrSectorNotFound) { + err = nil + } if err != nil { return nil, false, err } diff --git a/extern/sector-storage/stores/index.go b/extern/sector-storage/stores/index.go index 4acc2ecdb6c..a9f7ef7f6ce 100644 --- a/extern/sector-storage/stores/index.go +++ b/extern/sector-storage/stores/index.go @@ -395,6 +395,9 @@ func (i *Index) StorageBestAlloc(ctx context.Context, allocate storiface.SectorF if (pathType == storiface.PathStorage) && !p.info.CanStore { continue } + if (pathType == storiface.PathStoragePrefer) && !p.info.CanStore && !p.info.CanSeal { + continue + } if spaceReq > uint64(p.fsi.Available) { log.Debugf("not allocating on %s, out of space (available: %d, need: %d)", p.info.ID, p.fsi.Available, spaceReq) diff --git a/extern/sector-storage/stores/local.go b/extern/sector-storage/stores/local.go index ab0a8eaebc8..bd03d34ed4f 100644 --- a/extern/sector-storage/stores/local.go +++ b/extern/sector-storage/stores/local.go @@ -493,6 +493,10 @@ func (st *Local) AcquireSector(ctx context.Context, sid storage.SectorRef, exist continue } + if (pathType == storiface.PathStoragePrefer) && !si.CanStore && !si.CanSeal { + continue + } + // TODO: Check free space best = p.sectorPath(sid.ID, fileType) diff --git a/extern/sector-storage/stores/remote.go b/extern/sector-storage/stores/remote.go index 4142dac091b..5c89fd24193 100644 --- a/extern/sector-storage/stores/remote.go +++ b/extern/sector-storage/stores/remote.go @@ -117,7 +117,7 @@ func (r *Remote) AcquireSector(ctx context.Context, s storage.SectorRef, existin } odt := storiface.FSOverheadSeal - if pathType == storiface.PathStorage { + if pathType == storiface.PathStorage || pathType == storiface.PathStoragePrefer { odt = storiface.FsOverheadFinalized } diff --git a/extern/sector-storage/storiface/storage.go b/extern/sector-storage/storiface/storage.go index e836002d5de..98d128b1cf3 100644 --- a/extern/sector-storage/storiface/storage.go +++ b/extern/sector-storage/storiface/storage.go @@ -5,6 +5,8 @@ type PathType string const ( PathStorage PathType = "storage" PathSealing PathType = "sealing" + + PathStoragePrefer PathType = "storage-prefer" ) type AcquireMode string