Co-authored-by: heihutu <heihutu@gmail.com> Co-authored-by: zhi22915 <qiuzgang@gmail.com> Co-authored-by: qunjiazhu <qunjiazhu@gmail.com>
22 KiB
Durability modes (drive sync tiers)
Use this when: choosing or debugging the fsync tier (strict|file-sync|relaxed|none|legacy-off) for a deployment or a single bucket, or changing any write-path sync behaviour.
Source of truth: crates/ecstore/src/disk/local.rs (ENV_RUSTFS_DURABILITY_MODE, ENV_RUSTFS_DRIVE_SYNC_ENABLE, mode resolution and per-write-point sync decisions), crates/ecstore/src/bucket/durability.rs (ENV_NEW_BUCKET_DURABILITY_MODE, per-bucket override), rustfs/src/admin/handlers/durability.rs (admin API), crates/ecstore/src/bucket/metadata_sys.rs (BUCKET_METADATA_REFRESH_INTERVAL).
RustFS lets operators choose how much fsync work runs on the object write
path. The default (strict) preserves the fully synced behavior RustFS has
always shipped. file-sync, relaxed, and none are opt-in trades of power-loss
durability for latency/IOPS. Newly created buckets inherit the process-wide
mode unless RUSTFS_NEW_BUCKET_DURABILITY_MODE explicitly sets an override.
Configuration
# New tiered switch (wins when set to a valid value)
RUSTFS_DURABILITY_MODE=strict|file-sync|relaxed|none # default: strict
# Legacy binary switch (kept for compatibility, superseded by the above)
RUSTFS_DRIVE_SYNC_ENABLE=true|false # default: true
# Tier seeded into a NEWLY CREATED bucket's own override (see "New-bucket default")
RUSTFS_NEW_BUCKET_DURABILITY_MODE=file-sync|relaxed|strict|none|inherit # default: inherit process mode
Resolution rules:
RUSTFS_DURABILITY_MODE |
RUSTFS_DRIVE_SYNC_ENABLE |
Effective mode |
|---|---|---|
| unset | unset | strict (default) |
| unset | true |
strict |
| unset | false |
legacy-off (the historical "everything off" semantics) |
strict / file-sync / relaxed / none |
anything | the named mode |
| invalid value | any | logged warning, falls back to the legacy switch, then the default |
Values are case-insensitive and whitespace-tolerant. The mode is resolved
once per process and cached (it also removes the per-call getenv the
old switch performed a dozen times per PUT); changing the environment
requires a restart. The resolved mode is logged at startup under the
disk_local_durability_mode event.
legacy-off is not a value of RUSTFS_DURABILITY_MODE; it is only reachable
through RUSTFS_DRIVE_SYNC_ENABLE=false so that existing deployments keep
their exact current behavior. It is deprecated and will be retained for at
least one major version.
Do not set the process-wide file-sync value until every node runs a version that recognizes it. An older node treats the value as invalid and falls back to its legacy switch. Prefer the fail-closed bucket override during a rolling upgrade, and keep RUSTFS_NEW_BUCKET_DURABILITY_MODE=inherit until the fleet upgrade is complete.
What each mode fsyncs
Write points on the object path and how each mode treats them:
| Write point | strict |
file-sync |
relaxed |
none |
legacy-off |
|---|---|---|---|---|---|
| Erasure shard files (fdatasync before the commit rename) | yes | yes | yes | no | no |
Multipart part payload (fdatasync before rename_part commit) |
yes | yes | yes | no | no |
| xl.meta contents (tmp write before the commit rename) | yes | yes | no | no | no |
| Inline objects (data embedded in xl.meta) | yes | yes | no | no | no |
| Recovery journals, witnesses, and rollback state | yes | yes | no | no | no |
| Ordinary commit and new ancestor directory entries | yes | no | no | no | no |
| System-critical writes (see pinning below) | yes | yes (pinned) | yes (pinned) | yes (pinned) | no |
Power-loss guarantees, honestly stated
strict (default). Every acknowledged write (PUT, UploadPart,
CompleteMultipartUpload, delete markers, metadata updates) is durable on the
individual drive before the 200 OK: payload bytes, xl.meta, rollback backups,
and the directory entries of the commit renames are all fsynced. A whole-node
(or whole-cluster) power failure does not lose acknowledged data. This is the
current mainline behavior, unchanged.
file-sync. Payload files and final xl.meta file contents are synchronized before acknowledgement, including inline object data, while ordinary commit rename and newly created ancestor directory entries are not individually fsynced. Recovery journals, multipart transaction witnesses, rollback state, and system-critical namespaces retain strict barriers. After sudden power loss, synchronized inode contents are protected, but a recently acknowledged fresh object name can disappear and an overwrite can revert to the previous namespace state. This matches MinIO's default object-path boundary more closely than relaxed, but it does not provide the complete per-drive acknowledgement guarantee of strict.
relaxed. Payload bytes of non-inline objects and multipart parts are
fdatasynced to the device before the acknowledgement, but the metadata
commits — xl.meta contents, rollback backups, and the directory entries of
the commit renames — are left to the page cache. Consequences on a power
failure:
- On the affected drive, a recently acknowledged version can be lost entirely — not merely "the directory entry rolls back". When neither the xl.meta bytes nor the rename's directory entry are synced, the commit itself can vanish; surviving shard bytes become unreferenced orphans on that drive.
- Inline (small) objects receive no per-object fsync at all in this mode: their data lives inside xl.meta, and xl.meta is not synced. This is weaker than MinIO's default object path, which synchronizes final xl.meta file contents while ordinarily omitting a per-object parent-directory fsync. Small objects therefore have the widest loss window under RustFS relaxed.
- Durability of acknowledged writes therefore rests on erasure-coded redundancy across other nodes plus the unclean-shutdown heal converging the affected drive afterwards.
Deployment rule for relaxed: only multi-node clusters whose nodes sit in
independent power domains (separate feeds/UPS). If all nodes can lose
power simultaneously, relaxed can lose recently acknowledged objects
cluster-wide. Single-node
deployments must stay on strict.
Small-object I/O profile
Small-object cost scales with object count, key depth, and the selected durability mode. Each inline object retains its own object directory and xl.meta, which contains both metadata and inline payload. Non-inline objects also have a data directory and shard files. Compression can reduce stored bytes while retaining this per-object namespace. The default single-drive inline admission budget is 128 KiB per shard. Versioned writes use a smaller budget. Explicit storage-class configuration, stream transformations, the single-erasure-block bound, and the erasure layout affect admission. See StorageClassConfig::should_inline in crates/ecstore/src/config/storageclass.rs and its PUT caller in crates/ecstore/src/set_disk/ops/object.rs.
The following application-level synchronization budget covers a successful ordinary Linux inline commit to a fresh key in an existing bucket. It assumes directory group commit is disabled and excludes multipart, healing, system metadata, retries, and background work. Let d be the number of prefix components before the final key component, so object has d = 0 and a/b/object has d = 2.
| Write shape | Metadata file synchronization | Directory synchronization |
|---|---|---|
Fresh inline key, strict |
One metadata sync_data, including inline payload |
One object-directory sync plus one per ancestor through the bucket, totaling d + 2 |
Fresh inline key, file-sync |
One metadata sync_data, including inline payload |
Zero ordinary commit-directory syncs |
Fresh inline key, relaxed or none |
Zero | Zero ordinary commit-directory syncs |
Linux stages ordinary inline metadata in a flat temporary file and publishes it by rename. The temporary name is removed by publication, so synchronizing that temporary directory entry would add work without protecting the acknowledged object. Strict mode synchronizes the final object directory and its ancestors. Even an existing shared prefix can have been created by another writer whose directory synchronization is still pending. Keeping the ancestor barriers protects that concurrent creation case. rename_data_fresh_inline_sync_budget tests exercise the real disk commit and pin the directory-call budget for flat and nested keys.
Overwrites and versioned writes can retain predecessor metadata for rollback and add backup, recovery, and cleanup work. Non-inline writes also synchronize shard contents under strict, file-sync, and relaxed. Their budgets depend on object shape and recovery state. A normal inline GET reads xl.meta. Non-inline GET also reads the required shard data and verifies integrity. Delete work depends on versioning, delete markers, retained versions, recovery state, and deferred trash cleanup. LIST, scanner, and heal perform additional directory and metadata reads, and repairs can perform writes. Measure each workload separately.
All metadata commit paths share the same recovery-aware object-directory policy. Publishing a persistent rollback directory requires synchronizing its entry in the object directory, including under file-sync and when replacing an inline object with an external-data object. The backup directory itself also remains synchronized. These barriers preserve the recovery source for a failed multi-drive publication.
A fresh inline file-sync commit can finish writing, synchronizing, and publishing metadata within its preparation task even when directory grouping is enabled. The sync-budget regression checks two disk-local queue submissions on Linux and one on macOS for that path. macOS also performs separate Tokio filesystem preparation. Persistent rollback publication and strict directory grouping retain their respective synchronization and scheduling requirements.
Application synchronization counts and device IOPS measure different layers. Filesystem journals, page-cache hits, writeback, request merging, and device behavior determine the physical operations and latency. For a reproducible profile, record the exact server revision, effective bucket durability mode, storage-class configuration, object-size distribution, key depth, versioning, concurrency, filesystem, and physical device mapping. Use an isolated test bucket with separate fresh-key PUT, overwrite, GET, and DELETE phases. Collect a background-only interval as well as each foreground interval, keeping scanner and heal state explicit. Pair application syscall traces with device telemetry over the same interval, then normalize counts by completed requests.
On Linux, an instrumented run can use strace -f -c -p <pid> -e trace=openat,openat2,close,newfstatat,fstat,statx,getdents64,mkdir,mkdirat,rmdir,rename,renameat,renameat2,unlink,unlinkat,read,pread64,write,pwrite64,fsync,fdatasync together with iostat -x 1. Tracing adds overhead and includes other server activity, so retain an untraced run for latency and throughput comparison. The scanner benchmark runbook covers background-pressure measurement.
Server-side packing of multiple S3 keys into shared containers requires a persistent index, atomic publication, per-key version/delete semantics, garbage collection, and heal/recovery support. These requirements also apply when compacting historical objects. Current inline storage keeps each object's directory and metadata entry independently addressable.
Destination-directory group commit metrics
The experimental destination-directory group commit path emits these metrics when RUSTFS_OBS_PUT_STAGE_METRICS_ENABLED and metrics export are enabled.
| Metric | Meaning |
|---|---|
rustfs_s3_put_object_rename_dst_dir_fsync_group_enqueue_total |
Waiters accepted into the group queue, or rejected at its active-group or waiter limit. The fixed outcome labels are accepted, group_limit, and waiter_limit. |
rustfs_s3_put_object_rename_dst_dir_fsync_group_batch_waiters |
Waiters drained per batch, split by kind=single or kind=multi. Histogram count is the number of drained batches and sum is the number of drained waiters. |
rustfs_s3_put_object_rename_dst_dir_fsync_group_queue_wait_ms |
Time from enqueue to drain, one sample per drained waiter. It excludes directory opening, the subsequent global permit wait, and the sync itself. |
rustfs_s3_put_object_rename_dst_dir_fsync_group_physical_sync_total |
Returned grouped directory sync_all() calls on Unix, labeled outcome=success or outcome=error. |
Batch and queue metrics describe the coordinator's work. Canceling a caller does not remove its waiter from the queue. A worker that shuts down before draining can discard queued waiters, while a drained batch can end before reaching the native sync. Use the physical counter for completed sync calls. These metrics cover the grouped destination-directory path, so comparisons with grouping disabled still require scoped syscall counts.
Recovery from corrupt object metadata
A zero-length or unreadable xl.meta is corruption, not an absent object.
RustFS reports it as a metadata error and keeps usage snapshots incomplete;
quota admission can fail closed until a complete snapshot is available. On a
multi-node deployment, attempt heal from healthy replicas and verify the
recovered versions before cleaning any drive. If no healthy metadata copy or
backup exists, the version index cannot be reconstructed from shard data
alone. Preserve the affected directory for recovery before any operator-led
cleanup. S3 DeleteObject is not a physical cleanup mechanism for corrupt
metadata. After a successful repair or cleanup, a complete scanner cycle
reconciles the failed-path cache; confirm the scanner reports a completed
cycle before relying on a newly published usage snapshot.
none. No fsync on the object data path at all; acknowledged objects can
vanish wholesale on power loss, payload included. System-critical writes are
still pinned (below). This is the tier equivalent of the old escape hatch,
useful for throwaway/benchmark data only.
legacy-off. The historical semantics of
RUSTFS_DRIVE_SYNC_ENABLE=false, preserved bit for bit for existing
deployments: nothing is fsynced anywhere, including system-critical
metadata such as format.json. Prefer RUSTFS_DURABILITY_MODE=none, which
keeps the system-critical writes safe.
System-critical pinning
Writes that commit into system namespaces are pinned to strict regardless
of the configured tier (except under legacy-off, see above):
.rustfs.sys—format.json, IAM and cluster configuration, bucket metadata, and everything else outside the scratch namespaces;.minio.sys— the same namespace during MinIO migration.
The scratch namespaces .rustfs.sys/tmp and .rustfs.sys/multipart stage
in-flight user object data and follow the configured tier — they are
exactly the writes the relaxed tiers exist for. Their durability is decided
by the destination volume at commit time, so an IAM or bucket-metadata object
staged in tmp still commits with full strict durability.
The durability mode is server-side configuration only; it cannot be raised or lowered by any request header.
Per-bucket durability
A bucket can override the process-wide mode with its own tier. The override
is stored in the bucket's metadata (a durability.json entry in
.rustfs.sys/buckets/<bucket>/.metadata.bin, written as a RustFS extension
field that MinIO's decoder skips) and resolved per write at the commit
points, so no restart is needed.
Configuration
# Set an override (admin credentials, ConfigUpdateAdminAction)
curl -X PUT "http://<host>/rustfs/admin/v3/bucket-durability/<bucket>" \
-d '{"mode":"file-sync"}' # strict | file-sync | relaxed | none
# Read it back ("mode": null means the bucket inherits the global mode)
curl "http://<host>/rustfs/admin/v3/bucket-durability/<bucket>"
# Clear it (the bucket inherits the global mode again)
curl -X DELETE "http://<host>/rustfs/admin/v3/bucket-durability/<bucket>"
mc integration is a follow-up; for now the admin API above is the
configuration plane.
New-bucket default
A newly created bucket inherits the process-wide mode by default. On an
otherwise unconfigured deployment this means strict. Operators can explicitly
set RUSTFS_NEW_BUCKET_DURABILITY_MODE=file-sync to seed a file-sync override into
new buckets, or choose strict, relaxed, none, or inherit. A non-strict override is
logged when the bucket is created; an explicitly non-strict process-wide mode
is warned at startup. Relaxed remains appropriate only for the multi-node,
independent-power-domain deployment described above.
- Pre-existing buckets are unaffected by this default change. Existing per-bucket overrides remain stored in metadata, and buckets without an override continue to follow the process-wide mode.
- Explicit global configuration still applies. If the process-wide mode is explicitly relaxed (or the legacy full-off mode is selected), an inherited new bucket follows that mode. Keep the process-wide mode strict on a single-node deployment.
- System-critical namespaces stay pinned to
strictregardless of any override (see System-critical pinning).
The seeded tier is controlled by an env var read once per bucket creation (bucket creation is not a hot path):
RUSTFS_NEW_BUCKET_DURABILITY_MODE=relaxed # explicitly seed `relaxed`
RUSTFS_NEW_BUCKET_DURABILITY_MODE=file-sync # explicitly seed `file-sync`
RUSTFS_NEW_BUCKET_DURABILITY_MODE=strict # seed `strict` instead
RUSTFS_NEW_BUCKET_DURABILITY_MODE=none # seed `none` instead
RUSTFS_NEW_BUCKET_DURABILITY_MODE=inherit # seed nothing: follow the global mode
inherit (the default) and any unrecognized value, which fails closed to
inherit, mean the new bucket gets no override and follows the process-wide
mode. The seed only applies at bucket creation; it never retroactively rewrites
existing buckets. To correct an existing bucket created with a relaxed
override, use the admin API above to set strict or delete the override to
inherit the process-wide mode. Stored overrides do not record whether relaxed
came from an earlier default or an explicit operator choice, so RustFS does not
rewrite them automatically. Read and correct each affected bucket through the
admin API; changing the env var alone is not a migration.
Resolution order
For a write committing into volume V:
- system-critical namespaces (
.rustfs.sys,.minio.sysoutside the scratch dirs) are alwaysstrict— a bucket override can never be attached to them, and any attempt is rejected and logged; - otherwise, if the destination bucket has an override, the override wins —
in both directions (a bucket can be
relaxedunder astrictglobal default, or pinnedstrictunder arelaxedglobal default); - otherwise the process-wide mode applies.
Under legacy-off (RUSTFS_DRIVE_SYNC_ENABLE=false) per-bucket overrides
do not apply at all: the legacy switch keeps its historical semantics bit
for bit. legacy-off is also not a valid per-bucket tier.
Because scratch-staged data commits under the destination volume, an object
staged in .rustfs.sys/tmp follows the override of the bucket it commits
into, exactly like the global tier.
Propagation and effect latency
The override rides the existing bucket-metadata cache, with no invalidation channel of its own:
- on the node that applies the config change, the new tier is effective for writes that resolve their durability after the update completes;
- other nodes are told to reload the bucket's metadata right away (the same peer notification used for every bucket config change); if a peer misses the notification, the periodic bucket-metadata refresh loop (15 minutes) converges it;
- an in-flight operation keeps the tier it resolved at its start — a single commit is never half-old-tier, half-new-tier;
- deleting the bucket drops the override with the rest of its metadata.
Until a peer has reloaded the metadata, its writes use the previous tier. This is the same eventual-consistency window every other bucket config (policy, quota, versioning) already has.
file-sync overrides use a backward-compatible fail-closed encoding: the stored JSON carries mode: strict plus a file_sync marker. Nodes that understand the marker apply file-sync; older nodes ignore the marker and apply the stronger strict mode. Roll back by setting the bucket to strict or clearing the override before downgrading if inheriting the process mode is intended.
Power-loss guarantees
Identical to the corresponding global tier, scoped to the bucket. In
particular the relaxed deployment rule (multi-node clusters in independent
power domains only) applies per bucket: overriding a bucket to relaxed on
a single-node deployment can lose recently acknowledged objects in that
bucket on power failure.
Performance expectations
Measure file-sync and relaxed independently on the target platform (Linux ext4/xfs) before relying on a number. Throughput deltas measured with sync fully off (none or legacy-off) do not transfer: file-sync keeps payload and metadata-file synchronization, while relaxed keeps payload synchronization. Do not use none numbers to size either tier.
Related Recovery Guides
- No-parity bitrot recovery explains how to
diagnose historical no-parity objects whose raw
part.Nfiles are present but fail bitrot validation.