How It Works
Where the namespace lives, how data reaches AIStor, and when a write is durable.
AIStor Files splits what a filesystem stores. The gateway answers metadata (names, directories, permissions, and locks) from the node's local drives, and keeps no file data. AIStor stores the data, and a copy of the metadata that any node can rebuild an export from.
Metadata is answered locally
A filesystem does far more metadata work than data work. A lookup, a directory listing, a create or a rename must be atomic and fast. An object store offers neither for operations that touch several entries, such as a rename.
So the gateway answers metadata from local disk. A lookup, create, rename, or listing makes no request to AIStor of its own. Two cases do wait on AIStor:
- Operations that free data. Removing a file's last link, renaming over a file, and a truncate delete objects in AIStor before they return. When a client still has the file open, its objects are deleted when the last handle closes instead.
- A checkpoint. After 1,024 changes, or on the first change after 30 seconds, the gateway writes the recent namespace changes to AIStor before that change returns. Operations queued behind it wait too, so a slow AIStor shows up as slower metadata.
The namespace survives a crash
The gateway records every namespace change in an append-only log, and keeps a queryable copy of the namespace that the log can rebuild.
- One operation is one log record. A rename that changes several entries is one record, applied all at once or not at all.
- A record states the result, not a change. Replaying a record twice gives the same namespace, so recovery is safe to repeat.
- The log is written to disk before the client gets an answer. After a crash, the node replays the log from its drive, so the change is not lost while that drive survives.
The gateway also sends the log to AIStor before it answers a change, and publishes a
full image of the namespace there as the log grows. Changes made at the same time share
one send. When a drive of the node is lost, the gateway rebuilds the metadata that was on
it from that copy, with every change it answered. A buffered write is kept once the application calls fsync or closes the
file, and a stable or O_DIRECT write as soon as it returns. See
If a node is lost.
How file data reaches AIStor
| Write | What happens | Data is in AIStor when |
|---|---|---|
| Buffered (an ordinary application write) | Gathered in memory into 16 MiB objects, sent in the background | The client commits or closes the file |
O_DIRECT, or a stable write | Written straight to AIStor | Before the write returns |
A buffered write is acknowledged as unstable, and a commit or close waits until it is in
AIStor. An application that calls fsync gets what POSIX promises. If the node that held
the write is lost first, the fsync or close returns an I/O error (EIO) instead of
success.
A stable or O_DIRECT write also sends the metadata that names its data to AIStor before
it returns, so it survives the loss of the node. See
If a node is lost.
A large file written in order becomes a few 16 MiB objects. A commit or close of a partly written 16 MiB range stores only the written bytes, as a smaller object. An application that commits often into the same range creates many small objects, and reads of that range slow down.
Reads come from AIStor. The client's page cache serves repeated reads. The gateway keeps no read cache.
Background work
This work runs in the background. A client waits on it when it commits or closes a file: the commit waits until the file's buffered data has reached AIStor. A write also waits when AIStor falls behind: past 512 MiB of buffered data, or 256 MiB already on its way to AIStor, the write sends its own data before it returns.
| Work | Purpose |
|---|---|
| Upload | Sends full 16 MiB objects to AIStor |
| Log shipping | Sends the namespace log to AIStor before a change is answered, and every 5 seconds |
| Namespace image | Publishes a full image as the log grows, so a rebuild starts from a recent point |
| Compaction | Folds the small objects of pNFS writes into whole objects, once a file has been idle for hours |
| Reconcile | Every 15 minutes, links data objects that no file names into lost+found/ at the export root |
| Lease renewal | Every 6 seconds, confirms that this node still owns the cells it runs |
Every node serves every export
AIStor splits each export into cells. A cell is one part of the namespace, with its own log and its own lease. AIStor gives each export about one cell per drive, a power of two from 2 to 16,384, and spreads the cells over every node. One node runs each cell.
A client can mount through any node. When a call is for a cell that another node runs, the gateway sends it to that node over AIStor's network between nodes. A file's data goes straight to AIStor from the gateway the client mounted through.
When a node is out of reach for 15 seconds, AIStor gives its cells to the other nodes.
A node that stopped cleanly released its leases, so the cells whose lease it released are taken at once.
Otherwise a cell is taken once its lease has gone unrenewed for the lease term plus 3
seconds. The term is 30 seconds by default, and you set it with lease_ttl. See
Change how fast cells move. AIStor moves the cells back once the node has stayed
up for 10 minutes. It also moves cells off a pool being decommissioned, and onto the
nodes of a new pool. See Take a node out of service.
Each export is isolated
Each export has its own cells, namespace logs, quota, leases, filesystem ID, and prefix in the bucket. File handles are unique across exports, so two exports are never confused, and a quota counts one export only.
The protocol layer
A mature NFS server handles the protocol: sessions, byte-range locks, grace after a restart, and NFSv4.1 compound operations. The gateway plugs its storage engine into that server through a thin interface. The interface isolates every call, so a fault in the engine cannot stop the NFS service. Clients therefore talk to standard NFSv4.1 and need nothing special.