FILESYSTEM IN USERSPACE (FUSE) development
 help / color / mirror / Atom feed
From: Joanne Koong <joannelkoong@gmail.com>
To: miklos@szeredi.hu
Cc: amir73il@gmail.com, fuse-devel@lists.linux.dev, luis@igalia.com
Subject: [PATCH v1 17/17] docs: fuse: document extended passthrough (FUSE_PASSTHROUGH_INO)
Date: Mon, 20 Apr 2026 15:16:37 -0700	[thread overview]
Message-ID: <20260420221637.2631478-18-joannelkoong@gmail.com> (raw)
In-Reply-To: <20260420221637.2631478-1-joannelkoong@gmail.com>

Add section about extended passthrough (FUSE_PASSTHROUGH_INO) mode.

Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
 .../filesystems/fuse/fuse-passthrough.rst     | 131 ++++++++++++++++++
 1 file changed, 131 insertions(+)

diff --git a/Documentation/filesystems/fuse/fuse-passthrough.rst b/Documentation/filesystems/fuse/fuse-passthrough.rst
index 2b0e7c2da54a..c7ccea597324 100644
--- a/Documentation/filesystems/fuse/fuse-passthrough.rst
+++ b/Documentation/filesystems/fuse/fuse-passthrough.rst
@@ -25,6 +25,12 @@ operations.
 Currently, passthrough is supported for operations like ``read(2)``/``write(2)``
 (via ``read_iter``/``write_iter``), ``splice(2)``, and ``mmap(2)``.
 
+With the extended ``FUSE_PASSTHROUGH_INO`` mode, passthrough is also supported
+for inode operations (getattr, setattr), directory operations (readdir), and
+kernel-initiated open (bypassing ``FUSE_OPEN``). In this mode, a backing file
+can be attached to a fuse inode for its entire lifetime, not just while a file
+is open.
+
 Enabling Passthrough
 ====================
 
@@ -46,6 +52,131 @@ To use FUSE passthrough:
      the ``backing_id`` to release the kernel's reference to the backing file
      when it's no longer needed for passthrough setups.
 
+Extended Passthrough (FUSE_PASSTHROUGH_INO)
+============================================
+
+``FUSE_PASSTHROUGH_INO`` is a stricter variant of ``FUSE_PASSTHROUGH`` in
+which the backing file inode number must match the fuse inode number, enforcing
+a one-to-one mapping. The kernel offers this flag during ``FUSE_INIT`` if
+``CONFIG_FUSE_PASSTHROUGH`` is enabled and the architecture has 64-bit
+``ino_t``. The server accepts by returning it back in the init reply.
+
+Enabling Extended Passthrough
+-----------------------------
+
+To use extended passthrough:
+
+  1. Follow steps 1-2 from `Enabling Passthrough`_ above. The server must
+     also negotiate the ``FUSE_PASSTHROUGH_INO`` capability during
+     ``FUSE_INIT``.
+  2. When registering a backing file via ``FUSE_DEV_IOC_BACKING_OPEN``, set
+     the ``ops_mask`` field in ``struct fuse_backing_map`` to declare which
+     operations should be passed through. At minimum,
+     ``FUSE_PASSTHROUGH_OP_GETATTR`` must be set for any inode-level
+     passthrough.
+  3. When handling a ``LOOKUP``, ``CREATE``, ``MKNOD``, ``MKDIR``,
+     ``SYMLINK``, or ``LINK`` request, the server responds with a
+     ``fuse_entry2_out`` (instead of ``fuse_entry_out``). To enable
+     passthrough on the inode, set ``backing_id`` to the id returned by
+     ``FUSE_DEV_IOC_BACKING_OPEN``. Set ``backing_id`` to 0 for inodes
+     that should not use passthrough. The ``nodeid`` in the response must
+     be the backing file's inode number (``i_ino``). If they don't match,
+     the kernel rejects the passthrough setup with ``-EIO``.
+  4. For passthrough open (``FUSE_PASSTHROUGH_OP_OPEN`` in ``ops_mask``),
+     no further action is needed. The kernel will open the backing file
+     directly without sending ``FUSE_OPEN`` / ``FUSE_OPENDIR`` to the
+     server. ``FUSE_RELEASE`` / ``FUSE_RELEASEDIR`` is also skipped.
+  5. For server-initiated passthrough open (without
+     ``FUSE_PASSTHROUGH_OP_OPEN``), the server handles ``FUSE_OPEN`` /
+     ``FUSE_OPENDIR`` as before and returns ``FOPEN_PASSTHROUGH`` with the
+     ``backing_id`` in the open response. A ``backing_id`` is required even
+     if the inode already has passthrough set up from lookup. The server
+     must use the same ``backing_id``. If the inode has passthrough,
+     the server must set ``FOPEN_PASSTHROUGH`` or ``FOPEN_DIRECT_IO``
+     on open as cached I/O mode is not allowed on passthrough inodes.
+  6. The server should call ``FUSE_DEV_IOC_BACKING_CLOSE`` to release the
+     backing file when it is no longer needed.
+
+Passthrough Operations Mask
+---------------------------
+
+When registering a backing file via ``FUSE_DEV_IOC_BACKING_OPEN``, the server
+sets ``ops_mask`` in ``struct fuse_backing_map`` to declare which operations
+should be passed through::
+
+    FUSE_PASSTHROUGH_OP_READ
+    FUSE_PASSTHROUGH_OP_WRITE
+    FUSE_PASSTHROUGH_OP_READDIR
+    FUSE_PASSTHROUGH_OP_GETATTR
+    FUSE_PASSTHROUGH_OP_SETATTR
+    FUSE_PASSTHROUGH_OP_OPEN
+
+Operations fall into three categories:
+
+**File operations** (read, write, readdir): Activated per-open when the
+server returns ``FOPEN_PASSTHROUGH`` in its open response. The backing file
+reference exists only while the file is open.
+
+**Inode operations** (getattr, setattr): Activated on lookup when the server
+returns a ``backing_id`` in the ``fuse_entry2_out`` response. The backing
+file reference persists for the lifetime of the fuse inode. Getattr is the
+minimum required inode operation.
+
+**Open passthrough**: The kernel opens the backing file directly without
+sending ``FUSE_OPEN`` / ``FUSE_OPENDIR`` to the server. ``FUSE_RELEASE`` /
+``FUSE_RELEASEDIR`` is also skipped. For regular files this implies passthrough
+read/write; for directories it implies passthrough readdir.
+
+Extended Entry Reply
+--------------------
+
+When ``FUSE_PASSTHROUGH_INO`` is negotiated, the kernel uses
+``fuse_entry2_out`` instead of ``fuse_entry_out`` for entry responses.
+This struct carries a ``backing_id`` and ``fuse_statx`` attributes instead
+of ``fuse_attr``.
+
+When ``backing_id > 0``, the kernel associates the inode with the backing file
+for passthrough inode operations. Statx attributes are not cached because
+passthrough getattr fetches them directly from the backing inode.
+
+When ``backing_id == 0`` (no passthrough), the statx attributes from the reply
+are cached normally.
+
+A negative ``backing_id`` is treated as an error. The kernel sends
+``FUSE_FORGET`` for the returned nodeid and fails the operation.
+
+IO Mode State Machine
+---------------------
+
+The ``iocachectr`` field in ``struct fuse_inode`` prevents conflicting access
+modes on the same inode (page-cache I/O and passthrough I/O cannot coexist)::
+
+    iocachectr > 0    Cached mode. N files using page cache.
+    iocachectr == 0   Idle. No files open, no passthrough.
+    iocachectr < 0    Uncached/passthrough mode. |N| references held.
+
+Each open file in passthrough mode holds one reference (``iocachectr--``).
+The inode-level passthrough setup holds one additional long-lived reference
+if the backing has inode ops (getattr/setattr). This long-lived reference is
+released on inode eviction.
+
+Cached mode and passthrough mode are mutually exclusive. Attempting either
+while the other is active returns ``-ETXTBSY``.
+
+For directories, the same mechanism arbitrates between cached readdir
+(``FOPEN_CACHE_DIR``) and passthrough readdir. A directory opened without
+``FOPEN_CACHE_DIR`` and without ``FOPEN_PASSTHROUGH`` is treated as direct I/O
+and does not affect io mode.
+
+Things to note
+--------------
+
+- ``FUSE_PASSTHROUGH_INO`` requires 64-bit ``ino_t``.
+- Readdirplus does not set up inode passthrough. Inodes created via readdirplus
+  use normal FUSE operations until a fresh lookup occurs.
+- An inode's backing association is set once and cannot be changed.
+- Passthrough and cached I/O cannot coexist on the same inode.
+
 Privilege Requirements
 ======================
 
-- 
2.52.0


  parent reply	other threads:[~2026-04-20 22:19 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 22:16 [PATCH v1 00/17] fuse: extend passthrough to inode operations Joanne Koong
2026-04-20 22:16 ` [PATCH v1 01/17] fuse: introduce FUSE_PASSTHROUGH_INO mode Joanne Koong
2026-04-21 21:11   ` Darrick J. Wong
2026-04-21 23:38     ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 02/17] fuse: prepare for passthrough of inode operations Joanne Koong
2026-04-21 21:16   ` Darrick J. Wong
2026-04-22  1:12     ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 03/17] fuse: prepare for readdir passthrough on directories Joanne Koong
2026-04-21 21:17   ` Darrick J. Wong
2026-04-21 23:12     ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 04/17] fuse: implement passthrough for readdir Joanne Koong
2026-04-20 22:16 ` [PATCH v1 05/17] fuse: prepare for long lived reference on backing file Joanne Koong
2026-04-20 22:16 ` [PATCH v1 06/17] fuse: implement passthrough for getattr/statx Joanne Koong
2026-04-20 22:16 ` [PATCH v1 07/17] fuse: prepare to setup backing inode passthrough on lookup Joanne Koong
2026-04-20 22:16 ` [PATCH v1 08/17] fuse: add passthrough ops gating Joanne Koong
2026-04-21 10:48   ` Amir Goldstein
2026-04-22  2:57     ` Joanne Koong
2026-04-22  7:27       ` Amir Goldstein
2026-04-23  1:47         ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 09/17] fuse: prepare to cache statx attributes from entry replies Joanne Koong
2026-04-21 12:26   ` Amir Goldstein
2026-04-20 22:16 ` [PATCH v1 10/17] fuse: add struct fuse_entry2_out and helpers for extended " Joanne Koong
2026-04-21 12:25   ` Amir Goldstein
2026-04-22  0:50     ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 11/17] fuse: add passthrough lookup Joanne Koong
2026-04-21 13:23   ` Amir Goldstein
2026-04-22  3:17     ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 12/17] fuse: add passthrough support for entry creation Joanne Koong
2026-04-21 14:08   ` Amir Goldstein
2026-04-22  3:01     ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 13/17] fuse: add passthrough support for atomic file creation Joanne Koong
2026-04-21 19:51   ` Amir Goldstein
2026-04-22  0:40     ` Joanne Koong
2026-04-22  5:10       ` Amir Goldstein
2026-04-20 22:16 ` [PATCH v1 14/17] fuse: use passthrough getattr in setattr suid/sgid handling Joanne Koong
2026-04-21 14:25   ` Amir Goldstein
2026-04-22  3:48     ` Joanne Koong
2026-04-22  5:22       ` Amir Goldstein
2026-04-23  0:03         ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 15/17] fuse: add passthrough setattr Joanne Koong
2026-04-21 14:20   ` Amir Goldstein
2026-04-21 14:32     ` Amir Goldstein
2026-04-22  1:09       ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 16/17] fuse: add passthrough open Joanne Koong
2026-04-21 20:20   ` Amir Goldstein
2026-04-22  4:19     ` Joanne Koong
2026-04-22  4:23       ` Joanne Koong
2026-04-22  6:51         ` Amir Goldstein
2026-04-20 22:16 ` Joanne Koong [this message]
2026-04-21 11:09   ` [PATCH v1 17/17] docs: fuse: document extended passthrough (FUSE_PASSTHROUGH_INO) Amir Goldstein
2026-04-22  1:04     ` Joanne Koong
2026-04-21  9:37 ` [PATCH v1 00/17] fuse: extend passthrough to inode operations Amir Goldstein
2026-04-21 13:55   ` Amir Goldstein
2026-04-21 21:05     ` Joanne Koong
2026-04-22  6:02       ` Amir Goldstein
2026-04-23  1:02         ` Joanne Koong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260420221637.2631478-18-joannelkoong@gmail.com \
    --to=joannelkoong@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=luis@igalia.com \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox