You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2026/10/26 08:37:09 UTC
(opendal-yinyang) branch xuanwo/linux-fuse-writable updated: fix(fuse): preserve handle state across executable updates
This is an automated email from the ASF dual-hosted git repository.
Xuanwo pushed a commit to branch xuanwo/linux-fuse-writable
in repository https://gitbox.apache.org/repos/asf/opendal-yinyang.git
The following commit(s) were added to refs/heads/xuanwo/linux-fuse-writable by this push:
new 4a5a42c fix(fuse): preserve handle state across executable updates
4a5a42c is described below
commit 4a5a42c2bfd96ed41d02e6404fc973b9e0c5cbc0
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Mon Oct 26 16:37:03 2026 +0800
fix(fuse): preserve handle state across executable updates
Require write access on MountFile::set_executable, remove the unused Runtime convenience, and make open-gate tests deterministic without polling assumptions. Document writable flush/fsync, path truncation, synthesized modes, and the kernel-local-only locking boundary.
Co-authored-by: Chojan Shang <ps...@apache.org>
---
specs/linux-fuse.md | 91 +++++++++++++++++++++++++++++++++++++----------------
src/mount.rs | 1 +
src/runtime.rs | 9 ------
tests/mount.rs | 27 ++++++++++++----
tests/runtime.rs | 13 --------
5 files changed, 86 insertions(+), 55 deletions(-)
diff --git a/specs/linux-fuse.md b/specs/linux-fuse.md
index af53674..c8b5d17 100644
--- a/specs/linux-fuse.md
+++ b/specs/linux-fuse.md
@@ -1,6 +1,6 @@
-# Read-only Linux FUSE frontend
+# Linux FUSE frontend
-**Status: experimental read-only Managed mount; protocol transport is the
+**Status: experimental Managed mount; protocol transport is the
`fuser` 0.17 binding, not a YinYang FUSE implementation.**
The Linux frontend mounts one Managed volume through the kernel FUSE ABI with
@@ -11,34 +11,35 @@ the Linux path.
## Startup and admission
-The volume configuration must declare `model = "managed"`, `access = "mount"`,
-`frontend = "fuse"` and `read_only = true`. The shared admission rules in
-[`volume-capabilities.md`](volume-capabilities.md) reject every other
-combination before an authority connection or staging lease exists, and reject
-the FUSE frontend entirely on non-Linux targets. Object and service publication
-authorities are both accepted through `Volume::connect`.
+The volume configuration must declare `model = "managed"`, `access = "mount"`
+and `frontend = "fuse"`. Both read-only and writable mounts use the shared
+admission rules in [`volume-capabilities.md`](volume-capabilities.md); the
+frontend is rejected entirely on non-Linux targets. Object and service
+publication authorities are both accepted through `Volume::connect`.
Startup order:
1. validate the configuration and the storage capability intersection;
2. connect the object or service authority;
-3. open the shared [`Mount`](mount-runtime.md) read-only (acquires the staging
- lease and runs the existing recovery);
-4. inspect the recovered runtime status and refuse the mount if any handle is
- pending, frozen, conflicted or failed;
+3. open the shared [`Mount`](mount-runtime.md) using the configured write
+ policy (acquires the staging lease and runs the existing recovery);
+4. for a read-only mount, inspect the recovered runtime status and refuse the
+ mount if any handle is pending, frozen, conflicted or failed;
5. observe the latest remote snapshot and verify the root is a directory;
6. handshake with the kernel as `fuse.yinyang` and serve requests.
Step 4 is the read-only dirty-data boundary. Recovered clean observations are
disposable and reclaimed by existing Mount recovery, while unpublished staged
bytes are never exposed as a remote snapshot: the mount fails with a
-diagnostic naming the handle instead. The lease is already held during the
-inspection, so another client cannot interleave. Refusing startup changes no
-remote state.
+diagnostic naming the handle instead. A writable mount instead serves recovered
+pending/frozen/error state through the shared Mount handles, so a later flush or
+fsync reports the real remote outcome. The lease is already held during the
+inspection, so another client cannot interleave. Refusing a read-only startup
+changes no remote state.
-The mount is owner-only (`SessionACL::Owner`) and advertised as `ro` with
-`fsname=yinyang-<name>` and `subtype=yinyang`, so the kernel reports
-`fuse.yinyang` as the filesystem type.
+The mount is owner-only (`SessionACL::Owner`) with `fsname=yinyang-<name>` and
+`subtype=yinyang`, so the kernel reports `fuse.yinyang` as the filesystem type.
+Only the read-only policy adds the kernel `ro` option.
## Identity and lookup references
@@ -64,15 +65,16 @@ reply per request and replaces a dropped unanswered reply with `EIO`.
`lookup` and non-handle `getattr` observe the latest snapshot for metadata and
use that same snapshot's revision for timestamps, so a reply never mixes
-metadata from two observations. Attributes are synthesized: directories
-`0555`, files `0444` (readable plus the core executable bit), the mounting
-user's uid/gid, size from the content descriptor or a fixed directory size,
-and timestamps encoding the revision sequence rather than wall-clock time.
-`getxattr`, `listxattr`, `readlink` and options outside the read-only contract
-return explicit errors; mutations return `EROFS`.
-
-`open` requires a read-only access mode, rejects cached directories with
-`EISDIR`, and takes one reference on the node's shared staged version through
+metadata from two observations. Attributes are synthesized: read-only
+directories are `0555` and files are `0444`; writable directories are `0755`
+and files are `0644` or `0755` according to the core executable bit. The
+mounting user's uid/gid, size from the content descriptor or a fixed directory
+size, and revision-derived timestamps are synthesized. `getxattr`,
+`listxattr`, `readlink`, links and special nodes return explicit unsupported
+errors.
+
+`open` validates the access mode, rejects cached directories with `EISDIR`, and
+takes one reference on the node's shared staged version through
`Mount::open_node`. The reply opens with `FOPEN_DIRECT_IO`, so the kernel does
not cache file pages. Reads stream from the staged version. `getattr` with an
open handle reports the staged record's length, so `fstat` and read bytes
@@ -88,6 +90,41 @@ that open's metadata and content never disagree. The frontend does not call
a writable layer that in-place refreshes must first define its open-fd and
kernel-cache invalidation policy.
+## Writable callbacks
+
+`write` stages bytes in the shared per-NodeId Mount handle. A handle opened with
+`O_APPEND` uses the node's append path, which chooses its offset under the same
+per-node lock as other writes; a regular write uses the kernel offset.
+`O_TRUNC` stages a zero length before the open reply. `O_SYNC`/`O_DSYNC` writes
+attempt publication before acknowledging the write. Unsupported write flags
+return an explicit error instead of silently changing semantics.
+
+`flush` publishes a writable handle and reports the real remote outcome to the
+closing descriptor. `release` never publishes and never discards staging.
+Flush or fsync on a read-only reference is a successful no-op even when another
+writable reference shares the node, so a reader close cannot publish somebody
+else's dirty bytes. A failed publication remains attached to the shared handle
+and volume ledger; later fsync/flush retries the original frozen request.
+
+`create` and `mkdir` use the Runtime helpers that return the NodeId produced by
+the committing Planner, avoiding a post-commit path lookup. `unlink`, `rmdir`,
+and path renames use the path-addressed Runtime methods, so lookup and commit
+share one guarded Snapshot. Plain `rename` replaces an existing destination;
+`RENAME_NOREPLACE` uses the no-replace form. Exchange and whiteout renames are
+explicitly unsupported.
+
+`setattr` supports size and the core executable flag only. Size on an open
+descriptor is staged for that descriptor's later flush/fsync; path truncation
+publishes before returning success. A mode request is accepted only when it is
+one of the synthesized modes above (`0444`/`0555` or `0644`/`0755` according to
+read-only policy and the executable bit); other permission combinations return
+`EOPNOTSUPP`. Before changing the executable flag, the shared node lock
+publishes dirty content, commits a Planner based on the handle's recorded
+content revision, and advances only that clean handle to the receipt revision.
+An external content change therefore produces Conflict rather than rebasing
+old staged bytes onto new content. Ownership, timestamps and other mode bits
+are not persisted.
+
## Pinned directory cursors
`opendir` pins one `Snapshot` revision and one directory identity. `readdir`
diff --git a/src/mount.rs b/src/mount.rs
index 5e9c4ba..464067b 100644
--- a/src/mount.rs
+++ b/src/mount.rs
@@ -327,6 +327,7 @@ impl MountFile {
/// Publish this node's dirty content first, then update the executable
/// flag and advance the shared clean handle to the metadata revision.
pub async fn set_executable(&self, executable: bool) -> Result<Receipt> {
+ self.require_write()?;
self.node
.handle
.lock()
diff --git a/src/runtime.rs b/src/runtime.rs
index af75bb3..f02f2d8 100644
--- a/src/runtime.rs
+++ b/src/runtime.rs
@@ -281,15 +281,6 @@ impl Runtime {
let receipt = outcome(self.authority().commit(&plan.finish()?).await?)?;
Ok((node, receipt))
}
- /// Persist the core executable flag. Permission bits other than executable
- /// state, ownership and timestamps have no durable core representation.
- pub async fn set_executable(&self, node: NodeId, executable: bool) -> Result<Receipt> {
- self.require_write()?;
- let snapshot = self.authority().observe_latest().await?;
- let mut plan = Planner::new(&snapshot, CommitId::generate());
- plan.set_executable(node, executable).await?;
- outcome(self.authority().commit(&plan.finish()?).await?)
- }
pub async fn rename(&self, node: NodeId, parent: NodeId, name: &str) -> Result<Receipt> {
self.require_write()?;
let snapshot = self.authority().observe_latest().await?;
diff --git a/tests/mount.rs b/tests/mount.rs
index f3d77cb..0ce8011 100644
--- a/tests/mount.rs
+++ b/tests/mount.rs
@@ -109,12 +109,22 @@ impl Authority for PausingObserveAuthority {
requests: &'a [Transaction],
) -> Pin<Box<dyn Future<Output = yinyang::core::Result<Vec<CommitOutcome>>> + Send + 'a>> {
Box::pin(async move {
- let pause = self
- .pause_after_commits
- .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |remaining| {
- remaining.checked_sub(1)
- })
- .ok();
+ let mut remaining = self.pause_after_commits.load(Ordering::SeqCst);
+ let mut pause = None;
+ while remaining > 0 {
+ match self.pause_after_commits.compare_exchange_weak(
+ remaining,
+ remaining - 1,
+ Ordering::SeqCst,
+ Ordering::SeqCst,
+ ) {
+ Ok(previous) => {
+ pause = Some(previous);
+ break;
+ }
+ Err(actual) => remaining = actual,
+ }
+ }
if pause == Some(1) {
self.commit_entered.add_permits(1);
self.commit_release.acquire().await.unwrap().forget();
@@ -404,6 +414,11 @@ async fn set_executable_serializes_with_dirty_mount_handle() {
.unwrap(),
b"dirtymore"
);
+ let read_only = mount.open_node(node, false).await.unwrap();
+ assert_eq!(
+ read_only.set_executable(false).await.unwrap_err().kind(),
+ ErrorKind::ReadOnly
+ );
let (retry, _) = mount
.namespace()
diff --git a/tests/runtime.rs b/tests/runtime.rs
index 5306074..76f2778 100644
--- a/tests/runtime.rs
+++ b/tests/runtime.rs
@@ -781,19 +781,6 @@ async fn create_results_keep_the_committed_node_identity() {
.node_id,
child
);
-
- runtime.set_executable(first, false).await.unwrap();
- assert!(
- !authority
- .observe_latest()
- .await
- .unwrap()
- .node(first)
- .await
- .unwrap()
- .unwrap()
- .executable()
- );
}
#[tokio::test]