Commit 5454a41c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c2e53f66
...@@ -242,15 +242,35 @@ package main ...@@ -242,15 +242,35 @@ package main
// tell the kernel it is fully responsible for invalidating pagecache. // tell the kernel it is fully responsible for invalidating pagecache.
import ( import (
"context"
"flag" "flag"
"log" "log"
"os" "os"
"github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen/go-fuse/fuse/nodefs"
"lab.nexedi.com/kirr/neo/go/zodb"
) )
// option to prevent starting if wcfs was already started ? // BigFileRoot represents "/bigfile"
// option to automatically exit/unmount if there are no requests for some t (UC: autospawned from join) type BigFileRoot struct {
nodefs.Node
zstor zodb.IStorage
}
func NewBigFileRoot(zstor zodb.IStorage) *BigFileRoot {
return &BigFileRoot{
Node: nodefs.NewDefaultNode(),
zstor: zstor,
}
}
// XXX option to prevent starting if wcfs was already started ?
// XXX option to automatically exit/unmount if there are no requests for some t
// (UC: autospawned from join)
func main() { func main() {
log.SetPrefix("wcfs: ") log.SetPrefix("wcfs: ")
...@@ -263,6 +283,16 @@ func main() { ...@@ -263,6 +283,16 @@ func main() {
zurl := flag.Args()[0] zurl := flag.Args()[0]
mntpt := flag.Args()[1] mntpt := flag.Args()[1]
// open zodb storage
ctx := context.Background() // XXX + timeout?
zstor, err := zodb.OpenStorage(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
log.Fatal(err)
}
defer zstor.Close()
// mount root
opts := nodefs.NewOptions() opts := nodefs.NewOptions()
opts.Debug = *debug opts.Debug = *debug
...@@ -275,7 +305,8 @@ func main() { ...@@ -275,7 +305,8 @@ func main() {
// add entries to / // add entries to /
mkfile(root, ".wcfs", NewStaticFile([]byte(zurl))) mkfile(root, ".wcfs", NewStaticFile([]byte(zurl)))
//mkdir(root, "bigfile", ...) mkdir(root, "bigfile", NewBigFileRoot(zstor))
// serve client requests
server.Serve() // XXX Serve returns no eror server.Serve() // XXX Serve returns no eror
} }
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
# See https://www.nexedi.com/licensing for rationale and options. # See https://www.nexedi.com/licensing for rationale and options.
from wendelin.lib.testing import getTestDB from wendelin.lib.testing import getTestDB
from wendelin.bigfile.file_zodb import ZBigFile
from wendelin.bigfile.tests.test_filezodb import blksize
from wendelin import wcfs from wendelin import wcfs
from golang import go, chan import transaction
import os, os.path, subprocess import os, os.path, subprocess
from pytest import raises from pytest import raises
...@@ -77,6 +79,7 @@ def test_join(): ...@@ -77,6 +79,7 @@ def test_join():
wc = wcfs._start(zurl) wc = wcfs._start(zurl)
assert wc.mountpoint == testmntpt assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs") == zurl assert readfile(wc.mountpoint + "/.wcfs") == zurl
assert os.path.isdir(wc.mountpoint + "/bigfile")
wc2 = wcfs.join(zurl, autostart=False) wc2 = wcfs.join(zurl, autostart=False)
assert wc2.mountpoint == wc.mountpoint assert wc2.mountpoint == wc.mountpoint
...@@ -93,5 +96,29 @@ def test_join_autostart(): ...@@ -93,5 +96,29 @@ def test_join_autostart():
wc = wcfs.join(zurl, autostart=True) wc = wcfs.join(zurl, autostart=True)
assert wc.mountpoint == testmntpt assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs") == zurl assert readfile(wc.mountpoint + "/.wcfs") == zurl
assert os.path.isdir(wc.mountpoint + "/bigfile")
wc.close() wc.close()
# XXX parametrize zblk0, zblk1
# XXX select !wcfs mode so that we prepare data through !wcfs path.
def _test_bigfile_empty():
root = testdb.dbopen()
root['zfile'] = f = ZBigFile(blksize)
transaction.commit()
root['aaa'] = 'bbb'
transaction.commit()
wc = wcfs.join(testzurl, autostart=True)
os.mkdir("%s/bigfile/%s" % (wc.mountpoint, f._p_oid.encode('hex')))
# XXX size(head/data) = 0
# XXX mtime(head/data) ~= last txn that changed bigdile
# XXX head/at = last txn of whole db
# XXX non-BigFile - rejected
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