Commit ae2730be authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b71c111b
......@@ -932,7 +932,7 @@ retry:
}
file.size = size
bfdir.δFtail.Track(file, -1, sizePath, nil)
bfdir.δFtail.Track(ctx, file, -1, sizePath, nil)
// XXX we can miss a change to file if δblk is not yet tracked
// -> need to update file.rev at read time -> locking=XXX
......@@ -1469,7 +1469,7 @@ func (f *BigFile) readPinWatchers(ctx context.Context, blk int64, treepath []btr
bfdir := f.head.bfdir
δFtail := bfdir.δFtail
bfdir.δFmu.Lock() // XXX locking correct? XXX -> better push down?
δFtail.Track(f, blk, treepath, zblk) // XXX pass in zblk.rev here?
δFtail.Track(ctx, f, blk, treepath, zblk) // XXX pass in zblk.rev here?
bfdir.δFmu.Unlock()
// make sure that file[blk] on clients side stays as of @w.at state.
......@@ -2156,7 +2156,7 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er
// only head/ needs δFtail, f.δtail and watches.
if head.rev == 0 {
head.bfdir.δFmu.Lock() // XXX locking ok?
head.bfdir.δFtail.Track(f, -1, sizePath, nil)
head.bfdir.δFtail.Track(ctx, f, -1, sizePath, nil)
head.bfdir.δFmu.Unlock()
// FIXME: scan zfile.blktab - so that we can detect all btree changes
......
......@@ -227,8 +227,12 @@ const (
// XXX TrackMinKey (we don't need it in WCFS)
)
// XXX kill keyPresent
func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags TrackFlags) { // XXX Tree|Bucket; path[0] = root
// XXX kill keyPresent?
// XXX keep in trackedKeys only keys that are not present in btree - i.e. only negative entries
// -> this requires to merge δc returned by diffT and adjust bChildren to tail into
// -> it will use less memory and offload Track from (re)loading leaf bucket
// ... for now we go more simple way
func (δBtail *ΔBtail) Track(ctx context.Context, key Key, keyPresent bool, path []Node, flags TrackFlags) error { // XXX Tree|Bucket; path[0] = root
l := len(path)
if l == 0 {
panic("empty path")
......@@ -272,8 +276,29 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track
// tracked += all keys of leaf bucket for every node up to the root
fmt.Printf(" oldTrack: %v leafBucket: %v\n", oldTrack, leafBucket)
if !oldTrack && leafBucket != nil {
// activate leaf node to get access to its data
if leafBucket.POid() != zodb.InvalidOid {
// normal bucket
err := leafBucket.PActivate(ctx)
if err != nil {
return err
}
defer leafBucket.PDeactivate()
} else {
// bucket embedded into tree
// XXX assert len(path) == 2
err := treeRoot.PActivate(ctx)
if err != nil {
return err
}
defer treeRoot.PActivate(ctx)
// XXX assert len(treeRoot.Entryv()) == 1
// XXX assert [0] is Bucket && POid == zodb.InvalidOid
leafBucket = treeRoot.Entryv()[0].Child().(*Bucket) // because it is recreated
}
bkeys := SetKey{}
for _, __ := range leafBucket.Entryv() { // XXX activate
for _, __ := range leafBucket.Entryv() {
bkeys.Add(__.Key())
}
fmt.Printf(" bkeys: %s\n", bkeys)
......@@ -302,6 +327,7 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track
// XXX update diff XXX here? or as separate step?
// XXX update lastRevOf
return nil
}
// Update updates δB with per-object level ZODB changes.
......
......@@ -548,7 +548,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
if k == kInf {
trackFlags = TrackMaxKey
}
δbtail.Track(k, ok, path, trackFlags)
err = δbtail.Track(ctx, k, ok, path, trackFlags); X(err)
kadjTracked.Update(kadj[k])
}
......
......@@ -136,13 +136,18 @@ func (δFtail *ΔFtail) Tail() zodb.Tid { return δFtail.δBtail.Tail() }
// XXX text
//
// A root can be associated with several files (each provided on different Track call).
func (δFtail *ΔFtail) Track(file *BigFile, blk int64, path []btree.LONode, zblk zBlk) {
//
// XXX try to avoid ctx
func (δFtail *ΔFtail) Track(ctx context.Context, file *BigFile, blk int64, path []btree.LONode, zblk zBlk) {
δbTrackFlags := TrackFlags(0)
if blk == -1 {
// XXX blk = ∞ ?
δbTrackFlags = TrackMaxKey
}
δFtail.δBtail.Track(blk, zblk != nil, path, δbTrackFlags)
err := δFtail.δBtail.Track(ctx, blk, zblk != nil, path, δbTrackFlags)
if err != nil {
panic(err) // XXX -> error? errctx
}
root := path[0].(*btree.LOBTree)
files, ok := δFtail.fileIdx[root.POid()]
if !ok {
......
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