diff --git a/metanode/dentry.go b/metanode/dentry.go index 142707746..ba6353924 100644 --- a/metanode/dentry.go +++ b/metanode/dentry.go @@ -52,8 +52,8 @@ type DentryMultiSnap struct { type Dentry struct { ParentId uint64 // FileID value of the parent inode. - Name string // Name of the current dentry. Inode uint64 // FileID value of the current inode. + Name string // Name of the current dentry. Type uint32 // snapshot multiSnap *DentryMultiSnap diff --git a/metanode/inode.go b/metanode/inode.go index 81206dd59..524f37509 100644 --- a/metanode/inode.go +++ b/metanode/inode.go @@ -77,32 +77,31 @@ type InodeMultiSnap struct { type Inode struct { sync.RWMutex - Inode uint64 // Inode ID - Type uint32 - Uid uint32 - Gid uint32 - Size uint64 - Generation uint64 - CreateTime int64 - AccessTime int64 - ModifyTime int64 + // 8-bytes + Inode uint64 // Inode ID + Size uint64 + Generation uint64 + CreateTime int64 + AccessTime int64 + ModifyTime int64 + Reserved uint64 // reserved space + LeaseExpireTime uint64 + + // 4-bytes + Type uint32 + Uid uint32 + Gid uint32 + NLink uint32 // NodeLink counts + Flag int32 + StorageClass uint32 + ClientID uint32 + + // pointer LinkTarget []byte // SymLink target name - NLink uint32 // NodeLink counts - Flag int32 - Reserved uint64 // reserved space - // Extents *ExtentsTree - // Extents *SortedExtents // in HybridCloud, this is for cache dp only - - // ObjExtents *SortedObjExtents // Snapshot - multiSnap *InodeMultiSnap - - // HybridCloud - StorageClass uint32 + multiSnap *InodeMultiSnap HybridCloudExtents *SortedHybridCloudExtents HybridCloudExtentsMigration *SortedHybridCloudExtentsMigration - ClientID uint32 - LeaseExpireTime uint64 } func (i *Inode) LeaseNotExpire() bool { @@ -635,7 +634,6 @@ func (i *Inode) MarshalV2(buff *buf.ByteBufExt) (err error) { i.MarshalValueV2(tmpBuf) valBytes := tmpBuf.Bytes() - // valBytes := i.MarshalValue() keyLen := uint32(len(keyBytes)) valLen := uint32(len(valBytes)) diff --git a/metanode/inode_test.go b/metanode/inode_test.go index 521ccc628..e7c726e64 100644 --- a/metanode/inode_test.go +++ b/metanode/inode_test.go @@ -315,3 +315,30 @@ func TestInodeMarshalCompitable(t *testing.T) { oldData = []byte{0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 195, 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 105, 0, 0, 0, 0, 0, 0, 0, 106, 0, 0, 0, 0, 0, 0, 0, 107, 0, 0, 0, 7, 116, 101, 115, 116, 32, 111, 112, 0, 0, 0, 108, 0, 0, 0, 109, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} checkInodeCompatibility(oldData, oldIno, t) } + +func BenchmarkInodeMarshal(b *testing.B) { + oldIno := NewInode(1024, 0) + oldIno.Uid = 101 + oldIno.Gid = 102 + oldIno.Generation = 104 + oldIno.CreateTime = 105 + oldIno.AccessTime = 106 + oldIno.ModifyTime = 107 + oldIno.NLink = 108 + oldIno.Flag = 109 + oldIno.StorageClass = proto.StorageClass_Replica_SSD + oldIno.HybridCloudExtents.sortedEks = NewSortedExtentsFromEks([]proto.ExtentKey{{FileOffset: 100}}) + + buff := GetInodeBuf() + defer PutInodeBuf(buff) + + b.ReportAllocs() + b.ResetTimer() + + for i := 0; i < b.N; i++ { + err := oldIno.MarshalV2(buff) + if err != nil { + b.Fatal(err) + } + } +}