Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
68d7065a
Commit
68d7065a
authored
Jul 01, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
638ae251
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
6 deletions
+58
-6
wcfs/wcfs.go
wcfs/wcfs.go
+45
-5
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+13
-1
No files found.
wcfs/wcfs.go
View file @
68d7065a
...
@@ -254,6 +254,9 @@ import (
...
@@ -254,6 +254,9 @@ import (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/pkg/errors"
pickle
"github.com/kisielk/og-rek"
// XXX should be temp here?
)
)
// BigFileRoot represents "/bigfile"
// BigFileRoot represents "/bigfile"
...
@@ -277,7 +280,7 @@ type BigFileHead struct {
...
@@ -277,7 +280,7 @@ type BigFileHead struct {
nodefs
.
Node
nodefs
.
Node
x
*
BigFileX
x
*
BigFileX
data
*
BigFile
Data
data
*
BigFile
//at *BigFileAt
//at *BigFileAt
//inv *BigFileInvalidations
//inv *BigFileInvalidations
}
}
...
@@ -286,7 +289,7 @@ type BigFileHead struct {
...
@@ -286,7 +289,7 @@ type BigFileHead struct {
// XXX also @<tidX>/data ?
// XXX also @<tidX>/data ?
type
BigFile
struct
{
type
BigFile
struct
{
nodefs
.
Node
nodefs
.
Node
head
*
BigFileHead
parent
*
BigFileHead
// XXX name
topoid
zodb
.
Oid
// oid of ZBigFile
topoid
zodb
.
Oid
// oid of ZBigFile
blksize
int64
// ZBigFile.blksize XXX if it is changed - invalidate all? allowed to change?
blksize
int64
// ZBigFile.blksize XXX if it is changed - invalidate all? allowed to change?
...
@@ -330,7 +333,7 @@ func NewBigFileHead(x *BigFileX) *BigFileHead {
...
@@ -330,7 +333,7 @@ func NewBigFileHead(x *BigFileX) *BigFileHead {
func
NewBigFile
(
head
*
BigFileHead
)
*
BigFile
{
func
NewBigFile
(
head
*
BigFileHead
)
*
BigFile
{
return
&
BigFile
{
Node
:
nodefs
.
NewDefaultNode
(),
head
:
head
}
return
&
BigFile
{
Node
:
nodefs
.
NewDefaultNode
(),
parent
:
head
}
}
}
...
@@ -343,19 +346,54 @@ func NewBigFile(head *BigFileHead) *BigFile {
...
@@ -343,19 +346,54 @@ func NewBigFile(head *BigFileHead) *BigFile {
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
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Printf
(
"/bigfile: mkdir
: non-oid: %q
"
,
name
)
log
.
Printf
(
"/bigfile: mkdir
%q: not-oid
"
,
name
)
return
nil
,
fuse
.
EINVAL
return
nil
,
fuse
.
EINVAL
}
}
// XXX ok to ignore mode?
// XXX ok to ignore mode?
br
.
mu
.
Lock
()
br
.
mu
.
Lock
()
defer
br
.
mu
.
Unlock
()
if
_
,
already
:=
br
.
tab
[
oid
];
already
{
if
_
,
already
:=
br
.
tab
[
oid
];
already
{
return
nil
,
fuse
.
Status
(
syscall
.
EEXIST
)
return
nil
,
fuse
.
Status
(
syscall
.
EEXIST
)
}
}
br
.
mu
.
Unlock
()
ctx
:=
context
.
Background
()
// XXX ok?
buf
,
_
,
err
:=
br
.
zstor
.
Load
(
ctx
,
zodb
.
Xid
{
Oid
:
oid
,
At
:
zodb
.
TidMax
})
// FIXME At, use serial
if
err
!=
nil
{
switch
errors
.
Cause
(
err
)
.
(
type
)
{
case
*
zodb
.
NoObjectError
:
return
nil
,
fuse
.
EINVAL
case
*
zodb
.
NoDataError
:
return
nil
,
fuse
.
EINVAL
// XXX ok?
default
:
log
.
Printf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
return
nil
,
fuse
.
EIO
}
}
pybf
,
err
:=
zodb
.
PyData
(
buf
.
Data
)
.
Decode
()
if
err
!=
nil
{
log
.
Printf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
return
nil
,
fuse
.
EIO
}
// XXX -> pyclass.FullName() != "wendelin.bigfile.file_zodb" + ".ZBigFile"
pybfClass
:=
pickle
.
Class
{
Module
:
"wendelin.bigfile.file_zodb"
,
Name
:
".ZBigFile"
}
if
pybf
.
PyClass
!=
pybfClass
{
return
nil
,
fuse
.
EINVAL
}
// XXX other checks?
br
.
mu
.
Lock
()
defer
br
.
mu
.
Unlock
()
// XXX recheck - maybe it was already created while we were not holding br.mu
bx
:=
NewBigFileX
(
oid
,
br
)
bx
:=
NewBigFileX
(
oid
,
br
)
br
.
tab
[
oid
]
=
bx
br
.
tab
[
oid
]
=
bx
...
@@ -390,11 +428,13 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs
...
@@ -390,11 +428,13 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs
// Read implements reading from /bigfile/<bigfileX>/head/data.
// Read implements reading from /bigfile/<bigfileX>/head/data.
// XXX and from /bigfile/<bigfileX>/@<tidX>/data.
// XXX and from /bigfile/<bigfileX>/@<tidX>/data.
/*
func (bf *BigFile) Read(_ nodefs.File, dest []byte, off int64, _ fuse.Context) (fuse.ReadResult, fuse.Status) {
func (bf *BigFile) Read(_ nodefs.File, dest []byte, off int64, _ fuse.Context) (fuse.ReadResult, fuse.Status) {
.at
.at
.topoid
.topoid
// XXX
// XXX
}
}
*/
...
...
wcfs/wcfs_test.py
View file @
68d7065a
...
@@ -28,6 +28,7 @@ from persistent import Persistent
...
@@ -28,6 +28,7 @@ from persistent import Persistent
from
persistent.timestamp
import
TimeStamp
from
persistent.timestamp
import
TimeStamp
import
os
,
os
.
path
,
subprocess
import
os
,
os
.
path
,
subprocess
from
errno
import
EINVAL
from
pytest
import
raises
from
pytest
import
raises
testdb
=
None
testdb
=
None
...
@@ -129,8 +130,18 @@ def test_bigfile_empty():
...
@@ -129,8 +130,18 @@ def test_bigfile_empty():
wc
=
wcfs
.
join
(
testzurl
,
autostart
=
True
)
wc
=
wcfs
.
join
(
testzurl
,
autostart
=
True
)
# path to bigfile/ under wcfs
bigpath
=
wc
.
mountpoint
+
"/bigfile"
# mkdir to non-BigFile - must be rejected
with
raises
(
OSError
)
as
exc
:
os
.
mkdir
(
"%s/%s"
%
(
bigpath
,
last
.
_p_oid
.
encode
(
'hex'
)))
assert
exc
.
value
.
errno
==
EINVAL
"""
# path to f under wcfs
# path to f under wcfs
fpath
=
"%s/
bigfile/%s"
%
(
wc
.
mountpoint
,
f
.
_p_oid
.
encode
(
'hex'
))
fpath = "%s/
%s" % (bigpath
, f._p_oid.encode('hex'))
os.mkdir(fpath)
os.mkdir(fpath)
st = os.stat(fpath + "/head/data")
st = os.stat(fpath + "/head/data")
...
@@ -139,6 +150,7 @@ def test_bigfile_empty():
...
@@ -139,6 +150,7 @@ def test_bigfile_empty():
assert readfile(fpath + "/head/at") == 'txn2'
assert readfile(fpath + "/head/at") == 'txn2'
# XXX head/at = last txn of whole db
# XXX head/at = last txn of whole db
"""
wc
.
close
()
wc
.
close
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment