diff --git a/pkg/meta/dump.go b/pkg/meta/dump.go index d97cc0a17964..c26f2c980251 100644 --- a/pkg/meta/dump.go +++ b/pkg/meta/dump.go @@ -69,6 +69,7 @@ type DumpedAttr struct { Nlink uint32 `json:"nlink"` Length uint64 `json:"length"` Rdev uint32 `json:"rdev,omitempty"` + full bool } type DumpedSlice struct { @@ -301,6 +302,7 @@ func dumpAttr(a *Attr, d *DumpedAttr) { } else { d.Length = 0 } + d.full = a.Full } func loadAttr(d *DumpedAttr) *Attr { diff --git a/pkg/meta/redis.go b/pkg/meta/redis.go index 5d33d4b7ed4f..173f233bed90 100644 --- a/pkg/meta/redis.go +++ b/pkg/meta/redis.go @@ -3613,7 +3613,7 @@ func (m *redisMeta) dumpEntries(es ...*DumpedEntry) error { return err } if inode != TrashInode { - logger.Warnf("The entry of the inode was not found. inode: %d", inode) + logger.Errorf("Corrupt inode: %d, missing attribute", inode) } } diff --git a/pkg/meta/sql.go b/pkg/meta/sql.go index 2e631c1ff6a0..7af7a1939596 100644 --- a/pkg/meta/sql.go +++ b/pkg/meta/sql.go @@ -3304,7 +3304,7 @@ func (m *dbMeta) dumpEntryFast(s *xorm.Session, inode Ino, typ uint8) *DumpedEnt e := &DumpedEntry{} n, ok := m.snap.node[inode] if !ok && inode != TrashInode { - logger.Warnf("The entry of the inode was not found. inode: %d", inode) + logger.Errorf("Corrupt inode: %d, missing attribute", inode) } attr := &Attr{Typ: typ, Nlink: 1} diff --git a/pkg/meta/tkv.go b/pkg/meta/tkv.go index 1f937aec6a2c..666ba8f1694a 100644 --- a/pkg/meta/tkv.go +++ b/pkg/meta/tkv.go @@ -2873,7 +2873,10 @@ func (m *kvMeta) dumpDir(inode Ino, tree *DumpedEntry, bw *bufio.Writer, depth i if m.snap != nil { e := m.snap[inode] entries = e.Entries - for n := range e.Entries { + for n, de := range e.Entries { + if !de.Attr.full && de.Attr.Inode != TrashInode { + logger.Errorf("Corrupt inode: %d, missing attribute", inode) + } sortedName = append(sortedName, n) } } else { @@ -2978,14 +2981,13 @@ func (m *kvMeta) DumpMeta(w io.Writer, root Ino, keepSecret bool) (err error) { ino := m.decodeInode(key[1:9]) e := m.snap[ino] if e == nil { - e = &DumpedEntry{} + e = &DumpedEntry{Attr: &DumpedAttr{Inode: ino}} m.snap[ino] = e } switch key[9] { case 'I': attr := &Attr{Nlink: 1} m.parseAttr(value, attr) - e.Attr = &DumpedAttr{} dumpAttr(attr, e.Attr) e.Attr.Inode = ino case 'C': @@ -3001,11 +3003,13 @@ func (m *kvMeta) DumpMeta(w io.Writer, root Ino, keepSecret bool) (err error) { e.Chunks = append(e.Chunks, &DumpedChunk{indx, slices}) case 'D': name := string(key[10:]) - _, inode := m.parseEntry(value) + typ, inode := m.parseEntry(value) child := m.snap[inode] if child == nil { - child = &DumpedEntry{} + child = &DumpedEntry{Attr: &DumpedAttr{Inode: inode, Type: typeToString(typ)}} m.snap[inode] = child + } else if child.Attr.Type == "" { + child.Attr.Type = typeToString(typ) } if e.Entries == nil { e.Entries = map[string]*DumpedEntry{}