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
100995d6
Commit
100995d6
authored
Oct 11, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
899b6102
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
1 deletion
+89
-1
wcfs/wcfs.go
wcfs/wcfs.go
+89
-1
No files found.
wcfs/wcfs.go
View file @
100995d6
...
...
@@ -287,6 +287,9 @@ type BigFileDir struct {
nodefs
.
Node
zdb
*
zodb
.
DB
revMu
sync
.
Mutex
revTab
map
[
zodb
.
Tid
]
*
BigFileRev
}
// BigFileHead represents "/bigfile/<bigfileX>/head"
...
...
@@ -409,7 +412,7 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
return
nil
,
fuse
.
EINVAL
}
// acti
c
ate ZBigFile and keep it this way
// acti
v
ate ZBigFile and keep it this way
err
=
zbf
.
PActivate
(
ctx
)
if
err
!=
nil
{
log
.
Errorf
(
"/bigfile: mkdir %q: %s"
,
name
,
err
)
...
...
@@ -475,6 +478,91 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
// XXX do we need to support rmdir? (probably no)
// /bigfile/<bigfileX> -> Mkdir receives client request to create @<tid>.
func
(
bfdir
*
BigFileDir
)
Mkdir
(
name
string
,
mode
uint32
,
fctx
*
fuse
.
Context
)
(
*
nodefs
.
Inode
,
fuse
.
Status
)
{
var
tid
zodb
.
Tid
var
err
error
ok
:=
false
if
strings
.
HasPrefix
(
name
,
"@"
)
{
tid
,
err
=
zodb
.
ParseTid
(
name
[
1
:
])
ok
=
(
err
==
nil
)
}
if
!
ok
{
log
.
Warning
(
"/bigfile/XXX: mkdir %q: not-@tid"
,
name
)
return
nil
,
fuse
.
EINVAL
}
// XXX ok to ignore mode?
// XXX vvv dups BigFileRoot.Mkdir ?
// check to see if dir(tid) is already
bfdir
.
mu
.
Lock
()
_
,
already
:=
bfdir
.
revTab
[
tid
]
bfdir
.
mu
.
Unlock
()
if
already
{
return
nil
,
fuse
.
Status
(
syscall
.
EEXIST
)
}
// not there - without bfdir lock proceed to create @tid historical connection
// create new read-only transaction for this bigfile conn
txn
,
txnCtx
:=
transaction
.
New
(
context
.
Background
())
defer
func
()
{
if
status
!=
fuse
.
OK
{
txn
.
Abort
()
}
}
// create new DB/Connection for this @tid
// XXX better ctx = transaction.PutIntoContext(ctx, txn)
ctx
,
cancel
:=
xcontext
.
Merge
(
asctx
(
fctx
),
txnCtx
)
defer
cancel
()
// XXX ok to reuse bfdir.zdb? (or better keep that only for head?)
zconn
,
err
:=
bfdir
.
zdb
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
tid
,
})
...
mkfile
(
bfrev
,
"data"
,
revdata
)
return
bfrev
.
Inode
(),
fuse
.
OK
}
// XXX -> zopen ?
func
openBigFile
(
zopt
*
zodb
.
ConnOptions
)
(,
err
error
){
// XXX errctx
defer
xerr
.
Contextf
(
&
err
,
"XXX"
)
// create new read-only transaction for this bigfile
txn
,
txnCtx
:=
transaction
.
New
(
context
.
Background
())
defer
func
()
{
if
status
!=
fuse
.
OK
{
txn
.
Abort
()
}
}()
// create new DB/Connection for this bigfile open
// XXX better ctx = transaction.PutIntoContext(ctx, txn)
ctx
,
cancel
:=
xcontext
.
Merge
(
asctx
(
fctx
),
txnCtx
)
defer
cancel
()
zconn
,
err
:=
zdb
.
Open
(
ctx
,
zope
)
if
err
!=
nil
{
return
err
//log.Errorf("/bigfile: mkdir %q: %s", name, err)
//return nil, fuse.EIO
}
}
// /bigfile/<bigfileX>/head/data -> Getattr serves stat.
func
(
bfdata
*
BigFileData
)
GetAttr
(
out
*
fuse
.
Attr
,
_
nodefs
.
File
,
fctx
*
fuse
.
Context
)
fuse
.
Status
{
...
...
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