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
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 (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
//"github.com/pkg/errors"
//pickle "github.com/kisielk/og-rek" // XXX should be temp here?
"github.com/pkg/errors"
)
// BigFileRoot represents "/bigfile"
...
...
@@ -278,15 +276,19 @@ type BigFileRoot struct {
// BigFileDir represents "/bigfile/<bigfileX>"
type
BigFileDir
struct
{
nodefs
.
Node
oid
zodb
.
Oid
root
*
BigFileRoot
zdb
*
zodb
.
DB
// zconn *zodb.Conn
//oid zodb.Oid
//root *BigFileRoot
}
// BigFileHead represents "/bigfile/<bigfileX>/head"
// XXX -> BigFileRev (with head | @tid) ?
type
BigFileHead
struct
{
nodefs
.
Node
x
*
BigFileDir
//
x *BigFileDir
data
*
BigFileData
//at *BigFileAt
...
...
@@ -297,13 +299,13 @@ type BigFileHead struct {
// XXX also @<tidX>/data ?
type
BigFileData
struct
{
nodefs
.
Node
parent
*
BigFileHead
// XXX name
//parent *BigFileHead
topoid
zodb
.
Oid
// oid of ZBigFile
blksize
int64
// ZBigFile.blksize XXX if it is changed - invalidate all? allowed to change?
zconn
*
zodb
.
Connection
// ZODB connection via whcih .zbf is accessed
zbf
*
ZBigFile
head
zodb
.
Tid
// current view of ZODB
lastChange
zodb
.
Tid
// last change to whole bigfile as of .head
view
// TODO
// lastChange zodb.Tid // last change to whole bigfile as of .zconn.At
view
}
...
...
@@ -318,38 +320,38 @@ func NewBigFileRoot(zstor zodb.IStorage) *BigFileRoot {
}
}
func
NewBigFileDir
(
oid
zodb
.
Oid
,
root
*
BigFileRoot
)
*
BigFileDir
{
bx
:=
&
BigFileDir
{
Node
:
nodefs
.
NewDefaultNode
(),
oid
:
oid
,
root
:
root
,
}
return
bx
}
// func NewBigFileDir(oid zodb.Oid, root *BigFileRoot) *BigFileDir {
// bx := &BigFileDir{
// Node: nodefs.NewDefaultNode(),
// oid: oid,
// //root: root,
// }
//
// 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
{
return
&
BigFileData
{
Node
:
nodefs
.
NewDefaultNode
(),
parent
:
head
}
}
//
func NewBigFileData(head *BigFileHead) *BigFileData {
//
return &BigFileData{Node: nodefs.NewDefaultNode(), parent: head}
//
}
// 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
)
if
err
!=
nil
{
log
.
Printf
(
"/bigfile: mkdir %q: not-oid"
,
name
)
...
...
@@ -358,51 +360,35 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nod
// 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
)
}
br
.
mu
.
Unlock
()
// no - without bfroot lock proceed to load corresponding objects from ZODB
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
{
log
.
Printf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
return
nil
,
fuse
.
EIO
}
*/
/* XXX reenable (.zpy not yet here)
pybf, err := br.zpy.Load(ctx, zodb.Xid{Oid: oid, At: zodb.TidMax}) // FIXME At, use serial
// XXX txn.Abort(), put conn back on error
xzbf
,
err
:=
zconn
.
Get
(
ctx
,
oid
)
if
err
!=
nil
{
switch
errors
.
Cause
(
err
)
.
(
type
)
{
case
*
zodb
.
NoObjectError
:
// XXX log?
return
nil
,
fuse
.
EINVAL
case
*
zodb
.
NoDataError
:
// XXX log?
return
nil
,
fuse
.
EINVAL
// XXX ok?
default
:
log
.
Printf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
...
...
@@ -410,34 +396,50 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nod
}
}
// XXX -> pyclass.FullName() != "wendelin.bigfile.file_zodb" + ".ZBigFile"
pybfClass := pickle.Class{Module: "wendelin.bigfile.file_zodb", Name: ".ZBigFile"}
if pybf.PyClass() != pybfClass {
// XXX log?
zbf
,
ok
:=
xzbf
.
(
*
ZBigFile
)
if
!
ok
{
log
.
Printf
(
"/bigfile: mkdir %q: %T is not a ZBigFile"
,
name
,
xzbf
)
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()
defer br.mu.Unlock()
bfdir
:=
&
BigFileDir
{
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)
br.tab[oid] = bx
bfdata
:=
&
BigFileData
{
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 ?
mkdir(bx, "head", bh)
mkfile(bh, "data", bh.data)
bfroot
.
tab
[
oid
]
=
bfdir
bfroot
.
mu
.
Unlock
()
// 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, "invalidations", bh.inv)
return bx.Inode(), fuse.OK
*/
return
bfdir
.
Inode
(),
fuse
.
OK
}
// 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