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
be9fda6c
Commit
be9fda6c
authored
Oct 21, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7829816b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
46 deletions
+21
-46
wcfs/wcfs.go
wcfs/wcfs.go
+21
-46
No files found.
wcfs/wcfs.go
View file @
be9fda6c
...
...
@@ -500,7 +500,6 @@ import (
"github.com/hanwen/go-fuse/v2/fuse/nodefs"
"github.com/pkg/errors"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/set"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/zdata"
)
...
...
@@ -513,8 +512,6 @@ type (
ZBlk1
=
zdata
.
ZBlk1
ZData
=
zdata
.
ZData
ZBigFile
=
zdata
.
ZBigFile
setI64
=
set
.
I64
)
// Root represents root of wcfs filesystem.
...
...
@@ -919,7 +916,6 @@ retry:
}
// resync .zhead to δZ.tid
// XXX -> Head.Resync() ?
// 1. abort old and resync to new txn/at
transaction
.
Current
(
zhead
.
TxnCtx
)
.
Abort
()
...
...
@@ -932,20 +928,21 @@ retry:
// 2. restat invalidated ZBigFile
// NOTE no lock needed since .blksize and .size are constant during lifetime of one txn.
//
XXX
-> parallel
for
foid
:=
range
δF
.
ByFile
{
//
TODO
-> parallel
for
foid
,
δfile
:=
range
δF
.
ByFile
{
file
:=
bfdir
.
fileTab
[
foid
]
// must be present
zfile
:=
file
.
zfile
// XXX need to do only if δfile.Size changed
size
,
sizePath
,
blkCov
,
err
:=
zfile
.
Size
(
ctx
)
if
err
!=
nil
{
return
err
}
if
δfile
.
Size
{
size
,
sizePath
,
blkCov
,
err
:=
zfile
.
Size
(
ctx
)
if
err
!=
nil
{
return
err
}
file
.
size
=
size
// see "3) for */head/data the following invariant is maintained..."
bfdir
.
δFtail
.
Track
(
zfile
,
-
1
,
sizePath
,
blkCov
,
nil
)
file
.
size
=
size
// see "3) for */head/data the following invariant is maintained..."
bfdir
.
δFtail
.
Track
(
zfile
,
-
1
,
sizePath
,
blkCov
,
nil
)
}
// XXX we can miss a change to file if δblk is not yet tracked
// -> need to update file.rev at read time -> locking=XXX
...
...
@@ -1048,7 +1045,7 @@ func (f *BigFile) invalidateBlk(ctx context.Context, blk int64) (err error) {
blkdata
=
make
([]
byte
,
blksize
)
n
,
st
:=
fsconn
.
FileRetrieveCache
(
f
.
Inode
(),
off
,
blkdata
)
if
st
!=
fuse
.
OK
{
// XXX warn
log
.
Errorf
(
"%s: retrieve blk #%d from cache: %s (ignoring, but reading @revX/bigfile will be slow)"
,
f
.
path
(),
blk
,
st
)
}
blkdata
=
blkdata
[
:
n
]
}
...
...
@@ -1143,27 +1140,7 @@ func (root *Root) lockRevFile(rev zodb.Tid, fid zodb.Oid) (_ *BigFile, unlock fu
frevpath
:=
fmt
.
Sprintf
(
"@%s/bigfile/%s"
,
rev
,
fid
)
// relative to fs root for now
defer
xerr
.
Contextf
(
&
err
,
"/: lockRevFile %s"
,
frevpath
)
// FIXME checking for "node{0}" is fragile:
// XXX the node could be still forgotten since we are not holding open on it
// XXX -> always os.open unconditionally for now
// or is it ok since it is just a cache?
// -> no, not ok: if inode ID is forgotten, the same ID could be
// reallocated to another file and then we'll corrupt in-kernel
// cache by wrongly storing data of one file into cache of
// another file.
// -> to avoid this we need to always lock the inode ID with real open.
// XXX (also disabled for now due to race-detector)
/*
// first check without going through kernel, whether the inode maybe known already
xfrev := fsconn.LookupNode(root.Inode(), frevpath)
if xfrev != nil {
if xfrev.String() != "node{0}" {
return xfrev.Node().(*BigFile), func(){}, nil
}
}
*/
// we have to ping the kernel
// open through kernel
frevospath
:=
gmntpt
+
"/"
+
frevpath
// now starting from OS /
f
,
err
:=
os
.
Open
(
frevospath
)
if
err
!=
nil
{
...
...
@@ -1179,7 +1156,7 @@ func (root *Root) lockRevFile(rev zodb.Tid, fid zodb.Oid) (_ *BigFile, unlock fu
// /(head|<rev>)/bigfile/<bigfileX> -> Read serves reading bigfile data.
func
(
f
*
BigFile
)
Read
(
_
nodefs
.
File
,
dest
[]
byte
,
off
int64
,
fctx
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
f
.
head
.
zheadMu
.
RLock
()
// XXX
+fctx to cancel
f
.
head
.
zheadMu
.
RLock
()
// TODO
+fctx to cancel
defer
f
.
head
.
zheadMu
.
RUnlock
()
// cap read request to file size
...
...
@@ -1203,10 +1180,10 @@ func (f *BigFile) Read(_ nodefs.File, dest []byte, off int64, fctx *fuse.Context
if
re
:=
end
%
f
.
blksize
;
re
!=
0
{
aend
+=
f
.
blksize
-
re
}
//
XXX
use original dest if it can fit the data
//
TODO
use original dest if it can fit the data
dest
=
make
([]
byte
,
aend
-
aoff
)
// ~> [aoff:aend) in file
//
XXX
better ctx = transaction.PutIntoContext(ctx, txn)
//
TODO
better ctx = transaction.PutIntoContext(ctx, txn)
ctx
,
cancel
:=
xcontext
.
Merge
(
fctx
,
f
.
head
.
zconn
.
TxnCtx
)
defer
cancel
()
...
...
@@ -2044,7 +2021,7 @@ func (bfdir *BigFileDir) lookup(out *fuse.Attr, name string, fctx *fuse.Context)
return
nil
,
eINVALf
(
"not oid"
)
}
bfdir
.
head
.
zheadMu
.
RLock
()
//
XXX
+fctx -> cancel
bfdir
.
head
.
zheadMu
.
RLock
()
//
TODO
+fctx -> cancel
defer
bfdir
.
head
.
zheadMu
.
RUnlock
()
defer
func
()
{
...
...
@@ -2123,7 +2100,6 @@ func (root *Root) lookup(name string, fctx *fuse.Context) (_ *Head, err error) {
}
// not there - without revMu lock proceed to open @rev view of ZODB
// zconnRev, err := root.zopenAt(fctx, rev)
zconnRev
,
err
:=
xzodb
.
ZOpen
(
fctx
,
root
.
zdb
,
&
zodb
.
ConnOptions
{
At
:
rev
})
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -2257,8 +2233,7 @@ func (f *BigFile) Close() error {
// /(head|<rev>)/at -> readAt serves read.
func
(
h
*
Head
)
readAt
(
fctx
*
fuse
.
Context
)
([]
byte
,
error
)
{
// XXX cancel on fctx cancel
h
.
zheadMu
.
RLock
()
h
.
zheadMu
.
RLock
()
// TODO +fctx -> cancel
defer
h
.
zheadMu
.
RUnlock
()
return
[]
byte
(
h
.
zconn
.
At
()
.
String
()),
nil
...
...
@@ -2268,7 +2243,7 @@ func (h *Head) readAt(fctx *fuse.Context) ([]byte, error) {
func
(
head
*
Head
)
GetAttr
(
out
*
fuse
.
Attr
,
_
nodefs
.
File
,
fctx
*
fuse
.
Context
)
fuse
.
Status
{
at
:=
head
.
rev
if
at
==
0
{
head
.
zheadMu
.
RLock
()
// XXX
+fctx -> cancel
head
.
zheadMu
.
RLock
()
// TODO
+fctx -> cancel
at
=
head
.
zconn
.
At
()
head
.
zheadMu
.
RUnlock
()
}
...
...
@@ -2281,7 +2256,7 @@ func (head *Head) GetAttr(out *fuse.Attr, _ nodefs.File, fctx *fuse.Context) fus
// /(head|<rev>)/bigfile/<bigfileX> -> Getattr serves stat.
func
(
f
*
BigFile
)
GetAttr
(
out
*
fuse
.
Attr
,
_
nodefs
.
File
,
fctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
head
.
zheadMu
.
RLock
()
// XXX
+fctx -> cancel
f
.
head
.
zheadMu
.
RLock
()
// TODO
+fctx -> cancel
defer
f
.
head
.
zheadMu
.
RUnlock
()
f
.
getattr
(
out
)
...
...
@@ -2340,7 +2315,7 @@ func (zh *_wcfs_Zhead) Open(flags uint32, fctx *fuse.Context) (nodefs.File, fuse
sk
:=
NewFileSock
()
sk
.
CloseRead
()
groot
.
head
.
zheadMu
.
Lock
()
// XXX
+fctx -> cancel
groot
.
head
.
zheadMu
.
Lock
()
// TODO
+fctx -> cancel
defer
groot
.
head
.
zheadMu
.
Unlock
()
// XXX del zheadSockTab[sk] on sk.File.Release (= client drops opened handle)
...
...
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