Commit e8804bd5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8316aa92
...@@ -67,6 +67,7 @@ import ( ...@@ -67,6 +67,7 @@ import (
"context" "context"
"fmt" "fmt"
"sort" "sort"
"sync"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/transaction" "lab.nexedi.com/kirr/neo/go/transaction"
...@@ -137,7 +138,11 @@ type ΔFtail struct { ...@@ -137,7 +138,11 @@ type ΔFtail struct {
// ΔFtail merges ΔBtail with history of ZBlk // ΔFtail merges ΔBtail with history of ZBlk
δBtail *xbtree.ΔBtail δBtail *xbtree.ΔBtail
// XXX mu sync.Mutex + comment // mu protects ΔFtail data _and_ all _ΔFileTail data for all files.
//
// NOTE: even though this lock is global, since ... XXX
// working with retrieved vδE snapshot(?) does not need to hold the lock.
mu sync.Mutex
byFile map[zodb.Oid]*_ΔFileTail // file -> vδf tail byFile map[zodb.Oid]*_ΔFileTail // file -> vδf tail
filesByRoot map[zodb.Oid]setOid // tree-root -> {} ZBigFile<oid> as of @head filesByRoot map[zodb.Oid]setOid // tree-root -> {} ZBigFile<oid> as of @head
...@@ -324,7 +329,7 @@ func (δFtail *ΔFtail) rebuild1IfNeeded(foid zodb.Oid) (vδE []_ΔFileEpoch, he ...@@ -324,7 +329,7 @@ func (δFtail *ΔFtail) rebuild1IfNeeded(foid zodb.Oid) (vδE []_ΔFileEpoch, he
δBtail := δFtail.δBtail δBtail := δFtail.δBtail
err = δftail._rebuild1(foid, δBtail.ΔZtail(), δBtail.DB()) err = δftail._rebuild1(foid, δBtail.ΔZtail(), δBtail.DB())
} }
return δftail, err return δftail.vδE, δftail.root, err
} }
// _rebuild1 rebuilds vδE. // _rebuild1 rebuilds vδE.
...@@ -542,7 +547,7 @@ func (δFtail *ΔFtail) ForgetPast(revCut zodb.Tid) { ...@@ -542,7 +547,7 @@ func (δFtail *ΔFtail) ForgetPast(revCut zodb.Tid) {
// TODO keep index which file changed epoch where (similarly to ΔBtail), // TODO keep index which file changed epoch where (similarly to ΔBtail),
// and, instead of scanning all files, trim vδE only on files that is really necessary. // and, instead of scanning all files, trim vδE only on files that is really necessary.
for _, δftail := range δFtail.byFile { for _, δftail := range δFtail.byFile {
δftail.forgetPast(revCut) δftail._forgetPast(revCut)
} }
} }
...@@ -844,13 +849,14 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zfile *ZBigFile, blk int6 ...@@ -844,13 +849,14 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zfile *ZBigFile, blk int6
// XXX locking // XXX locking
δftail, err := δFtail.rebuild1IfNeeded(foid) // δftail, err := δFtail.rebuild1IfNeeded(foid)
vδE, headRoot, err := δFtail.rebuild1IfNeeded(foid)
if err != nil { if err != nil {
return zodb.InvalidTid, false, err return zodb.InvalidTid, false, err
} }
// find epoch that covers at and associated blktab root/object // find epoch that covers at and associated blktab root/object
vδE := δftail.vδE // vδE := δftail.vδE
//fmt.Printf(" vδE: %v\n", vδE) //fmt.Printf(" vδE: %v\n", vδE)
l := len(vδE) l := len(vδE)
i := sort.Search(l, func(i int) bool { i := sort.Search(l, func(i int) bool {
...@@ -862,7 +868,8 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zfile *ZBigFile, blk int6 ...@@ -862,7 +868,8 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zfile *ZBigFile, blk int6
// root // root
var root zodb.Oid var root zodb.Oid
if i == l { if i == l {
root = δftail.root // root = δftail.root
root = headRoot
} else { } else {
root = vδE[i].oldRoot root = vδE[i].oldRoot
} }
......
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