Commit 100995d6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 899b6102
......@@ -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
}
// acticate ZBigFile and keep it this way
// activate 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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment