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
991d1453
Commit
991d1453
authored
Dec 26, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b720f172
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
25 deletions
+29
-25
wcfs/wcfs.go
wcfs/wcfs.go
+29
-25
No files found.
wcfs/wcfs.go
View file @
991d1453
...
@@ -410,6 +410,7 @@ type Root struct {
...
@@ -410,6 +410,7 @@ type Root struct {
// ZODB DB handle for zstor.
// ZODB DB handle for zstor.
// keeps cache of connections for both head/ and @<rev>/ accesses.
// keeps cache of connections for both head/ and @<rev>/ accesses.
// XXX head won't be kept here and will be .Resync()'ed explicitly?
//
//
// only one connection is used for head/ and only one for each @<rev>.
// only one connection is used for head/ and only one for each @<rev>.
zdb
*
zodb
.
DB
zdb
*
zodb
.
DB
...
@@ -426,12 +427,15 @@ type Root struct {
...
@@ -426,12 +427,15 @@ type Root struct {
type
Head
struct
{
type
Head
struct
{
nodefs
.
Node
nodefs
.
Node
rev
zodb
.
Tid
// 0 for head/, !0 for @<rev>/
rev
zodb
.
Tid
// 0 for head/, !0 for @<rev>/
bfdir
*
BigFileDir
bfdir
*
BigFileDir
// bigfile/
// at, watch, etc - all implicitly linked to by fs
// at - served by .readAt
// watch - implicitly linked to by fs
// ZODB connection for everything under this head
// ZODB connection for everything under this head
zconnMu
sync
.
RWMutex
// protects access to zconn & live _objects_ associated with it
zconnMu
sync
.
RWMutex
// protects access to zconn & live _objects_ associated with it
zconn
*
ZConn
// for head/ zwatcher resyncs head.zconn; others only read zconn objects.
zconn
*
ZConn
// for head/ zwatcher resyncs head.zconn; others only read zconn objects.
// XXX move zconn's current transaction to Head here?
}
}
// /head/watch - served by Watch.
// /head/watch - served by Watch.
...
@@ -447,15 +451,15 @@ type BigFileDir struct {
...
@@ -447,15 +451,15 @@ type BigFileDir struct {
head
*
Head
// parent head/ or @<rev>/
head
*
Head
// parent head/ or @<rev>/
// {} oid -> <bigfileX>
// {} oid -> <bigfileX>
mu
sync
.
Mutex
mu
sync
.
Mutex
t
ab
map
[
zodb
.
Oid
]
*
BigFile
fileT
ab
map
[
zodb
.
Oid
]
*
BigFile
}
}
// /(head|<rev>)/bigfile/<bigfileX> - served by BigFile.
// /(head|<rev>)/bigfile/<bigfileX> - served by BigFile.
type
BigFile
struct
{
type
BigFile
struct
{
nodefs
.
Node
nodefs
.
Node
// this BigFile is under
head; it views ZODB via
head.zconn
// this BigFile is under
.head/bigfile/; it views ZODB via .
head.zconn
// parent's BigFileDir.head is the same.
// parent's BigFileDir.head is the same.
head
*
Head
head
*
Head
...
@@ -465,8 +469,8 @@ type BigFile struct {
...
@@ -465,8 +469,8 @@ type BigFile struct {
// zbf.Size(). It is constant during liftime of current transaction.
// zbf.Size(). It is constant during liftime of current transaction.
zbfSize
int64
zbfSize
int64
// change history of this file.
//
tail
change history of this file.
δFtail
*
ΔTailI64
// [](rev, []#blk)
δFtail
*
ΔTailI64
// [](rev
↑
, []#blk)
// TODO -> δFtail
// TODO -> δFtail
// lastChange zodb.Tid // last change to whole bigfile as of .zconn.At view
// lastChange zodb.Tid // last change to whole bigfile as of .zconn.At view
...
@@ -578,7 +582,7 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) {
...
@@ -578,7 +582,7 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) {
// bfdir locking: similarly not needed, since we are
// bfdir locking: similarly not needed, since we are
// exclusively holding head lock.
// exclusively holding head lock.
for
zfile
,
objBlk
:=
range
obj
.
blkBoundTo
()
{
for
zfile
,
objBlk
:=
range
obj
.
blkBoundTo
()
{
file
,
ok
:=
bfdir
.
t
ab
[
zfile
.
POid
()]
file
,
ok
:=
bfdir
.
fileT
ab
[
zfile
.
POid
()]
if
!
ok
{
if
!
ok
{
// even though zfile is in ZODB cache, the
// even though zfile is in ZODB cache, the
// filesystem already forgot about this file.
// filesystem already forgot about this file.
...
@@ -690,6 +694,14 @@ func (root *Root) mkrevfile(rev zodb.Tid, fid zodb.Oid) (_ *BigFile, err error)
...
@@ -690,6 +694,14 @@ func (root *Root) mkrevfile(rev zodb.Tid, fid zodb.Oid) (_ *BigFile, err error)
// ----------------------------------------
// ----------------------------------------
// /(head|<rev>)/at -> readAt serves read.
func
(
h
*
Head
)
readAt
()
[]
byte
{
h
.
zconnMu
.
RLock
()
defer
h
.
zconnMu
.
RUnlock
()
return
[]
byte
(
h
.
zconn
.
At
()
.
String
())
}
// /(head|<rev>)/bigfile/ -> Lookup receives client request to create /(head|<rev>)/bigfile/<bigfileX>.
// /(head|<rev>)/bigfile/ -> Lookup receives client request to create /(head|<rev>)/bigfile/<bigfileX>.
func
(
bfdir
*
BigFileDir
)
Lookup
(
out
*
fuse
.
Attr
,
name
string
,
fctx
*
fuse
.
Context
)
(
*
nodefs
.
Inode
,
fuse
.
Status
)
{
func
(
bfdir
*
BigFileDir
)
Lookup
(
out
*
fuse
.
Attr
,
name
string
,
fctx
*
fuse
.
Context
)
(
*
nodefs
.
Inode
,
fuse
.
Status
)
{
f
,
err
:=
bfdir
.
lookup
(
out
,
name
,
fctx
)
f
,
err
:=
bfdir
.
lookup
(
out
,
name
,
fctx
)
...
@@ -720,7 +732,7 @@ func (bfdir *BigFileDir) lookup(out *fuse.Attr, name string, fctx *fuse.Context)
...
@@ -720,7 +732,7 @@ func (bfdir *BigFileDir) lookup(out *fuse.Attr, name string, fctx *fuse.Context)
// check to see if dir(oid) is already there
// check to see if dir(oid) is already there
bfdir
.
mu
.
Lock
()
bfdir
.
mu
.
Lock
()
f
,
already
:=
bfdir
.
t
ab
[
oid
]
f
,
already
:=
bfdir
.
fileT
ab
[
oid
]
bfdir
.
mu
.
Unlock
()
bfdir
.
mu
.
Unlock
()
if
already
{
if
already
{
...
@@ -736,14 +748,14 @@ func (bfdir *BigFileDir) lookup(out *fuse.Attr, name string, fctx *fuse.Context)
...
@@ -736,14 +748,14 @@ func (bfdir *BigFileDir) lookup(out *fuse.Attr, name string, fctx *fuse.Context)
// relock bfdir and either register f or, if the file was maybe
// relock bfdir and either register f or, if the file was maybe
// simultanously created while we were not holding bfdir.mu, return that.
// simultanously created while we were not holding bfdir.mu, return that.
bfdir
.
mu
.
Lock
()
bfdir
.
mu
.
Lock
()
f2
,
already
:=
bfdir
.
t
ab
[
oid
]
f2
,
already
:=
bfdir
.
fileT
ab
[
oid
]
if
already
{
if
already
{
bfdir
.
mu
.
Unlock
()
bfdir
.
mu
.
Unlock
()
f
.
Close
()
f
.
Close
()
return
f2
,
nil
return
f2
,
nil
}
}
bfdir
.
t
ab
[
oid
]
=
f
bfdir
.
fileT
ab
[
oid
]
=
f
bfdir
.
mu
.
Unlock
()
bfdir
.
mu
.
Unlock
()
// mkfile takes filesystem treeLock - do it outside bfdir.mu
// mkfile takes filesystem treeLock - do it outside bfdir.mu
...
@@ -813,9 +825,9 @@ func (root *Root) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Inode, err e
...
@@ -813,9 +825,9 @@ func (root *Root) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Inode, err e
}
}
bfdir
:=
&
BigFileDir
{
bfdir
:=
&
BigFileDir
{
Node
:
nodefs
.
NewDefaultNode
(),
Node
:
nodefs
.
NewDefaultNode
(),
head
:
revDir
,
head
:
revDir
,
tab
:
make
(
map
[
zodb
.
Oid
]
*
BigFile
),
fileTab
:
make
(
map
[
zodb
.
Oid
]
*
BigFile
),
}
}
revDir
.
bfdir
=
bfdir
revDir
.
bfdir
=
bfdir
...
@@ -1097,14 +1109,6 @@ func (f *BigFile) readBlk(ctx context.Context, blk int64, dest []byte) error {
...
@@ -1097,14 +1109,6 @@ func (f *BigFile) readBlk(ctx context.Context, blk int64, dest []byte) error {
}
}
// /(head|<rev>)/at -> readAt serves read.
func
(
h
*
Head
)
readAt
()
[]
byte
{
h
.
zconnMu
.
RLock
()
defer
h
.
zconnMu
.
RUnlock
()
return
[]
byte
(
h
.
zconn
.
At
()
.
String
())
}
...
@@ -1170,9 +1174,9 @@ func main() {
...
@@ -1170,9 +1174,9 @@ func main() {
zconn
:
zhead
,
zconn
:
zhead
,
}
}
bfdir
:=
&
BigFileDir
{
bfdir
:=
&
BigFileDir
{
Node
:
nodefs
.
NewDefaultNode
(),
Node
:
nodefs
.
NewDefaultNode
(),
head
:
head
,
head
:
head
,
tab
:
make
(
map
[
zodb
.
Oid
]
*
BigFile
),
fileTab
:
make
(
map
[
zodb
.
Oid
]
*
BigFile
),
}
}
head
.
bfdir
=
bfdir
head
.
bfdir
=
bfdir
...
...
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