Commit 3765bd53 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f4e2197d
......@@ -740,12 +740,14 @@ retry:
zhead := head.zconn
bfdir := head.bfdir
/*
// fileInvalidate describes invalidations for one file
type fileInvalidate struct {
blkmap SetI64 // changed blocks
size bool // whether to invalidate file size
}
toinvalidate := map[*BigFile]*fileInvalidate{} // {} file -> set(#blk), sizeChanged
*/
// btreeChangev := []zodb.Oid{} // oids changing BTree|Bucket
//fmt.Printf("\n\n\n")
......@@ -815,6 +817,7 @@ retry:
//fmt.Printf("\nbtreeChangev: %v\n", btreeChangev)
δF := bfdir.δFtail.Update(δZ, zhead)
//fmt.Printf("xfiles: %v\n", xfiles)
/*
for file, δfile := range δF.Change {
finv, ok := toinvalidate[file]
if !ok {
......@@ -827,8 +830,9 @@ retry:
finv.blkmap = δfile // XXX copy?
file.δtail.Append(δF.Rev, δfile.Elements())
file.δtail.Append(δF.Rev, δfile.Blocks.Elements())
}
*/
//fmt.Printf("\n\nzδhandle: toinvalidate (#%d):\n", len(toinvalidate))
//for file := range toinvalidate {
......@@ -836,9 +840,10 @@ retry:
//}
wg, ctx := errgroup.WithContext(context.TODO()) // XXX ctx = ?
for file, finv := range toinvalidate {
// for file, finv := range toinvalidate {
for file, δfile := range δF.Change {
file := file
for blk := range finv.blkmap {
for blk := range δfile.Blocks {
blk := blk
wg.Go(func() error {
return file.invalidateBlk(ctx, blk)
......@@ -855,10 +860,11 @@ retry:
//
// do it after completing data invalidations.
wg, ctx = errgroup.WithContext(context.TODO()) // XXX ctx = ?
for file, finv := range toinvalidate {
if !finv.size {
for file, δfile := range δF.Change {
if !δfile.Size {
continue
}
file := file
wg.Go(func() error {
return file.invalidateAttr() // XXX pass ctx?
})
......@@ -883,7 +889,7 @@ retry:
// 2. restat invalidated ZBigFile
// XXX -> parallel
// XXX locking
for file := range toinvalidate {
for file := range δF.Change {
size, sizePath, err := file.zfile.Size(ctx)
if err != nil {
panic(err) // XXX
......@@ -906,7 +912,7 @@ retry:
}
// XXX δFtail.ForgetPast(...)
// XXX for f in toinvalidate: f.δtail.ForgetPast(...)
// XXX for f in δF: f.δtail.ForgetPast(...)
}
// invalidateBlk invalidates 1 file block in kernel cache.
......
......@@ -71,13 +71,14 @@ type ΔFtail struct {
// ΔF represents a change in files space.
type ΔF struct {
Rev zodb.Tid
Change map[*BigFile]SetI64 // file -> δfile (= {}#blk)
Change map[*BigFile]*ΔFile // file -> δfile
}
// Δfile represents a change to one file.
type Δfile struct {
// ΔFile represents a change to one file.
type ΔFile struct {
Rev zodb.Tid
Change SetI64 // changed blocks
Blocks SetI64 // changed blocks
Size bool // whether file size changed
}
......@@ -168,7 +169,7 @@ func (δFtail *ΔFtail) Track(file *BigFile, blk int64, path []btree.LONode, zbl
// During call to Update zhead must not be otherwise used - even for reading.
func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *ZConn) ΔF {
δB := δFtail.δBtail.Update(δZ)
δF := ΔF{Rev: δB.Rev, Change: make(map[*BigFile]SetI64)}
δF := ΔF{Rev: δB.Rev, Change: make(map[*BigFile]*ΔFile)}
// take btree changes into account
for root, δt := range δB.Change {
......@@ -179,14 +180,20 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *ZConn) ΔF {
for file := range files {
δfile, ok := δF.Change[file]
if !ok {
δfile = make(SetI64)
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(SetI64)}
δF.Change[file] = δfile
}
for blk /*, zblk*/ := range δt {
// FIXME stub - need to take both keys and zblk changes into account
// XXX document, and in particular how to include atTail
δfile.Add(blk)
δfile.Blocks.Add(blk)
}
// TODO invalidate .size only if key >= maxkey was changed (size increase),
// or if on the other hand maxkey was deleted (size decrese).
//
// XXX currently we invalidate size on any topology change.
δfile.Size = true
}
}
......@@ -210,11 +217,11 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit, zhead *ZConn) ΔF {
for file, blocks := range z.infile {
δfile, ok := δF.Change[file]
if !ok {
δfile = make(SetI64)
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(SetI64)}
δF.Change[file] = δfile
}
δfile.Update(blocks)
δfile.Blocks.Update(blocks)
}
// XXX update z.infile according to btree changes
......@@ -255,7 +262,7 @@ func (δFtail *ΔFtail) SliceByRev(lo, hi zodb.Tid) /*readonly*/ []ΔF {
// the caller must not modify returned slice.
//
// Note: contrary to regular go slicing, low is exclusive while high is inclusive.
func (δFtail *ΔFtail) SliceByFileRev(file *BigFile, lo, hi zodb.Tid) /*readonly*/[]Δfile {
func (δFtail *ΔFtail) SliceByFileRev(file *BigFile, lo, hi zodb.Tid) /*readonly*/[]ΔFile {
δassertSlice(δFtail, lo, hi)
// merging tree (δT) and Zblk (δZblk) histories into file history (δFile):
......
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