Merge pull request #6233 from nonsense/fix-finalizesector-storage-req
consider storiface.PathStorage when calculating storage requirements
This commit is contained in:
commit
2d4eaf08c4
12
extern/sector-storage/stores/index.go
vendored
12
extern/sector-storage/stores/index.go
vendored
@ -3,6 +3,7 @@ package stores
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
gopath "path"
|
||||
"sort"
|
||||
@ -383,7 +384,16 @@ func (i *Index) StorageBestAlloc(ctx context.Context, allocate storiface.SectorF
|
||||
|
||||
var candidates []storageEntry
|
||||
|
||||
spaceReq, err := allocate.SealSpaceUse(ssize)
|
||||
var err error
|
||||
var spaceReq uint64
|
||||
switch pathType {
|
||||
case storiface.PathSealing:
|
||||
spaceReq, err = allocate.SealSpaceUse(ssize)
|
||||
case storiface.PathStorage:
|
||||
spaceReq, err = allocate.StoreSpaceUse(ssize)
|
||||
default:
|
||||
panic(fmt.Sprintf("unexpected pathType: %s", pathType))
|
||||
}
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("estimating required space: %w", err)
|
||||
}
|
||||
|
18
extern/sector-storage/storiface/filetype.go
vendored
18
extern/sector-storage/storiface/filetype.go
vendored
@ -73,6 +73,24 @@ func (t SectorFileType) SealSpaceUse(ssize abi.SectorSize) (uint64, error) {
|
||||
return need, nil
|
||||
}
|
||||
|
||||
func (t SectorFileType) StoreSpaceUse(ssize abi.SectorSize) (uint64, error) {
|
||||
var need uint64
|
||||
for _, pathType := range PathTypes {
|
||||
if !t.Has(pathType) {
|
||||
continue
|
||||
}
|
||||
|
||||
oh, ok := FsOverheadFinalized[pathType]
|
||||
if !ok {
|
||||
return 0, xerrors.Errorf("no finalized overhead info for %s", pathType)
|
||||
}
|
||||
|
||||
need += uint64(oh) * uint64(ssize) / FSOverheadDen
|
||||
}
|
||||
|
||||
return need, nil
|
||||
}
|
||||
|
||||
func (t SectorFileType) All() [FileTypes]bool {
|
||||
var out [FileTypes]bool
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user