Commit d5568544 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 57a27d67
......@@ -521,6 +521,8 @@ func (bfdata *BigFileData) Read(_ nodefs.File, dest []byte, off int64, fctx *fus
// readBlk serves Read to read 1 ZBlk #blk into destination buffer.
func (bfdata *BigFileData) readBlk(ctx context.Context, blk int64, dest []byte) error {
// XXX errctx?
// check if someone else is already loading this block
bfdata.loadMu.Lock()
loading, already := bfdata.loading[blk]
......@@ -532,7 +534,7 @@ func (bfdata *BigFileData) readBlk(ctx context.Context, blk int64, dest []byte)
}
bfdata.loadMu.Unlock()
// if it is already loading - wait for it
// if it is already loading - just wait for it
if already {
select {
case <-ctx.Done():
......@@ -581,13 +583,20 @@ func (bfdata *BigFileData) readBlk(ctx context.Context, blk int64, dest []byte)
// and thus would trigger DB access again.
go func() {
// XXX locking - invalidation must make sure this workers are finished.
// XXX if direct-io: don't touch pagecache
st := gfsconn.FileNotifyStoreCache(bfdata.Inode(), blk*blksize, blkdata)
bfdata.loadMu.Lock()
delete(bfdata.loading, blk)
bfdata.loadMu.Unlock()
// XXX where to report error
// XXX where to report error (-> log)
// XXX st == ENOSYS -> log once + disable pagecache update?
// EINVAL | ENOENT -> bug
// ENOMEN - kernel is already under memory pressure - we must not keep here
if st != fuse.OK {
return fmt.Errorf("bigfile %s: blk %d: -> pagecache: %s", zbf.POid(), blk, st)
}
......@@ -681,6 +690,11 @@ func main() {
}
gfsconn = fsconn // FIXME temp workaround (see ^^^)
supports := fssrv.KernelSettings().SupportsNotify
if !(supports(fuse.NOTIFY_STORE) && supports(fuse.NOTIFY_RETRIEVE)) {
log.Fatalf("kernel FUSE does not support cache control") // XXX more details?
}
// add entries to /
mkfile(root, ".wcfs", NewStaticFile([]byte(zurl)))
mkdir(root, "bigfile", &BigFileRoot{
......
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