From 07a4553e6e5fee9ab360e39a1eb3858bac583ad4 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Mon, 7 Sep 2020 16:04:12 +0200 Subject: [PATCH 1/2] fix: storage manager - bail out with an error if unsealed cid is undefined --- extern/sector-storage/manager.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/extern/sector-storage/manager.go b/extern/sector-storage/manager.go index 300958e397a..86a739c1903 100644 --- a/extern/sector-storage/manager.go +++ b/extern/sector-storage/manager.go @@ -217,16 +217,11 @@ func (m *Manager) ReadPiece(ctx context.Context, sink io.Writer, sector abi.Sect return xerrors.Errorf("read piece: checking for already existing unsealed sector: %w", err) } + var readOk bool var selector WorkerSelector if len(best) == 0 { // new selector = newAllocSelector(m.index, stores.FTUnsealed, stores.PathSealing) } else { // append to existing - selector = newExistingSelector(m.index, sector, stores.FTUnsealed, false) - } - - var readOk bool - - if len(best) > 0 { // There is unsealed sector, see if we can read from it selector = newExistingSelector(m.index, sector, stores.FTUnsealed, false) @@ -257,6 +252,10 @@ func (m *Manager) ReadPiece(ctx context.Context, sink io.Writer, sector abi.Sect return nil } + if unsealed == cid.Undef { + return xerrors.Errorf("cannot unseal piece (sector: %d, offset: %d size: %d) - unsealed cid is undefined", sector, offset, size) + } + err = m.sched.Schedule(ctx, sector, sealtasks.TTUnseal, selector, unsealFetch, func(ctx context.Context, w Worker) error { return w.UnsealPiece(ctx, sector, offset, size, ticket, unsealed) }) From a97f978cad5b832f658743e25eb9c14eb6e998aa Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Mon, 7 Sep 2020 16:14:19 +0200 Subject: [PATCH 2/2] fix: storage manager - dont fail on successful read piece --- extern/sector-storage/manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/sector-storage/manager.go b/extern/sector-storage/manager.go index 86a739c1903..7513b2dbf1b 100644 --- a/extern/sector-storage/manager.go +++ b/extern/sector-storage/manager.go @@ -273,7 +273,7 @@ func (m *Manager) ReadPiece(ctx context.Context, sink io.Writer, sector abi.Sect return xerrors.Errorf("reading piece from sealed sector: %w", err) } - if readOk { + if !readOk { return xerrors.Errorf("failed to read unsealed piece") }