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
341cc93b
Commit
341cc93b
authored
Oct 14, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
523794af
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
5 deletions
+45
-5
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+45
-5
No files found.
wcfs/internal/zdata/δftail.go
View file @
341cc93b
...
...
@@ -158,6 +158,8 @@ type ΔFtail struct {
type
_ΔFileTail
struct
{
root
zodb
.
Oid
// .blktab as of @head
vδE
[]
_ΔFileEpoch
// epochs (changes to ZBigFile object itself) ; nil if not yet rebuilt
rebuildJob
*
_RebuildJob
// !nil if vδE rebuild is currently in-progress
}
// _ΔFileEpoch represent a change to ZBigFile object.
...
...
@@ -177,6 +179,12 @@ type zblkTrack struct {
inroot
map
[
zodb
.
Oid
]
setI64
// {} root -> {}blk
}
// _RebuildJob represents currently in-progress vδE rebuilding job.
type
_RebuildJob
struct
{
ready
chan
struct
{}
// closed when job completes
err
error
}
// ΔF represents a change in files space.
type
ΔF
struct
{
...
...
@@ -299,10 +307,11 @@ func (δFtail *ΔFtail) rebuildAll() (err error) {
δZtail
:=
δBtail
.
ΔZtail
()
db
:=
δBtail
.
DB
()
for
foid
:=
range
δFtail
.
trackNew
{
δFtail
.
trackNew
.
Del
(
foid
)
// XXX -> to after vδEBuild
δFtail
.
trackNew
.
Del
(
foid
)
δftail
:=
δFtail
.
byFile
[
foid
]
δftail
.
vδE
,
err
=
vδEBuild
(
foid
,
δZtail
,
db
)
if
err
!=
nil
{
δFtail
.
trackNew
.
Add
(
foid
)
return
err
}
}
...
...
@@ -315,23 +324,54 @@ func (δFtail *ΔFtail) rebuildAll() (err error) {
// it returns corresponding δftail for convenience. XXX
// the only case when vδE actually needs to be rebuilt is when the file just started to be tracked.
//
// XXX naming -> vδEForFile ?
// XXX naming -> vδEForFile ?
vδEBuildIfNeeded?
func
(
δFtail
*
ΔFtail
)
rebuild1IfNeeded
(
foid
zodb
.
Oid
)
(
vδE
[]
_ΔFileEpoch
,
headRoot
zodb
.
Oid
,
err
error
)
{
δFtail
.
mu
.
Lock
()
// TODO verify that there is no in-progress writers
defer
δFtail
.
mu
.
Unlock
()
δftail
:=
δFtail
.
byFile
[
foid
]
if
δftail
.
vδE
==
nil
{
root
:=
δftail
.
root
vδE
=
δftail
.
vδE
if
vδE
!=
nil
{
return
vδE
,
root
,
nil
}
// vδE needs to be built
job
:=
δftail
.
rebuildJob
// rebuild is currently in-progress -> wait for corrsponding job to complete
if
job
!=
nil
{
δFtail
.
mu
.
Unlock
()
<-
job
.
ready
if
job
.
err
==
nil
{
δFtail
.
mu
.
Lock
()
vδE
=
δftail
.
vδE
}
return
vδE
,
root
,
job
.
err
}
// we become responsible to build vδE
// do the build without the lock
job
=
&
_RebuildJob
{
ready
:
make
(
chan
struct
{})}
δftail
.
rebuildJob
=
job
δFtail
.
trackNew
.
Del
(
foid
)
δBtail
:=
δFtail
.
δBtail
// XXX indicate in-progress rebuild via job
δFtail
.
mu
.
Unlock
()
vδE
,
err
=
vδEBuild
(
foid
,
δBtail
.
ΔZtail
(),
δBtail
.
DB
())
δFtail
.
mu
.
Lock
()
if
err
==
nil
{
δftail
.
vδE
=
vδE
}
else
{
δFtail
.
trackNew
.
Add
(
foid
)
}
return
δftail
.
vδE
,
δftail
.
root
,
err
δftail
.
rebuildJob
=
nil
job
.
err
=
err
close
(
job
.
ready
)
return
vδE
,
root
,
err
}
// Update updates δFtail given raw ZODB changes.
...
...
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