The helper function is deprecated. The package gvisor.dev/gvisor/pkg/rand
depends on crypto/rand which performs worse thatn math/rand, the changes
are fine since they are not at any gVisor's hot path.
The ultimate goal is to migrate math/rand to math/rand/v2.
In some test environments, the `TEST_TMPDIR` path is too long.
So creating a socket file inside that via bind(2) fails with EINVAL.
bind(2) requires paths to be shorter than 108.
PiperOrigin-RevId: 609110892
It is an idea of running codespell as part of our presubmit checks.
Before enabling it for new changes, let's fix what it has found.
Signed-off-by: Andrei Vagin <avagin@gmail.com>
This test was attempting to create a link with the same name as the target.
Changed that to use a different name for link. This test also exposed a ref
count bug in LISAFS RPC handlers. Fixed that.
Updates #8688
PiperOrigin-RevId: 516912550
This is not used as of now. This is required for directfs later. The impacted
RPCs are Mount and Open. Mount has been modified to now donate an optional FD
to the mount point.
As the mount point can be a socket or a symlink, which needs to be opened with
O_PATH, we can no longer expect unix.SetNonblock() to work always while donating
FD in lisafs. So allow it to fail. Just log a warning in such cases.
Also split out the logic to start channels from lisafs.NewClient(). Not all
clients require channels.
PiperOrigin-RevId: 504631423
The new `host-uds` flag has the following differences:
* More granular control: user can specify whether to ignore host UDS,
connect to an existing host UDS, create a host UDS, or both
* Will shortly be used to also control pipes from the host, hence the
removal of UDS from the name
* Can be used with other filesystems, not gofer-based, hence the
removal of fsgofer from the name
This change also removes support for bind() from 9P based gofer since it's
not supported and would make this change more complicated.
Updates #8037
PiperOrigin-RevId: 483538832
In some scenarios, like closing special FDs in the gofer
client, we make a one-shot RPC to close the gofer FDID
immediately because that FD closure is critical to application
behavior.
Since we are making the round trip anyway, we can use that RPC
to also flush the entire to-be-closed FDID queue. This will
help reduce the number of Close RPCs.
Another change in behavior is that Bound Socket FDs are now
closed immediately, instead of being batched. This is because
socket FD closure can impact app behavior. 492ea1a04e ("Do
not batch close gofer.handle in lisafs.") was a similar effort.
Updates #7613
PiperOrigin-RevId: 450781423
Earlier lisafs let the client choose where the connection will be mounted.
Because the client can be compromised, we can not trust the Mount RPC to
dictate the mount path. Instead, decide the mount path on startup on the server
as per the sandbox configuration.
lisafs made the following two assumptions where were incorrect:
- runsc/fsgofer always chroot()s the gofer process. This is currently always
the case but in the future this might not be true.
- Non root mountpoints will not always correspond to the same directory inside
the root mount. For instance, if application sets bind mount
`-v host/dir:app/dir`, then it is not necessary that the app/dir endpoint is
placed at path "app/dir" inside the root endpoint. This is currently the case
for runsc/fsgofer, but it might not be in the future.
To support attach paths, make the client do a normal Walk RPC to the attach
point. The Mount RPC now mounts the connection to an endpoint that was
predetermined during startup according to sandbox configuration.
PiperOrigin-RevId: 424948561
This is very similar to p9 in design and helps address all the discussed
security concerns around the old lisafs design.
In p9, the path tree grows unbounded. Once a path is walked, those path nodes
exist for the lifetime of the server. That hurts memory performance and usage.
Additionally, nodes are allocated separately from FidRefs which are allocated
separately from Files. Each path node also has 3 hashmaps tracking various
things. This leads to a LOT of allocations.
In lisafs, we cut down almost all the additional allocations. Nodes have a
bounded lifetime. Once all refs on node are dropped, the node is removed from
the filesystem tree. In the overwhelming common case, where the client is not
compromised and is behaving correctly (gofer client in sentry), the lifecycle
of the ControlFD and Node are equivalent. So lisafs allocates them together.
lisafs also only uses 1 hashmap in each node to track children. This too has
been optimized. Experimentation showed that majority of directories have at
most 3 children to track. So we only allocate the hashmap once we hit 4
children. Before that, we statically track 3 children using hardcoded pointers.
Tested: All 221 syscall tests pass with lisafs.
PiperOrigin-RevId: 424933787
This is so that server implementations do not need to worry about marshalling
details. Having them centralized is also less error prone. Less code copying.
Updates #5465
PiperOrigin-RevId: 415651622
The p9 client does the same. This allows applications to read/write >= 2MB of
data. This enables the read write benchmarks to work with lisafs.
Updates #5466
PiperOrigin-RevId: 398659947
Introduces RPC methods in lisafs. Makes that gofer client use lisafs RPCs
instead of p9 when lisafs is enabled.
Implements the handlers for those methods in fsgofer.
Fixes#5465
PiperOrigin-RevId: 398080310