Commit e8c26821 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 46e6f6a0
...@@ -34,12 +34,9 @@ import ( ...@@ -34,12 +34,9 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb" "lab.nexedi.com/kirr/neo/go/zodb"
) )
// // errors as fuse.Status (not already exposed by fuse iteself)
// const (
// fEEXIST = fuse.Status(syscall.EEXIST)
// )
// eInvalError is the error wrapper signifying that underlying error is about "invalid argument". // eInvalError is the error wrapper signifying that underlying error is about "invalid argument".
// err2LogStatus converts such errors into EINVAL return code + logs as warning.
type eInvalError struct { type eInvalError struct {
err error err error
} }
...@@ -75,18 +72,15 @@ func err2LogStatus(err error) fuse.Status { ...@@ -75,18 +72,15 @@ func err2LogStatus(err error) fuse.Status {
} }
// otherwise log as warnings EINVAL and as errors everything else // otherwise log as warnings EINVAL and as errors everything else
var st fuse.Status
switch errors.Cause(err).(type) { switch errors.Cause(err).(type) {
case *eInvalError: case *eInvalError:
st = fuse.EINVAL
log.Warning(err) log.Warning(err)
return fuse.EINVAL
default: default:
st = fuse.EIO
log.Error(err) log.Error(err)
return fuse.EIO
} }
return st
} }
......
...@@ -356,74 +356,11 @@ type blkLoadState struct { ...@@ -356,74 +356,11 @@ type blkLoadState struct {
// ---------------------------------------- // ----------------------------------------
/*
// 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
// 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 {
log.Errorf("/bigfile: mkdir %q: %s", name, err)
return nil, fuse.EIO
}
xzbf, err := zconn.Get(ctx, oid)
if err != nil {
switch errors.Cause(err).(type) {
case *zodb.NoObjectError:
return nil, fuse.EINVAL
case *zodb.NoDataError:
return nil, fuse.EINVAL // XXX what to do if it was existing and got deleted?
default:
log.Errorf("/bigfile: mkdir %q: %s", name, err)
return nil, fuse.EIO
}
}
zbf, ok := xzbf.(*ZBigFile)
if !ok {
log.Warningf("/bigfile: mkdir %q: %s is not a ZBigFile", name, typeOf(xzbf))
return nil, fuse.EINVAL
}
// activate ZBigFile and keep it this way
err = zbf.PActivate(ctx)
if err != nil {
log.Errorf("/bigfile: mkdir %q: %s", name, err)
return nil, fuse.EIO
}
defer func() {
if status != fuse.OK {
zbf.PDeactivate()
}
}()
zbfSize, err := zbf.Size(ctx)
if err != nil {
log.Errorf("/bigfile: mkdir %q: %s", name, err)
return nil, fuse.EIO
}
*/
// /bigfile -> Mkdir receives client request to create /bigfile/<bigfileX>. // /bigfile -> Mkdir receives client request to create /bigfile/<bigfileX>.
// //
// It creates <bigfileX>/head/* along the way. // It creates <bigfileX>/head/* along the way.
func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (_ *nodefs.Inode, status fuse.Status) { func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nodefs.Inode, fuse.Status) {
// XXX ok to ignore mode? inode, err := bfroot.mkdir(name, fctx) // XXX ok to ignore mode?
inode, err := bfroot.mkdir(name, fctx)
return inode, err2LogStatus(err) return inode, err2LogStatus(err)
} }
...@@ -436,7 +373,6 @@ func (bfroot *BigFileRoot) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Ino ...@@ -436,7 +373,6 @@ func (bfroot *BigFileRoot) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Ino
return nil, eINVALf("not oid") return nil, eINVALf("not oid")
} }
// check to see if dir(oid) is already there // check to see if dir(oid) is already there
bfroot.mu.Lock() bfroot.mu.Lock()
_, already := bfroot.tab[oid] _, already := bfroot.tab[oid]
...@@ -446,7 +382,7 @@ func (bfroot *BigFileRoot) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Ino ...@@ -446,7 +382,7 @@ func (bfroot *BigFileRoot) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Ino
return nil, syscall.EEXIST return nil, syscall.EEXIST
} }
// not there - without bfroot lock proceed to load corresponding objects from ZODB // not there - without bfroot lock proceed to open BigFile from ZODB
zdb := zodb.NewDB(bfroot.zstor) zdb := zodb.NewDB(bfroot.zstor)
bf, err := bigopen(asctx(fctx), zdb, oid, &zodb.ConnOptions{}) bf, err := bigopen(asctx(fctx), zdb, oid, &zodb.ConnOptions{})
if err != nil { if err != nil {
...@@ -500,8 +436,7 @@ func (bfroot *BigFileRoot) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Ino ...@@ -500,8 +436,7 @@ func (bfroot *BigFileRoot) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Ino
// /bigfile/<bigfileX> -> Mkdir receives client request to create @<tid>/. // /bigfile/<bigfileX> -> Mkdir receives client request to create @<tid>/.
func (bfdir *BigFileDir) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nodefs.Inode, fuse.Status) { func (bfdir *BigFileDir) Mkdir(name string, mode uint32, fctx *fuse.Context) (*nodefs.Inode, fuse.Status) {
// XXX ok to ignore mode? inode, err := bfdir.mkdir(name, fctx) // XXX ok to ignore mode?
inode, err := bfdir.mkdir(name, fctx)
return inode, err2LogStatus(err) return inode, err2LogStatus(err)
} }
...@@ -519,8 +454,7 @@ func (bfdir *BigFileDir) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Inode ...@@ -519,8 +454,7 @@ func (bfdir *BigFileDir) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Inode
return nil, eINVALf("not @tid") return nil, eINVALf("not @tid")
} }
// check to see if dir(tid) is already there
// check to see if dir(tid) is already
bfdir.mu.Lock() bfdir.mu.Lock()
_, already := bfdir.revTab[tid] _, already := bfdir.revTab[tid]
bfdir.mu.Unlock() bfdir.mu.Unlock()
...@@ -529,8 +463,7 @@ func (bfdir *BigFileDir) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Inode ...@@ -529,8 +463,7 @@ func (bfdir *BigFileDir) mkdir(name string, fctx *fuse.Context) (_ *nodefs.Inode
return nil, syscall.EEXIST return nil, syscall.EEXIST
} }
// not there - without bfdir lock proceed to create @tid historical connection // not there - without bfdir lock proceed to open BigFile @tid view of ZODB
bf, err := bigopen(asctx(fctx), bfdir.zdb, bfdir.oid, &zodb.ConnOptions{ bf, err := bigopen(asctx(fctx), bfdir.zdb, bfdir.oid, &zodb.ConnOptions{
At: tid, At: tid,
}) })
......
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