mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Ensure that files created after save are visible after restore.
PiperOrigin-RevId: 615197421
This commit is contained in:
@@ -833,15 +833,17 @@ type dentry struct {
|
||||
children map[string]*dentry
|
||||
|
||||
// If this dentry represents a directory, negativeChildrenCache cache
|
||||
// names of negative children.
|
||||
// names of negative children. negativeChildrenCache is not saved since
|
||||
// dentry.prepareSaveRecursive() drops all negative children.
|
||||
//
|
||||
// +checklocks:childrenMu
|
||||
negativeChildrenCache stringFixedCache
|
||||
// If this dentry represents a directory, negativeChildren is the number
|
||||
// of negative children cached in dentry.children
|
||||
negativeChildrenCache stringFixedCache `state:"nosave"`
|
||||
// If this dentry represents a directory, negativeChildren is the number of
|
||||
// negative children cached in dentry.children. negativeChildren is not
|
||||
// saved since dentry.prepareSaveRecursive() drops all negative children.
|
||||
//
|
||||
// +checklocks:childrenMu
|
||||
negativeChildren int
|
||||
negativeChildren int `state:"nosave"`
|
||||
|
||||
// If this dentry represents a directory, syntheticChildren is the number
|
||||
// of child dentries for which dentry.isSynthetic() == true.
|
||||
@@ -857,9 +859,9 @@ type dentry struct {
|
||||
// childrenSet share the same lifecycle.
|
||||
//
|
||||
// +checklocks:childrenMu
|
||||
dirents []vfs.Dirent
|
||||
dirents []vfs.Dirent `state:"nosave"`
|
||||
// +checklocks:childrenMu
|
||||
childrenSet map[string]struct{}
|
||||
childrenSet map[string]struct{} `state:"nosave"`
|
||||
|
||||
// Cached metadata; protected by metadataMu.
|
||||
// To access:
|
||||
|
||||
@@ -111,11 +111,16 @@ func (d *dentry) prepareSaveRecursive(ctx context.Context) error {
|
||||
}
|
||||
d.childrenMu.Lock()
|
||||
defer d.childrenMu.Unlock()
|
||||
for _, child := range d.children {
|
||||
if child != nil {
|
||||
if err := child.prepareSaveRecursive(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
for childName, child := range d.children {
|
||||
if child == nil {
|
||||
// Unsaved filesystem state may change across save/restore. Remove
|
||||
// negative entries from d.children to ensure that files created
|
||||
// after save are visible after restore.
|
||||
delete(d.children, childName)
|
||||
continue
|
||||
}
|
||||
if err := child.prepareSaveRecursive(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user