Commit e4125185 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 968a761e
...@@ -255,6 +255,9 @@ import ( ...@@ -255,6 +255,9 @@ import (
"sync" "sync"
"syscall" "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"
"lab.nexedi.com/kirr/neo/go/zodb/btree" "lab.nexedi.com/kirr/neo/go/zodb/btree"
_ "lab.nexedi.com/kirr/neo/go/zodb/wks" _ "lab.nexedi.com/kirr/neo/go/zodb/wks"
...@@ -301,7 +304,13 @@ type BigFileData struct { ...@@ -301,7 +304,13 @@ type BigFileData struct {
nodefs.Node nodefs.Node
//parent *BigFileHead //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 zbf *ZBigFile
// TODO // TODO
...@@ -312,7 +321,7 @@ type BigFileData struct { ...@@ -312,7 +321,7 @@ type BigFileData struct {
// /bigfile -> Mkdir receives client request to create /bigfile/<bigfileX>. // /bigfile -> Mkdir receives client request to create /bigfile/<bigfileX>.
// //
// It creates <bigfileX>/head/data along the way. // 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) oid, err := zodb.ParseOid(name)
if err != nil { if err != nil {
log.Printf("/bigfile: mkdir %q: not-oid", name) log.Printf("/bigfile: mkdir %q: not-oid", name)
...@@ -330,11 +339,23 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) ( ...@@ -330,11 +339,23 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
return nil, fuse.Status(syscall.EEXIST) return nil, fuse.Status(syscall.EEXIST)
} }
// no - without bfroot lock proceed to load corresponding objects from ZODB // not there - without bfroot lock proceed to load corresponding objects from ZODB:
ctx := asctx(fctx)
// 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 // 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) zdb := zodb.NewDB(bfroot.zstor)
zconn, err := zdb.Open(ctx, &zodb.ConnOptions{}) // XXX .NoSync=true ? zconn, err := zdb.Open(ctx, &zodb.ConnOptions{}) // XXX .NoSync=true ?
if err != nil { if err != nil {
...@@ -342,8 +363,6 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) ( ...@@ -342,8 +363,6 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
return nil, fuse.EIO return nil, fuse.EIO
} }
// XXX txn.Abort(), put conn back on error
xzbf, err := zconn.Get(ctx, oid) xzbf, err := zconn.Get(ctx, oid)
if err != nil { if err != nil {
switch errors.Cause(err).(type) { switch errors.Cause(err).(type) {
...@@ -383,9 +402,10 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) ( ...@@ -383,9 +402,10 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
} }
bfdata := &BigFileData{ bfdata := &BigFileData{
Node: nodefs.NewDefaultNode(), Node: nodefs.NewDefaultNode(),
zconn: zconn, txnCtx: txnCtx,
zbf: zbf, zconn: zconn,
zbf: zbf,
} }
bfhead.data = bfdata 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