try ClearCache for update cache
This commit is contained in:
parent
142ba6660a
commit
e271bae5ec
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,6 +10,7 @@
|
|||||||
* [Add](#Add)
|
* [Add](#Add)
|
||||||
* [AddPiece](#AddPiece)
|
* [AddPiece](#AddPiece)
|
||||||
* [Finalize](#Finalize)
|
* [Finalize](#Finalize)
|
||||||
|
* [FinalizeReplicaUpdate](#FinalizeReplicaUpdate)
|
||||||
* [FinalizeSector](#FinalizeSector)
|
* [FinalizeSector](#FinalizeSector)
|
||||||
* [Generate](#Generate)
|
* [Generate](#Generate)
|
||||||
* [GenerateSectorKeyFromData](#GenerateSectorKeyFromData)
|
* [GenerateSectorKeyFromData](#GenerateSectorKeyFromData)
|
||||||
@ -1112,6 +1113,41 @@ Response:
|
|||||||
## Finalize
|
## Finalize
|
||||||
|
|
||||||
|
|
||||||
|
### FinalizeReplicaUpdate
|
||||||
|
|
||||||
|
|
||||||
|
Perms: admin
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"ID": {
|
||||||
|
"Miner": 1000,
|
||||||
|
"Number": 9
|
||||||
|
},
|
||||||
|
"ProofType": 8
|
||||||
|
},
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"Offset": 1024,
|
||||||
|
"Size": 1024
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Response:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Sector": {
|
||||||
|
"Miner": 1000,
|
||||||
|
"Number": 9
|
||||||
|
},
|
||||||
|
"ID": "07070707-0707-0707-0707-070707070707"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### FinalizeSector
|
### FinalizeSector
|
||||||
|
|
||||||
|
|
||||||
|
90
extern/sector-storage/ffiwrapper/sealer_cgo.go
vendored
90
extern/sector-storage/ffiwrapper/sealer_cgo.go
vendored
@ -769,7 +769,7 @@ func (sb *Sealer) ReleaseSealed(ctx context.Context, sector storage.SectorRef) e
|
|||||||
return xerrors.Errorf("not supported at this layer")
|
return xerrors.Errorf("not supported at this layer")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *Sealer) FinalizeSector(ctx context.Context, sector storage.SectorRef, keepUnsealed []storage.Range) error {
|
func (sb *Sealer) freeUnsealed(ctx context.Context, sector storage.SectorRef, keepUnsealed []storage.Range) error {
|
||||||
ssize, err := sector.ProofType.SectorSize()
|
ssize, err := sector.ProofType.SectorSize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -834,6 +834,19 @@ func (sb *Sealer) FinalizeSector(ctx context.Context, sector storage.SectorRef,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sb *Sealer) FinalizeSector(ctx context.Context, sector storage.SectorRef, keepUnsealed []storage.Range) error {
|
||||||
|
ssize, err := sector.ProofType.SectorSize()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := sb.freeUnsealed(ctx, sector, keepUnsealed); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTCache, 0, storiface.PathStorage)
|
paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTCache, 0, storiface.PathStorage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("acquiring sector cache path: %w", err)
|
return xerrors.Errorf("acquiring sector cache path: %w", err)
|
||||||
@ -848,75 +861,36 @@ func (sb *Sealer) FinalizeReplicaUpdate(ctx context.Context, sector storage.Sect
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
maxPieceSize := abi.PaddedPieceSize(ssize)
|
|
||||||
|
|
||||||
if len(keepUnsealed) > 0 { // TODO dedupe with the above
|
if err := sb.freeUnsealed(ctx, sector, keepUnsealed); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
sr := partialfile.PieceRun(0, maxPieceSize)
|
{
|
||||||
|
paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTCache, 0, storiface.PathStorage)
|
||||||
for _, s := range keepUnsealed {
|
|
||||||
si := &rlepluslazy.RunSliceIterator{}
|
|
||||||
if s.Offset != 0 {
|
|
||||||
si.Runs = append(si.Runs, rlepluslazy.Run{Val: false, Len: uint64(s.Offset)})
|
|
||||||
}
|
|
||||||
si.Runs = append(si.Runs, rlepluslazy.Run{Val: true, Len: uint64(s.Size)})
|
|
||||||
|
|
||||||
var err error
|
|
||||||
sr, err = rlepluslazy.Subtract(sr, si)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTUnsealed, 0, storiface.PathStorage)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("acquiring sector cache path: %w", err)
|
return xerrors.Errorf("acquiring sector cache path: %w", err)
|
||||||
}
|
}
|
||||||
defer done()
|
defer done()
|
||||||
|
|
||||||
pf, err := partialfile.OpenPartialFile(maxPieceSize, paths.Unsealed)
|
if err := ffi.ClearCache(uint64(ssize), paths.Cache); err != nil {
|
||||||
if err == nil {
|
return xerrors.Errorf("clear cache: %w", err)
|
||||||
var at uint64
|
|
||||||
for sr.HasNext() {
|
|
||||||
r, err := sr.NextRun()
|
|
||||||
if err != nil {
|
|
||||||
_ = pf.Close()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
offset := at
|
|
||||||
at += r.Len
|
|
||||||
if !r.Val {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
err = pf.Free(storiface.PaddedByteIndex(abi.UnpaddedPieceSize(offset).Padded()), abi.UnpaddedPieceSize(r.Len).Padded())
|
|
||||||
if err != nil {
|
|
||||||
_ = pf.Close()
|
|
||||||
return xerrors.Errorf("free partial file range: %w", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := pf.Close(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if !xerrors.Is(err, os.ErrNotExist) {
|
|
||||||
return xerrors.Errorf("opening partial file: %w", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTCache, 0, storiface.PathStorage)
|
{
|
||||||
if err != nil {
|
paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTUpdateCache, 0, storiface.PathStorage)
|
||||||
return xerrors.Errorf("acquiring sector cache path: %w", err)
|
if err != nil {
|
||||||
|
return xerrors.Errorf("acquiring sector cache path: %w", err)
|
||||||
|
}
|
||||||
|
defer done()
|
||||||
|
|
||||||
|
if err := ffi.ClearCache(uint64(ssize), paths.UpdateCache); err != nil {
|
||||||
|
return xerrors.Errorf("clear cache: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
defer done()
|
|
||||||
|
|
||||||
return ffi.ClearCache(uint64(ssize), paths.Cache)
|
return nil
|
||||||
|
|
||||||
// TODO: ^ above but for snapdeals
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *Sealer) ReleaseUnsealed(ctx context.Context, sector storage.SectorRef, safeToFree []storage.Range) error {
|
func (sb *Sealer) ReleaseUnsealed(ctx context.Context, sector storage.SectorRef, safeToFree []storage.Range) error {
|
||||||
|
4
extern/sector-storage/mock/mock.go
vendored
4
extern/sector-storage/mock/mock.go
vendored
@ -477,6 +477,10 @@ func (mgr *SectorMgr) FinalizeSector(context.Context, storage.SectorRef, []stora
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mgr *SectorMgr) FinalizeReplicaUpdate(context.Context, storage.SectorRef, []storage.Range) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (mgr *SectorMgr) ReleaseUnsealed(ctx context.Context, sector storage.SectorRef, safeToFree []storage.Range) error {
|
func (mgr *SectorMgr) ReleaseUnsealed(ctx context.Context, sector storage.SectorRef, safeToFree []storage.Range) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,12 @@ func TestCCUpgrade(t *testing.T) {
|
|||||||
} {
|
} {
|
||||||
height := height // make linters happy by copying
|
height := height // make linters happy by copying
|
||||||
t.Run(fmt.Sprintf("upgrade-%d", height), func(t *testing.T) {
|
t.Run(fmt.Sprintf("upgrade-%d", height), func(t *testing.T) {
|
||||||
runTestCCUpgrade(t, height)
|
runTestCCUpgrade(t)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTestCCUpgrade(t *testing.T, upgradeHeight abi.ChainEpoch) *kit.TestFullNode {
|
func runTestCCUpgrade(t *testing.T) *kit.TestFullNode {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
blockTime := 1 * time.Millisecond
|
blockTime := 1 * time.Millisecond
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ func TestCCUpgradeAndPoSt(t *testing.T) {
|
|||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
t.Run("upgrade and then post", func(t *testing.T) {
|
t.Run("upgrade and then post", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
n := runTestCCUpgrade(t, 100)
|
n := runTestCCUpgrade(t)
|
||||||
ts, err := n.ChainHead(ctx)
|
ts, err := n.ChainHead(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
start := ts.Height()
|
start := ts.Height()
|
||||||
|
Loading…
Reference in New Issue
Block a user