Skip to content

Red 54742 parallel sync io - #287

Merged
hbirth merged 5 commits into
DDNStorage:redfs-ubuntu-hwe-6.17.0-16.16-24.04.1from
hbirth:red-54742-parallel-sync-io
Nov 12, 2026
Merged

hbirth merged 5 commits into
DDNStorage:redfs-ubuntu-hwe-6.17.0-16.16-24.04.1from
hbirth:red-54742-parallel-sync-io

Conversation

@hbirth

@hbirth hbirth commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the single-stream limit in RED-54742 (Ubuntu 6.17). A synchronous call of more than one max_write/max_read piece (4 MiB on redfs) was sent one piece at a time, each waiting for the reply of the one before. redfsd and the servers take several pieces at once: through libaio, which already sends all pieces together, a 16 MiB O_DIRECT write ran at 3.3 GB/s against 1.4 GB/s synchronously. Found with h5bench, where one Open MPI aggregator issues every pwrite of an 8-rank job.

A synchronous read or write on a FOPEN_DIRECT_IO open went through
fuse_direct_io() with FUSE_IO_PRIV_SYNC, which sends one max_read or
max_write piece and waits for its reply before it sends the next. With
the 4 MiB pieces redfs uses, that caps one stream at the latency of one
piece: 16 MiB O_DIRECT writes ran at 1.4 GB/s and 32 MiB reads at
2.0 GB/s on a 6.17 client, while the same requests through libaio, which
sends all pieces before waiting, ran at 3.3 and 5.7 GB/s.

With async_dio, synchronous calls now take __fuse_direct_IO() as well.
It already handles a blocking kiocb: it sends every piece as a background
request and waits on io->done. The caller advances ki_pos, as
generic_file_direct_write() and generic_file_read_iter() do for
->direct_IO. Without async_dio nothing changes.

The completion is the aio one, so a short write reply now fails the call
with -EIO, as it already did for aio, instead of returning the short
count.

Signed-off-by: Sven Oehme <soehme@ddn.com>
…4742)

fuse_perform_write() filled up to max_write bytes of folios, sent them
with fuse_simple_request() and waited for the reply before it filled the
next piece. A single buffered writer was capped at the round trip of one
piece: 16 MiB writes ran at 0.85 GB/s with a 4 MiB max_write, while the
daemon and servers could take several pieces at once. One MPI-IO
aggregator writing an HDF5 file through glibc's POSIX aio issues exactly
such synchronous pwrites.

Each piece is now sent as a background request, and up to
FUSE_WRITE_PAGES_INFLIGHT (8) are outstanding before the oldest is waited
for. The reply handler does what fuse_send_write_pages() did after the
request: it clears uptodate on a failed or short write, unlocks the last
folio if it was left locked and drops the folio references. Replies are
accounted in file order, so the result and ki_pos cover only the bytes
before the first failed or short piece, as before. The pieces cover
disjoint ranges and keep uring_critical, so under the writeback cache a
background one does not wait for the background budget either.

Signed-off-by: Sven Oehme <soehme@ddn.com>
…nd the wait (RED-54742)

Synchronous direct I/O through __fuse_direct_IO() changed two things the
one-piece-at-a-time path did. A call that failed part-way returned the
error instead of the bytes before the failed piece, so a 64 MiB write
that hit ENOSPC on its third piece returned -ENOSPC instead of 8 MiB,
and an extending write under the exclusive lock was then truncated back.
And the caller waited in wait_for_completion(), so a stalled server left
it unkillable.

With sync_result, set for synchronous calls from fuse_direct_read_iter()
and fuse_direct_write_iter(), a failed piece records its start as the end
of the result, fuse_get_res_by_io() returns the bytes before the first
failed or short piece, or the error if there are none, i_size follows the
returned count and nothing is truncated. The pieces after the failed one
were applied by the server all the same, as noted at __fuse_direct_IO().
The cached O_DIRECT path, fuse_direct_IO(), and aio keep their result.

The caller now waits killably. On a fatal signal it clears io->done under
io->lock, drops its reference and returns -EINTR; the pieces in flight
hold references on io and the last completion frees it.

Signed-off-by: Sven Oehme <soehme@ddn.com>
…-54742)

A buffered write of a single max_write piece became 16-26 % slower with
pieces sent in the background: ior-easy with 4 MiB transfers on a
writeback_cache mount went from 1.13 to 0.84 GB/s with one process. A
background request goes to the queue of the next CPU, and that queue's
ring task copies the payload, 482 us per 4 MiB piece, while a foreground
request is copied by the caller; the call waits for the hand-off as well.
The piece nothing is sent after is now sent with fuse_simple_request(),
as before the series, so a one-piece call takes the old path and the
last piece of a longer one overlaps with the pieces in flight.

The wait for a piece is killable. On a fatal signal no further piece is
sent and the pieces in flight are still waited for, since they reference
the request and the folios; fuse_simple_request() also waits for a
request once the server has it.

Under DLM the server takes the DLM lock for a write without
FUSE_WRITE_CACHE, which can wait on a revoke. Such pieces are
uring_critical and would hold up to eight critical entries of the queue.
A writer like that, a write dropping suid/sgid, keeps a single piece in
flight, as before the series. FUSE_WRITE_CACHE writes, and mounts
without the writeback cache, where no entry is critical, keep eight.

The comment now says that the pieces after a failed one have been
applied by the server, so its file can hold data and a size past the
returned count.

Signed-off-by: Sven Oehme <soehme@ddn.com>
Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>

@yongzech yongzech left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I read fs/fuse/file.c, dev.c and dev_uring.c at 04da668687 and compared the branch with #285. I did not build or run anything. Apart from the Signed-off-by lines and reworded comments, the only code change from #285 is 04da668687. It is correct: a killed buffered writer now stops sending, and the pieces in flight are still waited for.

The synchronous O_DIRECT path, which now goes through __fuse_direct_IO() when async_dio is on, still has two signal problems. Details are inline:

  1. Should fix: the send loop in fuse_direct_io() doesn't check for a fatal signal, so a killed caller sends the rest of its buffer. This is the gap 04da668687 closed for buffered writes.
  2. Should fix: on a fatal signal __fuse_direct_IO() returns -EINTR while pieces are still outstanding at the server. The caller then drops the inode lock, and on exit the file can be closed (FUSE_FLUSH, then FUSE_RELEASE) while READs or WRITEs on the same handle are still in flight.

The fix for both is to do what fuse_perform_write() does: stop sending on the signal, then wait for the pieces in flight.

Process: the PR description is empty. #285's description held the measurements, the behaviour changes and what was not tested, and this PR replaces it. The title could also follow #285's, e.g. "fuse: send the pieces of a synchronous large read or write together (RED-54742)".

Comment thread fs/fuse/file.c Resolved
Comment thread fs/fuse/file.c Resolved
fuse_perform_write() saw a fatal signal only in
wait_for_completion_killable(), which tests for one only while it sleeps.
A piece complete by the time it is waited for, as every foreground piece
is, never ended the loop, and a killed writer sent the rest of its buffer.
Test for the signal before each piece is sent.  A writer killed before
its first piece now returns -EINTR.

The pieces still waited for after the signal include those the server has
not received yet.  Say so in the comment.

fuse_direct_io() sent every piece of a killed synchronous caller, as no
background request ends on a signal.  Stop sending there too.
__fuse_direct_IO() then returned -EINTR with pieces still at the server,
and the caller dropped the inode lock and could release the file under
them.  Wait for them uninterruptibly instead, as fuse_perform_write()
does, and drop the io->done handshake.

Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
@hbirth

hbirth commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

I read fs/fuse/file.c, dev.c and dev_uring.c at 04da668687 and compared the branch with #285. I did not build or run anything. Apart from the Signed-off-by lines and reworded comments, the only code change from #285 is 04da668687. It is correct: a killed buffered writer now stops sending, and the pieces in flight are still waited for.

The synchronous O_DIRECT path, which now goes through __fuse_direct_IO() when async_dio is on, still has two signal problems. Details are inline:

  1. Should fix: the send loop in fuse_direct_io() doesn't check for a fatal signal, so a killed caller sends the rest of its buffer. This is the gap 04da668687 closed for buffered writes.
  2. Should fix: on a fatal signal __fuse_direct_IO() returns -EINTR while pieces are still outstanding at the server. The caller then drops the inode lock, and on exit the file can be closed (FUSE_FLUSH, then FUSE_RELEASE) while READs or WRITEs on the same handle are still in flight.

The fix for both is to do what fuse_perform_write() does: stop sending on the signal, then wait for the pieces in flight.

Process: the PR description is empty. #285's description held the measurements, the behaviour changes and what was not tested, and this PR replaces it. The title could also follow #285's, e.g. "fuse: send the pieces of a synchronous large read or write together (RED-54742)".

  • fuse_direct_write_iter: "Agreed. fuse_direct_io() now stops sending on a fatal signal when it sends in the background and the caller waits (io->async && io->blocking), which covers reads and writes."
  • __fuse_direct_IO: "Agreed. The killable wait is gone and the caller waits for every piece in flight, as fuse_perform_write() does."

@hbirth
hbirth force-pushed the red-54742-parallel-sync-io branch from 04da668 to c3c668f Compare November 12, 2026 10:16

@yongzech yongzech left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-read at c3c668ffdb. I did not build or run anything. Both points from my last review are fixed:

  1. fuse_direct_io() now checks fatal_signal_pending() before each piece when io->async && io->blocking. The check comes before fuse_get_user_pages(), so no pages are pinned for a piece that is never sent, and ia is freed after the break. If no piece was sent the call returns -EINTR. Otherwise it returns the bytes of the pieces that were sent and succeeded.
  2. __fuse_direct_IO() waits for every piece in flight, so the inode lock and the open file outlive them at the server. The io->done = NULL handshake is gone, and fuse_aio_complete() is back to if (!left && io->blocking).

Both paths now handle a kill the same way: stop sending, then wait for what is already out. Remaining points, none blocking:

  1. The direct I/O wait can't be interrupted and can cover many pieces (inline). It's acceptable, but please say so in the description.
  2. O_DIRECT on a cached open still gets the aio result, as it did before this series (inline). This could be a follow-up.
  3. 04aa09d528's subject says "…let a fatal signal end the wait", and its body describes the io->done handshake. c3c668ffdb removes both. Squashing the direct I/O part of c3c668ffdb into 04aa09d528, or rewording it, would keep any single commit from claiming a killable direct I/O wait.
  4. The description is still empty and the title is still "Red 54742 parallel sync io". The measurements, behaviour notes and untested cases exist only on #285.

I'd approve once the description is filled in.

Comment thread fs/fuse/file.c Resolved
Comment thread fs/fuse/file.c Resolved
@hbirth
hbirth requested a review from yongzech November 12, 2026 15:53

@achhenderson achhenderson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks good to me. Thanks!

@hbirth
hbirth merged commit 7f4503d into DDNStorage:redfs-ubuntu-hwe-6.17.0-16.16-24.04.1 Nov 12, 2026
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.

4 participants