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

.

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