Skip to content

Conversation

@Nikratio
Copy link
Contributor

@Nikratio Nikratio commented Jan 4, 2026

What's happening here is the following:

  • If the FUSE (kernel-level) writeback cache is enabled, the filesystem daemon cannot be trusted by the kernel to produce accurate mtime and ctime values, because there may be pending writes in the cache that have not been flushed to the daemon.
  • Therefore, the kernel still calls the getattr() handler, but ignores the mtime and ctime values, and instead maintains them internally.
  • When a file is closed, the kernel communicates the correct mtime and ctime values to the filesystem daemon through an extra setattr() call.
  • Therefore, the (correct) mtime value that a userspace program gets from the kernel for the FUSE filesystem will not agree with the (also correct) mtime value reported by the underlying filesystem as long as the file is open.
  • Once the file has been closed, the mtime values agree, but the filesystem daemon has updated this with an utimens() call which has resulted in ctime change, so now the ctime values do not agree.

To fix this, make the writeback cache configurable and only check mtimes if writeback caching is disabled.

Fixes: #57.

…ences.

What's happening here is the following:

- If the FUSE (kernel-level) writeback cache is enabled, the filesystem
  daemon cannot be trusted by the kernel to produce accurate mtime and
  ctime values, because there may be pending writes in the cache that
  have not been flushed to the daemon.
- Therefore, the kernel still calls the getattr() handler, but ignores
  the mtime and ctime values, and instead maintains them internally.
- When a file is closed, the kernel communicates the correct mtime and
  ctime values to the filesystem daemon through an extra setattr() call.
- Therefore, the (correct) mtime value that a userspace program gets
  from the kernel for the FUSE filesystem will not agree with the (also
  correct) mtime value reported by the underlying filesystem as long as
  the file is open.
- Once the file has been closed, the mtime values agree, but the
  filesystem daemon has updated this with an utimens() call which has
  resulted in ctime change, so now the ctime values do not agree.

To fix this, make the writeback cache configurable and only check mtimes
if writeback caching is disabled.

Fixes: #57.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes test failures in test_passthroughfs() caused by mtime/ctime mismatches when FUSE writeback cache is enabled. The kernel maintains its own mtime/ctime values when writeback cache is active, leading to discrepancies with the underlying filesystem until files are closed.

Key Changes:

  • Made writeback cache configurable via a new command-line flag --enable-writeback-cache
  • Modified tests to run with both writeback cache enabled and disabled
  • Updated time comparison logic to skip mtime/ctime checks when writeback cache is enabled

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
examples/passthroughfs.py Made enable_writeback_cache configurable through constructor parameter and CLI flag instead of hardcoded class attribute
test/test_examples.py Parametrized test_passthroughfs to test both cache modes, and conditionally skip time checks when writeback cache is enabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Nikratio and others added 2 commits January 4, 2026 18:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Nikratio Nikratio merged commit 5326a68 into main Jan 4, 2026
5 checks passed
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.

test_passthroughfs sometimes fails due to timestamp difference

2 participants