Truncate ar before calling mm.breakCopyOnWriteLocked().

... as required by the latter's precondition.

PiperOrigin-RevId: 226033824
Change-Id: I6bc46d0e100c61cc58cb5fc69e70c4ca905cd92d
This commit is contained in:
Jamie Liu
2018-12-18 11:52:31 -08:00
committed by Shentubot
parent 41903586fd
commit 3b3f026278
+8
View File
@@ -138,6 +138,10 @@ func (mm *MemoryManager) getPMAsLocked(ctx context.Context, vseg vmaIterator, ar
var cowerr error
if opts.breakCOW {
if pend.Start() < ar.End {
// Adjust ar to reflect missing pmas.
ar.End = pend.Start()
}
var invalidated bool
pend, invalidated, cowerr = mm.breakCopyOnWriteLocked(pstart, ar)
if pend.Start() <= ar.Start {
@@ -189,6 +193,10 @@ func (mm *MemoryManager) getVecPMAsLocked(ctx context.Context, ars usermem.AddrR
if !pstart.Ok() {
pstart = mm.findOrSeekPrevUpperBoundPMA(ar.Start, pend)
}
if pend.Start() < ar.End {
// Adjust ar to reflect missing pmas.
ar.End = pend.Start()
}
pend, _, cowerr = mm.breakCopyOnWriteLocked(pstart, ar)
}