From 67780346e284d278de74488f7447b05525a37df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 25 Jan 2021 21:39:15 +0100 Subject: [PATCH] storagemgr: Always unseal full sectors --- extern/sector-storage/manager.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/extern/sector-storage/manager.go b/extern/sector-storage/manager.go index c56bbdf50..a9b31f38a 100644 --- a/extern/sector-storage/manager.go +++ b/extern/sector-storage/manager.go @@ -285,9 +285,19 @@ func (m *Manager) ReadPiece(ctx context.Context, sink io.Writer, sector storage. if unsealed == cid.Undef { return xerrors.Errorf("cannot unseal piece (sector: %d, offset: %d size: %d) - unsealed cid is undefined", sector, offset, size) } + + ssize, err := sector.ProofType.SectorSize() + if err != nil { + return xerrors.Errorf("getting sector size: %w", err) + } + err = m.sched.Schedule(ctx, sector, sealtasks.TTUnseal, selector, unsealFetch, func(ctx context.Context, w Worker) error { // TODO: make restartable - _, err := m.waitSimpleCall(ctx)(w.UnsealPiece(ctx, sector, offset, size, ticket, unsealed)) + + // NOTE: we're unsealing the whole sector here as with SDR we can't really + // unseal the sector partially. Requesting the whole sector here can + // save us some work in case another piece is requested from here + _, err := m.waitSimpleCall(ctx)(w.UnsealPiece(ctx, sector, 0, abi.PaddedPieceSize(ssize).Unpadded(), ticket, unsealed)) return err }) if err != nil {