From 7a89edc5983480404005d2a653acd7b9bee14296 Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 14 Jul 2021 22:26:55 +0300 Subject: [PATCH] remove BlockstoreMover interface we decided it's premature --- blockstore/blockstore.go | 16 --------------- blockstore/splitstore/splitstore_gc.go | 27 -------------------------- 2 files changed, 43 deletions(-) diff --git a/blockstore/blockstore.go b/blockstore/blockstore.go index da5c5ba1afe..97f9f5f7b58 100644 --- a/blockstore/blockstore.go +++ b/blockstore/blockstore.go @@ -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 diff --git a/blockstore/splitstore/splitstore_gc.go b/blockstore/splitstore/splitstore_gc.go index 6191745ebb4..46668167ccc 100644 --- a/blockstore/splitstore/splitstore_gc.go +++ b/blockstore/splitstore/splitstore_gc.go @@ -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")