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
6364dc14
Commit
6364dc14
authored
Oct 09, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b77b21f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
21 deletions
+30
-21
wcfs/wcfs.go
wcfs/wcfs.go
+30
-21
No files found.
wcfs/wcfs.go
View file @
6364dc14
...
...
@@ -307,9 +307,13 @@ type BigFile struct {
// XXX do we need to keep it here explicitly?
zconn
*
zodb
.
Connection
// ZBigFile top-level object. Kept a
lways activated (XXX clarify)
// ZBigFile top-level object. Kept a
ctivated during lifetime of current transaction.
zbf
*
ZBigFile
// zbf.Size(). It is constant during liftime of a transaction
// (we do only read-only txn) XXX -> organization overview.
zbfSize
int64
// TODO
// lastChange zodb.Tid // last change to whole bigfile as of .zconn.At view
}
...
...
@@ -417,6 +421,12 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
}
}()
zbfSize
,
err
:=
zbf
.
Size
(
ctx
)
if
err
!=
nil
{
log
.
Errorf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
return
nil
,
fuse
.
EIO
}
// relock bfroot and either mkdir or EEXIST if the directory was maybe
// simultanously created while we were not holding bfroot.mu
bfroot
.
mu
.
Lock
()
...
...
@@ -436,9 +446,10 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
}
bf
:=
&
BigFile
{
txnCtx
:
txnCtx
,
zconn
:
zconn
,
zbf
:
zbf
,
txnCtx
:
txnCtx
,
zconn
:
zconn
,
zbf
:
zbf
,
zbfSize
:
zbfSize
,
}
bfdata
:=
&
BigFileData
{
...
...
@@ -470,26 +481,15 @@ func (bfdata *BigFileData) GetAttr(out *fuse.Attr, _ nodefs.File, fctx *fuse.Con
// XXX locking
bf
:=
bfdata
.
bigfile
zbf
:=
bfdata
.
bigfile
.
zbf
// XXX better ctx = transaction.PutIntoContext(ctx, txn)
ctx
,
cancel
:=
xcontext
.
Merge
(
asctx
(
fctx
),
bf
.
txnCtx
)
defer
cancel
()
size
,
err
:=
zbf
.
Size
(
ctx
)
if
err
!=
nil
{
log
.
Errorf
(
"%s"
,
err
)
// XXX errctx
return
fuse
.
EIO
// XXX extract EFBIG when it is the cause?
}
out
.
Mode
=
fuse
.
S_IFREG
|
0444
out
.
Size
=
uint64
(
s
ize
)
out
.
Size
=
uint64
(
bf
.
zbfS
ize
)
// .Blocks
// .Blksize
// FIXME lastChange should cover all bigfile data, not only ZBigFile itself
//mtime := &bfdata.lastChange.Time().Time
lastChange
:=
bf
data
.
bigfile
.
zbf
.
PSerial
()
lastChange
:=
bf
.
zbf
.
PSerial
()
mtime
:=
lastChange
.
Time
()
.
Time
out
.
SetTimes
(
/*atime=*/
nil
,
/*mtime=*/
&
mtime
,
/*ctime=*/
&
mtime
)
...
...
@@ -505,17 +505,26 @@ func (bfdata *BigFileData) Read(_ nodefs.File, dest []byte, off int64, fctx *fus
bf
:=
bfdata
.
bigfile
zbf
:=
bf
.
zbf
// XXX better ctx = transaction.PutIntoContext(ctx, txn)
ctx
,
cancel
:=
xcontext
.
Merge
(
asctx
(
fctx
),
bf
.
txnCtx
)
defer
cancel
()
// cap read request to file size
end
:=
off
+
int64
(
len
(
dest
))
// XXX overflow?
if
end
>
bf
.
zbfSize
{
end
=
bf
.
zbfSize
}
if
end
<=
off
{
// XXX off >= size -> EINVAL? (but when size=0 kernel issues e.g. [0 +4K) read)
return
fuse
.
ReadResultData
(
nil
),
fuse
.
OK
}
// widen read request to be aligned with blksize granularity
// (we can load only whole ZBlk* blocks)
end
:=
off
+
int64
(
len
(
dest
))
// XXX overflow?
aoff
:=
off
-
(
off
%
zbf
.
blksize
)
aend
:=
end
+
(
zbf
.
blksize
-
(
end
%
zbf
.
blksize
))
dest
=
make
([]
byte
,
aend
-
aoff
)
// ~> [off:aend] in file
// XXX better ctx = transaction.PutIntoContext(ctx, txn)
ctx
,
cancel
:=
xcontext
.
Merge
(
asctx
(
fctx
),
bf
.
txnCtx
)
defer
cancel
()
// read/load all block(s) in parallel
wg
,
ctx
:=
errgroup
.
WithContext
(
ctx
)
for
blkoff
:=
aoff
;
blkoff
<
aend
;
blkoff
+=
zbf
.
blksize
{
...
...
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