feat(sdk): add full path parameter to metadata write function

Signed-off-by: NaturalSelect <2145973003@qq.com>
This commit is contained in:
NaturalSelect 2023-09-28 00:52:56 +08:00 committed by Victor1319
parent e839eae5a7
commit bdc1a8ab06
5 changed files with 154 additions and 132 deletions

View File

@ -204,6 +204,8 @@ type file struct {
//rw
fileWriter *blobstore.Writer
fileReader *blobstore.Reader
path string
}
type dirStream struct {
@ -491,12 +493,12 @@ func cfs_open(id C.int64_t, path *C.char, flags C.int, mode C.mode_t) C.int {
parentIno = dirInfo.Inode
defer func() {
if info != nil {
auditlog.FormatLog("Create", dirpath, "nil", err, time.Since(start).Microseconds(), info.Inode, 0)
auditlog.LogClientOp("Create", dirpath, "nil", err, time.Since(start).Microseconds(), info.Inode, 0)
} else {
auditlog.FormatLog("Create", dirpath, "nil", err, time.Since(start).Microseconds(), 0, 0)
auditlog.LogClientOp("Create", dirpath, "nil", err, time.Since(start).Microseconds(), 0, 0)
}
}()
newInfo, err := c.create(dirInfo.Inode, name, fuseMode)
newInfo, err := c.create(dirInfo.Inode, name, fuseMode, absPath)
if err != nil {
if err != syscall.EEXIST {
return errorToStatus(err)
@ -527,7 +529,7 @@ func cfs_open(id C.int64_t, path *C.char, flags C.int, mode C.mode_t) C.int {
fileCachePattern := fmt.Sprintf(".*%s.*", c.cacheRuleKey)
fileCache, _ = regexp.MatchString(fileCachePattern, absPath)
}
f := c.allocFD(info.Inode, fuseFlags, fuseMode, fileCache, info.Size, parentIno)
f := c.allocFD(info.Inode, fuseFlags, fuseMode, fileCache, info.Size, parentIno, absPath)
if f == nil {
return statusEMFILE
}
@ -920,9 +922,9 @@ func cfs_mkdirs(id C.int64_t, path *C.char, mode C.mode_t) C.int {
defer func() {
if gerr == nil {
auditlog.FormatLog("Mkdir", dirpath, "nil", gerr, time.Since(start).Microseconds(), gino, 0)
auditlog.LogClientOp("Mkdir", dirpath, "nil", gerr, time.Since(start).Microseconds(), gino, 0)
} else {
auditlog.FormatLog("Mkdir", dirpath, "nil", gerr, time.Since(start).Microseconds(), 0, 0)
auditlog.LogClientOp("Mkdir", dirpath, "nil", gerr, time.Since(start).Microseconds(), 0, 0)
}
}()
@ -935,7 +937,7 @@ func cfs_mkdirs(id C.int64_t, path *C.char, mode C.mode_t) C.int {
child, _, err := c.mw.Lookup_ll(pino, dir)
if err != nil {
if err == syscall.ENOENT {
info, err := c.mkdir(pino, dir, uint32(mode))
info, err := c.mkdir(pino, dir, uint32(mode), dirpath)
if err != nil {
if err != syscall.EEXIST {
@ -970,9 +972,9 @@ func cfs_rmdir(id C.int64_t, path *C.char) C.int {
absPath := c.absPath(C.GoString(path))
defer func() {
if info == nil {
auditlog.FormatLog("Rmdir", absPath, "nil", err, time.Since(start).Microseconds(), 0, 0)
auditlog.LogClientOp("Rmdir", absPath, "nil", err, time.Since(start).Microseconds(), 0, 0)
} else {
auditlog.FormatLog("Rmdir", absPath, "nil", err, time.Since(start).Microseconds(), info.Inode, 0)
auditlog.LogClientOp("Rmdir", absPath, "nil", err, time.Since(start).Microseconds(), info.Inode, 0)
}
}()
dirpath, name := gopath.Split(absPath)
@ -981,7 +983,7 @@ func cfs_rmdir(id C.int64_t, path *C.char) C.int {
return errorToStatus(err)
}
info, err = c.mw.Delete_ll(dirInfo.Inode, name, true)
info, err = c.mw.Delete_ll(dirInfo.Inode, name, true, absPath)
c.ic.Delete(dirInfo.Inode)
c.dc.Delete(absPath)
return errorToStatus(err)
@ -1003,9 +1005,9 @@ func cfs_unlink(id C.int64_t, path *C.char) C.int {
defer func() {
if info == nil {
auditlog.FormatLog("Unlink", absPath, "nil", err, time.Since(start).Microseconds(), 0, 0)
auditlog.LogClientOp("Unlink", absPath, "nil", err, time.Since(start).Microseconds(), 0, 0)
} else {
auditlog.FormatLog("Unlink", absPath, "nil", err, time.Since(start).Microseconds(), info.Inode, 0)
auditlog.LogClientOp("Unlink", absPath, "nil", err, time.Since(start).Microseconds(), info.Inode, 0)
}
}()
dirInfo, err := c.lookupPath(dirpath)
@ -1021,13 +1023,13 @@ func cfs_unlink(id C.int64_t, path *C.char) C.int {
return statusEISDIR
}
info, err = c.mw.Delete_ll(dirInfo.Inode, name, false)
info, err = c.mw.Delete_ll(dirInfo.Inode, name, false, absPath)
if err != nil {
return errorToStatus(err)
}
if info != nil {
_ = c.mw.Evict(info.Inode)
_ = c.mw.Evict(info.Inode, absPath)
c.ic.Delete(info.Inode)
}
return 0
@ -1047,7 +1049,7 @@ func cfs_rename(id C.int64_t, from *C.char, to *C.char) C.int {
absTo := c.absPath(C.GoString(to))
defer func() {
auditlog.FormatLog("Rename", absFrom, absTo, err, time.Since(start).Microseconds(), 0, 0)
auditlog.LogClientOp("Rename", absFrom, absTo, err, time.Since(start).Microseconds(), 0, 0)
}()
srcDirPath, srcName := gopath.Split(absFrom)
@ -1062,7 +1064,7 @@ func cfs_rename(id C.int64_t, from *C.char, to *C.char) C.int {
return errorToStatus(err)
}
err = c.mw.Rename_ll(srcDirInfo.Inode, srcName, dstDirInfo.Inode, dstName, false)
err = c.mw.Rename_ll(srcDirInfo.Inode, srcName, dstDirInfo.Inode, dstName, absFrom, absTo, false)
c.ic.Delete(srcDirInfo.Inode)
c.ic.Delete(dstDirInfo.Inode)
c.dc.Delete(absFrom)
@ -1267,7 +1269,7 @@ func (c *client) checkPermission() (err error) {
return
}
func (c *client) allocFD(ino uint64, flags, mode uint32, fileCache bool, fileSize uint64, parentInode uint64) *file {
func (c *client) allocFD(ino uint64, flags, mode uint32, fileCache bool, fileSize uint64, parentInode uint64, path string) *file {
c.fdlock.Lock()
defer c.fdlock.Unlock()
fd, ok := c.fdset.NextClear(0)
@ -1275,7 +1277,7 @@ func (c *client) allocFD(ino uint64, flags, mode uint32, fileCache bool, fileSiz
return nil
}
c.fdset.Set(fd)
f := &file{fd: fd, ino: ino, flags: flags, mode: mode, pino: parentInode}
f := &file{fd: fd, ino: ino, flags: flags, mode: mode, pino: parentInode, path: path}
if proto.IsCold(c.volType) {
clientConf := blobstore.ClientConfig{
VolName: c.volName,
@ -1367,15 +1369,15 @@ func (c *client) setattr(info *proto.InodeInfo, valid uint32, mode, uid, gid uin
return c.mw.Setattr(info.Inode, valid, mode, uid, gid, atime, mtime)
}
func (c *client) create(pino uint64, name string, mode uint32) (info *proto.InodeInfo, err error) {
func (c *client) create(pino uint64, name string, mode uint32, fullPath string) (info *proto.InodeInfo, err error) {
fuseMode := mode & 0777
return c.mw.Create_ll(pino, name, fuseMode, 0, 0, nil)
return c.mw.Create_ll(pino, name, fuseMode, 0, 0, nil, fullPath)
}
func (c *client) mkdir(pino uint64, name string, mode uint32) (info *proto.InodeInfo, err error) {
func (c *client) mkdir(pino uint64, name string, mode uint32, fullPath string) (info *proto.InodeInfo, err error) {
fuseMode := mode & 0777
fuseMode |= uint32(os.ModeDir)
return c.mw.Create_ll(pino, name, fuseMode, 0, 0, nil)
return c.mw.Create_ll(pino, name, fuseMode, 0, 0, nil, fullPath)
}
func (c *client) openStream(f *file) {
@ -1402,7 +1404,7 @@ func (c *client) flush(f *file) error {
}
func (c *client) truncate(f *file, size int) error {
err := c.ec.Truncate(c.mw, f.pino, f.ino, size)
err := c.ec.Truncate(c.mw, f.pino, f.ino, size, f.path)
if err != nil {
return err
}

View File

@ -40,7 +40,7 @@ import (
type SplitExtentKeyFunc func(parentInode, inode uint64, key proto.ExtentKey) error
type AppendExtentKeyFunc func(parentInode, inode uint64, key proto.ExtentKey, discard []proto.ExtentKey) error
type GetExtentsFunc func(inode uint64) (uint64, uint64, []proto.ExtentKey, error)
type TruncateFunc func(inode, size uint64) error
type TruncateFunc func(inode, size uint64, fullPath string) error
type EvictIcacheFunc func(inode uint64)
type LoadBcacheFunc func(key string, buf []byte, offset uint64, size uint32) (int, error)
type CacheBcacheFunc func(key string, buf []byte) error
@ -517,7 +517,7 @@ func (client *ExtentClient) Write(inode uint64, offset int, data []byte, flags i
return
}
func (client *ExtentClient) Truncate(mw *meta.MetaWrapper, parentIno uint64, inode uint64, size int) error {
func (client *ExtentClient) Truncate(mw *meta.MetaWrapper, parentIno uint64, inode uint64, size int, fullPath string) error {
prefix := fmt.Sprintf("Truncate{ino(%v)size(%v)}", inode, size)
s := client.GetStreamer(inode)
if s == nil {
@ -531,7 +531,7 @@ func (client *ExtentClient) Truncate(mw *meta.MetaWrapper, parentIno uint64, ino
info, err = mw.InodeGet_ll(inode)
oldSize = info.Size
}
err = s.IssueTruncRequest(size)
err = s.IssueTruncRequest(size, fullPath)
if err != nil {
err = errors.Trace(err, prefix)
log.LogError(errors.Stack(err))

View File

@ -87,9 +87,10 @@ type ReleaseRequest struct {
// TruncRequest defines a truncate request.
type TruncRequest struct {
size int
err error
done chan struct{}
size int
err error
fullPath string
done chan struct{}
}
// EvictRequest defines an evict request.
@ -154,9 +155,10 @@ func (s *Streamer) IssueReleaseRequest() error {
return err
}
func (s *Streamer) IssueTruncRequest(size int) error {
func (s *Streamer) IssueTruncRequest(size int, fullPath string) error {
request := truncRequestPool.Get().(*TruncRequest)
request.size = size
request.fullPath = fullPath
request.done = make(chan struct{}, 1)
s.request <- request
<-request.done
@ -284,7 +286,7 @@ func (s *Streamer) handleRequest(request interface{}) {
request.writeBytes, request.err = s.write(request.data, request.fileOffset, request.size, request.flags, request.checkFunc)
request.done <- struct{}{}
case *TruncRequest:
request.err = s.truncate(request.size)
request.err = s.truncate(request.size, request.fullPath)
request.done <- struct{}{}
case *FlushRequest:
request.err = s.flush()
@ -936,14 +938,14 @@ func (s *Streamer) abort() {
}
}
func (s *Streamer) truncate(size int) error {
func (s *Streamer) truncate(size int, fullPath string) error {
s.closeOpenHandler()
err := s.flush()
if err != nil {
return err
}
err = s.client.truncate(s.inode, uint64(size))
err = s.client.truncate(s.inode, uint64(size), fullPath)
if err != nil {
return err
}

View File

@ -112,7 +112,7 @@ func (mw *MetaWrapper) Statfs() (total, used, inodeCount uint64) {
return
}
func (mw *MetaWrapper) Create_ll(parentID uint64, name string, mode, uid, gid uint32, target []byte) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) Create_ll(parentID uint64, name string, mode, uid, gid uint32, target []byte, fullPath string) (*proto.InodeInfo, error) {
// if mw.EnableTransaction {
txMask := proto.TxOpMaskOff
if proto.IsRegular(mode) {
@ -126,13 +126,13 @@ func (mw *MetaWrapper) Create_ll(parentID uint64, name string, mode, uid, gid ui
}
txType := proto.TxMaskToType(txMask)
if mw.enableTx(txMask) && txType != proto.TxTypeUndefined {
return mw.txCreate_ll(parentID, name, mode, uid, gid, target, txType)
return mw.txCreate_ll(parentID, name, mode, uid, gid, target, txType, fullPath)
} else {
return mw.create_ll(parentID, name, mode, uid, gid, target)
return mw.create_ll(parentID, name, mode, uid, gid, target, fullPath)
}
}
func (mw *MetaWrapper) txCreate_ll(parentID uint64, name string, mode, uid, gid uint32, target []byte, txType uint32) (info *proto.InodeInfo, err error) {
func (mw *MetaWrapper) txCreate_ll(parentID uint64, name string, mode, uid, gid uint32, target []byte, txType uint32, fullPath string) (info *proto.InodeInfo, err error) {
var (
status int
// err error
@ -179,7 +179,7 @@ func (mw *MetaWrapper) txCreate_ll(parentID uint64, name string, mode, uid, gid
return nil, syscall.EAGAIN
}
status, info, err = mw.txIcreate(tx, mp, mode, uid, gid, target, quotaIds)
status, info, err = mw.txIcreate(tx, mp, mode, uid, gid, target, quotaIds, fullPath)
if err == nil && status == statusOK {
goto create_dentry
} else if status == statusNoSpace {
@ -197,7 +197,7 @@ create_dentry:
log.LogDebugf("txCreate_ll: tx.txInfo(%v)", tx.txInfo)
}
status, err = mw.txDcreate(tx, parentMP, parentID, name, info.Inode, mode, quotaIds)
status, err = mw.txDcreate(tx, parentMP, parentID, name, info.Inode, mode, quotaIds, fullPath)
if err != nil || status != statusOK {
return nil, statusErrToErrno(status, err)
}
@ -223,7 +223,7 @@ create_dentry:
return info, nil
}
func (mw *MetaWrapper) create_ll(parentID uint64, name string, mode, uid, gid uint32, target []byte) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) create_ll(parentID uint64, name string, mode, uid, gid uint32, target []byte, fullPath string) (*proto.InodeInfo, error) {
var (
status int
err error
@ -268,7 +268,7 @@ get_rwmp:
for i := 0; i < length; i++ {
index := (int(epoch) + i) % length
mp = rwPartitions[index]
status, info, err = mw.quotaIcreate(mp, mode, uid, gid, target, quotaIds)
status, info, err = mw.quotaIcreate(mp, mode, uid, gid, target, quotaIds, fullPath)
if err == nil && status == statusOK {
goto create_dentry
} else if status == statusFull {
@ -291,7 +291,7 @@ get_rwmp:
for i := 0; i < length; i++ {
index := (int(epoch) + i) % length
mp = rwPartitions[index]
status, info, err = mw.icreate(mp, mode, uid, gid, target)
status, info, err = mw.icreate(mp, mode, uid, gid, target, fullPath)
if err == nil && status == statusOK {
goto create_dentry
} else if status == statusFull {
@ -314,20 +314,20 @@ get_rwmp:
return nil, syscall.ENOMEM
create_dentry:
if mw.EnableQuota {
status, err = mw.quotaDcreate(parentMP, parentID, name, info.Inode, mode, quotaIds)
status, err = mw.quotaDcreate(parentMP, parentID, name, info.Inode, mode, quotaIds, fullPath)
} else {
status, err = mw.dcreate(parentMP, parentID, name, info.Inode, mode)
status, err = mw.dcreate(parentMP, parentID, name, info.Inode, mode, fullPath)
}
if err != nil {
if status == statusOpDirQuota || status == statusNoSpace {
mw.iunlink(mp, info.Inode, mw.Client.GetLatestVer(), 0)
mw.ievict(mp, info.Inode)
mw.iunlink(mp, info.Inode, mw.Client.GetLatestVer(), 0, fullPath)
mw.ievict(mp, info.Inode, fullPath)
}
return nil, statusToErrno(status)
} else if status != statusOK {
if status != statusExist {
mw.iunlink(mp, info.Inode, mw.Client.GetLatestVer(), 0)
mw.ievict(mp, info.Inode)
mw.iunlink(mp, info.Inode, mw.Client.GetLatestVer(), 0, fullPath)
mw.ievict(mp, info.Inode, fullPath)
}
return nil, statusToErrno(status)
}
@ -481,13 +481,13 @@ func (mw *MetaWrapper) BatchInodeGet(inodes []uint64) []*proto.InodeInfo {
// InodeDelete_ll is a low-level api that removes specified inode immediately
// and do not effect extent data managed by this inode.
func (mw *MetaWrapper) InodeDelete_ll(inode uint64) error {
func (mw *MetaWrapper) InodeDelete_ll(inode uint64, fullPath string) error {
mp := mw.getPartitionByInode(inode)
if mp == nil {
log.LogErrorf("InodeDelete: No such partition, ino(%v)", inode)
return syscall.ENOENT
}
status, err := mw.idelete(mp, inode)
status, err := mw.idelete(mp, inode, fullPath)
if err != nil || status != statusOK {
return statusToErrno(status)
}
@ -551,26 +551,26 @@ func (mw *MetaWrapper) BatchGetXAttr(inodes []uint64, keys []string) ([]*proto.X
return xattrs, nil
}
func (mw *MetaWrapper) Delete_ll(parentID uint64, name string, isDir bool) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) Delete_ll(parentID uint64, name string, isDir bool, fullPath string) (*proto.InodeInfo, error) {
if mw.enableTx(proto.TxOpMaskRemove) {
return mw.txDelete_ll(parentID, name, isDir)
return mw.txDelete_ll(parentID, name, isDir, fullPath)
} else {
return mw.Delete_ll_EX(parentID, name, isDir, 0)
return mw.Delete_ll_EX(parentID, name, isDir, 0, fullPath)
}
}
func (mw *MetaWrapper) Delete_Ver_ll(parentID uint64, name string, isDir bool, verSeq uint64) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) Delete_Ver_ll(parentID uint64, name string, isDir bool, verSeq uint64, fullPath string) (*proto.InodeInfo, error) {
if verSeq == 0 {
verSeq = math.MaxUint64
}
log.LogDebugf("Delete_Ver_ll.parentId %v name %v isDir %v verSeq %v", parentID, name, isDir, verSeq)
return mw.Delete_ll_EX(parentID, name, isDir, verSeq)
return mw.Delete_ll_EX(parentID, name, isDir, verSeq, fullPath)
}
func (mw *MetaWrapper) DeleteWithCond_ll(parentID, cond uint64, name string, isDir bool) (*proto.InodeInfo, error) {
return mw.deletewithcond_ll(parentID, cond, name, isDir)
func (mw *MetaWrapper) DeleteWithCond_ll(parentID, cond uint64, name string, isDir bool, fullPath string) (*proto.InodeInfo, error) {
return mw.deletewithcond_ll(parentID, cond, name, isDir, fullPath)
}
func (mw *MetaWrapper) txDelete_ll(parentID uint64, name string, isDir bool) (info *proto.InodeInfo, err error) {
func (mw *MetaWrapper) txDelete_ll(parentID uint64, name string, isDir bool, fullPath string) (info *proto.InodeInfo, err error) {
var (
status int
inode uint64
@ -636,7 +636,7 @@ func (mw *MetaWrapper) txDelete_ll(parentID uint64, name string, isDir bool) (in
var newSt int
var newErr error
newSt, _, newErr = mw.txDdelete(tx, parentMP, parentID, inode, name)
newSt, _, newErr = mw.txDdelete(tx, parentMP, parentID, inode, name, fullPath)
return newSt, newErr
})
@ -644,7 +644,7 @@ func (mw *MetaWrapper) txDelete_ll(parentID uint64, name string, isDir bool) (in
var newSt int
var newErr error
newSt, info, newErr = mw.txIunlink(tx, mp, inode)
newSt, info, newErr = mw.txIunlink(tx, mp, inode, fullPath)
return newSt, newErr
})
@ -690,7 +690,7 @@ func (mw *MetaWrapper) txDelete_ll(parentID uint64, name string, isDir bool) (in
* and the caller should make sure InodeInfo is valid before using it.
*/
func (mw *MetaWrapper) Delete_ll_EX(parentID uint64, name string, isDir bool, verSeq uint64) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) Delete_ll_EX(parentID uint64, name string, isDir bool, verSeq uint64, fullPath string) (*proto.InodeInfo, error) {
var (
status int
inode uint64
@ -775,7 +775,7 @@ func (mw *MetaWrapper) Delete_ll_EX(parentID uint64, name string, isDir bool, ve
log.LogDebugf("action[Delete_ll] parentID %v name %v verSeq %v", parentID, name, verSeq)
status, inode, _, err = mw.ddelete(parentMP, parentID, name, inodeCreateTime, verSeq)
status, inode, _, err = mw.ddelete(parentMP, parentID, name, inodeCreateTime, verSeq, fullPath)
if err != nil || status != statusOK {
if status == statusNoent {
log.LogDebugf("action[Delete_ll] parentID %v name %v verSeq %v", parentID, name, verSeq)
@ -792,7 +792,7 @@ func (mw *MetaWrapper) Delete_ll_EX(parentID uint64, name string, isDir bool, ve
return nil, nil
}
log.LogDebugf("action[Delete_ll] parentID %v name %v verSeq %v", parentID, name, verSeq)
status, info, err = mw.iunlink(mp, inode, verSeq, denVer)
status, info, err = mw.iunlink(mp, inode, verSeq, denVer, fullPath)
if err != nil || status != statusOK {
log.LogDebugf("action[Delete_ll] parentID %v inode %v name %v verSeq %v err %v", parentID, inode, name, verSeq, err)
return nil, nil
@ -831,7 +831,7 @@ func isObjectLocked(mw *MetaWrapper, inode uint64, name string) error {
return nil
}
func (mw *MetaWrapper) deletewithcond_ll(parentID, cond uint64, name string, isDir bool) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) deletewithcond_ll(parentID, cond uint64, name string, isDir bool, fullPath string) (*proto.InodeInfo, error) {
err := isObjectLocked(mw, cond, name)
if err != nil {
@ -892,7 +892,7 @@ func (mw *MetaWrapper) deletewithcond_ll(parentID, cond uint64, name string, isD
Type: mode,
},
}
status, resp, err := mw.ddeletes(parentMP, parentID, dentry)
status, resp, err := mw.ddeletes(parentMP, parentID, dentry, []string{fullPath})
if err != nil || status != statusOK {
if status == statusNoent {
return nil, nil
@ -913,7 +913,7 @@ func (mw *MetaWrapper) deletewithcond_ll(parentID, cond uint64, name string, isD
return nil, nil
}
status, info, err = mw.iunlink(mp, resp.Items[0].Inode, 0, 0)
status, info, err = mw.iunlink(mp, resp.Items[0].Inode, 0, 0, fullPath)
if err != nil || status != statusOK {
return nil, nil
}
@ -931,15 +931,15 @@ func (mw *MetaWrapper) deletewithcond_ll(parentID, cond uint64, name string, isD
return info, nil
}
func (mw *MetaWrapper) Rename_ll(srcParentID uint64, srcName string, dstParentID uint64, dstName string, overwritten bool) (err error) {
func (mw *MetaWrapper) Rename_ll(srcParentID uint64, srcName string, dstParentID uint64, dstName string, srcFullPath string, dstFullPath string, overwritten bool) (err error) {
if mw.enableTx(proto.TxOpMaskRename) {
return mw.txRename_ll(srcParentID, srcName, dstParentID, dstName, overwritten)
return mw.txRename_ll(srcParentID, srcName, dstParentID, dstName, srcFullPath, dstFullPath, overwritten)
} else {
return mw.rename_ll(srcParentID, srcName, dstParentID, dstName, overwritten)
return mw.rename_ll(srcParentID, srcName, dstParentID, dstName, srcFullPath, dstFullPath, overwritten)
}
}
func (mw *MetaWrapper) txRename_ll(srcParentID uint64, srcName string, dstParentID uint64, dstName string, overwritten bool) (err error) {
func (mw *MetaWrapper) txRename_ll(srcParentID uint64, srcName string, dstParentID uint64, dstName string, srcFullPath string, dstFullPath string, overwritten bool) (err error) {
var tx *Transaction
defer func() {
if tx != nil {
@ -989,14 +989,14 @@ func (mw *MetaWrapper) txRename_ll(srcParentID uint64, srcName string, dstParent
funcs = append(funcs, func() (int, error) {
var newSt int
var newErr error
newSt, _, newErr = mw.txDupdate(tx, dstParentMP, dstParentID, dstName, srcInode, dstInode)
newSt, _, newErr = mw.txDupdate(tx, dstParentMP, dstParentID, dstName, srcInode, dstInode, dstFullPath)
return newSt, newErr
})
funcs = append(funcs, func() (int, error) {
var newSt int
var newErr error
newSt, _, newErr = mw.txIunlink(tx, oldInodeMP, dstInode)
newSt, _, newErr = mw.txIunlink(tx, oldInodeMP, dstInode, dstFullPath)
if newSt == statusNoent {
return statusOK, nil
}
@ -1011,7 +1011,7 @@ func (mw *MetaWrapper) txRename_ll(srcParentID uint64, srcName string, dstParent
funcs = append(funcs, func() (int, error) {
var newSt int
var newErr error
newSt, newErr = mw.txDcreate(tx, dstParentMP, dstParentID, dstName, srcInode, srcMode, []uint32{})
newSt, newErr = mw.txDcreate(tx, dstParentMP, dstParentID, dstName, srcInode, srcMode, []uint32{}, dstFullPath)
return newSt, newErr
})
@ -1023,7 +1023,7 @@ func (mw *MetaWrapper) txRename_ll(srcParentID uint64, srcName string, dstParent
funcs = append(funcs, func() (int, error) {
var newSt int
var newErr error
newSt, _, newErr = mw.txDdelete(tx, srcParentMP, srcParentID, srcInode, srcName)
newSt, _, newErr = mw.txDdelete(tx, srcParentMP, srcParentID, srcInode, srcName, srcFullPath)
return newSt, newErr
})
@ -1123,7 +1123,7 @@ func (mw *MetaWrapper) txRename_ll(srcParentID uint64, srcName string, dstParent
return nil
}
func (mw *MetaWrapper) rename_ll(srcParentID uint64, srcName string, dstParentID uint64, dstName string, overwritten bool) (err error) {
func (mw *MetaWrapper) rename_ll(srcParentID uint64, srcName string, dstParentID uint64, dstName string, srcFullPath string, dstFullPath string, overwritten bool) (err error) {
var (
oldInode uint64
lastVerSeq uint64
@ -1160,13 +1160,13 @@ func (mw *MetaWrapper) rename_ll(srcParentID uint64, srcName string, dstParentID
return syscall.ENOENT
}
status, _, err = mw.ilink(srcMP, inode)
status, _, err = mw.ilink(srcMP, inode, srcFullPath)
if err != nil || status != statusOK {
return statusToErrno(status)
}
// create dentry in dst parent
status, err = mw.dcreate(dstParentMP, dstParentID, dstName, inode, mode)
status, err = mw.dcreate(dstParentMP, dstParentID, dstName, inode, mode, dstFullPath)
if err != nil {
if status == statusOpDirQuota {
return statusToErrno(status)
@ -1185,7 +1185,7 @@ func (mw *MetaWrapper) rename_ll(srcParentID uint64, srcName string, dstParentID
return syscall.EEXIST
}
status, oldInode, err = mw.dupdate(dstParentMP, dstParentID, dstName, inode)
status, oldInode, err = mw.dupdate(dstParentMP, dstParentID, dstName, inode, dstFullPath)
if err != nil {
return syscall.EAGAIN
}
@ -1195,13 +1195,13 @@ func (mw *MetaWrapper) rename_ll(srcParentID uint64, srcName string, dstParentID
}
if status != statusOK {
mw.iunlink(srcMP, inode, lastVerSeq, 0)
mw.iunlink(srcMP, inode, lastVerSeq, 0, srcFullPath)
return statusToErrno(status)
}
var denVer uint64
// delete dentry from src parent
status, _, denVer, err = mw.ddelete(srcParentMP, srcParentID, srcName, 0, lastVerSeq)
status, _, denVer, err = mw.ddelete(srcParentMP, srcParentID, srcName, 0, lastVerSeq, srcFullPath)
if err != nil {
log.LogErrorf("mw.ddelete(srcParentMP, srcParentID, %s) failed.", srcName)
@ -1212,25 +1212,25 @@ func (mw *MetaWrapper) rename_ll(srcParentID uint64, srcName string, dstParentID
e error
)
if oldInode == 0 {
sts, inode, denVer, e = mw.ddelete(dstParentMP, dstParentID, dstName, 0, lastVerSeq)
sts, inode, denVer, e = mw.ddelete(dstParentMP, dstParentID, dstName, 0, lastVerSeq, dstFullPath)
} else {
sts, denVer, e = mw.dupdate(dstParentMP, dstParentID, dstName, oldInode)
sts, denVer, e = mw.dupdate(dstParentMP, dstParentID, dstName, oldInode, dstFullPath)
}
if e == nil && sts == statusOK {
mw.iunlink(srcMP, inode, lastVerSeq, denVer)
mw.iunlink(srcMP, inode, lastVerSeq, denVer, srcFullPath)
}
return statusToErrno(status)
}
mw.iunlink(srcMP, inode, lastVerSeq, denVer)
mw.iunlink(srcMP, inode, lastVerSeq, denVer, srcFullPath)
if oldInode != 0 {
// overwritten
inodeMP := mw.getPartitionByInode(oldInode)
if inodeMP != nil {
mw.iunlink(inodeMP, oldInode, lastVerSeq, 0)
mw.iunlink(inodeMP, oldInode, lastVerSeq, 0, dstFullPath)
// evict oldInode to avoid oldInode becomes orphan inode
mw.ievict(inodeMP, oldInode)
mw.ievict(inodeMP, oldInode, dstFullPath)
}
if mw.EnableSummary {
sizeInc := srcInodeInfo.Size - dstInodeInfo.Size
@ -1340,27 +1340,27 @@ func (mw *MetaWrapper) ReadDirLimit_ll(parentID uint64, from string, limit uint6
return children, nil
}
func (mw *MetaWrapper) DentryCreate_ll(parentID uint64, name string, inode uint64, mode uint32) error {
func (mw *MetaWrapper) DentryCreate_ll(parentID uint64, name string, inode uint64, mode uint32, fullPath string) error {
parentMP := mw.getPartitionByInode(parentID)
if parentMP == nil {
return syscall.ENOENT
}
var err error
var status int
if status, err = mw.dcreate(parentMP, parentID, name, inode, mode); err != nil || status != statusOK {
if status, err = mw.dcreate(parentMP, parentID, name, inode, mode, fullPath); err != nil || status != statusOK {
return statusToErrno(status)
}
return nil
}
func (mw *MetaWrapper) DentryUpdate_ll(parentID uint64, name string, inode uint64) (oldInode uint64, err error) {
func (mw *MetaWrapper) DentryUpdate_ll(parentID uint64, name string, inode uint64, fullPath string) (oldInode uint64, err error) {
parentMP := mw.getPartitionByInode(parentID)
if parentMP == nil {
err = syscall.ENOENT
return
}
var status int
status, oldInode, err = mw.dupdate(parentMP, parentID, name, inode)
status, oldInode, err = mw.dupdate(parentMP, parentID, name, inode, fullPath)
if err != nil || status != statusOK {
err = statusToErrno(status)
return
@ -1501,14 +1501,14 @@ func (mw *MetaWrapper) GetObjExtents(inode uint64) (gen uint64, size uint64, ext
return gen, size, extents, objExtents, nil
}
func (mw *MetaWrapper) Truncate(inode, size uint64) error {
func (mw *MetaWrapper) Truncate(inode, size uint64, fullPath string) error {
mp := mw.getPartitionByInode(inode)
if mp == nil {
log.LogErrorf("Truncate: No inode partition, ino(%v)", inode)
return syscall.ENOENT
}
status, err := mw.truncate(mp, inode, size)
status, err := mw.truncate(mp, inode, size, fullPath)
if err != nil || status != statusOK {
return statusToErrno(status)
}
@ -1516,16 +1516,16 @@ func (mw *MetaWrapper) Truncate(inode, size uint64) error {
}
func (mw *MetaWrapper) Link(parentID uint64, name string, ino uint64) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) Link(parentID uint64, name string, ino uint64, fullPath string) (*proto.InodeInfo, error) {
// if mw.EnableTransaction {
if mw.EnableTransaction&proto.TxOpMaskLink > 0 {
return mw.txLink(parentID, name, ino)
return mw.txLink(parentID, name, ino, fullPath)
} else {
return mw.link(parentID, name, ino)
return mw.link(parentID, name, ino, fullPath)
}
}
func (mw *MetaWrapper) txLink(parentID uint64, name string, ino uint64) (info *proto.InodeInfo, err error) {
func (mw *MetaWrapper) txLink(parentID uint64, name string, ino uint64, fullPath string) (info *proto.InodeInfo, err error) {
// var err error
var status int
parentMP := mw.getPartitionByInode(parentID)
@ -1562,7 +1562,7 @@ func (mw *MetaWrapper) txLink(parentID uint64, name string, ino uint64) (info *p
funcs = append(funcs, func() (int, error) {
var newSt int
var newErr error
newSt, info, newErr = mw.txIlink(tx, mp, ino)
newSt, info, newErr = mw.txIlink(tx, mp, ino, fullPath)
return newSt, newErr
})
@ -1589,7 +1589,7 @@ func (mw *MetaWrapper) txLink(parentID uint64, name string, ino uint64) (info *p
return newSt, newErr
}
newSt, newErr = mw.txDcreate(tx, parentMP, parentID, name, ino, ifo.Mode, quotaIds)
newSt, newErr = mw.txDcreate(tx, parentMP, parentID, name, ino, ifo.Mode, quotaIds, fullPath)
return newSt, newErr
})
@ -1615,7 +1615,7 @@ func (mw *MetaWrapper) txLink(parentID uint64, name string, ino uint64) (info *p
return info, nil
}
func (mw *MetaWrapper) link(parentID uint64, name string, ino uint64) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) link(parentID uint64, name string, ino uint64, fullPath string) (*proto.InodeInfo, error) {
parentMP := mw.getPartitionByInode(parentID)
if parentMP == nil {
log.LogErrorf("Link: No parent partition, parentID(%v)", parentID)
@ -1640,7 +1640,7 @@ func (mw *MetaWrapper) link(parentID uint64, name string, ino uint64) (*proto.In
}
// increase inode nlink
status, info, err = mw.ilink(mp, ino)
status, info, err = mw.ilink(mp, ino, fullPath)
if err != nil || status != statusOK {
return nil, statusToErrno(status)
}
@ -1655,29 +1655,29 @@ func (mw *MetaWrapper) link(parentID uint64, name string, ino uint64) (*proto.In
quotaIds = append(quotaIds, quotaId)
}
// create new dentry and refer to the inode
status, err = mw.quotaDcreate(parentMP, parentID, name, ino, info.Mode, quotaIds)
status, err = mw.quotaDcreate(parentMP, parentID, name, ino, info.Mode, quotaIds, fullPath)
} else {
status, err = mw.dcreate(parentMP, parentID, name, ino, info.Mode)
status, err = mw.dcreate(parentMP, parentID, name, ino, info.Mode, fullPath)
}
if err != nil {
return nil, statusToErrno(status)
} else if status != statusOK {
if status != statusExist {
mw.iunlink(mp, ino, mw.Client.GetLatestVer(), 0)
mw.iunlink(mp, ino, mw.Client.GetLatestVer(), 0, fullPath)
}
return nil, statusToErrno(status)
}
return info, nil
}
func (mw *MetaWrapper) Evict(inode uint64) error {
func (mw *MetaWrapper) Evict(inode uint64, fullPath string) error {
mp := mw.getPartitionByInode(inode)
if mp == nil {
log.LogWarnf("Evict: No such partition, ino(%v)", inode)
return syscall.EINVAL
}
status, err := mw.ievict(mp, inode)
status, err := mw.ievict(mp, inode, fullPath)
if err != nil || status != statusOK {
log.LogWarnf("Evict: ino(%v) err(%v) status(%v)", inode, err, status)
return statusToErrno(status)
@ -1701,7 +1701,7 @@ func (mw *MetaWrapper) Setattr(inode uint64, valid, mode, uid, gid uint32, atime
return nil
}
func (mw *MetaWrapper) InodeCreate_ll(parentID uint64, mode, uid, gid uint32, target []byte, quotaIds []uint64) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) InodeCreate_ll(parentID uint64, mode, uid, gid uint32, target []byte, quotaIds []uint64, fullPath string) (*proto.InodeInfo, error) {
var (
status int
err error
@ -1733,7 +1733,7 @@ get_rwmp:
for i := 0; i < length; i++ {
index := (int(epoch) + i) % length
mp = rwPartitions[index]
status, info, err = mw.quotaIcreate(mp, mode, uid, gid, target, quotaIds)
status, info, err = mw.quotaIcreate(mp, mode, uid, gid, target, quotaIds, fullPath)
if err == nil && status == statusOK {
return info, nil
} else if status == statusFull {
@ -1756,7 +1756,7 @@ get_rwmp:
for i := 0; i < length; i++ {
index := (int(epoch) + i) % length
mp = rwPartitions[index]
status, info, err = mw.icreate(mp, mode, uid, gid, target)
status, info, err = mw.icreate(mp, mode, uid, gid, target, fullPath)
if err == nil && status == statusOK {
return info, nil
} else if status == statusFull {
@ -1780,13 +1780,13 @@ get_rwmp:
}
// InodeUnlink_ll is a low-level api that makes specified inode link value +1.
func (mw *MetaWrapper) InodeLink_ll(inode uint64) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) InodeLink_ll(inode uint64, fullPath string) (*proto.InodeInfo, error) {
mp := mw.getPartitionByInode(inode)
if mp == nil {
log.LogErrorf("InodeLink_ll: No such partition, ino(%v)", inode)
return nil, syscall.EINVAL
}
status, info, err := mw.ilink(mp, inode)
status, info, err := mw.ilink(mp, inode, fullPath)
if err != nil || status != statusOK {
log.LogErrorf("InodeLink_ll: ino(%v) err(%v) status(%v)", inode, err, status)
return nil, statusToErrno(status)
@ -1795,7 +1795,7 @@ func (mw *MetaWrapper) InodeLink_ll(inode uint64) (*proto.InodeInfo, error) {
}
// InodeUnlink_ll is a low-level api that makes specified inode link value -1.
func (mw *MetaWrapper) InodeUnlink_ll(inode uint64) (*proto.InodeInfo, error) {
func (mw *MetaWrapper) InodeUnlink_ll(inode uint64, fullPath string) (*proto.InodeInfo, error) {
mp := mw.getPartitionByInode(inode)
if mp == nil {
log.LogErrorf("InodeUnlink_ll: No such partition, ino(%v)", inode)
@ -1805,7 +1805,7 @@ func (mw *MetaWrapper) InodeUnlink_ll(inode uint64) (*proto.InodeInfo, error) {
if mw.Client != nil {
ver = mw.Client.GetLatestVer()
}
status, info, err := mw.iunlink(mp, inode, ver, 0)
status, info, err := mw.iunlink(mp, inode, ver, 0, fullPath)
if err != nil || status != statusOK {
log.LogErrorf("InodeUnlink_ll: ino(%v) err(%v) status(%v)", inode, err, status)
return nil, statusToErrno(status)

View File

@ -32,7 +32,7 @@ import (
//
// txIcreate create inode and tx together
func (mw *MetaWrapper) txIcreate(tx *Transaction, mp *MetaPartition, mode, uid, gid uint32,
target []byte, quotaIds []uint32) (status int, info *proto.InodeInfo, err error) {
target []byte, quotaIds []uint32, fullPath string) (status int, info *proto.InodeInfo, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("txIcreate", err, bgTime, 1)
@ -49,6 +49,7 @@ func (mw *MetaWrapper) txIcreate(tx *Transaction, mp *MetaPartition, mode, uid,
Target: target,
QuotaIds: quotaIds,
TxInfo: tx.txInfo,
FullPath: fullPath,
}
resp := new(proto.TxCreateInodeResponse)
@ -102,7 +103,7 @@ func (mw *MetaWrapper) txIcreate(tx *Transaction, mp *MetaPartition, mode, uid,
return status, resp.Info, nil
}
func (mw *MetaWrapper) quotaIcreate(mp *MetaPartition, mode, uid, gid uint32, target []byte, quotaIds []uint32) (status int,
func (mw *MetaWrapper) quotaIcreate(mp *MetaPartition, mode, uid, gid uint32, target []byte, quotaIds []uint32, fullPath string) (status int,
info *proto.InodeInfo, err error) {
bgTime := stat.BeginStat()
defer func() {
@ -117,6 +118,7 @@ func (mw *MetaWrapper) quotaIcreate(mp *MetaPartition, mode, uid, gid uint32, ta
Gid: gid,
Target: target,
QuotaIds: quotaIds,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
@ -161,7 +163,7 @@ func (mw *MetaWrapper) quotaIcreate(mp *MetaPartition, mode, uid, gid uint32, ta
return statusOK, resp.Info, nil
}
func (mw *MetaWrapper) icreate(mp *MetaPartition, mode, uid, gid uint32, target []byte) (status int,
func (mw *MetaWrapper) icreate(mp *MetaPartition, mode, uid, gid uint32, target []byte, fullPath string) (status int,
info *proto.InodeInfo, err error) {
bgTime := stat.BeginStat()
defer func() {
@ -175,6 +177,7 @@ func (mw *MetaWrapper) icreate(mp *MetaPartition, mode, uid, gid uint32, target
Uid: uid,
Gid: gid,
Target: target,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
@ -292,7 +295,7 @@ func (mw *MetaWrapper) SendTxPack(req proto.TxPack, resp interface{}, Opcode uin
return
}
func (mw *MetaWrapper) txIunlink(tx *Transaction, mp *MetaPartition, inode uint64) (status int, info *proto.InodeInfo, err error) {
func (mw *MetaWrapper) txIunlink(tx *Transaction, mp *MetaPartition, inode uint64, fullPath string) (status int, info *proto.InodeInfo, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("txIunlink", err, bgTime, 1)
@ -303,6 +306,7 @@ func (mw *MetaWrapper) txIunlink(tx *Transaction, mp *MetaPartition, inode uint6
PartitionID: mp.PartitionID,
Inode: inode,
TxInfo: tx.txInfo,
FullPath: fullPath,
}
resp := new(proto.TxUnlinkInodeResponse)
metric := exporter.NewTPCnt("OpMetaTxUnlinkInode")
@ -320,7 +324,7 @@ func (mw *MetaWrapper) txIunlink(tx *Transaction, mp *MetaPartition, inode uint6
return statusOK, resp.Info, nil
}
func (mw *MetaWrapper) iunlink(mp *MetaPartition, inode uint64, verSeq uint64, denVerSeq uint64) (status int, info *proto.InodeInfo, err error) {
func (mw *MetaWrapper) iunlink(mp *MetaPartition, inode uint64, verSeq uint64, denVerSeq uint64, fullPath string) (status int, info *proto.InodeInfo, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("iunlink", err, bgTime, 1)
@ -340,6 +344,7 @@ func (mw *MetaWrapper) iunlink(mp *MetaPartition, inode uint64, verSeq uint64, d
UniqID: uniqID,
VerSeq: verSeq,
DenVerSeq: denVerSeq,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
@ -423,7 +428,7 @@ func (mw *MetaWrapper) iclearCache(mp *MetaPartition, inode uint64) (status int,
return status, nil
}
func (mw *MetaWrapper) ievict(mp *MetaPartition, inode uint64) (status int, err error) {
func (mw *MetaWrapper) ievict(mp *MetaPartition, inode uint64, fullPath string) (status int, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("ievict", err, bgTime, 1)
@ -433,6 +438,7 @@ func (mw *MetaWrapper) ievict(mp *MetaPartition, inode uint64) (status int, err
VolName: mw.volname,
PartitionID: mp.PartitionID,
Inode: inode,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
@ -466,7 +472,7 @@ func (mw *MetaWrapper) ievict(mp *MetaPartition, inode uint64) (status int, err
return statusOK, nil
}
func (mw *MetaWrapper) txDcreate(tx *Transaction, mp *MetaPartition, parentID uint64, name string, inode uint64, mode uint32, quotaIds []uint32) (status int, err error) {
func (mw *MetaWrapper) txDcreate(tx *Transaction, mp *MetaPartition, parentID uint64, name string, inode uint64, mode uint32, quotaIds []uint32, fullPath string) (status int, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("txDcreate", err, bgTime, 1)
@ -485,6 +491,7 @@ func (mw *MetaWrapper) txDcreate(tx *Transaction, mp *MetaPartition, parentID ui
Mode: mode,
QuotaIds: quotaIds,
TxInfo: tx.txInfo,
FullPath: fullPath,
}
metric := exporter.NewTPCnt("OpMetaTxCreateDentry")
@ -514,7 +521,7 @@ func (mw *MetaWrapper) txDcreate(tx *Transaction, mp *MetaPartition, parentID ui
}
func (mw *MetaWrapper) quotaDcreate(mp *MetaPartition, parentID uint64, name string, inode uint64, mode uint32,
quotaIds []uint32) (status int, err error) {
quotaIds []uint32, fullPath string) (status int, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("dcreate", err, bgTime, 1)
@ -532,6 +539,7 @@ func (mw *MetaWrapper) quotaDcreate(mp *MetaPartition, parentID uint64, name str
Name: name,
Mode: mode,
QuotaIds: quotaIds,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
@ -565,7 +573,7 @@ func (mw *MetaWrapper) quotaDcreate(mp *MetaPartition, parentID uint64, name str
return
}
func (mw *MetaWrapper) dcreate(mp *MetaPartition, parentID uint64, name string, inode uint64, mode uint32) (status int, err error) {
func (mw *MetaWrapper) dcreate(mp *MetaPartition, parentID uint64, name string, inode uint64, mode uint32, fullPath string) (status int, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("dcreate", err, bgTime, 1)
@ -586,6 +594,7 @@ func (mw *MetaWrapper) dcreate(mp *MetaPartition, parentID uint64, name string,
Name: name,
Mode: mode,
VerSeq: verSeq,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
@ -619,7 +628,7 @@ func (mw *MetaWrapper) dcreate(mp *MetaPartition, parentID uint64, name string,
return
}
func (mw *MetaWrapper) txDupdate(tx *Transaction, mp *MetaPartition, parentID uint64, name string, newInode, oldIno uint64) (status int, oldInode uint64, err error) {
func (mw *MetaWrapper) txDupdate(tx *Transaction, mp *MetaPartition, parentID uint64, name string, newInode, oldIno uint64, fullPath string) (status int, oldInode uint64, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("txDupdate", err, bgTime, 1)
@ -637,6 +646,7 @@ func (mw *MetaWrapper) txDupdate(tx *Transaction, mp *MetaPartition, parentID ui
Inode: newInode,
OldIno: oldIno,
TxInfo: tx.txInfo,
FullPath: fullPath,
}
resp := new(proto.TxUpdateDentryResponse)
@ -655,7 +665,7 @@ func (mw *MetaWrapper) txDupdate(tx *Transaction, mp *MetaPartition, parentID ui
return statusOK, resp.Inode, nil
}
func (mw *MetaWrapper) dupdate(mp *MetaPartition, parentID uint64, name string, newInode uint64) (status int, oldInode uint64, err error) {
func (mw *MetaWrapper) dupdate(mp *MetaPartition, parentID uint64, name string, newInode uint64, fullPath string) (status int, oldInode uint64, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("dupdate", err, bgTime, 1)
@ -671,6 +681,7 @@ func (mw *MetaWrapper) dupdate(mp *MetaPartition, parentID uint64, name string,
ParentID: parentID,
Name: name,
Inode: newInode,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
@ -782,7 +793,7 @@ func (mw *MetaWrapper) txCreateTX(tx *Transaction, mp *MetaPartition) (status in
// return statusOK, nil
//}
func (mw *MetaWrapper) txDdelete(tx *Transaction, mp *MetaPartition, parentID, ino uint64, name string) (status int, inode uint64, err error) {
func (mw *MetaWrapper) txDdelete(tx *Transaction, mp *MetaPartition, parentID, ino uint64, name string, fullPath string) (status int, inode uint64, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("txDdelete", err, bgTime, 1)
@ -795,6 +806,7 @@ func (mw *MetaWrapper) txDdelete(tx *Transaction, mp *MetaPartition, parentID, i
Name: name,
Ino: ino,
TxInfo: tx.txInfo,
FullPath: fullPath,
}
resp := new(proto.TxDeleteDentryResponse)
@ -814,7 +826,7 @@ func (mw *MetaWrapper) txDdelete(tx *Transaction, mp *MetaPartition, parentID, i
return statusOK, resp.Inode, nil
}
func (mw *MetaWrapper) ddelete(mp *MetaPartition, parentID uint64, name string, inodeCreateTime int64, verSeq uint64) (status int, inode uint64, denVer uint64, err error) {
func (mw *MetaWrapper) ddelete(mp *MetaPartition, parentID uint64, name string, inodeCreateTime int64, verSeq uint64, fullPath string) (status int, inode uint64, denVer uint64, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("ddelete", err, bgTime, 1)
@ -827,6 +839,7 @@ func (mw *MetaWrapper) ddelete(mp *MetaPartition, parentID uint64, name string,
Name: name,
InodeCreateTime: inodeCreateTime,
Verseq: verSeq,
FullPath: fullPath,
}
log.LogDebugf("action[ddelete] %v", req)
packet := proto.NewPacketReqID()
@ -880,7 +893,7 @@ func (mw *MetaWrapper) canDeleteInode(mp *MetaPartition, info *proto.InodeInfo,
return true, nil
}
func (mw *MetaWrapper) ddeletes(mp *MetaPartition, parentID uint64, dentries []proto.Dentry) (status int,
func (mw *MetaWrapper) ddeletes(mp *MetaPartition, parentID uint64, dentries []proto.Dentry, fullPaths []string) (status int,
resp *proto.BatchDeleteDentryResponse, err error) {
bgTime := stat.BeginStat()
defer func() {
@ -892,6 +905,7 @@ func (mw *MetaWrapper) ddeletes(mp *MetaPartition, parentID uint64, dentries []p
PartitionID: mp.PartitionID,
ParentID: parentID,
Dens: dentries,
FullPaths: fullPaths,
}
packet := proto.NewPacketReqID()
@ -1386,7 +1400,7 @@ func (mw *MetaWrapper) getObjExtents(mp *MetaPartition, inode uint64) (status in
// return status, nil
// }
func (mw *MetaWrapper) truncate(mp *MetaPartition, inode, size uint64) (status int, err error) {
func (mw *MetaWrapper) truncate(mp *MetaPartition, inode, size uint64, fullPath string) (status int, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("truncate", err, bgTime, 1)
@ -1397,6 +1411,7 @@ func (mw *MetaWrapper) truncate(mp *MetaPartition, inode, size uint64) (status i
PartitionID: mp.PartitionID,
Inode: inode,
Size: size,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
@ -1432,7 +1447,7 @@ func (mw *MetaWrapper) truncate(mp *MetaPartition, inode, size uint64) (status i
return statusOK, nil
}
func (mw *MetaWrapper) txIlink(tx *Transaction, mp *MetaPartition, inode uint64) (status int, info *proto.InodeInfo, err error) {
func (mw *MetaWrapper) txIlink(tx *Transaction, mp *MetaPartition, inode uint64, fullPath string) (status int, info *proto.InodeInfo, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("txIlink", err, bgTime, 1)
@ -1443,6 +1458,7 @@ func (mw *MetaWrapper) txIlink(tx *Transaction, mp *MetaPartition, inode uint64)
PartitionID: mp.PartitionID,
Inode: inode,
TxInfo: tx.txInfo,
FullPath: fullPath,
}
resp := new(proto.TxLinkInodeResponse)
@ -1463,11 +1479,11 @@ func (mw *MetaWrapper) txIlink(tx *Transaction, mp *MetaPartition, inode uint64)
return statusOK, resp.Info, nil
}
func (mw *MetaWrapper) ilink(mp *MetaPartition, inode uint64) (status int, info *proto.InodeInfo, err error) {
return mw.ilinkWork(mp, inode, proto.OpMetaLinkInode)
func (mw *MetaWrapper) ilink(mp *MetaPartition, inode uint64, fullPath string) (status int, info *proto.InodeInfo, err error) {
return mw.ilinkWork(mp, inode, proto.OpMetaLinkInode, fullPath)
}
func (mw *MetaWrapper) ilinkWork(mp *MetaPartition, inode uint64, op uint8) (status int, info *proto.InodeInfo, err error) {
func (mw *MetaWrapper) ilinkWork(mp *MetaPartition, inode uint64, op uint8, fullPath string) (status int, info *proto.InodeInfo, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("ilink", err, bgTime, 1)
@ -1485,6 +1501,7 @@ func (mw *MetaWrapper) ilinkWork(mp *MetaPartition, inode uint64, op uint8) (sta
PartitionID: mp.PartitionID,
Inode: inode,
UniqID: uniqID,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
@ -1795,7 +1812,7 @@ func (mw *MetaWrapper) addMultipartPart(mp *MetaPartition, path, multipartId str
return status, resp.OldInode, resp.Update, nil
}
func (mw *MetaWrapper) idelete(mp *MetaPartition, inode uint64) (status int, err error) {
func (mw *MetaWrapper) idelete(mp *MetaPartition, inode uint64, fullPath string) (status int, err error) {
bgTime := stat.BeginStat()
defer func() {
stat.EndStat("idelete", err, bgTime, 1)
@ -1805,6 +1822,7 @@ func (mw *MetaWrapper) idelete(mp *MetaPartition, inode uint64) (status int, err
VolName: mw.volname,
PartitionId: mp.PartitionID,
Inode: inode,
FullPath: fullPath,
}
packet := proto.NewPacketReqID()
packet.Opcode = proto.OpMetaDeleteInode