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
9f5efdff
Commit
9f5efdff
authored
Dec 25, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
822366a7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
30 deletions
+46
-30
wcfs/wcfs.go
wcfs/wcfs.go
+46
-30
No files found.
wcfs/wcfs.go
View file @
9f5efdff
...
...
@@ -378,6 +378,7 @@ package main
import
(
"context"
"flag"
"fmt"
stdlog
"log"
"os"
"strings"
...
...
@@ -520,7 +521,6 @@ func (cc *zodbCacheControl) WantEvict(obj zodb.IPersistent) bool {
return
false
}
/*
// zwatcher watches for ZODB changes.
// see "4) when we receive an invalidation message from ZODB ..."
func
(
r
*
Root
)
zwatcher
(
ctx
context
.
Context
)
(
err
error
)
{
...
...
@@ -603,6 +603,7 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) {
// XXX see "4.4) for all file/blk to in invalidate we do"
func
(
f
*
BigFile
)
invalidateBlk
(
ctx
context
.
Context
,
blk
int64
)
error
{
fsconn
:=
gfsconn
blksize
:=
f
.
zbf
.
blksize
off
:=
blk
*
blksize
// try to retrieve cache of current head/data[blk]
...
...
@@ -615,11 +616,11 @@ func (f *BigFile) invalidateBlk(ctx context.Context, blk int64) error {
// XXX st != OK -> warn?
blkdata
:=
make
([]
byte
,
blksize
)
n
,
st
:=
fsconn
.
FileRetrieveCache
(
f
.
Inode
(),
off
,
blkdata
)
if
n
== blksize {
if
int64
(
n
)
==
blksize
{
// XXX -> go
// store retrieved data back to OS cache for file @<rev>/file[blk]
blkrev
,
_
:=
f
.
δFtail
.
LastRevOf
(
blk
,
f
.
head
.
zconn
.
At
())
frev
:= groot.revisionedFile(ctx,
blkrev, f.zbf.POid())
frev
,
err
:=
groot
.
mkrevfile
(
blkrev
,
f
.
zbf
.
POid
())
st
=
fsconn
.
FileNotifyStoreCache
(
frev
.
Inode
(),
off
,
blkdata
)
if
st
!=
fuse
.
OK
{
// XXX log - dup wrt readBlk -> common func.
...
...
@@ -634,17 +635,42 @@ func (f *BigFile) invalidateBlk(ctx context.Context, blk int64) error {
}
// mkrevfile makes sure inode of /@<rev>/bigfile/<fid> is known to kernel.
// mkrevfile makes sure inode
ID
of /@<rev>/bigfile/<fid> is known to kernel.
//
// We need node ID to be know to the kernel, when we need to store data into
// file's kernel cache.
//
// For kernel to know node IDmkrevfile has
// file's kernel cache - if the kernel don't have the node ID for the file in
// question, FileNotifyStoreCche will just fail.
//
// XXX why we go through kernel.lookup
func (root *Root) mkrevfile(ctx context.Context, rev zodb.Tid, fid zodb.Oid) (*BigFile, error) {
// For kernel to know the inode mkrevfile issues regular filesystem lookup
// request which goes to kernel and should go back to wcfs. It is thus not safe
// to use mkrevfile from under FUSE request handler as doing so might deadlock.
func
(
root
*
Root
)
mkrevfile
(
rev
zodb
.
Tid
,
fid
zodb
.
Oid
)
(
_
*
BigFile
,
err
error
)
{
fsconn
:=
gfsconn
frevpath
:=
fmt
.
Sprintf
(
"@%s/bigfile/%s"
,
rev
,
fid
)
// relative to fs root for now
defer
xerr
.
Contextf
(
&
err
,
"/: mkrevfile %s"
,
frevpath
)
// first check without going through kernel, whether the inode maybe know already
xfrev
:=
fsconn
.
LookupNode
(
root
.
Inode
(),
frevpath
)
if
xfrev
!=
nil
{
// FIXME checking for "node{0}" is fragile, but currently no other way
if
xfrev
.
String
()
!=
"node{0}"
{
return
xfrev
.
Node
()
.
(
*
BigFile
),
nil
}
}
// we have to ping the kernel
frevospath
:=
gmntpt
+
"/"
+
frevpath
// now starting from OS /
f
,
err
:=
os
.
Open
(
frevospath
)
if
err
!=
nil
{
return
nil
,
err
}
defer
f
.
Close
()
xfrev
=
fsconn
.
LookupNode
(
root
.
Inode
(),
frevpath
)
// must be !nil as open succeeded
return
xfrev
.
Node
()
.
(
*
BigFile
),
nil
}
*/
// ----------------------------------------
...
...
@@ -1070,8 +1096,14 @@ func (h *Head) readAt() []byte {
var
groot
*
Root
var
gfsconn
*
nodefs
.
FileSystemConnector
// file descriptor for opened root of the filesystem
var
grootf
*
os
.
File
// XXX -> fd
// root of the filesystem is mounted here.
//
// we need to talk to kernel and lookup @<rev>/bigfile/<fid> before uploading
// data to kernel cache there. Referencing root of the filesystem via path is
// vulnerable to bugs wrt e.g. `mount --move` and/or mounting something else
// over wcfs. However keeping opened root fd will prevent wcfs to be unmounted,
// so we still have to reference the root via path.
var
gmntpt
string
func
main
()
{
stdlog
.
SetPrefix
(
"wcfs: "
)
...
...
@@ -1138,6 +1170,7 @@ func main() {
}
groot
=
root
// FIXME temp workaround (see ^^^)
gfsconn
=
fsconn
// FIXME ----//----
gmntpt
=
mntpt
// we require proper pagecache control (added to Linux 2.6.36 in 2010)
supports
:=
fssrv
.
KernelSettings
()
.
SupportsNotify
...
...
@@ -1159,22 +1192,5 @@ func main() {
_
=
autoexit
// serve client requests
done
:=
make
(
chan
struct
{})
go
func
()
{
fssrv
.
Serve
()
// XXX Serve returns no error
close
(
done
)
}()
err
=
fssrv
.
WaitMount
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
grootf
,
err
=
os
.
Open
(
mntpt
)
if
err
!=
nil
{
fssrv
.
Unmount
()
log
.
Fatal
(
err
)
}
<-
done
}
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