diff --git a/api/api_storage.go b/api/api_storage.go index 4379031b0..9c3262df9 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -150,6 +150,8 @@ type StorageMiner interface { // SealingSchedDiag dumps internal sealing scheduler state SealingSchedDiag(ctx context.Context, doSched bool) (interface{}, error) //perm:admin SealingAbort(ctx context.Context, call storiface.CallID) error //perm:admin + //SealingSchedRemove removes a request from sealing pipeline + SealingRemoveRequest(ctx context.Context, sectorID abi.SectorID, task string, priority int) error //perm:admin // paths.SectorIndex StorageAttach(context.Context, storiface.StorageInfo, fsutil.FsStat) error //perm:admin diff --git a/api/proxy_gen.go b/api/proxy_gen.go index f1e520b7e..7c377f9b4 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -802,6 +802,8 @@ type StorageMinerStruct struct { SealingAbort func(p0 context.Context, p1 storiface.CallID) error `perm:"admin"` + SealingRemoveRequest func(p0 context.Context, p1 abi.SectorID, p2 string, p3 int) error `perm:"admin"` + SealingSchedDiag func(p0 context.Context, p1 bool) (interface{}, error) `perm:"admin"` SectorAbortUpgrade func(p0 context.Context, p1 abi.SectorNumber) error `perm:"admin"` @@ -4761,6 +4763,17 @@ func (s *StorageMinerStub) SealingAbort(p0 context.Context, p1 storiface.CallID) return ErrNotSupported } +func (s *StorageMinerStruct) SealingRemoveRequest(p0 context.Context, p1 abi.SectorID, p2 string, p3 int) error { + if s.Internal.SealingRemoveRequest == nil { + return ErrNotSupported + } + return s.Internal.SealingRemoveRequest(p0, p1, p2, p3) +} + +func (s *StorageMinerStub) SealingRemoveRequest(p0 context.Context, p1 abi.SectorID, p2 string, p3 int) error { + return ErrNotSupported +} + func (s *StorageMinerStruct) SealingSchedDiag(p0 context.Context, p1 bool) (interface{}, error) { if s.Internal.SealingSchedDiag == nil { return nil, ErrNotSupported diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index 8554e0a01..397c8a4dd 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/build/openrpc/gateway.json.gz b/build/openrpc/gateway.json.gz index c8489039b..3e1b629d9 100644 Binary files a/build/openrpc/gateway.json.gz and b/build/openrpc/gateway.json.gz differ diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index f1f95854c..ca987eeef 100644 Binary files a/build/openrpc/miner.json.gz and b/build/openrpc/miner.json.gz differ diff --git a/build/openrpc/worker.json.gz b/build/openrpc/worker.json.gz index c2b5bdedd..1ec87a2c8 100644 Binary files a/build/openrpc/worker.json.gz and b/build/openrpc/worker.json.gz differ diff --git a/documentation/en/api-v0-methods-miner.md b/documentation/en/api-v0-methods-miner.md index e24520b20..885b19a08 100644 --- a/documentation/en/api-v0-methods-miner.md +++ b/documentation/en/api-v0-methods-miner.md @@ -128,6 +128,7 @@ * [RuntimeSubsystems](#RuntimeSubsystems) * [Sealing](#Sealing) * [SealingAbort](#SealingAbort) + * [SealingRemoveRequest](#SealingRemoveRequest) * [SealingSchedDiag](#SealingSchedDiag) * [Sector](#Sector) * [SectorAbortUpgrade](#SectorAbortUpgrade) @@ -2749,6 +2750,26 @@ Inputs: Response: `{}` +### SealingRemoveRequest +SealingSchedRemove removes a request from sealing pipeline + + +Perms: admin + +Inputs: +```json +[ + { + "Miner": 1000, + "Number": 9 + }, + "string value", + 123 +] +``` + +Response: `{}` + ### SealingSchedDiag SealingSchedDiag dumps internal sealing scheduler state diff --git a/node/impl/storminer.go b/node/impl/storminer.go index 74b1dc776..264349116 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -56,6 +56,7 @@ import ( "github.com/filecoin-project/lotus/storage/pipeline/sealiface" "github.com/filecoin-project/lotus/storage/sealer" "github.com/filecoin-project/lotus/storage/sealer/fsutil" + "github.com/filecoin-project/lotus/storage/sealer/sealtasks" "github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sectorblocks" "github.com/filecoin-project/lotus/storage/wdpost" @@ -462,6 +463,11 @@ func (sm *StorageMinerAPI) SealingAbort(ctx context.Context, call storiface.Call return sm.StorageMgr.Abort(ctx, call) } +func (sm *StorageMinerAPI) SealingRemoveRequest(ctx context.Context, sectorID abi.SectorID, task string, priority int) error { + rtask := sealtasks.TaskType(task) + return sm.StorageMgr.RemoveSchedRequest(ctx, sectorID, rtask, priority) +} + func (sm *StorageMinerAPI) MarketImportDealData(ctx context.Context, propCid cid.Cid, path string) error { fi, err := os.Open(path) if err != nil { diff --git a/storage/sealer/manager.go b/storage/sealer/manager.go index 3e5e6032b..11061a626 100644 --- a/storage/sealer/manager.go +++ b/storage/sealer/manager.go @@ -1168,6 +1168,12 @@ func (m *Manager) SchedDiag(ctx context.Context, doSched bool) (interface{}, err return i, nil } +func (m *Manager) RemoveSchedRequest(ctx context.Context, sectorID abi.SectorID, tasktype sealtasks.TaskType, priority int) error { + m.workLk.Lock() + defer m.workLk.Unlock() + return m.sched.RemoveRequest(ctx, sectorID, tasktype, priority) +} + func (m *Manager) Close(ctx context.Context) error { m.windowPoStSched.schedClose() m.winningPoStSched.schedClose() diff --git a/storage/sealer/sched.go b/storage/sealer/sched.go index 323def986..8c6ece4d0 100644 --- a/storage/sealer/sched.go +++ b/storage/sealer/sched.go @@ -381,6 +381,22 @@ func (sh *Scheduler) Info(ctx context.Context) (interface{}, error) { } } +func (sh *Scheduler) RemoveRequest(ctx context.Context, sectorID abi.SectorID, tasktype sealtasks.TaskType, priority int) error { + if sh.SchedQueue.Len() < 0 { + return xerrors.Errorf("No requests in the scheduler") + } + sh.workersLk.Lock() + defer sh.workersLk.Unlock() + queue := sh.SchedQueue + for i, r := range *queue { + if r.Sector.ID == sectorID && r.Priority == priority && r.TaskType == tasktype { // TODO: Add check to ensure request in not scheduled + queue.Remove(i) + return nil + } + } + return xerrors.Errorf("No request with provided details found") +} + func (sh *Scheduler) Close(ctx context.Context) error { close(sh.closing) select {