Skip to content

Commit 196ab65

Browse files
avagingvisor-bot
authored andcommitted
fsimpl/gofer: report warning instead of panic if a file type has been changed
Replaces a panic with a warning and cache invalidation when a file's type is detected to have changed during lisafs revalidation, despite the inode key remaining the same. PiperOrigin-RevId: 809324446
1 parent 6448dbe commit 196ab65

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pkg/sentry/fsimpl/gofer/lisafs_inode.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,13 +704,11 @@ func doRevalidationLisafs(ctx context.Context, vfsObj *vfs.VirtualFilesystem, st
704704
for i := 0; i < len(state.dentries); i++ {
705705
d := state.dentries[i]
706706
found := i < len(stats)
707-
// Advance lastUnlockedDentry. It is the responsibility of this for loop
708-
// block to unlock i.metadataMu.
709-
lastUnlockedDentry = i
710707

711708
// Note that synthetic dentries will always fail this comparison check.
712709
if !found || d.inode.inoKey != inoKeyFromStatx(&stats[i]) {
713710
d.inode.metadataMu.Unlock()
711+
lastUnlockedDentry = i
714712
if !found && d.inode.isSynthetic() {
715713
// We have a synthetic file, and no remote file has arisen to replace
716714
// it.
@@ -725,13 +723,18 @@ func doRevalidationLisafs(ctx context.Context, vfsObj *vfs.VirtualFilesystem, st
725723
// Check that the file type has not changed.
726724
if stats[i].Mask&linux.STATX_TYPE != 0 {
727725
if got, want := stats[i].Mode&linux.FileTypeMask, d.inode.fileType(); uint32(got) != want {
728-
panic(fmt.Sprintf("file type of %q changed from %#o to %#o while inode key (%+v) did not change", genericDebugPathname(d.inode.fs, d), want, got, d.inode.inoKey))
726+
ctx.Warningf("file type of %q changed from %#o to %#o while inode key (%+v) did not change", genericDebugPathname(d.inode.fs, d), want, got, d.inode.inoKey)
727+
d.inode.metadataMu.Unlock()
728+
lastUnlockedDentry = i
729+
d.invalidate(ctx, vfsObj, ds)
730+
return nil
729731
}
730732
}
731733

732734
// The file at this path hasn't changed. Just update cached metadata.
733735
d.inode.impl.(*lisafsInode).updateMetadataFromStatxLocked(&stats[i]) // +checklocksforce: see above.
734736
d.inode.metadataMu.Unlock()
737+
lastUnlockedDentry = i
735738
}
736739
return nil
737740
}

0 commit comments

Comments
 (0)