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
b720f172
Commit
b720f172
authored
Dec 25, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2f9c12da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
15 deletions
+37
-15
wcfs/wcfs.go
wcfs/wcfs.go
+37
-15
No files found.
wcfs/wcfs.go
View file @
b720f172
...
...
@@ -425,8 +425,9 @@ type Root struct {
// /(head|<rev>)/ - served by Head.
type
Head
struct
{
nodefs
.
Node
rev
zodb
.
Tid
// 0 for head/, !0 for @<rev>/
// bigfile/, at, watch, etc - all implicitly linked to by fs
rev
zodb
.
Tid
// 0 for head/, !0 for @<rev>/
bfdir
*
BigFileDir
// at, watch, etc - all implicitly linked to by fs
// ZODB connection for everything under this head
zconnMu
sync
.
RWMutex
// protects access to zconn & live _objects_ associated with it
...
...
@@ -541,10 +542,13 @@ func (r *Root) zwatcher(ctx context.Context) (err error) {
// zhandle1 handles 1 event from ZODB notification.
func
(
r
*
Root
)
zhandle1
(
zevent
zodb
.
WatchEvent
)
{
// XXX locking correct? XXX too coarse? -> lock only around "resync .zhead ..." ?
// while we are invalidating OS cache, make sure that nothing, that
// even reads /head/bigfile/*, is running (see 4.6).
r
.
head
.
zconnMu
.
Lock
()
defer
r
.
head
.
zconnMu
.
Unlock
()
zhead
:=
r
.
head
.
zconn
bfdir
:=
r
.
head
.
bfdir
toinvalidate
:=
map
[
*
BigFile
]
SetI64
{}
// {} file -> set(#blk)
...
...
@@ -570,11 +574,21 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) {
// since we write-locked head.zconnMu and bindZFile is
// run when loading objects - thus when head.zconnMu is
// read-locked.
//
// bfdir locking: similarly not needed, since we are
// exclusively holding head lock.
for
zfile
,
objBlk
:=
range
obj
.
blkBoundTo
()
{
blkmap
,
ok
:=
toinvalidate
[
zfile
]
file
,
ok
:=
bfdir
.
tab
[
zfile
.
POid
()]
if
!
ok
{
// even though zfile is in ZODB cache, the
// filesystem already forgot about this file.
continue
}
blkmap
,
ok
:=
toinvalidate
[
file
]
if
!
ok
{
blkmap
=
SetI64
{}
toinvalidate
[
z
file
]
=
blkmap
toinvalidate
[
file
]
=
blkmap
}
blkmap
.
Update
(
objBlk
)
}
...
...
@@ -791,22 +805,27 @@ func (root *Root) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Inode, err e
return
nil
,
syscall
.
EEXIST
}
// XXX -> newHead()
revDir
:=
&
Head
{
Node
:
nodefs
.
NewDefaultNode
(),
rev
:
rev
,
zconn
:
zconnRev
,
}
bfdir
:=
&
BigFileDir
{
Node
:
nodefs
.
NewDefaultNode
(),
head
:
revDir
,
tab
:
make
(
map
[
zodb
.
Oid
]
*
BigFile
),
}
revDir
.
bfdir
=
bfdir
root
.
revTab
[
rev
]
=
revDir
root
.
revMu
.
Unlock
()
// mkdir takes filesystem treeLock - do it outside revMu.
mkdir
(
root
,
name
,
revDir
)
mkdir
(
revDir
,
"bigfile"
,
&
BigFileDir
{
Node
:
nodefs
.
NewDefaultNode
(),
head
:
revDir
,
tab
:
make
(
map
[
zodb
.
Oid
]
*
BigFile
),
})
mkdir
(
revDir
,
"bigfile"
,
bfdir
)
// XXX + "at"
return
revDir
.
Inode
(),
nil
}
...
...
@@ -1144,11 +1163,18 @@ func main() {
zhead
.
Cache
()
.
SetControl
(
&
zodbCacheControl
{})
// XXX +locking?
// mount root + head/
// XXX -> newHead()
head
:=
&
Head
{
Node
:
nodefs
.
NewDefaultNode
(),
rev
:
0
,
zconn
:
zhead
,
}
bfdir
:=
&
BigFileDir
{
Node
:
nodefs
.
NewDefaultNode
(),
head
:
head
,
tab
:
make
(
map
[
zodb
.
Oid
]
*
BigFile
),
}
head
.
bfdir
=
bfdir
root
:=
&
Root
{
Node
:
nodefs
.
NewDefaultNode
(),
...
...
@@ -1183,11 +1209,7 @@ func main() {
// add entries to /
mkfile
(
root
,
".wcfs"
,
NewStaticFile
([]
byte
(
zurl
)))
mkdir
(
root
,
"head"
,
head
)
mkdir
(
head
,
"bigfile"
,
&
BigFileDir
{
Node
:
nodefs
.
NewDefaultNode
(),
head
:
head
,
tab
:
make
(
map
[
zodb
.
Oid
]
*
BigFile
),
})
mkdir
(
head
,
"bigfile"
,
bfdir
)
mkfile
(
head
,
"at"
,
NewSmallFile
(
head
.
readAt
))
// TODO mtime(at) = tidtime(at)
// TODO handle autoexit
...
...
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