- Exclusive mode - By default (
archil mount), mounting an Archil disk puts it in exclusive mode. This locks the entire file system for the machine which mounted. That machine will receive local-like performance that matches an EBS volume, but other machines will not be able to write to the disk until it’s unmounted. Other machines can still mount the disk witharchil mount --read-onlyto read it. - Shared mode - If you mount the disk in shared mode (
archil mount --shared), no lock is taken out on the disk. By default, the entire disk will appear read-only to the client until it manually requests a delegation (archil checkout <path>). With a delegation, the client will have exclusive write access to the specified<path>and receive local-like performance. - Conditional mode - If you mount the disk in conditional mode (
archil mount --conditional), you enable the disk to execute operations remotely, like an NFS or 9p file system. This means that all files (which are not write-locked by another client) are immediately writeable, but the disk performance will be reduced to that of a remote file system. Users in conditional mode can continue to usearchil checkoutto get exclusive write access and higher performance to subdirectories on the disk.
Choosing a mode
Selecting a mode on serverless execution
By default, disks in serverless execution are mounted in Shared mode (archil mount --shared) to enable multiple sandboxes to easily access
the same data.
You can change the disk into Exclusive mode by first executing archil checkout /mnt/archil as part of your serverless execution
command.
You can select Conditional mode by using the more verbose serverless execution API, like below:
/mnt/archil/data instead of /mnt/archil.
Automatic delegations in shared mode
When mounting in Shared mode, some operations automatically grant a write-lock on the file, to reduce the number of times that you need to callarchil checkout. These operations are:
- Creating a new file inside of a directory that does not have a delegation
- Opening a file that is not covered by a delegation for writing (delegation automatically released on close)
- Creating a new directory
archil checkin on
the resource after creation.
These rules lead to a common pitfall with Archil in which it’s possible to create a file or directory, but a removal
operation will fail with EROFS: Read-only file system. This is because of the automatic delegation granting on
file/folder creation. Deleting a file or folder is a directory-level operation, and requires a delegation on the parent
directory of the file being removed.
These rules apply only to clients in Shared mode. Clients mounting in Conditional mode will never have delegations
automatically issued to them.
Understanding delegations
Each delegation is an exclusive write-lock on a part of an Archil disk for a single client. When you callarchil checkout <path>,
all files and folders underneath that path will be included as part of the write delegation. This will prevent other write operations,
including S3 PutObject operations, from completing against those paths.
For example, consider a file system with the following structure:
archil checkout group/ to get exclusive write-access to the “group” directory, it will also have exclusive
write access to the group/models/ directory and its contents. Other clients will be able to continue to read these files and folders
but will not be able to write to them, or call PutObject. Unless it’s mounted in conditional mode, this client would not be
able to edit any other part of the disk. Other clients are simultaneously able to call PutObject to add files to the data/ directory
or get exclusive write access over that directory by calling archil checkout data/.
When your client is operating in conditional mode, write operations are executed on the server-side, and multiple clients can
simultaneously read and write to any part of the file system without a delegation.
Releasing delegations
Delegations represent an exclusive write-lock on a part of the Archil disk. As a result, they need to be manually released by clients to signal that they are no longer performing writes to that portion of the disk. You can do this by either unmounting the disk from the server which requested the delegation or by manually callingarchil checkin <path>.
Forcing ownership
In some cases, a client may crash or poweroff without cleanly unmounting or callingarchil checkin to release a delegation.
If this happens, you will not automatically be able to write to the location where the client’s delegation was held. Instead,
you will need to force release the delegation. This will cause any in-progress writes from the original client to be lost. This
mirrors “force detaching” a block device, such as an EBS or Hyperdisk disk.
You can force checkout a delegation by calling archil checkout <path> --force, and you can force mount a disk into exclusive
mode by calling archil mount --force.
You can also remove delegations using the Archil API, if you don’t have the disk mounted locally:
Typescript
Conditional mode
When mounting in Conditional mode, a client can write to any file or directory on the disk without callingarchil checkout,
as long as no other client holds a delegation on it. This makes Conditional mode a good fit when several clients need to write to
the same disk, such as multiple agents working in a shared workspace.
Creating, renaming, and deleting files and directories are executed on the server before the operation returns. Writes to file
contents are buffered on the client and sent to the server in the background, like on any Archil mount. Closing the file or
calling fsync waits for them to reach the disk.
Clients in conditional mode don’t lock files for each other. If two clients write to the same part of a file, the last write to
reach the disk wins. If several clients need to update the same file, coordinate them in your application, or use
archil checkout to give one client exclusive access to it.
A client in conditional mode can still call archil checkout <path> to get exclusive write access and higher performance on part
of the disk. While a client holds a delegation, other clients in conditional mode can’t write to that path. If a client in
conditional mode still has unsent writes to that path when another client checks it out, those writes are lost and its mount
becomes read-only; see Troubleshooting.