Commit dfb82ecc authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4ce4b808
...@@ -54,11 +54,16 @@ func (f *StaticFile) Read(_ nodefs.File, dest []byte, off int64, _ *fuse.Context ...@@ -54,11 +54,16 @@ func (f *StaticFile) Read(_ nodefs.File, dest []byte, off int64, _ *fuse.Context
// mkdir adds child to parent as directory. // mkdir adds child to parent as directory.
//
// Note: parent must to be already in the filesystem tree - i.e. associated
// with inode. if not - nodefs will panic in Inode.NewChild on nil dereference.
func mkdir(parent nodefs.Node, name string, child nodefs.Node) { func mkdir(parent nodefs.Node, name string, child nodefs.Node) {
parent.Inode().NewChild(name, true, child) parent.Inode().NewChild(name, true, child)
} }
// mkfile adds child to parent as file. // mkfile adds child to parent as file.
//
// Note: parent must be already in the filesystem tree (see mkdir for details).
func mkfile(parent nodefs.Node, name string, child nodefs.Node) { func mkfile(parent nodefs.Node, name string, child nodefs.Node) {
parent.Inode().NewChild(name, false, child) parent.Inode().NewChild(name, false, child)
} }
...@@ -262,17 +262,76 @@ type BigFileRoot struct { ...@@ -262,17 +262,76 @@ type BigFileRoot struct {
zstor zodb.IStorage zstor zodb.IStorage
mu sync.Mutex mu sync.Mutex
tab map[zodb.Oid]*BigFile tab map[zodb.Oid]*BigFileX
} }
// BigFileX represents "/bigfile/<bigfileX>"
type BigFileX struct {
nodefs.Node
oid zodb.Oid
root *BigFileRoot
}
// BigFile represents "/bigfile/<bigfileX>/head"
type BigFile struct {
nodefs.Node
x *BigFileX
data *BigFileData
//at *BigFileAt
//inv *BigFileInvalidations
}
// BigFileData represents "/bigfile/<bigfileX>/head/data"
type BigFileData struct {
nodefs.Node
head *BigFile
}
// ---- ctors ---- XXX to down?
func NewBigFileRoot(zstor zodb.IStorage) *BigFileRoot { func NewBigFileRoot(zstor zodb.IStorage) *BigFileRoot {
return &BigFileRoot{ return &BigFileRoot{
Node: nodefs.NewDefaultNode(), Node: nodefs.NewDefaultNode(),
zstor: zstor, zstor: zstor,
tab: make(map[zodb.Oid]*BigFile), tab: make(map[zodb.Oid]*BigFileX),
} }
} }
func NewBigFileX(oid zodb.Oid, root *BigFileRoot) *BigFileX {
bx := &BigFileX{
Node: nodefs.NewDefaultNode(),
oid: oid,
root: root,
}
return bx
}
func NewBigFile(x *BigFileX) *BigFile {
f := &BigFile{Node: nodefs.NewDefaultNode(), x: x}
f.data = NewBigFileData(f)
// XXX + .at
return f
}
func NewBigFileData(head *BigFile) *BigFileData {
return &BigFileData{Node: nodefs.NewDefaultNode(), head: head}
}
// Mkdir receives client request to create /bigfile/<bigfileX>. // Mkdir receives client request to create /bigfile/<bigfileX>.
func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs.Inode, fuse.Status) { func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs.Inode, fuse.Status) {
oid, err := zodb.ParseOid(name) oid, err := zodb.ParseOid(name)
...@@ -290,29 +349,20 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs ...@@ -290,29 +349,20 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs
return nil, fuse.Status(syscall.EEXIST) return nil, fuse.Status(syscall.EEXIST)
} }
bf := NewBigFile(oid, br) bx := NewBigFileX(oid, br)
br.tab[oid] = bf br.tab[oid] = bx
mkdir(br, name, bf) // XXX takes treeLock - ok under br.mu ?
return bf.Inode(), fuse.OK
}
// XXX do we need to support rmdir? (probably no) bf := NewBigFile(bx)
mkdir(br, name, bx) // XXX takes treeLock - ok under br.mu ?
mkdir(bx, "head", bf)
mkfile(bf, "data", bf.data)
// BigFile represents "/bigfile/<bigfileX>" return bx.Inode(), fuse.OK
type BigFile struct {
nodefs.Node
oid zodb.Oid
root *BigFileRoot
} }
func NewBigFile(oid zodb.Oid, root *BigFileRoot) *BigFile { // XXX do we need to support rmdir? (probably no)
return &BigFile{
Node: nodefs.NewDefaultNode(),
oid: oid,
root: root,
}
}
......
...@@ -112,7 +112,12 @@ def test_bigfile_empty(): ...@@ -112,7 +112,12 @@ def test_bigfile_empty():
transaction.commit() transaction.commit()
wc = wcfs.join(testzurl, autostart=True) wc = wcfs.join(testzurl, autostart=True)
os.mkdir("%s/bigfile/%s" % (wc.mountpoint, f._p_oid.encode('hex')))
# path to f under wcfs
fpath = "%s/bigfile/%s" % (wc.mountpoint, f._p_oid.encode('hex'))
os.mkdir(fpath)
os.stat(fpath + "/head/data")
# XXX size(head/data) = 0 # XXX size(head/data) = 0
# XXX mtime(head/data) ~= last txn that changed bigdile # XXX mtime(head/data) ~= last txn that changed bigdile
......
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