Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider storiface.PathStorage when calculating storage requirements #6233

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion extern/sector-storage/stores/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package stores
import (
"context"
"errors"
"fmt"
"net/url"
gopath "path"
"sort"
Expand Down Expand Up @@ -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)
}
Expand Down
18 changes: 18 additions & 0 deletions extern/sector-storage/storiface/filetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down