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
9b5b068c
Commit
9b5b068c
authored
Apr 05, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6a1e4f53
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
109 deletions
+2
-109
wcfs/misc.go
wcfs/misc.go
+0
-108
wcfs/wcfs.go
wcfs/wcfs.go
+2
-1
No files found.
wcfs/misc.go
View file @
9b5b068c
...
@@ -455,14 +455,6 @@ type ZConn struct {
...
@@ -455,14 +455,6 @@ type ZConn struct {
// read-only transaction under which we access zodb.Connection data.
// read-only transaction under which we access zodb.Connection data.
txnCtx
context
.
Context
// XXX -> better directly store txn
txnCtx
context
.
Context
// XXX -> better directly store txn
/* XXX redecided to purge files and @<rev>/ on atime timeout
// for historic @<rev> access the connection can be shared between several bigfiles.
// since we want to free such connections when no longer needed we
// return zodb.Connection back to zodb.DB when refcnt drops to 0.
refcnt int32
*/
}
}
// zopen opens new connection to ZODB database + associated read-only transaction.
// zopen opens new connection to ZODB database + associated read-only transaction.
...
@@ -487,109 +479,9 @@ func zopen(ctx context.Context, zdb *zodb.DB, zopt *zodb.ConnOptions) (_ *ZConn,
...
@@ -487,109 +479,9 @@ func zopen(ctx context.Context, zdb *zodb.DB, zopt *zodb.ConnOptions) (_ *ZConn,
return
&
ZConn
{
return
&
ZConn
{
Connection
:
zconn
,
Connection
:
zconn
,
txnCtx
:
txnCtx
,
txnCtx
:
txnCtx
,
// refcnt: 1,
},
nil
},
nil
}
}
/*
// Release decrements reference count and releases connection back to zodb.DB
// if it is no longer used.
func (zc *ZConn) Release() {
rc := atomic.AddInt32(&zc.refcnt, -1)
if rc < 0 {
panic("ZConn.Release: refcnt < 0")
}
if rc > 0 {
return
}
txn := transaction.Current(zc.txnCtx)
txn.Abort()
zc.Connection = nil
zc.txnCtx = nil
}
// Incref increments connection's reference counter by 1.
func (zc *ZConn) Incref() {
rc := atomic.AddInt32(&zc.refcnt, +1)
if rc <= 1 {
panic("Zconn.Incref: refcnt was < 1")
}
}
// zopenAt opens historic connection @<rev>.
//
// if the connection for this @<rev> was already opened - it is shared.
func (r *Root) zopenAt(ctx context.Context, rev zodb.Tid) (_ *ZConn, err error) {
// check if zconn for @<rev> is already there
r.revMu.Lock()
zconn := r.revTab[rev]
if zconn != nil {
if atomic.LoadInt32(&zconn.refcnt) > 0 {
zconn.Incref()
} else {
zconn = nil // in-progress destruction
}
}
r.revMu.Unlock()
if zconn != nil {
return zconn, nil
}
// not there - without revMu lock proceed to open it
zconn, err = zopen(ctx, r.zdb, &zodb.ConnOptions{At: rev})
if err != nil {
return nil, err
}
// relock revTab and either register zconn, or return another zconn2,
// that might have been opened while we were not holding revMu.
r.revMu.Lock()
defer r.revMu.Unlock()
zconn2 := r.revTab[rev]
if zconn2 != nil {
if atomic.LoadInt32(&zconn2.refcnt) > 0 {
zconn.Release() // FIXME aborts txn -> just drop zconn
zconn2.Incref()
return zconn2, nil
}
// else it was another in-progress destruction
}
r.revTab[rev] = zconn
// schedule del revTab[rev] on zconn destroy
txn := transaction.Current(zconn.txnCtx)
txn.RegisterSync(&zrevTabUnregister{r, zconn})
return zconn, nil
}
// zrevTabUnregister unregisters zconn from root.revTab on zconn's transaction abort.
type zrevTabUnregister struct {
root *Root
zconn *ZConn
}
func (u *zrevTabUnregister) BeforeCompletion(txn transaction.Transaction) {}
func (u *zrevTabUnregister) AfterCompletion(txn transaction.Transaction) {
rev := u.zconn.At()
u.root.revMu.Lock()
defer u.root.revMu.Unlock()
// delete only if zconn is still registered - as another zconn2 might have
// been already registered instead while zconn was in revTab with refcnt=0.
if u.root.revTab[rev] == u.zconn {
delete(u.root.revTab, rev)
}
}
*/
// tidmax returns latest revision.
// tidmax returns latest revision.
func
tidmax
(
a
,
b
zodb
.
Tid
)
zodb
.
Tid
{
func
tidmax
(
a
,
b
zodb
.
Tid
)
zodb
.
Tid
{
if
a
>
b
{
if
a
>
b
{
...
...
wcfs/wcfs.go
View file @
9b5b068c
...
@@ -2040,6 +2040,7 @@ func (root *Root) lookup(name string, fctx *fuse.Context) (_ *Head, err error) {
...
@@ -2040,6 +2040,7 @@ func (root *Root) lookup(name string, fctx *fuse.Context) (_ *Head, err error) {
root
.
revMu
.
Unlock
()
root
.
revMu
.
Unlock
()
if
already
{
if
already
{
// XXX race wrt simlutaneous "FORGET @<rev>" ?
return
revDir
,
nil
return
revDir
,
nil
}
}
...
@@ -2065,7 +2066,7 @@ func (root *Root) lookup(name string, fctx *fuse.Context) (_ *Head, err error) {
...
@@ -2065,7 +2066,7 @@ func (root *Root) lookup(name string, fctx *fuse.Context) (_ *Head, err error) {
revDir
=
&
Head
{
revDir
=
&
Head
{
fsNode
:
newFSNode
(
&
fsOptions
{
Sticky
:
false
}),
// XXX + Head.OnForget() -> del root.revTab[]
fsNode
:
newFSNode
(
&
fsOptions
{
Sticky
:
false
}),
// XXX + Head.OnForget() -> del root.revTab[]
rev
:
rev
,
rev
:
rev
,
zconn
:
zconnRev
,
zconn
:
zconnRev
,
// XXX + Head.OnForget() -> release zconn (= abort zconn.txnCtx)
}
}
bfdir
:=
&
BigFileDir
{
bfdir
:=
&
BigFileDir
{
...
...
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