18 Commits
Author SHA1 Message Date
Jing Chen 7cc17225e6 Remove references to math/rand package's Read function.
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.
2024-10-16 18:17:15 +00:00
Koichi Shiraishi 0cf77c02f8 all: remove use io/ioutil deprecated package & fix some deprecated thing
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2024-10-10 20:36:24 +09:00
Ayush RanjanandgVisor bot 1303df5f70 Skip running the UDS lisafs test for runsc/fsgofer.
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
2024-02-21 13:54:19 -08:00
Andrei Vagin 5f4abad306 Fix a few typos
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>
2023-10-25 12:13:42 -07:00
Ayush RanjanandgVisor bot 8fb66eb289 Get HardLink test in //runsc/fsgofer:lisafs_test to pass.
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
2023-03-15 13:26:13 -07:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Ayush RanjanandgVisor bot dbfc591d94 Optionally donate a host FD to the mount point in lisafs.
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
2023-01-25 12:30:20 -08:00
Ayush RanjanandgVisor bot 175db901ca Replace pkg/refs with pkg/refsvfs2.
All VFS1 only bits have been deleted.

Updates #1624

PiperOrigin-RevId: 492273183
2022-12-01 12:46:11 -08:00
Fabricio VoznikaandgVisor bot 7e3bd4db0f Add rudimentary UDS test to lisafs
PiperOrigin-RevId: 483732841
2022-10-25 11:35:28 -07:00
Fabricio VoznikaandgVisor bot 0eb861df56 Replace fsgofer-host-uds flag
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
2022-10-24 18:26:44 -07:00
Ayush RanjanandgVisor bot 38a3c98a0d Flush to-be-closed FDIDs queue when making one-shot Close.
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
2022-05-24 15:21:56 -07:00
Ayush RanjanandgVisor bot 71764f1b8c Generalize lisafs testsuite for external users.
PiperOrigin-RevId: 445300994
2022-04-28 18:47:54 -07:00
Ayush RanjanandgVisor bot 2a3d59997f Enable reference count leak checking for lisafs.
Also add DoRepeatedLeakCheck() to refsvfs2 package.

Updates #5466

PiperOrigin-RevId: 425004987
2022-01-28 19:14:08 -08:00
Ayush RanjanandgVisor bot 3f42b2da94 Fix semantics of Mount RPC in lisafs.
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
2022-01-28 13:50:17 -08:00
Ayush RanjanandgVisor bot 575a6f5003 Introduce filesystem tree nodes to lisafs.
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
2022-01-28 12:41:25 -08:00
Ayush RanjanandgVisor bot 597dc4f7f0 Move RPC response marshalling to lisafs handlers.
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
2021-12-10 18:06:47 -08:00
Ayush RanjanandgVisor bot 12175748ab Allow lisafs client to send more data than MaxMessageSize using chunks.
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
2021-09-23 23:33:45 -07:00
Ayush RanjanandgVisor bot 6fccc18560 [lisa] Implement lisafs protocol methods in VFS2 gofer client and fsgofer.
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
2021-09-21 14:09:18 -07:00