Skip to content

Redfs ubuntu hwe fix splice read - #279

Closed
hbirth wants to merge 2 commits into
DDNStorage:redfs-ubuntu-hwe-6.17.0-16.16-24.04.1from
hbirth:redfs-ubuntu-hwe-fix-splice-read
Closed

hbirth wants to merge 2 commits into
DDNStorage:redfs-ubuntu-hwe-6.17.0-16.16-24.04.1from
hbirth:redfs-ubuntu-hwe-fix-splice-read

Conversation

@hbirth

@hbirth hbirth commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

…e write grant"

This reverts commit 9973e48.

Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
filemap_splice_read() serves the page cache without calling ->read_iter,
so splice, sendfile and the copy_file_range fallback skip the size
update, the DLM read grant with its invalidation fence and the direct io
dispatch, and fill pages that no grant covers.  Use copy_splice_read().

Fixes: 2cb1e08 ("splice: Use filemap_splice_read() instead of generic_file_splice_read()")
Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
@hbirth
hbirth force-pushed the redfs-ubuntu-hwe-fix-splice-read branch from 6cc84c6 to 95d0826 Compare November 6, 2026 14:31
@cryptosven76

Copy link
Copy Markdown

Tested this PR (6cc84c6) on a lab client: kernel 6.17.0-42, redfs.ko built from this branch, against a one-node Infinia cluster on main. Each copy is a 4 GiB file within one mount, run after a cold remount. All 24 copies matched their source under cmp.

Copy, MB/s Before, writeback cache This PR, writeback cache Before, no writeback cache This PR, no writeback cache
Python shutil.copyfile (sendfile) 7 58 67 68
cat a > b (kernel splice fallback) 7 55 63 67
cp (kernel splice fallback) 6 57 63 69
dd bs=1M 305 344 315 351
socket.sendfile, 512 MiB 8 552 - -

Read side: fixed. In a FUSE request sample taken during shutil with the writeback cache, the old module sent 2243 READ/s, 85% of them single 4 KiB read_folio calls. With this PR it sends 41 READ/s, all of them 2-4 MiB readahead.

Write side: now the limit for splice copies, at 55-69 MB/s. Each 64 KiB chunk from the internal splice pipe becomes one synchronous WRITE: 64 KiB is at REDFS_WRITE_STREAM_MIN, so the cached write path writes it through, and with the writeback cache it takes a DLM write lock first. The sample shows 1320 WRITE/s of 64 KiB at about 0.83 ms each. dd bs=64k with plain read/write gives the same 55-65 MB/s, while the same splice copy through a 1 MiB pipe gives 304-307 MB/s. I'll put a write-side change up as a separate PR stacked on this one, for you to review.

Correctness, old and new module:

  • a writer on a second mount (O_DIRECT and buffered) left no stale pages for the sendfile reader;
  • concurrent writers on both mounts produced no torn pages;
  • the socket.sendfile output matched by sha256.

Two questions:

  1. This PR also reverts 9973e48, "fuse: flush dirty times when a whole-file DLM revoke drops the write grant", which is unrelated to splice reads. Is that intended? The module I tested never had that commit, so this test does not cover the revert.
  2. The rhel10_0 (6.12), 6.8 and 7.0 branches still use filemap_splice_read and need the same change. The rhel9_4/5/6 branches already go through ->read_iter. Will you port it, or should I?

Tracking: RED-54152.

@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.

The splice fix looks right, but this PR also reverts an unrelated fix without saying why. That revert needs to come out or get its own PR before this can merge.

1. Silent revert of #277 (blocking)

Commit b8b2f2c reverts 9973e48 ("fuse: flush dirty times when a whole-file DLM revoke drops the write grant"). That commit is the RED-52104 fix for a WRITEBACK SETATTR hang of more than ten minutes that held an RPC credit. The revert has nothing to do with splice reads, its commit message gives no reason, and neither the PR title nor the description mentions it.

If the reason is the metadata-design concern raised on #277, please put the revert in its own PR. That PR should say what replaces the fix, or explain why the RED-52104 hang can't come back, so @hazhou-ddn can respond. Merging this PR as it stands would bring back RED-52104 without anyone deciding to.

2. Splice fix (fs/fuse/file.c, fuse_splice_read): correct

filemap_splice_read() serves the page cache without calling fuse_file_read_iter(). So splice, sendfile and the splice_copy_file_range() fallback skipped the size refresh in fuse_cache_read_iter(), the range lock and DLM READ grant, and the FOPEN_DIRECT_IO / fuse_inode_force_dio() dispatch.

copy_splice_read() goes through ->read_iter with an ITER_BVEC iterator, and I checked that both read paths handle it:

  • Cached path: copying into kernel pages can't fault, so the pagefault_disable() loop runs once and !user_backed_iter() exits it cleanly. The ABBA case that loop guards against doesn't apply.
  • Direct path: bvec is not kvec, so fuse_get_user_pages() takes the iov_iter_extract_pages() route, and should_dirty is false, which is right for pipe pages.

3. Non-blocking

  • Cost: every buffered fuse splice loses zero-copy and pays an extra memcpy plus a bulk page allocation. That includes non-DLM mounts and knfsd re-export, which splices reads. Consider using copy_splice_read() only where it's needed (fc->dlm && fc->writeback_cache, FOPEN_DIRECT_IO, or fuse_inode_force_dio()) and keeping filemap_splice_read() otherwise. Or state in the commit message that the cost is accepted.
  • The passthrough branch checks FOPEN_DIRECT_IO but not fuse_inode_force_dio(), while fuse_file_read_iter() checks both. A force-DIO inode with passthrough still splices from the backing file. Since this commit's goal is to make splice match ->read_iter, this seems worth fixing here too.
  • The FOPEN_DIRECT_IO part of the bug also exists upstream (see the Fixes: tag), so this may be worth sending upstream.

4. Housekeeping

  • The PR body is empty. Please describe the change and how it was tested, for example a sendfile or splice read on a DLM mount after another node writes, checking that it returns the new data and size.
  • The title doesn't describe the change and doesn't mention the revert.

@hbirth

hbirth commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

the revert is necessary ... before we add this patch ... it is a separate patch so it will be correct in the git log.
The revert has to go in before the patch either by this PR or a new one ... and is exactly identical in the git log afterwards, so completely overhead.

regarding the PR body ... we only care about git in the kernel. No PR log here.

@cryptosven76 tested it in the way described above

regarding nfsd ... we don't export redfs AFAIK

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.

3 participants