fuse: atomic open
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v9 Latest3 patches 0 repliesNew
- v82 patches 5 repliesSuperseded
- v72 patches 0 repliesSuperseded
Earlier versions · 6
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v6 | 2 patches | 4 replies | Superseded | |
| v5 | 2 patches | 0 replies | Superseded | |
| v4 | 3 patches | 0 replies | Superseded | |
| v3 | 3 patches | 0 replies | Superseded | |
| v2 | 3 patches | 2 replies | Superseded | |
| v1 | 3 patches | 10 replies | Superseded |
Changes in v9 from the cover letter
- 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().
Patches in v9 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | fuse: move fuse_statx_to_attr() upfs/ | +20 | 0 replies | |
| 2/3 | fuse: add FUSE_OPEN_ATOMICfs/ fs/ fs/ +1 more | +359 | 0 replies | |
| 3/3 | selftests/fuse: add test for FUSE_OPEN_ATOMICtools/ tools/ tools/ | +923 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v9 yet.
Cover letter [PATCH v9 0/3] fuse: atomic open
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/[email protected]/
v7: https://lore.kernel.org/fuse-devel/[email protected]/
v6: https://lore.kernel.org/fuse-devel/[email protected]/
v5: https://lore.kernel.org/fuse-devel/[email protected]/
v4: https://lore.kernel.org/fuse-devel/[email protected]/
v3: https://lore.kernel.org/fuse-devel/[email protected]/
v2: https://lore.kernel.org/fuse-devel/[email protected]/
v1: https://lore.kernel.org/fuse-devel/[email protected]/
[1] Dharmendra Singh, "FUSE: Implement atomic lookup + open/create"
https://lore.kernel.org/all/[email protected]/ [2] Bernd Schubert, "fuse: full atomic open and atomic-open-revalidate" https://lore.kernel.org/all/[email protected]/
[3] Joanne Koong, "fuse: add FOPEN_FETCH_ATTR flag for fetching attributes after open"
https://lore.kernel.org/all/[email protected]/
[4] Bernd Schubert, "fuse: Add open-gettr for fuse-file-open"
https://lore.kernel.org/all/[email protected]/ [5] https://lore.kernel.org/fuse-devel/[email protected]/ [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
Signature · 1 line
2.50.1