All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9 0/3] fuse: atomic open
@ 2026-11-21  0:16 Jimmy Zuber
  2026-11-21  0:16 ` [PATCH v9 1/3] fuse: move fuse_statx_to_attr() up Jimmy Zuber
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jimmy Zuber @ 2026-11-21  0:16 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: fuse-devel, linux-kselftest, Shuah Khan, Bernd Schubert,
	Jim Harris, Horst Birthelmer, Luis Henriques, NeilBrown,
	Joanne Koong

Add FUSE_OPEN_ATOMIC, a request that combines FUSE_LOOKUP with FUSE_OPEN
or FUSE_CREATE. With this series, the kernel sends it from
->atomic_open(), so that an open() of a name that is not in the dcache
needs one request instead of two:

  open() of a name not in the dcache    today           with this series
  existing file                         LOOKUP + OPEN   OPEN_ATOMIC
  O_CREAT, new file                     LOOKUP + CREATE OPEN_ATOMIC
  O_CREAT, existing file                LOOKUP + OPEN   OPEN_ATOMIC
  missing name                          LOOKUP          OPEN_ATOMIC

The server must handle FUSE_OPEN_ATOMIC as one conditional operation:
open the name or return only its entry if it is a regular file, create
and open it for O_CREAT if it is missing, return only the entry for any
other file type, and report whether it created the file. The open
depends on the nodeid that the lookup finds, and the choice between
opening, creating and returning the entry depends on what the server
finds, so both steps need to run on the server in one request, as in
openat(2) (see also [6] on combined requests). Returning -ENOSYS
triggers fallback to the old behavior.

The series gives the request and reply their own structs, as suggested
by Bernd Schubert [5]. The request carries per-request flags
(atomic_flags). A server must ignore atomic_flags bits that it does not
implement and must return the bits it honored in the reply, so that
later variants of the request would need no FUSE_INIT flag. The series
defines the reply with a fixed size, explicit OPENED and CREATED flags,
and the attributes as struct fuse_statx, so that later variants could
return attributes that struct fuse_attr lacks.

With this series, if the server opens an existing file, the VFS checks
permissions only after the reply, as it does on other filesystems with
->atomic_open(). The kernel then sends FUSE_RELEASE for a file that the
server opened and that open() does not return, as it does for
FUSE_CREATE. The kernel clears O_TRUNC in the request and truncates with
FUSE_SETATTR after the permission check.

Not supported by this series, and unchanged:
- names that are already in the dcache (FUSE_OPEN);
- O_DIRECTORY, O_EXCL without O_CREAT, and O_TRUNC on a server with
  FUSE_ATOMIC_O_TRUNC (FUSE_LOOKUP, then FUSE_OPEN).

Earlier series also proposed one request for lookup and open in FUSE
[1][2], and one for open and getattr [3][4].

I used Claude Code and Sashiko to help write and review the code.
I reviewed and tested every change. Tested with a new selftest under
UML.

Changes in v9 (from Bernd Schubert's review of v8 [5]):
- Replace fuse_create_in and fuse_entry_out with fuse_open_atomic_in and
  fuse_open_atomic_out: per-request atomic_flags, fuse_statx attributes,
  and OPENED and CREATED reply flags. FOPEN_CREATED becomes
  FUSE_OPEN_ATOMIC_CREATED.
- Require the full reply size.
- A server must ignore atomic_flags bits that it does not implement and
  must report the bits it honored in the reply.
- Move the ->atomic_open() condition into fuse_use_open_atomic().
- Move fuse_statx_to_attr() up, in its own patch.
- Reject FUSE_OPEN_ATOMIC_CREATED without O_CREAT, and an opened
  existing file for O_EXCL.
- Drop cached pages on open as FUSE_CREATE does, and open an existing
  DAX file in ->open().

Changes in v2-v8: see the earlier versions below.

On truncation in the request without default_permissions (Bernd's
question): the VFS can still refuse the open after the reply, for
example with -EROFS on a read-only bind mount, for an append-only file,
or from an LSM, so this series clears O_TRUNC in the request and
truncates after the checks.

v8: https://lore.kernel.org/fuse-devel/20261110204421.1251726-1-jamz@amazon.com/
v7: https://lore.kernel.org/fuse-devel/20261110155219.2175318-1-jamz@amazon.com/
v6: https://lore.kernel.org/fuse-devel/20261029130758.818617-1-jamz@amazon.com/
v5: https://lore.kernel.org/fuse-devel/20261028200459.2922951-1-jamz@amazon.com/
v4: https://lore.kernel.org/fuse-devel/20261026221639.628325-1-jamz@amazon.com/
v3: https://lore.kernel.org/fuse-devel/20261026190747.2373775-1-jamz@amazon.com/
v2: https://lore.kernel.org/fuse-devel/20261026151828.562870-1-jamz@amazon.com/
v1: https://lore.kernel.org/fuse-devel/20261020141647.3271341-1-jamz@amazon.com/

[1] Dharmendra Singh, "FUSE: Implement atomic lookup + open/create"
    https://lore.kernel.org/all/20220517100744.26849-1-dharamhans87@gmail.com/
[2] Bernd Schubert, "fuse: full atomic open and atomic-open-revalidate"
    https://lore.kernel.org/all/20231023183035.11035-1-bschubert@ddn.com/
[3] Joanne Koong, "fuse: add FOPEN_FETCH_ATTR flag for fetching
    attributes after open"
    https://lore.kernel.org/all/20240813212149.1909627-1-joannelkoong@gmail.com/
[4] Bernd Schubert, "fuse: Add open-gettr for fuse-file-open"
    https://lore.kernel.org/all/20240820211735.2098951-1-bschubert@ddn.com/
[5] https://lore.kernel.org/fuse-devel/fa582b7f-23ba-449d-b311-20f6ac8e867c@bsbernd.com/
[6] Miklos Szeredi, on combined requests and compounds
    https://lore.kernel.org/all/CAJfpegshcrjXJ0USZ8RRdBy=e0MxmBTJSCE0xnxG8LXgXy-xuQ@mail.gmail.com/

Jimmy Zuber (3):
  fuse: move fuse_statx_to_attr() up
  fuse: add FUSE_OPEN_ATOMIC
  selftests/fuse: add test for FUSE_OPEN_ATOMIC

 fs/fuse/dir.c                                 | 321 +++++-
 fs/fuse/fuse_i.h                              |   3 +
 fs/fuse/fuse_trace.h                          |   1 +
 include/uapi/linux/fuse.h                     |  75 +-
 .../selftests/filesystems/fuse/.gitignore     |   1 +
 .../selftests/filesystems/fuse/Makefile       |   3 +-
 .../filesystems/fuse/atomic_open_test.c       | 920 ++++++++++++++++++
 7 files changed, 1302 insertions(+), 22 deletions(-)
 create mode 100644 tools/testing/selftests/filesystems/fuse/atomic_open_test.c


base-commit: ab9787d7e66ac7e6e94fc975b37c5b56fff98ca9
-- 
2.50.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-21  0:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21  0:16 [PATCH v9 0/3] fuse: atomic open Jimmy Zuber
2026-11-21  0:16 ` [PATCH v9 1/3] fuse: move fuse_statx_to_attr() up Jimmy Zuber
2026-11-21  0:16 ` [PATCH v9 2/3] fuse: add FUSE_OPEN_ATOMIC Jimmy Zuber
2026-11-21  0:16 ` [PATCH v9 3/3] selftests/fuse: add test for FUSE_OPEN_ATOMIC Jimmy Zuber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.