remove BlockstoreMover interface
we decided it's premature
This commit is contained in:
parent
023146803d
commit
3f3a12b75c
@ -35,22 +35,6 @@ type BlockstoreIterator interface {
|
||||
ForEachKey(func(cid.Cid) error) error
|
||||
}
|
||||
|
||||
// BlockstoreMover is a trait for movable blockstores
|
||||
type BlockstoreMover interface {
|
||||
// Moves the blockstore to path, and creates a symlink from the current path
|
||||
// to the new path; the old blockstore is deleted.
|
||||
// If path is empty, then a new path adjacent to the current path is created
|
||||
// automatically.
|
||||
// If the filter function is not nil, then the move filters and moves only
|
||||
// objects whose cid satisfyn the filter.
|
||||
//
|
||||
// The blockstore must accept new writes during the move and ensure that these
|
||||
// are persisted to the new blockstore; if a failure occurs aboring the move,
|
||||
// then they must be peristed to the old blockstore.
|
||||
// In short, the blockstore must not lose data from new writes during the move.
|
||||
MoveTo(path string, filter func(cid.Cid) bool) error
|
||||
}
|
||||
|
||||
// BlockstoreGC is a trait for blockstores that support online garbage collection
|
||||
type BlockstoreGC interface {
|
||||
CollectGarbage() error
|
||||
|
@ -5,41 +5,14 @@ import (
|
||||
"time"
|
||||
|
||||
bstore "github.com/filecoin-project/lotus/blockstore"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
func (s *SplitStore) gcHotstore() {
|
||||
// we only perform moving gc every 20 compactions (about once a week) as it can take a while
|
||||
if s.compactionIndex%20 == 0 {
|
||||
if err := s.gcBlockstoreMoving(s.hot, "", nil); err != nil {
|
||||
log.Warnf("error moving hotstore: %s", err)
|
||||
// fallthrough to online gc
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.gcBlockstoreOnline(s.hot); err != nil {
|
||||
log.Warnf("error garbage collecting hostore: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SplitStore) gcBlockstoreMoving(b bstore.Blockstore, path string, filter func(cid.Cid) bool) error {
|
||||
if mover, ok := b.(bstore.BlockstoreMover); ok {
|
||||
log.Info("moving blockstore")
|
||||
startMove := time.Now()
|
||||
|
||||
if err := mover.MoveTo(path, filter); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Infow("moving hotstore done", "took", time.Since(startMove))
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("blockstore doesn't support moving: %T", b)
|
||||
}
|
||||
|
||||
func (s *SplitStore) gcBlockstoreOnline(b bstore.Blockstore) error {
|
||||
if gc, ok := b.(bstore.BlockstoreGC); ok {
|
||||
log.Info("garbage collecting blockstore")
|
||||
|
Loading…
Reference in New Issue
Block a user