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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
9 deletions
+49
-9
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+49
-9
No files found.
wcfs/internal/zdata/δftail.go
View file @
341cc93b
...
@@ -158,6 +158,8 @@ type ΔFtail struct {
...
@@ -158,6 +158,8 @@ type ΔFtail struct {
type
_ΔFileTail
struct
{
type
_ΔFileTail
struct
{
root
zodb
.
Oid
// .blktab as of @head
root
zodb
.
Oid
// .blktab as of @head
vδE
[]
_ΔFileEpoch
// epochs (changes to ZBigFile object itself) ; nil if not yet rebuilt
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.
// _ΔFileEpoch represent a change to ZBigFile object.
...
@@ -177,6 +179,12 @@ type zblkTrack struct {
...
@@ -177,6 +179,12 @@ type zblkTrack struct {
inroot
map
[
zodb
.
Oid
]
setI64
// {} root -> {}blk
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.
// ΔF represents a change in files space.
type
ΔF
struct
{
type
ΔF
struct
{
...
@@ -299,10 +307,11 @@ func (δFtail *ΔFtail) rebuildAll() (err error) {
...
@@ -299,10 +307,11 @@ func (δFtail *ΔFtail) rebuildAll() (err error) {
δZtail
:=
δBtail
.
ΔZtail
()
δZtail
:=
δBtail
.
ΔZtail
()
db
:=
δBtail
.
DB
()
db
:=
δBtail
.
DB
()
for
foid
:=
range
δFtail
.
trackNew
{
for
foid
:=
range
δFtail
.
trackNew
{
δFtail
.
trackNew
.
Del
(
foid
)
// XXX -> to after vδEBuild
δFtail
.
trackNew
.
Del
(
foid
)
δftail
:=
δFtail
.
byFile
[
foid
]
δftail
:=
δFtail
.
byFile
[
foid
]
δftail
.
vδE
,
err
=
vδEBuild
(
foid
,
δZtail
,
db
)
δftail
.
vδE
,
err
=
vδEBuild
(
foid
,
δZtail
,
db
)
if
err
!=
nil
{
if
err
!=
nil
{
δFtail
.
trackNew
.
Add
(
foid
)
return
err
return
err
}
}
}
}
...
@@ -315,23 +324,54 @@ func (δFtail *ΔFtail) rebuildAll() (err error) {
...
@@ -315,23 +324,54 @@ func (δFtail *ΔFtail) rebuildAll() (err error) {
// it returns corresponding δftail for convenience. XXX
// 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.
// 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
)
{
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
δFtail
.
mu
.
Lock
()
// TODO verify that there is no in-progress writers
defer
δFtail
.
mu
.
Unlock
()
defer
δFtail
.
mu
.
Unlock
()
δftail
:=
δFtail
.
byFile
[
foid
]
δftail
:=
δFtail
.
byFile
[
foid
]
if
δftail
.
vδE
==
nil
{
root
:=
δftail
.
root
δFtail
.
trackNew
.
Del
(
foid
)
vδE
=
δftail
.
vδE
δBtail
:=
δFtail
.
δBtail
if
vδE
!=
nil
{
// XXX indicate in-progress rebuild via job
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
()
δFtail
.
mu
.
Unlock
()
vδE
,
err
=
vδEBuild
(
foid
,
δBtail
.
ΔZtail
(),
δBtail
.
DB
())
<-
job
.
ready
δFtail
.
mu
.
Lock
()
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
δFtail
.
mu
.
Unlock
()
vδE
,
err
=
vδEBuild
(
foid
,
δBtail
.
ΔZtail
(),
δBtail
.
DB
())
δFtail
.
mu
.
Lock
()
if
err
==
nil
{
δftail
.
vδE
=
vδE
δ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.
// 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