diff --git a/api/api_storage.go b/api/api_storage.go index 2176456b7df..d003ec776b6 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -70,7 +70,7 @@ type StorageMiner interface { storiface.WorkerReturn // SealingSchedDiag dumps internal sealing scheduler state - SealingSchedDiag(context.Context) (interface{}, error) + SealingSchedDiag(ctx context.Context, doSched bool) (interface{}, error) stores.SectorIndex diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 3a4ae75a8f3..4381c36ada6 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -321,7 +321,7 @@ type StorageMinerStruct struct { ReturnReadPiece func(ctx context.Context, callID storiface.CallID, ok bool, err string) error `perm:"admin" retry:"true"` ReturnFetch func(ctx context.Context, callID storiface.CallID, err string) error `perm:"admin" retry:"true"` - SealingSchedDiag func(context.Context) (interface{}, error) `perm:"admin"` + SealingSchedDiag func(context.Context, bool) (interface{}, error) `perm:"admin"` StorageList func(context.Context) (map[stores.ID][]stores.Decl, error) `perm:"admin"` StorageLocal func(context.Context) (map[stores.ID]string, error) `perm:"admin"` @@ -1298,8 +1298,8 @@ func (c *StorageMinerStruct) ReturnFetch(ctx context.Context, callID storiface.C return c.Internal.ReturnFetch(ctx, callID, err) } -func (c *StorageMinerStruct) SealingSchedDiag(ctx context.Context) (interface{}, error) { - return c.Internal.SealingSchedDiag(ctx) +func (c *StorageMinerStruct) SealingSchedDiag(ctx context.Context, doSched bool) (interface{}, error) { + return c.Internal.SealingSchedDiag(ctx, doSched) } func (c *StorageMinerStruct) StorageAttach(ctx context.Context, si stores.StorageInfo, st fsutil.FsStat) error { diff --git a/cmd/lotus-storage-miner/sealing.go b/cmd/lotus-storage-miner/sealing.go index 440d4aaea76..49003fc26d1 100644 --- a/cmd/lotus-storage-miner/sealing.go +++ b/cmd/lotus-storage-miner/sealing.go @@ -215,6 +215,11 @@ var sealingJobsCmd = &cli.Command{ var sealingSchedDiagCmd = &cli.Command{ Name: "sched-diag", Usage: "Dump internal scheduler state", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "force-sched", + }, + }, Action: func(cctx *cli.Context) error { nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx) if err != nil { @@ -224,7 +229,7 @@ var sealingSchedDiagCmd = &cli.Command{ ctx := lcli.ReqContext(cctx) - st, err := nodeApi.SealingSchedDiag(ctx) + st, err := nodeApi.SealingSchedDiag(ctx, cctx.Bool("force-sched")) if err != nil { return err } diff --git a/extern/sector-storage/manager.go b/extern/sector-storage/manager.go index f32a363e7ba..9a41dcd44e4 100644 --- a/extern/sector-storage/manager.go +++ b/extern/sector-storage/manager.go @@ -679,7 +679,15 @@ func (m *Manager) FsStat(ctx context.Context, id stores.ID) (fsutil.FsStat, erro return m.storage.FsStat(ctx, id) } -func (m *Manager) SchedDiag(ctx context.Context) (interface{}, error) { +func (m *Manager) SchedDiag(ctx context.Context, doSched bool) (interface{}, error) { + if doSched { + select { + case m.sched.workerChange <- struct{}{}: + case <-ctx.Done(): + return nil, ctx.Err() + } + } + return m.sched.Info(ctx) } diff --git a/node/impl/storminer.go b/node/impl/storminer.go index dee48f5de2a..a58621c97f5 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -296,8 +296,8 @@ func (sm *StorageMinerAPI) WorkerConnect(ctx context.Context, url string) error return sm.StorageMgr.AddWorker(ctx, w) } -func (sm *StorageMinerAPI) SealingSchedDiag(ctx context.Context) (interface{}, error) { - return sm.StorageMgr.SchedDiag(ctx) +func (sm *StorageMinerAPI) SealingSchedDiag(ctx context.Context, doSched bool) (interface{}, error) { + return sm.StorageMgr.SchedDiag(ctx, doSched) } func (sm *StorageMinerAPI) MarketImportDealData(ctx context.Context, propCid cid.Cid, path string) error {