Commit 57a27d67 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 32eb3adf
......@@ -323,9 +323,9 @@ type BigFileData struct {
bigfile *BigFile
// inflight loadings from ZBigFile
// inflight loadings of ZBigFile from ZODB
loadMu sync.Mutex
loading map[int64]*blkLoadState
loading map[int64]*blkLoadState // #blk -> ...
}
// blkLoadState represents a ZBlk load state/result.
......@@ -528,7 +528,7 @@ func (bfdata *BigFileData) readBlk(ctx context.Context, blk int64, dest []byte)
loading = &blkLoadState{
ready: make(chan struct{}),
}
bfdata.loading = loading
bfdata.loading[blk] = loading
}
bfdata.loadMu.Unlock()
......@@ -547,6 +547,8 @@ func (bfdata *BigFileData) readBlk(ctx context.Context, blk int64, dest []byte)
}
// noone was loading - we became reponsible to load this block
zbf := bfdata.bigfile.zbf
blkdata, err := zbf.LoadBlk(ctx, blk)
loading.blkdata = blkdata
loading.err = err
......@@ -555,7 +557,7 @@ func (bfdata *BigFileData) readBlk(ctx context.Context, blk int64, dest []byte)
// data loaded with error - cleanup .loading
if loading.err != nil {
bfdata.loadMu.Lock()
delete bfdata.loading[blk]
delete(bfdata.loading, blk)
bfdata.loadMu.Unlock()
return err
}
......@@ -574,18 +576,22 @@ func (bfdata *BigFileData) readBlk(ctx context.Context, blk int64, dest []byte)
// in deadlock inside kernel.
//
// .loading cleanup is done once we are finished with putting the data into OS cache.
// If we do it earlier - a simultaneous read covered by the same block could result
// into missing both kernel pagecache (if not yet updated) and empty .loading[blk],
// and thus would trigger DB access again.
go func() {
// XXX locking - invalidation must make sure this workers are finished.
st := gfsconn.FileNotifyStoreCache(bfdata.Inode(), blk*blksize, blkdata)
bfdata.loadMu.Lock()
delete bfdata.loading[blk]
delete(bfdata.loading, blk)
bfdata.loadMu.Unlock()
// XXX where to report error
if st != fuse.OK {
return fmt.Errorf("bigfile %s: blk %d: -> pagecache: %s", zbf.POid(), blk, st)
}
}
}()
return nil
}
......
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