Commit e4125185 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 968a761e
......@@ -255,6 +255,9 @@ import (
"sync"
"syscall"
"lab.nexedi.com/kirr/go123/xcontext"
"lab.nexedi.com/kirr/neo/go/transaction"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
_ "lab.nexedi.com/kirr/neo/go/zodb/wks"
......@@ -301,7 +304,13 @@ type BigFileData struct {
nodefs.Node
//parent *BigFileHead
zconn *zodb.Connection // ZODB connection via whcih .zbf is accessed
// current read-only transaction under which we access ZODB data
txnCtx context.Context // XXX -> directly store txn
// connection via which ZODB object for this bigfile are accessed
// XXX do we need to keep it here explicitly?
zconn *zodb.Connection
zbf *ZBigFile
// TODO
......@@ -312,7 +321,7 @@ type BigFileData struct {
// /bigfile -> Mkdir receives client request to create /bigfile/<bigfileX>.
//
// It creates <bigfileX>/head/data along the way.
func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nodefs.Inode, fuse.Status) {
func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (_ *nodefs.Inode, status fuse.Status) {
oid, err := zodb.ParseOid(name)
if err != nil {
log.Printf("/bigfile: mkdir %q: not-oid", name)
......@@ -330,11 +339,23 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
return nil, fuse.Status(syscall.EEXIST)
}
// no - without bfroot lock proceed to load corresponding objects from ZODB
ctx := asctx(fctx)
// not there - without bfroot lock proceed to load corresponding objects from ZODB:
// create new read-only transaction for this bigfile
txn, txnCtx := transaction.New(context.Background())
defer func() {
if status != fuse.OK {
txn.Abort()
}
}()
// XXX create txn
// create new DB/Connection for this bigfile
// XXX better ctx = transaction.PutIntoContext(ctx, txn)
ctx, cancel := xcontext.Merge(asctx(fctx), txnCtx)
defer cancel()
zdb := zodb.NewDB(bfroot.zstor)
zconn, err := zdb.Open(ctx, &zodb.ConnOptions{}) // XXX .NoSync=true ?
if err != nil {
......@@ -342,8 +363,6 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
return nil, fuse.EIO
}
// XXX txn.Abort(), put conn back on error
xzbf, err := zconn.Get(ctx, oid)
if err != nil {
switch errors.Cause(err).(type) {
......@@ -383,9 +402,10 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
}
bfdata := &BigFileData{
Node: nodefs.NewDefaultNode(),
zconn: zconn,
zbf: zbf,
Node: nodefs.NewDefaultNode(),
txnCtx: txnCtx,
zconn: zconn,
zbf: zbf,
}
bfhead.data = bfdata
......
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