Skip to content

fix: silent noop ftruncate, remove FOPEN_KEEP_CACHE, add --no-disk-cache#27

Merged
XciD merged 14 commits into
mainfrom
fix/sparse-ftruncate
Mar 9, 2026
Merged

fix: silent noop ftruncate, remove FOPEN_KEEP_CACHE, add --no-disk-cache#27
XciD merged 14 commits into
mainfrom
fix/sparse-ftruncate

Conversation

@XciD

@XciD XciD commented Mar 8, 2026

Copy link
Copy Markdown
Member

Summary

  • Silent noop ftruncate (simple mode): setattr(size) returns success without changing the inode, instead of returning EPERM. Real truncation goes through open(O_TRUNC).
  • Remove FOPEN_KEEP_CACHE: kernel now invalidates the page cache on each open(), ensuring fresh data from remote.
  • --no-disk-cache flag: disables xorb chunk cache so every read fetches from CAS. Useful for benchmarking.

Changes

  • setattr -- simple mode returns Ok instead of EPERM for size changes (noop, size unchanged)
  • fuse.rs -- FopenFlags::empty() instead of FOPEN_KEEP_CACHE
  • setup.rs -- new --no-disk-cache CLI flag, conditionally creates xorb cache
  • Tests updated: setattr_simple_mode_eperm renamed to setattr_simple_mode_noop, new setattr_simple_mode_empty_file_noop test
  • README.md -- added --no-disk-cache to options table

ftruncate(fd, N) on an empty/new file now sets size=N and marks the
inode as sparse instead of uploading N bytes of zeros to CAS. Reads on
sparse files return zeros directly. The sparse flag is cleared when the
file is opened for real writes (O_TRUNC).

This makes ftruncate instant (metadata-only) like ext4, instead of
triggering a full CAS upload cycle. Useful for any tool that
pre-allocates files via ftruncate before writing.
@github-actions

github-actions Bot commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results

============================================================
  Benchmark — 50MB
------------------------------------------------------------
  Metric                                 FUSE          NFS
  ------------------------------ ------------ ------------
  Sequential read                    198.3 MB/s     206.7 MB/s
  Sequential re-read                1110.6 MB/s    2512.0 MB/s
  Range read (1MB@25MB)                8.2 ms         0.2 ms
  Random reads (100x4KB avg)           7.9 ms         0.0 ms
  Sequential write (FUSE)           1195.0 MB/s
  Close latency (CAS+Hub)            0.233 s
  Write end-to-end                   182.0 MB/s
  Dedup write                       1191.1 MB/s
  Dedup close latency                0.076 s
  Dedup end-to-end                   422.5 MB/s
============================================================
============================================================
  Benchmark — 200MB
------------------------------------------------------------
  Metric                                 FUSE          NFS
  ------------------------------ ------------ ------------
  Sequential read                   1470.3 MB/s    1203.9 MB/s
  Sequential re-read                1684.6 MB/s    2417.4 MB/s
  Range read (1MB@25MB)                8.9 ms         0.2 ms
  Random reads (100x4KB avg)           8.4 ms         0.0 ms
  Sequential write (FUSE)           1411.7 MB/s
  Close latency (CAS+Hub)            0.090 s
  Write end-to-end                   862.0 MB/s
  Dedup write                       1379.1 MB/s
  Dedup close latency                0.098 s
  Dedup end-to-end                   824.1 MB/s
============================================================
============================================================
  Benchmark — 500MB
------------------------------------------------------------
  Metric                                 FUSE          NFS
  ------------------------------ ------------ ------------
  Sequential read                   1715.4 MB/s    1513.7 MB/s
  Sequential re-read                1733.0 MB/s    2519.4 MB/s
  Range read (1MB@25MB)                8.9 ms         0.2 ms
  Random reads (100x4KB avg)           8.5 ms         0.0 ms
  Sequential write (FUSE)           1106.8 MB/s
  Close latency (CAS+Hub)            0.106 s
  Write end-to-end                   896.3 MB/s
  Dedup write                       1220.4 MB/s
  Dedup close latency                0.115 s
  Dedup end-to-end                   953.1 MB/s
============================================================
============================================================
  fio Benchmark Results
------------------------------------------------------------
  Job                        FUSE MB/s   NFS MB/s  FUSE IOPS   NFS IOPS
  ------------------------- ---------- ---------- ---------- ----------
  seq-read-100M                  442.5      318.5                      
  seq-reread-100M               2040.8     1282.1                      
  rand-read-4k-100M                0.4        0.4        110        115
  seq-read-5x10M                 581.4      555.6                      
  rand-read-10x1M                181.5       62.9      46460      16101
  Random Read Latency           FUSE avg      NFS avg
  ------------------------- ------------ ------------
  rand-read-4k-100M            9054.6 us    8683.4 us
  rand-read-10x1M                20.8 us      61.2 us
============================================================

@github-actions

github-actions Bot commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

POSIX Compliance (pjdfstest)

============================================================
  pjdfstest POSIX Compliance Results
------------------------------------------------------------
  Files: 130/130 passed    Tests: 832 total (0 subtests failed)
  Result: PASS
------------------------------------------------------------
  Category               Passed    Total   Status
  -------------------- -------- -------- --------
  chflags                     5        5       OK
  chmod                       8        8       OK
  chown                       6        6       OK
  ftruncate                  13       13       OK
  granular                    5        5       OK
  mkdir                       9        9       OK
  open                       19       19       OK
  posix_fallocate             1        1       OK
  rename                     10       10       OK
  rmdir                      11       11       OK
  symlink                    10       10       OK
  truncate                   13       13       OK
  unlink                     11       11       OK
  utimensat                   9        9       OK
============================================================

XciD added 13 commits March 9, 2026 07:46
Allows benchmarking without the on-disk xorb cache, comparable to
mountpoint-s3 without --cache. Reads go directly to CAS on each FUSE
miss (OS page cache still applies).

The FileDownloadSession API already supported None for chunk_cache;
this wires it up via a CLI flag and a HF_NO_DISK_CACHE=1 env var
in the benchmark scripts.
Drop FOPEN_KEEP_CACHE from FUSE open() reply, matching mountpoint-s3's
approach. Without this flag, the kernel invalidates the page cache on
each open(), ensuring reads fetch fresh data from the remote.

Previously, FOPEN_KEEP_CACHE preserved stale page cache across re-opens,
which both masked data staleness issues and inflated benchmark numbers
(reads served from DRAM instead of CAS).
The sparse pre-allocation feature added significant complexity (sparse
field, 6 code paths, rollback logic) for a single use case (fio
--create_only) that we no longer need since read benchmarks now write
real data first.

Simple mode now silently ignores setattr(size) like mountpoint-s3 does.
Advanced-writes mode keeps its existing staging file resize behavior.
@XciD XciD changed the title fix: sparse ftruncate on empty files (no CAS upload) fix: silent noop ftruncate, remove FOPEN_KEEP_CACHE, add --no-disk-cache Mar 9, 2026
@XciD XciD marked this pull request as ready for review March 9, 2026 10:05
@XciD XciD merged commit 1670320 into main Mar 9, 2026
4 checks passed
@XciD XciD deleted the fix/sparse-ftruncate branch March 23, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant