Commit 8b0816bc authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 424beee4
...@@ -495,12 +495,12 @@ type BigFile struct { ...@@ -495,12 +495,12 @@ type BigFile struct {
head *Head head *Head
// ZBigFile top-level object // ZBigFile top-level object
zbf *ZBigFile zfile *ZBigFile
// things read/computed from .zbf; constant during lifetime of current transaction. // things read/computed from .zfile; constant during lifetime of current transaction.
blksize int64 // zbf.blksize blksize int64 // zfile.blksize
size int64 // zbf.Size() size int64 // zfile.Size()
rev zodb.Tid // last revision that modified zbf data rev zodb.Tid // last revision that modified zfile data
// tail change history of this file. // tail change history of this file.
δFtail *ΔTailI64 // [](rev↑, []#blk) δFtail *ΔTailI64 // [](rev↑, []#blk)
...@@ -750,7 +750,7 @@ retry: ...@@ -750,7 +750,7 @@ retry:
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 {
fmt.Printf("\t- %s\n", file.zbf.POid()) fmt.Printf("\t- %s\n", file.zfile.POid())
} }
wg, ctx := errgroup.WithContext(context.TODO()) wg, ctx := errgroup.WithContext(context.TODO())
...@@ -802,7 +802,7 @@ retry: ...@@ -802,7 +802,7 @@ retry:
// XXX -> parallel? // XXX -> parallel?
// XXX locking // XXX locking
for file := range toinvalidate { for file := range toinvalidate {
size, treePath, err := file.zbf.Size(ctx) size, treePath, err := file.zfile.Size(ctx)
if err != nil { if err != nil {
panic(err) // XXX panic(err) // XXX
} }
...@@ -870,7 +870,7 @@ func (f *BigFile) invalidateBlk(ctx context.Context, blk int64) (err error) { ...@@ -870,7 +870,7 @@ func (f *BigFile) invalidateBlk(ctx context.Context, blk int64) (err error) {
func() { func() {
// store retrieved data back to OS cache for file @<rev>/file[blk] // store retrieved data back to OS cache for file @<rev>/file[blk]
blkrev, _ := f.δFtail.LastRevOf(blk, f.head.zconn.At()) blkrev, _ := f.δFtail.LastRevOf(blk, f.head.zconn.At())
frev, frelease, err := groot.mkrevfile(blkrev, f.zbf.POid()) frev, frelease, err := groot.mkrevfile(blkrev, f.zfile.POid())
if err != nil { if err != nil {
log.Errorf("BUG: %s: invalidate blk #%d: %s (ignoring, but reading @revX/bigfile will be slow)", f.path(), blk, err) log.Errorf("BUG: %s: invalidate blk #%d: %s (ignoring, but reading @revX/bigfile will be slow)", f.path(), blk, err)
} }
...@@ -1110,7 +1110,7 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er ...@@ -1110,7 +1110,7 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er
ctx, cancel := xcontext.Merge(ctx, zconn.txnCtx) ctx, cancel := xcontext.Merge(ctx, zconn.txnCtx)
defer cancel() defer cancel()
xzbf, err := zconn.Get(ctx, oid) xzfile, err := zconn.Get(ctx, oid)
if err != nil { if err != nil {
switch errors.Cause(err).(type) { switch errors.Cause(err).(type) {
case *zodb.NoObjectError: case *zodb.NoObjectError:
...@@ -1122,26 +1122,26 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er ...@@ -1122,26 +1122,26 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er
} }
} }
zbf, ok := xzbf.(*ZBigFile) zfile, ok := xzfile.(*ZBigFile)
if !ok { if !ok {
return nil, eINVALf("%s is not a ZBigFile", typeOf(xzbf)) return nil, eINVALf("%s is not a ZBigFile", typeOf(xzfile))
} }
// extract blksize, size and initial approximation for file revision // extract blksize, size and initial approximation for file revision
err = zbf.PActivate(ctx) err = zfile.PActivate(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }
blksize := zbf.blksize blksize := zfile.blksize
// XXX it should be revision of both ZBigFile and its data. But we // XXX it should be revision of both ZBigFile and its data. But we
// cannot get data revision without expensive scan of all ZBigFile's objects. // cannot get data revision without expensive scan of all ZBigFile's objects.
// -> approximate mtime initially with ZBigFile object mtime. // -> approximate mtime initially with ZBigFile object mtime.
// //
// XXX for @rev/... we can know initial mtime more exactly? // XXX for @rev/... we can know initial mtime more exactly?
rev := zbf.PSerial() rev := zfile.PSerial()
zbf.PDeactivate() zfile.PDeactivate()
size, treePath, err := zbf.Size(ctx) size, treePath, err := zfile.Size(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -1150,7 +1150,7 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er ...@@ -1150,7 +1150,7 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er
f := &BigFile{ f := &BigFile{
fsNode: newFSNode(&fsOptions{Sticky: false}), // XXX + BigFile.OnForget -> del .head.bfdir.fileTab[] fsNode: newFSNode(&fsOptions{Sticky: false}), // XXX + BigFile.OnForget -> del .head.bfdir.fileTab[]
head: head, head: head,
zbf: zbf, zfile: zfile,
blksize: blksize, blksize: blksize,
size: size, size: size,
rev: rev, rev: rev,
...@@ -1173,7 +1173,7 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er ...@@ -1173,7 +1173,7 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er
// Close release all resources of BigFile. // Close release all resources of BigFile.
func (f *BigFile) Close() error { func (f *BigFile) Close() error {
// XXX locking? // XXX locking?
f.zbf = nil f.zfile = nil
// f.zconn.Release() // f.zconn.Release()
// f.zconn = nil // f.zconn = nil
...@@ -1303,8 +1303,8 @@ func (f *BigFile) readBlk(ctx context.Context, blk int64, dest []byte) error { ...@@ -1303,8 +1303,8 @@ func (f *BigFile) readBlk(ctx context.Context, blk int64, dest []byte) error {
// noone was loading - we became responsible to load this block // noone was loading - we became responsible to load this block
zbf := f.zbf zfile := f.zfile
blkdata, treepath, pathRevMax, err := zbf.LoadBlk(ctx, blk) blkdata, treepath, pathRevMax, err := zfile.LoadBlk(ctx, blk)
loading.blkdata = blkdata loading.blkdata = blkdata
loading.err = err loading.err = err
close(loading.ready) close(loading.ready)
...@@ -1318,7 +1318,7 @@ func (f *BigFile) readBlk(ctx context.Context, blk int64, dest []byte) error { ...@@ -1318,7 +1318,7 @@ func (f *BigFile) readBlk(ctx context.Context, blk int64, dest []byte) error {
} }
// XXX before loading.ready? // XXX before loading.ready?
blkrevmax, _ := f.δFtail.LastRevOf(blk, zbf.PJar().At()) blkrevmax, _ := f.δFtail.LastRevOf(blk, zfile.PJar().At())
blkrevmax = tidmin(blkrevmax, pathRevMax) blkrevmax = tidmin(blkrevmax, pathRevMax)
/* /*
...@@ -1411,7 +1411,7 @@ retry: ...@@ -1411,7 +1411,7 @@ retry:
return return
} }
oid := f.zbf.POid() oid := f.zfile.POid()
// signal to zwatcher not to run while we are performing the upload. // signal to zwatcher not to run while we are performing the upload.
// upload with released zconnMu so that zwatcher can lock it even if to // upload with released zconnMu so that zwatcher can lock it even if to
......
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