Commit 926408d3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1476e602
...@@ -325,7 +325,7 @@ func (δFtail *ΔFtail) rebuild1IfNeeded(foid zodb.Oid) (vδE []_ΔFileEpoch, he ...@@ -325,7 +325,7 @@ func (δFtail *ΔFtail) rebuild1IfNeeded(foid zodb.Oid) (vδE []_ΔFileEpoch, he
// vδE needs to be built // vδE needs to be built
job := δftail.rebuildJob job := δftail.rebuildJob
// rebuild is currently in-progress -> wait for corrsponding job to complete // rebuild is currently in-progress -> wait for corresponding job to complete
if job != nil { if job != nil {
δFtail.mu.Unlock() δFtail.mu.Unlock()
<-job.ready <-job.ready
...@@ -362,7 +362,7 @@ func (δFtail *ΔFtail) rebuild1IfNeeded(foid zodb.Oid) (vδE []_ΔFileEpoch, he ...@@ -362,7 +362,7 @@ func (δFtail *ΔFtail) rebuild1IfNeeded(foid zodb.Oid) (vδE []_ΔFileEpoch, he
// _rebuildAll rebuilds vδE for all files from ftrackNew requests. // _rebuildAll rebuilds vδE for all files from ftrackNew requests.
// //
// must be calledwith δFtail.mu locked. // must be called with δFtail.mu locked.
func (δFtail *ΔFtail) _rebuildAll() (err error) { func (δFtail *ΔFtail) _rebuildAll() (err error) {
defer xerr.Contextf(&err, "ΔFtail rebuildAll") defer xerr.Contextf(&err, "ΔFtail rebuildAll")
...@@ -619,7 +619,7 @@ func (δftail *_ΔFileTail) _forgetPast(revCut zodb.Tid) { ...@@ -619,7 +619,7 @@ func (δftail *_ΔFileTail) _forgetPast(revCut zodb.Tid) {
// func (δFtail *ΔFtail) SliceByRev(lo, hi zodb.Tid) /*readonly*/ []ΔF // func (δFtail *ΔFtail) SliceByRev(lo, hi zodb.Tid) /*readonly*/ []ΔF
// _ZinblkOverlay is used by SliceByFileRev. // _ZinblkOverlay is used by SliceByFileRev.
// It combiness read-only Zinblk base with read-write adjustment. // It combines read-only Zinblk base with read-write adjustment.
// It provides the following operations: // It provides the following operations:
// //
// - Get(zblk) -> {blk}, // - Get(zblk) -> {blk},
...@@ -627,7 +627,7 @@ func (δftail *_ΔFileTail) _forgetPast(revCut zodb.Tid) { ...@@ -627,7 +627,7 @@ func (δftail *_ΔFileTail) _forgetPast(revCut zodb.Tid) {
// - DelBlk(zblk, blk) // - DelBlk(zblk, blk)
type _ZinblkOverlay struct { type _ZinblkOverlay struct {
Base map[zodb.Oid]setI64 // taken from _RootTrack.Zinblk or _ΔFileEpoch.oldZinblk Base map[zodb.Oid]setI64 // taken from _RootTrack.Zinblk or _ΔFileEpoch.oldZinblk
Adj map[zodb.Oid]setI64 // adjustement over base; blk<0 reresents whitout Adj map[zodb.Oid]setI64 // adjustment over base; blk<0 represents whiteout
} }
// SliceByFileRev returns history of file changes in (lo, hi] range. // SliceByFileRev returns history of file changes in (lo, hi] range.
...@@ -724,10 +724,37 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado ...@@ -724,10 +724,37 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado
// head // head
root = headRoot root = headRoot
head = δFtail.Head() head = δFtail.Head()
rt, ok := δFtail.byRoot[root] // XXX locking
// take atomic Zinblk snapshot that covers vδZ
//
// - the reason we take snapshot is because simultaneous Track requests might
// change Zinblk concurrently, and without snapshotting this might result
// in changes to a block being not uniformly present in result (some
// revision indicates change to that block, while another one - where the
// block is too actually changed - does not indicate change to that block).
//
// - the reason we limit snapshot to vδZ is to reduce amount of under-lock
// copying, because original Zinblk is potentially very large.
ZinblkSnap := map[zodb.Oid]setI64{}
δZAllOid := setOid{}
for _, δZ := range vδZ {
for _, oid := range δZ.Changev {
δZAllOid.Add(oid)
}
}
δFtail.mu.Lock()
rt, ok := δFtail.byRoot[root]
if ok { if ok {
Zinblk.Base = rt.Zinblk for oid := range δZAllOid {
inblk, ok := rt.Zinblk[oid]
if ok {
ZinblkSnap[oid] = inblk.Clone()
}
}
} }
δFtail.mu.Unlock()
Zinblk.Base = ZinblkSnap
} else { } else {
δE := vδE[ie+1] δE := vδE[ie+1]
root = δE.oldRoot root = δE.oldRoot
...@@ -1044,7 +1071,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zfile *ZBigFile, blk int6 ...@@ -1044,7 +1071,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zfile *ZBigFile, blk int6
} }
// ---- vδEBuild (rebuild core) ---- // ---- vδEBuild (vδE rebuild core) ----
// vδEBuild builds vδE for file from vδZ. // vδEBuild builds vδE for file from vδZ.
func vδEBuild(foid zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB) (vδE []_ΔFileEpoch, err error) { func vδEBuild(foid zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB) (vδE []_ΔFileEpoch, err error) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment