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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
0e64f33a
Commit
0e64f33a
authored
Oct 01, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
657da1d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
77 deletions
+79
-77
wcfs/wcfs.go
wcfs/wcfs.go
+79
-77
No files found.
wcfs/wcfs.go
View file @
0e64f33a
...
@@ -261,9 +261,7 @@ import (
...
@@ -261,9 +261,7 @@ 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"
"github.com/pkg/errors"
//pickle "github.com/kisielk/og-rek" // XXX should be temp here?
)
)
// BigFileRoot represents "/bigfile"
// BigFileRoot represents "/bigfile"
...
@@ -278,15 +276,19 @@ type BigFileRoot struct {
...
@@ -278,15 +276,19 @@ type BigFileRoot struct {
// BigFileDir represents "/bigfile/<bigfileX>"
// BigFileDir represents "/bigfile/<bigfileX>"
type
BigFileDir
struct
{
type
BigFileDir
struct
{
nodefs
.
Node
nodefs
.
Node
oid
zodb
.
Oid
root
*
BigFileRoot
zdb
*
zodb
.
DB
// zconn *zodb.Conn
//oid zodb.Oid
//root *BigFileRoot
}
}
// BigFileHead represents "/bigfile/<bigfileX>/head"
// BigFileHead represents "/bigfile/<bigfileX>/head"
// XXX -> BigFileRev (with head | @tid) ?
// XXX -> BigFileRev (with head | @tid) ?
type
BigFileHead
struct
{
type
BigFileHead
struct
{
nodefs
.
Node
nodefs
.
Node
x
*
BigFileDir
//
x *BigFileDir
data
*
BigFileData
data
*
BigFileData
//at *BigFileAt
//at *BigFileAt
...
@@ -297,13 +299,13 @@ type BigFileHead struct {
...
@@ -297,13 +299,13 @@ type BigFileHead struct {
// XXX also @<tidX>/data ?
// XXX also @<tidX>/data ?
type
BigFileData
struct
{
type
BigFileData
struct
{
nodefs
.
Node
nodefs
.
Node
parent
*
BigFileHead
// XXX name
//parent *BigFileHead
topoid
zodb
.
Oid
// oid of ZBigFile
zconn
*
zodb
.
Connection
// ZODB connection via whcih .zbf is accessed
blksize
int64
// ZBigFile.blksize XXX if it is changed - invalidate all? allowed to change?
zbf
*
ZBigFile
head
zodb
.
Tid
// current view of ZODB
// TODO
lastChange
zodb
.
Tid
// last change to whole bigfile as of .head
view
// lastChange zodb.Tid // last change to whole bigfile as of .zconn.At
view
}
}
...
@@ -318,38 +320,38 @@ func NewBigFileRoot(zstor zodb.IStorage) *BigFileRoot {
...
@@ -318,38 +320,38 @@ func NewBigFileRoot(zstor zodb.IStorage) *BigFileRoot {
}
}
}
}
func
NewBigFileDir
(
oid
zodb
.
Oid
,
root
*
BigFileRoot
)
*
BigFileDir
{
// func NewBigFileDir(oid zodb.Oid, root *BigFileRoot) *BigFileDir {
bx
:=
&
BigFileDir
{
// bx := &BigFileDir{
Node
:
nodefs
.
NewDefaultNode
(),
// Node: nodefs.NewDefaultNode(),
oid
:
oid
,
// oid: oid,
root
:
root
,
// //root: root,
}
// }
//
return
bx
// return bx
}
// }
func
NewBigFileHead
(
x
*
BigFileDir
)
*
BigFileHead
{
f
:=
&
BigFileHead
{
Node
:
nodefs
.
NewDefaultNode
(),
x
:
x
}
f
.
data
=
NewBigFileData
(
f
)
// XXX + .at
return
f
// func NewBigFileHead(x *BigFileDir) *BigFileHead {
}
// f := &BigFileHead{Node: nodefs.NewDefaultNode(), x: x}
// f.data = NewBigFileData(f)
//
// // XXX + .at
//
// return f
// }
func
NewBigFileData
(
head
*
BigFileHead
)
*
BigFileData
{
//
func NewBigFileData(head *BigFileHead) *BigFileData {
return
&
BigFileData
{
Node
:
nodefs
.
NewDefaultNode
(),
parent
:
head
}
//
return &BigFileData{Node: nodefs.NewDefaultNode(), parent: head}
}
//
}
// Mkdir receives client request to create /bigfile/<bigfileX>.
// Mkdir receives client request to create /bigfile/<bigfileX>.
func
(
b
r
*
BigFileRoot
)
Mkdir
(
name
string
,
mode
uint32
,
fctx
*
fuse
.
Context
)
(
*
nodefs
.
Inode
,
fuse
.
Status
)
{
func
(
b
froot
*
BigFileRoot
)
Mkdir
(
name
string
,
mode
uint32
,
fctx
*
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 %q: not-oid"
,
name
)
log
.
Printf
(
"/bigfile: mkdir %q: not-oid"
,
name
)
...
@@ -358,51 +360,35 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nod
...
@@ -358,51 +360,35 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nod
// XXX ok to ignore mode?
// XXX ok to ignore mode?
br
.
mu
.
Lock
()
// check to see if dir(oid) is already there
bfroot
.
mu
.
Lock
()
_
,
already
:=
bfroot
.
tab
[
oid
]
bfroot
.
mu
.
Unlock
()
if
_
,
already
:=
br
.
tab
[
oid
];
already
{
if
already
{
return
nil
,
fuse
.
Status
(
syscall
.
EEXIST
)
return
nil
,
fuse
.
Status
(
syscall
.
EEXIST
)
}
}
br
.
mu
.
Unlock
()
// no - without bfroot lock proceed to load corresponding objects from ZODB
ctx
:=
asctx
(
fctx
)
ctx
:=
asctx
(
fctx
)
_
=
ctx
return
nil
,
fuse
.
ENOSYS
// XXX temp
// xbf, err := zconn.Get(ctx, oid)
// check err
// check if xbf.(*ZBigFile)
/* XXX kill
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()
// XXX create txn
// create new DB/Connection for this bigfile
zdb
:=
zodb
.
NewDB
(
bfroot
.
zstor
)
zconn
,
err
:=
zdb
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{})
// XXX .NoSync=true ?
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Printf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
log
.
Printf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
return
nil
,
fuse
.
EIO
return
nil
,
fuse
.
EIO
}
}
*/
/* XXX reenable (.zpy not yet here)
// XXX txn.Abort(), put conn back on error
pybf, err := br.zpy.Load(ctx, zodb.Xid{Oid: oid, At: zodb.TidMax}) // FIXME At, use serial
xzbf
,
err
:=
zconn
.
Get
(
ctx
,
oid
)
if
err
!=
nil
{
if
err
!=
nil
{
switch
errors
.
Cause
(
err
)
.
(
type
)
{
switch
errors
.
Cause
(
err
)
.
(
type
)
{
case
*
zodb
.
NoObjectError
:
case
*
zodb
.
NoObjectError
:
// XXX log?
return
nil
,
fuse
.
EINVAL
return
nil
,
fuse
.
EINVAL
case
*
zodb
.
NoDataError
:
case
*
zodb
.
NoDataError
:
// XXX log?
return
nil
,
fuse
.
EINVAL
// XXX ok?
return
nil
,
fuse
.
EINVAL
// XXX ok?
default
:
default
:
log
.
Printf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
log
.
Printf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
...
@@ -410,34 +396,50 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nod
...
@@ -410,34 +396,50 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nod
}
}
}
}
// XXX -> pyclass.FullName() != "wendelin.bigfile.file_zodb" + ".ZBigFile"
zbf
,
ok
:=
xzbf
.
(
*
ZBigFile
)
pybfClass := pickle.Class{Module: "wendelin.bigfile.file_zodb", Name: ".ZBigFile"}
if
!
ok
{
if pybf.PyClass() != pybfClass {
log
.
Printf
(
"/bigfile: mkdir %q: %T is not a ZBigFile"
,
name
,
xzbf
)
// XXX log?
return
nil
,
fuse
.
EINVAL
return
nil
,
fuse
.
EINVAL
}
}
// XXX other checks?
// relock bfroot and either mkdir or EEXIST if the directory was maybe
// simultanously created while we were not holding bfroot.mu
bfroot
.
mu
.
Lock
()
_
,
already
=
bfroot
.
tab
[
oid
]
if
already
{
bfroot
.
mu
.
Unlock
()
return
nil
,
fuse
.
Status
(
syscall
.
EEXIST
)
}
br.mu.Lock()
bfdir
:=
&
BigFileDir
{
defer br.mu.Unlock()
Node
:
nodefs
.
NewDefaultNode
(),
zdb
:
zdb
,
}
// XXX recheck - maybe it was already created while we were not holding br.mu
bfhead
:=
&
BigFileHead
{
Node
:
nodefs
.
NewDefaultNode
(),
}
bx := NewBigFileX(oid, br)
bfdata
:=
&
BigFileData
{
br.tab[oid] = bx
Node
:
nodefs
.
NewDefaultNode
(),
zconn
:
zconn
,
zbf
:
zbf
,
}
b
h := NewBigFileHead(bx)
b
fhead
.
data
=
bfdata
mkdir(br, name, bx) // XXX takes treeLock - ok under br.mu ?
bfroot
.
tab
[
oid
]
=
bfdir
mkdir(bx, "head", bh)
bfroot
.
mu
.
Unlock
()
mkfile(bh, "data", bh.data)
// mkdir takes filesystem treeLock - do it outside bfroot.mu
mkdir
(
bfroot
,
name
,
bfdir
)
mkdir
(
bfdir
,
"head"
,
bfhead
)
mkfile
(
bfhead
,
"data"
,
bfdata
)
// XXX mkfile(bh, "at", bh.at)
// XXX mkfile(bh, "at", bh.at)
// XXX mkfile(bh, "invalidations", bh.inv)
// XXX mkfile(bh, "invalidations", bh.inv)
return bx.Inode(), fuse.OK
return
bfdir
.
Inode
(),
fuse
.
OK
*/
}
}
// XXX do we need to support rmdir? (probably no)
// XXX do we need to support rmdir? (probably no)
...
...
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