Fix synthetic file bugs in gofer fs.

Always check if a synthetic file already exists at a location before creating a
file there, and do not try to delete synthetic gofer files from the remote fs.

This fixes runsc_ptrace socket tests that create/unlink synthetic, named socket
files.

Updates #2923.

PiperOrigin-RevId: 317293648
This commit is contained in:
Dean Deng
2020-06-19 05:57:15 -07:00
committed by gVisor bot
parent 408f3d2cd6
commit 46957ed24f
2 changed files with 26 additions and 8 deletions
+11 -8
View File
@@ -374,13 +374,16 @@ func (fs *filesystem) doCreateAt(ctx context.Context, rp *vfs.ResolvingPath, dir
return nil
}
if fs.opts.interop == InteropModeShared {
// The existence of a dentry at name would be inconclusive because the
// file it represents may have been deleted from the remote filesystem,
// so we would need to make an RPC to revalidate the dentry. Just
// attempt the file creation RPC instead. If a file does exist, the RPC
// will fail with EEXIST like we would have. If the RPC succeeds, and a
// stale dentry exists, the dentry will fail revalidation next time
// it's used.
if child := parent.children[name]; child != nil && child.isSynthetic() {
return syserror.EEXIST
}
// The existence of a non-synthetic dentry at name would be inconclusive
// because the file it represents may have been deleted from the remote
// filesystem, so we would need to make an RPC to revalidate the dentry.
// Just attempt the file creation RPC instead. If a file does exist, the
// RPC will fail with EEXIST like we would have. If the RPC succeeds, and a
// stale dentry exists, the dentry will fail revalidation next time it's
// used.
return createInRemoteDir(parent, name)
}
if child := parent.children[name]; child != nil {
@@ -518,7 +521,7 @@ func (fs *filesystem) unlinkAt(ctx context.Context, rp *vfs.ResolvingPath, dir b
if child == nil {
return syserror.ENOENT
}
} else {
} else if child == nil || !child.isSynthetic() {
err = parent.file.unlinkAt(ctx, name, flags)
if err != nil {
if child != nil {
+15
View File
@@ -57,6 +57,7 @@ syscall_test(
size = "large",
add_overlay = True,
test = "//test/syscalls/linux:bind_test",
vfs2 = "True",
)
syscall_test(
@@ -700,6 +701,7 @@ syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:socket_filesystem_non_blocking_test",
vfs2 = "True",
)
syscall_test(
@@ -707,12 +709,14 @@ syscall_test(
add_overlay = True,
shard_count = 50,
test = "//test/syscalls/linux:socket_filesystem_test",
vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:socket_inet_loopback_test",
vfs2 = "True",
)
syscall_test(
@@ -721,6 +725,7 @@ syscall_test(
# Takes too long for TSAN. Creates a lot of TCP sockets.
tags = ["nogotsan"],
test = "//test/syscalls/linux:socket_inet_loopback_nogotsan_test",
vfs2 = "True",
)
syscall_test(
@@ -796,6 +801,7 @@ syscall_test(
syscall_test(
test = "//test/syscalls/linux:socket_blocking_local_test",
vfs2 = "True",
)
syscall_test(
@@ -805,6 +811,7 @@ syscall_test(
syscall_test(
test = "//test/syscalls/linux:socket_non_stream_blocking_local_test",
vfs2 = "True",
)
syscall_test(
@@ -815,6 +822,7 @@ syscall_test(
syscall_test(
size = "large",
test = "//test/syscalls/linux:socket_stream_blocking_local_test",
vfs2 = "True",
)
syscall_test(
@@ -826,11 +834,13 @@ syscall_test(
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_stream_local_test",
vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_stream_nonblock_local_test",
vfs2 = "True",
)
syscall_test(
@@ -838,6 +848,7 @@ syscall_test(
size = "enormous",
shard_count = 5,
test = "//test/syscalls/linux:socket_unix_dgram_local_test",
vfs2 = "True",
)
syscall_test(
@@ -859,11 +870,13 @@ syscall_test(
size = "enormous",
shard_count = 5,
test = "//test/syscalls/linux:socket_unix_seqpacket_local_test",
vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_unix_stream_test",
vfs2 = "True",
)
syscall_test(
@@ -881,6 +894,7 @@ syscall_test(
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_unix_unbound_filesystem_test",
vfs2 = "True",
)
syscall_test(
@@ -894,6 +908,7 @@ syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:socket_unix_unbound_stream_test",
vfs2 = "True",
)
syscall_test(