Commit be9fda6c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7829816b
...@@ -500,7 +500,6 @@ import ( ...@@ -500,7 +500,6 @@ import (
"github.com/hanwen/go-fuse/v2/fuse/nodefs" "github.com/hanwen/go-fuse/v2/fuse/nodefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/set"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb" "lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/zdata" "lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/zdata"
) )
...@@ -513,8 +512,6 @@ type ( ...@@ -513,8 +512,6 @@ type (
ZBlk1 = zdata.ZBlk1 ZBlk1 = zdata.ZBlk1
ZData = zdata.ZData ZData = zdata.ZData
ZBigFile = zdata.ZBigFile ZBigFile = zdata.ZBigFile
setI64 = set.I64
) )
// Root represents root of wcfs filesystem. // Root represents root of wcfs filesystem.
...@@ -919,7 +916,6 @@ retry: ...@@ -919,7 +916,6 @@ retry:
} }
// resync .zhead to δZ.tid // resync .zhead to δZ.tid
// XXX -> Head.Resync() ?
// 1. abort old and resync to new txn/at // 1. abort old and resync to new txn/at
transaction.Current(zhead.TxnCtx).Abort() transaction.Current(zhead.TxnCtx).Abort()
...@@ -932,20 +928,21 @@ retry: ...@@ -932,20 +928,21 @@ retry:
// 2. restat invalidated ZBigFile // 2. restat invalidated ZBigFile
// NOTE no lock needed since .blksize and .size are constant during lifetime of one txn. // NOTE no lock needed since .blksize and .size are constant during lifetime of one txn.
// XXX -> parallel // TODO -> parallel
for foid := range δF.ByFile { for foid, δfile := range δF.ByFile {
file := bfdir.fileTab[foid] // must be present file := bfdir.fileTab[foid] // must be present
zfile := file.zfile zfile := file.zfile
// XXX need to do only if δfile.Size changed if δfile.Size {
size, sizePath, blkCov, err := zfile.Size(ctx) size, sizePath, blkCov, err := zfile.Size(ctx)
if err != nil { if err != nil {
return err return err
} }
file.size = size file.size = size
// see "3) for */head/data the following invariant is maintained..." // see "3) for */head/data the following invariant is maintained..."
bfdir.δFtail.Track(zfile, -1, sizePath, blkCov, nil) bfdir.δFtail.Track(zfile, -1, sizePath, blkCov, nil)
}
// XXX we can miss a change to file if δblk is not yet tracked // XXX we can miss a change to file if δblk is not yet tracked
// -> need to update file.rev at read time -> locking=XXX // -> need to update file.rev at read time -> locking=XXX
...@@ -1048,7 +1045,7 @@ func (f *BigFile) invalidateBlk(ctx context.Context, blk int64) (err error) { ...@@ -1048,7 +1045,7 @@ func (f *BigFile) invalidateBlk(ctx context.Context, blk int64) (err error) {
blkdata = make([]byte, blksize) blkdata = make([]byte, blksize)
n, st := fsconn.FileRetrieveCache(f.Inode(), off, blkdata) n, st := fsconn.FileRetrieveCache(f.Inode(), off, blkdata)
if st != fuse.OK { if st != fuse.OK {
// XXX warn log.Errorf("%s: retrieve blk #%d from cache: %s (ignoring, but reading @revX/bigfile will be slow)", f.path(), blk, st)
} }
blkdata = blkdata[:n] blkdata = blkdata[:n]
} }
...@@ -1143,27 +1140,7 @@ func (root *Root) lockRevFile(rev zodb.Tid, fid zodb.Oid) (_ *BigFile, unlock fu ...@@ -1143,27 +1140,7 @@ func (root *Root) lockRevFile(rev zodb.Tid, fid zodb.Oid) (_ *BigFile, unlock fu
frevpath := fmt.Sprintf("@%s/bigfile/%s", rev, fid) // relative to fs root for now frevpath := fmt.Sprintf("@%s/bigfile/%s", rev, fid) // relative to fs root for now
defer xerr.Contextf(&err, "/: lockRevFile %s", frevpath) defer xerr.Contextf(&err, "/: lockRevFile %s", frevpath)
// FIXME checking for "node{0}" is fragile: // open through kernel
// XXX the node could be still forgotten since we are not holding open on it
// XXX -> always os.open unconditionally for now
// or is it ok since it is just a cache?
// -> no, not ok: if inode ID is forgotten, the same ID could be
// reallocated to another file and then we'll corrupt in-kernel
// cache by wrongly storing data of one file into cache of
// another file.
// -> to avoid this we need to always lock the inode ID with real open.
// XXX (also disabled for now due to race-detector)
/*
// first check without going through kernel, whether the inode maybe known already
xfrev := fsconn.LookupNode(root.Inode(), frevpath)
if xfrev != nil {
if xfrev.String() != "node{0}" {
return xfrev.Node().(*BigFile), func(){}, nil
}
}
*/
// we have to ping the kernel
frevospath := gmntpt + "/" + frevpath // now starting from OS / frevospath := gmntpt + "/" + frevpath // now starting from OS /
f, err := os.Open(frevospath) f, err := os.Open(frevospath)
if err != nil { if err != nil {
...@@ -1179,7 +1156,7 @@ func (root *Root) lockRevFile(rev zodb.Tid, fid zodb.Oid) (_ *BigFile, unlock fu ...@@ -1179,7 +1156,7 @@ func (root *Root) lockRevFile(rev zodb.Tid, fid zodb.Oid) (_ *BigFile, unlock fu
// /(head|<rev>)/bigfile/<bigfileX> -> Read serves reading bigfile data. // /(head|<rev>)/bigfile/<bigfileX> -> Read serves reading bigfile data.
func (f *BigFile) Read(_ nodefs.File, dest []byte, off int64, fctx *fuse.Context) (fuse.ReadResult, fuse.Status) { func (f *BigFile) Read(_ nodefs.File, dest []byte, off int64, fctx *fuse.Context) (fuse.ReadResult, fuse.Status) {
f.head.zheadMu.RLock() // XXX +fctx to cancel f.head.zheadMu.RLock() // TODO +fctx to cancel
defer f.head.zheadMu.RUnlock() defer f.head.zheadMu.RUnlock()
// cap read request to file size // cap read request to file size
...@@ -1203,10 +1180,10 @@ func (f *BigFile) Read(_ nodefs.File, dest []byte, off int64, fctx *fuse.Context ...@@ -1203,10 +1180,10 @@ func (f *BigFile) Read(_ nodefs.File, dest []byte, off int64, fctx *fuse.Context
if re := end % f.blksize; re != 0 { if re := end % f.blksize; re != 0 {
aend += f.blksize - re aend += f.blksize - re
} }
// XXX use original dest if it can fit the data // TODO use original dest if it can fit the data
dest = make([]byte, aend - aoff) // ~> [aoff:aend) in file dest = make([]byte, aend - aoff) // ~> [aoff:aend) in file
// XXX better ctx = transaction.PutIntoContext(ctx, txn) // TODO better ctx = transaction.PutIntoContext(ctx, txn)
ctx, cancel := xcontext.Merge(fctx, f.head.zconn.TxnCtx) ctx, cancel := xcontext.Merge(fctx, f.head.zconn.TxnCtx)
defer cancel() defer cancel()
...@@ -2044,7 +2021,7 @@ func (bfdir *BigFileDir) lookup(out *fuse.Attr, name string, fctx *fuse.Context) ...@@ -2044,7 +2021,7 @@ func (bfdir *BigFileDir) lookup(out *fuse.Attr, name string, fctx *fuse.Context)
return nil, eINVALf("not oid") return nil, eINVALf("not oid")
} }
bfdir.head.zheadMu.RLock() // XXX +fctx -> cancel bfdir.head.zheadMu.RLock() // TODO +fctx -> cancel
defer bfdir.head.zheadMu.RUnlock() defer bfdir.head.zheadMu.RUnlock()
defer func() { defer func() {
...@@ -2123,7 +2100,6 @@ func (root *Root) lookup(name string, fctx *fuse.Context) (_ *Head, err error) { ...@@ -2123,7 +2100,6 @@ func (root *Root) lookup(name string, fctx *fuse.Context) (_ *Head, err error) {
} }
// not there - without revMu lock proceed to open @rev view of ZODB // not there - without revMu lock proceed to open @rev view of ZODB
// zconnRev, err := root.zopenAt(fctx, rev)
zconnRev, err := xzodb.ZOpen(fctx, root.zdb, &zodb.ConnOptions{At: rev}) zconnRev, err := xzodb.ZOpen(fctx, root.zdb, &zodb.ConnOptions{At: rev})
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -2257,8 +2233,7 @@ func (f *BigFile) Close() error { ...@@ -2257,8 +2233,7 @@ func (f *BigFile) Close() error {
// /(head|<rev>)/at -> readAt serves read. // /(head|<rev>)/at -> readAt serves read.
func (h *Head) readAt(fctx *fuse.Context) ([]byte, error) { func (h *Head) readAt(fctx *fuse.Context) ([]byte, error) {
// XXX cancel on fctx cancel h.zheadMu.RLock() // TODO +fctx -> cancel
h.zheadMu.RLock()
defer h.zheadMu.RUnlock() defer h.zheadMu.RUnlock()
return []byte(h.zconn.At().String()), nil return []byte(h.zconn.At().String()), nil
...@@ -2268,7 +2243,7 @@ func (h *Head) readAt(fctx *fuse.Context) ([]byte, error) { ...@@ -2268,7 +2243,7 @@ func (h *Head) readAt(fctx *fuse.Context) ([]byte, error) {
func (head *Head) GetAttr(out *fuse.Attr, _ nodefs.File, fctx *fuse.Context) fuse.Status { func (head *Head) GetAttr(out *fuse.Attr, _ nodefs.File, fctx *fuse.Context) fuse.Status {
at := head.rev at := head.rev
if at == 0 { if at == 0 {
head.zheadMu.RLock() // XXX +fctx -> cancel head.zheadMu.RLock() // TODO +fctx -> cancel
at = head.zconn.At() at = head.zconn.At()
head.zheadMu.RUnlock() head.zheadMu.RUnlock()
} }
...@@ -2281,7 +2256,7 @@ func (head *Head) GetAttr(out *fuse.Attr, _ nodefs.File, fctx *fuse.Context) fus ...@@ -2281,7 +2256,7 @@ func (head *Head) GetAttr(out *fuse.Attr, _ nodefs.File, fctx *fuse.Context) fus
// /(head|<rev>)/bigfile/<bigfileX> -> Getattr serves stat. // /(head|<rev>)/bigfile/<bigfileX> -> Getattr serves stat.
func (f *BigFile) GetAttr(out *fuse.Attr, _ nodefs.File, fctx *fuse.Context) fuse.Status { func (f *BigFile) GetAttr(out *fuse.Attr, _ nodefs.File, fctx *fuse.Context) fuse.Status {
f.head.zheadMu.RLock() // XXX +fctx -> cancel f.head.zheadMu.RLock() // TODO +fctx -> cancel
defer f.head.zheadMu.RUnlock() defer f.head.zheadMu.RUnlock()
f.getattr(out) f.getattr(out)
...@@ -2340,7 +2315,7 @@ func (zh *_wcfs_Zhead) Open(flags uint32, fctx *fuse.Context) (nodefs.File, fuse ...@@ -2340,7 +2315,7 @@ func (zh *_wcfs_Zhead) Open(flags uint32, fctx *fuse.Context) (nodefs.File, fuse
sk := NewFileSock() sk := NewFileSock()
sk.CloseRead() sk.CloseRead()
groot.head.zheadMu.Lock() // XXX +fctx -> cancel groot.head.zheadMu.Lock() // TODO +fctx -> cancel
defer groot.head.zheadMu.Unlock() defer groot.head.zheadMu.Unlock()
// XXX del zheadSockTab[sk] on sk.File.Release (= client drops opened handle) // XXX del zheadSockTab[sk] on sk.File.Release (= client drops opened handle)
......
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