Repository navigation
Linux 6.17: optional DLM write grant ahead of copies and streamed writes; fix aligned writeback requests - #281
Conversation
yongzech
left a comment
There was a problem hiding this comment.
Review of the kernel side of red/red#30245.
The inline comments cover most findings. One concerns a line outside the diff:
fs/fuse/file.c:2561 (and 2880, 3369): some writes skip fuse_cache_write_iter()'s flush and leave the staged batch in place. These are FOPEN_DIRECT_IO handles, forced-DIO inodes, fallocate and server-side copy_file_range. Example: task A has [0, 3 MiB) staged mid-sendfile. Task B writes the same range through FOPEN_DIRECT_IO, or punches a hole. B's change reaches the server first, then A's batch is sent at the 4 MiB boundary and writes old bytes over it. The design comment says staged bytes are sent before another cached or O_DIRECT write, but these paths never call fuse_splice_batch_flush().
| */ | ||
| if (b->ia.write.folio_locked || pos == end || | ||
| b->ia.ap.num_folios == b->max_folios) { | ||
| err = fuse_splice_batch_send(b); |
There was a problem hiding this comment.
A send that fails here (the boundary, max_folios or !more send, and the discontinuity send at 2125) is returned for this round only and never stored in ff->splice_batch_err. do_splice_direct() then hides it: splice_direct_to_actor() returns the bytes counted so far because bytes != 0. Example: an 8 MiB sendfile with splice_write_batch=1 fails the 4 MiB send in round 64. sendfile returns about 4 MiB as copied, and the next sendfile finds splice_batch_err == 0 and carries on. The lost data only shows up at fsync or close, not from the next write as the design comment promises.
There was a problem hiding this comment.
Withdrawn from this PR; the rework sends through writeback and waits on the copied range before sendfile returns, so a failed send fails that call instead of being folded into a partial count.
| if (fuse_is_bad(inode)) | ||
| return -EIO; | ||
|
|
||
| err = fuse_splice_batch_flush_unlocked(inode); |
There was a problem hiding this comment.
On a FOPEN_NOFLUSH open without writeback cache, this returns right after fuse_splice_batch_flush_unlocked() and never calls filemap_check_errors(). Suppose the task_work send fails after sendfile has returned its full count, which sets AS_EIO and splice_batch_err. A later close() without fsync then returns 0, although the comment says the error is kept for fsync and close.
There was a problem hiding this comment.
Withdrawn from this PR; the rework keeps no private batch or flush hook, so close() reports through the normal writeback error path like any other cached write.
| err = fuse_splice_batch_send(b); | ||
| if (err) { | ||
| ff = b->file->private_data; | ||
| WRITE_ONCE(ff->splice_batch_err, err); |
There was a problem hiding this comment.
One send failure is reported twice: through the mapping (fsync or close) and again through ff->splice_batch_err, which fsync and close do not clear. After fsync() returns -EIO, the application rewrites the data and the xchg at 2884 returns the same stale -EIO, so the retry fails although nothing new went wrong.
There was a problem hiding this comment.
Withdrawn from this PR; the rework drops splice_batch_err and reports only through the mapping's errseq, so fsync consumes the error once.
| * A partly written folio that is not uptodate stays locked | ||
| * until it is sent; the next round would lock it again. | ||
| */ | ||
| if (b->ia.write.folio_locked || pos == end || |
There was a problem hiding this comment.
When the destination offset is not page aligned, the partial head folio is not uptodate and sets folio_locked, which forces an immediate send. The tail folio of the round is partial again, so each 64 KiB round issues 2 synchronous WRITEs and never batches up to 4 MiB. That is slower than the unbatched fuse_perform_write path. Example: sendfile to destination offset 100, or any resume offset that is not 4K aligned.
There was a problem hiding this comment.
Withdrawn from this PR; the rework dirties folios through the normal buffered write path, which brings a partial head folio uptodate once instead of forcing a send, so an unaligned destination batches like an aligned one; it will be tested at offset 100.
| end = fuse_splice_batch_end(fc, b->pos); | ||
|
|
||
| iov_iter_truncate(from, end - pos); | ||
| count = fuse_fill_write_pages(&b->ia, mapping, from, pos, |
There was a problem hiding this comment.
When a round ends partway into an uptodate folio, the next round adds the same folio to ap->folios again. fuse_send_write_pages() assumes each entry runs from its offset to the end of the folio (folio_size - offset). On a short write, the count loop subtracts a whole folio for each duplicate entry and can leave a folio the server never received marked uptodate. Reads are then served from the page cache with bytes the server doesn't have.
There was a problem hiding this comment.
Withdrawn from this PR; the rework does not build its own folio array, so writepages owns each folio once and a short write leaves it dirty or in error, not falsely uptodate.
| if (pos + count > i_size_read(inode)) | ||
| set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); | ||
|
|
||
| init_sync_kiocb(&kiocb, b->file); |
There was a problem hiding this comment.
When another task triggers the flush (a reader, fsync, close, truncate or a competing writer), the staging task's WRITE is sent with that task's credentials and pid (args.force uses current's fsuid). If user B, who can only read the file, does a splice-read or close on the inode, the FUSE_WRITE reaches the server with B's uid. A server that checks permissions per request (no default_permissions) rejects it with EACCES, A's data is dropped, and A's next write fails with B's error.
There was a problem hiding this comment.
Withdrawn from this PR; the rework sends through fuse_writepages(), whose requests carry no caller credentials, so a reader's or closer's flush cannot fail or misattribute the writer's data.
| behind = READ_ONCE(stream_write_behind); | ||
| if (behind) { | ||
| through = false; | ||
| err = errseq_check(&mapping->wb_err, |
There was a problem hiding this comment.
errseq_check() never advances file->f_wb_err. After one writeback error, including one from another opener of the inode, every later streamed write on this file fails at once until fsync, while a non-streamed 4 KiB write on the same fd still succeeds. Should this be errseq_check_and_advance(), or report through the normal fsync path?
There was a problem hiding this comment.
Withdrawn from this PR together with write-behind; the rework will report through the normal fsync path (or advance with errseq_check_and_advance), so a streamed write and a small write on the same fd see the same error once.
| return round_down(pos, align) + align; | ||
| } | ||
|
|
||
| static int fuse_splice_batch_send(struct fuse_splice_batch *b) |
There was a problem hiding this comment.
This duplicates the send tail of fuse_perform_write(): setting FUSE_I_SIZE_UNSTABLE, fuse_send_write_pages, the short-write -EIO, fuse_write_update_attr and clear_bit. A future fix to the i_size or attr-version handling there will miss this path. A shared "send filled ia and commit attrs" helper would remove about 25 lines.
There was a problem hiding this comment.
Withdrawn from this PR; with the send left to writeback there is no second copy of the i_size/attr-version tail to keep in sync.
| * Stage one splice round in the batch of its inode, sending the batch each | ||
| * time it reaches its boundary. Called with inode->i_rwsem held exclusive. | ||
| */ | ||
| static ssize_t fuse_splice_batch_write(struct kiocb *iocb, |
There was a problem hiding this comment.
Design question: the private per-inode staging buffer, the TWA_RESUME task_work and the lock-free hint fields on fuse_file rebuild writeback by hand. Every operation that must see server state then needs its own fuse_splice_batch_flush() hook, and a missing hook is a silent ordering bug (see the direct-I/O note in the review summary). Could fuse_splice_write() instead dirty the folios and call filemap_write_and_wait_range() on the copied range when SPLICE_F_MORE is clear (or once per do_splice_direct)? That reuses the aligned writepages path and its error reporting, and drops the task_work and the hint fields.
There was a problem hiding this comment.
Agreed, batching and write-behind are withdrawn from #281 and will be redone that way: dirty the folios, write and wait the copied range when SPLICE_F_MORE is clear (and kick aligned chunks for streams), with no task_work, staging buffer or hint fields; the review-summary point about FOPEN_DIRECT_IO, fallocate and server-side copy_file_range bypassing the flush hook goes away with the hooks.
sendfile(2) and the copy_file_range() fallback go through do_splice_direct(), whose internal pipe holds 16 pages, so a copy into a fuse file arrives as one 64 KiB ->write_iter per pipe round. Under DLM with the writeback cache, fuse_cache_write_iter() asks the server for a write grant covering exactly the bytes of that write, and the server grants exactly that range. The next round starts where the grant ends, so every 64 KiB waits for a FUSE_DLM_WB_LOCK round trip of its own. Since "fuse: do not write through a write that drains a pipe" these copies are cached and written back in max_write requests, and the grant is what is left. During a 4 GiB shutil.copyfile (Python 3.12, sendfile) on a 6.17 client over TCP, the client sent 4000-6000 DLM_WB_LOCK a second at 66 us each, one per 64 KiB, against 42 WRITEs of 4 MiB. Over RoCE the same copy runs at 519-667 MB/s, while a splice loop through a 1 MiB pipe, which pays one grant per MiB, reaches 1014 MB/s. do_splice_direct() sets SPLICE_F_MORE on every round but the last. When it is set, request the grant ahead of the write, for as far as the run of sequential splice writes through this file has already come, at most 4 MiB, and never past the next 4 MiB boundary after the write. A copy then costs one grant round trip per 4 MiB instead of one per 64 KiB: 1030 instead of 65536 for 4 GiB. Growing the request with the run and stopping at the boundary keep a copy into one region of a file that other nodes write from taking a grant over their regions, as long as the regions are aligned to 4 MiB. The request is only a hint. It takes a range lock over the whole range, as every grant request does, so an invalidate cannot run between the reply and the recording of the grant. The write itself still requests its own range under its own range lock; when the grant ahead is there it finds it held and goes on without a round trip, and when a revoke took it in between, it asks again as before. Errors are left to the write. Unchanged: splice(2) without SPLICE_F_MORE, writes without the writeback cache or DLM, O_DIRECT, FOPEN_DIRECT_IO and passthrough files, files with suid or sgid set, and sendfile to a socket or a pipe, which does not reach ->splice_write of a fuse file. Signed-off-by: Sven Oehme <soehme@ddn.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the server sets FUSE_ALIGN_PG_ORDER, fuse_writepage_need_send() ends a writeback request at an alignment boundary if the chunk that starts there no longer fits. It counted the folio at the boundary, which is the first page of that chunk, once in the request and once in the chunk, so the chunk never fit when the alignment is a power of two below max_pages: with a 2 MiB alignment and 4 MiB requests every request held a single 2 MiB chunk. Count only the pages queued before the boundary folio. Requests then carry max_pages again, start and end on alignment boundaries after the first one of a run, and only the head of a run that starts unaligned is short. An alignment equal to max_pages, the only setting that worked before, behaves as it did. RED codes each 2 MiB bucket as one erasure-coded extent, so a server that announces its bucket size gets bucket-aligned writeback requests at the full request size. Signed-off-by: Sven Oehme <soehme@ddn.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under DLM with the writeback cache, a cached write asks the server for a write grant covering exactly its own bytes, and the server grants exactly that range: redfsd extends read grants over what the node already holds, not write grants. The next write starts where the grant ends, so every write(2) of a stream waits for a FUSE_DLM_WB_LOCK round trip of 80-90 us before it is written through. A stream of 64 KiB records on a RoCE client spends about 590 us in each write(2), one grant and one synchronous FUSE_WRITE of 64 KiB, and pays the grant 65536 times for 4 GiB. The client already records any granted range that covers the request, and the server grants a wider write range when asked for one. So the round trip can go without a server change, the way it went for splice copies: a streamed write is one of a run of writes of the same size, so request the grant ahead of it, with the same ramp and 4 MiB boundary that splice uses. A sequential stream then pays one grant round trip per 4 MiB instead of one per write. Generalise fuse_splice_write_grant_ahead() to fuse_write_grant_ahead(), which takes whether more follows instead of the splice flags, and call it for a write that is written through as a stream, before the inode lock is taken, as splice does. An append is left out: it lands at EOF, not at ki_pos. A wider write grant makes another node that writes in the same 4 MiB revoke it sooner, which is why the run has to have come as far as the grant reaches. A writer whose records do not follow each other restarts the run at every write and never asks ahead. The write itself is unchanged: it is still written through and still requests its own range, which it now finds granted. Signed-off-by: Sven Oehme <soehme@ddn.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7e0f0fe to
8a48273
Compare
|
@yongzech Thanks for the review. Splice batching and write-behind are withdrawn from this PR (force-pushed to 8a48273). It now holds only the DLM grant-ahead for splice and streamed writes, and the aligned-writeback fix. The withdrawn code is kept on |
|
The second problem I see is ... If we request DLM locks ahead, we then heavily favor a client doing this kind of stuff since redfsd has to acquire a larger portion and invalidate the larger byte range, which leads to page cache flushes on other nodes. |
| #define FUSE_WRITE_STREAM_MIN (64 * 1024) | ||
|
|
||
| /* Largest DLM write grant requested ahead of writes still to come */ | ||
| #define FUSE_WRITE_GRANT_AHEAD_MAX (4 * 1024 * 1024) |
There was a problem hiding this comment.
I would use the server alignment here ... IF we actually have to over request
There was a problem hiding this comment.
Agreed, it now defaults to off. The fourth commit (4fc2c00) puts the grant-ahead behind a dlm_grant_ahead module parameter, and at 0 the client sends exactly the requests it sends today. When set, the value is a multiple of the server alignment (align_page_order, falling back to max_write), capped at 64 units and 256 MiB. A grant never crosses the next multiple of that window, so writers on aligned regions don't take each other's ranges. Before anyone turns it on, we'll run a two-client test on a shared file to measure the revokes and page-cache invalidations you describe.
The grant-ahead requests a wider DLM write grant than the write needs. That saves this client a round trip per write, but the node holding the wider grant is favoured: every other node that writes or caches in that range has to give its grant back and drop its cached pages there, a trade-off that was found counterproductive for shared files before. Whether it pays depends on how the cluster's clients share files, so leave it to the administrator and keep the default behaviour as it was before grant-ahead: a write requests exactly its own range. dlm_grant_ahead (0644, default 0) sets the window in units of the server's write alignment (fc->alignment_pages, which redfsd sets with align_page_order), so that a grant ends where a server extent ends. A server that announces no alignment gets units of fc->max_write, the size of a writeback request. The window is at most 64 units and 256 MiB, so that one client never takes an unbounded range from the others; larger values are rejected. The ramp and the boundary rule stay: a grant never reaches further ahead than the run has come, nor past the next multiple of the window. At 0 neither caller tracks a run nor sends a request. 1 with a 4 MiB unit, which a RED server without align_page_order gives today, is the behaviour of the previous two commits; with a 2 MiB alignment that is 2. Signed-off-by: Sven Oehme <soehme@ddn.com>
|
@hbirth On your second point: grant-ahead is now behind |
|
@hbirth If you agree with the change as it is now, with grant-ahead behind |
|
@hbirth Two-client contention results for
The parameter stays at 0 by default. The batching rework that builds on it is #283. |
I agree with the idea |
yongzech
left a comment
There was a problem hiding this comment.
Review of 4fc2c00. I found no correctness bug. Two small fixes are in the inline comments; the rest are nits.
Checked and correct:
- At
dlm_grant_ahead=0the function returns before it touches the run fields, so the default sends exactly today's requests. - The ramp and boundary rule: 64 KiB writes from offset 0 with N=1 request 128K–256K, 256K–512K, and so on up to 4M, then one per 4 MiB. That fits the ~1,032 round trips per 4 GiB in the table.
- A splice write arrives as a bvec on a sync kiocb, which isn't counted as a stream, so a splice never also takes the streamed-write grant-ahead and resets the run.
- O_APPEND can't reach the splice path (
do_splice_directand copy_file_range reject it), and the write path excludes it. Passthrough, FOPEN_DIRECT_IO, forced direct IO, O_DIRECT and suid/sgid files are excluded. - The aligned-writeback fix: with 4 MiB requests and a 2 MiB alignment, the 512 pages before the boundary plus a 512-page chunk now fit in 1024. An unaligned run sends its short head first, then full aligned requests. Setting the alignment equal to
max_pagesbehaves as before. As the PR says, it can't be exercised on 6.17 until thealign_page_orderlayout question is settled.
Other points:
- Commits 1 and 3 turn grant-ahead on unconditionally, and only commit 4 makes it opt-in, so a bisect lands on the default @hbirth called counterproductive. Could commit 4 be folded into commit 1, or the parameter come first?
- Nit: the unit is the server alignment, falling back to
max_write. N=1 means 4 MiB today and becomes 2 MiB once red-libfuse#137 lands, so an administrator's setting halves silently. A byte value rounded up to the unit would keep its meaning stable. - Nit:
FUSE_GRANT_AHEAD_MAX_UNITSandFUSE_GRANT_AHEAD_MAX_BYTESare only used in file.c and could live there. The PR body says values that are too large are rejected, but only the 64-unit limit is rejected; the 256 MiB limit is clamped silently.
| fuse_dlm_lock_is_held(fi, pos, len, FUSE_PAGE_LOCK_WRITE)) | ||
| return; | ||
|
|
||
| if (fuse_range_lock_acquire_init(fi, &rlock, pos, end - 1, |
There was a problem hiding this comment.
This takes a WRITE range lock over the whole window, up to 256 MiB, and blocks for it. It holds the lock for the whole round trip, and the INIT state conflicts with every existing range. So, only for a hint:
- Local reads and writes anywhere in
[pos, end)on this node wait for the round trip. - mmap faults in the window fail their trylock, return
VM_FAULT_NOPAGEand fault again. fuse_get_dlm_lock()first calls the blockingfuse_range_lock_mark_locked(). The writer then waits behind any invalidation draining anywhere in the window, not just over its own bytes. That is the stuck-invalidation case from RED-52104.
Since the request is only a hint, could this use fuse_range_lock_try_acquire_init() and skip the request when the lock is contended?
There was a problem hiding this comment.
Fixed in a43bfbe. Grant-ahead now takes the window with fuse_range_lock_try_acquire_init() and moves it to LOCKED with fuse_range_lock_try_mark_locked() before fuse_get_dlm_lock(). If either finds the window busy, the request is skipped, so the writer never waits on other IO or on an invalidate draining in the window. On u24 with a local reader in the window, the hint was skipped in 45-48% of attempts and the writer never waited on the window lock. One thing remains: local IO that arrives in the window while the request is in flight waits for that one request, at most once per window. I didn't use a READ-mode lock, because that would put a READ and a WRITE request over one range in flight from one node, which the client never does today.
| start = pos; | ||
| WRITE_ONCE(ff->write_run_start, start); | ||
| } | ||
| WRITE_ONCE(ff->write_run_next, pos + len); |
There was a problem hiding this comment.
The run advances by the length the caller asked for, not the length written. For do_splice_direct the two are the same. With splice(2), len is the caller's length, often larger than the pipe holds (for example 1 MiB requested with 64 KiB in the pipe). Then write_run_next jumps past where the next splice starts, so every call restarts the run, and end - pos <= len returns early as well. So splice(2) with SPLICE_F_MORE never gets a grant ahead, although commit 1 implies it does. A short write breaks the run in the same way.
Could the run be advanced from the result instead: *ppos after iter_file_splice_write(), or ki_pos after the write?
There was a problem hiding this comment.
Fixed in 85e06f1. The run now advances from *ppos after iter_file_splice_write() and from ki_pos after a streamed write, so a short write or splice continues it. Before a splice with SPLICE_F_MORE, the length comes from what the pipe holds; that is read only when the parameter is set. On u24, splice(2) with a 1 MiB length and SPLICE_F_MORE at N=1 dropped from 65,537 DLM requests per 4 GiB to 1,031, the same as sendfile. At N=0 nothing changed.
The grant-ahead reserved its window, up to 256 MiB, with the blocking fuse_range_lock_acquire_init(), and fuse_get_dlm_lock() then moved it to LOCKED with the blocking fuse_range_lock_mark_locked(). The writer so waited for any local read or write anywhere in the window, and for any invalidate draining anywhere in it, not only over its own bytes: the stuck-invalidation case of RED-52104, for a request that is only a hint. Take the range lock with fuse_range_lock_try_acquire_init() and move it to LOCKED with fuse_range_lock_try_mark_locked() before the request, and skip the grant-ahead when either finds the window busy. The write then requests its own range, as it does with grant-ahead off. Once the range is LOCKED, nothing can take an overlapping READY or LOCKED range, so the mark_locked() in fuse_get_dlm_lock() returns at once, and the range goes back to INIT for the round trip as before. Local IO that arrives in the window while the request is in flight still waits for that request, as it would behind a write over the window; that happens at most once per window. Signed-off-by: Sven Oehme <soehme@ddn.com>
The run of sequential writes that a grant-ahead reaches from advanced before the write, by the length the caller asked for. For sendfile(2) and the copy_file_range() fallback that is the length written: the internal pipe holds exactly what is spliced. splice(2) callers commonly ask for far more than the pipe holds, 1 MiB for 64 KiB for example, and a short write(2) writes less than it asked for. The next write then starts short of where the run was said to continue, every call starts a new run, and no grant is ever requested ahead: splice(2) with SPLICE_F_MORE, which the first grant-ahead commit covers, never got one. The same overstated length made the request reach only once the run had come further than the asked length, and past the window boundary after the bytes really written. Advance the run after the write, from the position it reached: *ppos after iter_file_splice_write() and ki_pos after a streamed write. Before a splice, estimate the length from what the pipe holds when it starts, which is what iter_file_splice_write() writes unless it has to wait for more, so a splice(2) asks for the grant a sendfile(2) of the same data asks for. A splice without SPLICE_F_MORE still advances the run, as before. With dlm_grant_ahead at 0 nothing changes: neither the pipe is read nor the run is tracked. Signed-off-by: Sven Oehme <soehme@ddn.com>
FUSE_GRANT_AHEAD_MAX_UNITS and FUSE_GRANT_AHEAD_MAX_BYTES are used only in file.c, next to dlm_grant_ahead, so define them there. Only the 64-unit limit rejects a value; the 256 MiB limit caps the window for a large unit, since the unit is per connection and not known when the parameter is set. Say so in the parameter description. Signed-off-by: Sven Oehme <soehme@ddn.com>
|
@yongzech On the nits in your review:
u24 with the new head (srcversion C6DABBBC): shutil 477/953 MB/s and rwrite 64k 118/141 MB/s at N=0/1, the same DLM counts as before, cc2 22/22. One timing note: with a local reader in the window at N=4, the writer's p99 was 2.3 ms against 1.8 ms at N=0, and its max 45-89 ms against 34-43 ms. That is the same with the earlier module, so it comes from the larger grant, not from these fixes. With a remote invalidation, p99 is better than at N=0. |
|
@yongzech do you think this is ready? |
hbirth
left a comment
There was a problem hiding this comment.
LGTM
If we have to request ahead ... and it seems like it improves performance
yongzech
left a comment
There was a problem hiding this comment.
@hbirth Yes, I think it's ready.
Review of 3d504d1. Both points from my last review are fixed, and I found no correctness bug in the three new commits.
- a43bfbe: grant-ahead only tries the window's range lock and skips the hint when it is busy, so the writer no longer waits on other IO or a draining invalidation. Once the window is LOCKED, nothing can overlap it, so the
mark_locked()insidefuse_get_dlm_lock()passes at once. The remaining wait, local IO that arrives in the window during the one request, is acceptable for an opt-in parameter. - 85e06f1: the run advances by what was written, and a splice with SPLICE_F_MORE estimates its length from the pipe.
->splice_writeis reached without the pipe locked, so thepipe_lock()there is safe. Atdlm_grant_ahead=0both new helpers return before touching anything, so the default still sends exactly today's requests. - The run fields are read and written without a lock. A torn read gives no hint or a bounded one, never a bad range.
- The hint runs before
inode_lock, so no rwsem is held across the round trip.
@cryptosven76 please fold the parameter into commit 1 before merge, so a bisect never lands on grant-ahead turned on by default. The unit question (alignment units vs. bytes) is @hbirth's call and doesn't block the merge.
Reviewed together with Claude Code.
|
@cryptosven76 I think the point about folding in the paramter could be addressed ... it's not a big deal though |
Four commits on
redfs-ubuntu-hwe-6.17.0-16.16-24.04.1(on top of #279/#280). The first three add a DLM write grant request ahead of sendfile/copy_file_range copies and streamedwrite(2), and fix the request size of aligned writeback. The fourth puts the grant-ahead behind a module parameter that is off by default, so with this PR merged and nothing configured a write requests exactly its own range, as today. Tracking: RED-54224, RED-54152.Why off by default. A wider write grant saves the writing client a round trip per write, but it favours that client: any other node that writes or caches in the granted range has to give its grant back and drop its cached pages there. Whether that pays depends on how clients share files, so it is an administrator's choice, and it stays off until a two-client contention test shows where it helps and where it hurts.
Why. Under DLM with the writeback cache, a cached write asks the server for a write grant over exactly its own bytes, and the server grants exactly that. The next write starts where the grant ends, so:
copy_file_rangefallback copy pays one FUSE_DLM_WB_LOCK round trip per 64 KiB pipe round;write(2)(written through since 3338f96) pays one per record.The parameter.
dlm_grant_ahead(/sys/module/redfs/parameters/, runtime-writable, default 0):align_page_order, 2 MiB once red-libfuse#137 is in), ormax_write(4 MiB on RED today) when the server announces none.Commits (review one at a time):
Measured on a 6.17.0-42 client against a one-node cluster over RoCE, 4 GiB files, writeback cache, cmp or a seeded-content check after a cold remount on every run. MB/s, mean of 2 runs:
After commits 5-7 (u24, srcversion C6DABBBC): shutil 477 / 953 MB/s and write(2) 64 KiB 118 / 141 MB/s at N=0 / 1, the same DLM counts. splice(2) with a 1 MiB length and SPLICE_F_MORE at N=1: 65,537 -> 1,031 DLM requests per 4 GiB.
The aligned-writeback fix (2) has no effect until the
align_page_orderlayout question below is settled.Correctness, all passed (
dlm_grant_ahead=1):Not exercised: two-client contention (planned before anyone turns the parameter on), quota ENOSPC, multi-client IOR.
Moved out of this PR. Splice batching without the writeback cache (
splice_write_batch) and write-behind for streamed writes (stream_write_behind) are withdrawn. @yongzech found correctness bugs in both, and asked whether they should be built on the normal writeback path instead of a private staging buffer. They will come back as a separate PR that does that. The withdrawn code is kept onred-sendfile-cfr-reworkin my fork.align_page_order. While testing (2) we found that the FUSE_INIT reply layout differs between RED's libfuse and these branches. The 6.17 and 7.0 redfs branches carry the upstream
request_timeoutat byte 40 and readalign_page_orderat byte 42. red-libfuse has norequest_timeoutand writesalign_page_orderat byte 40, which is also where the pre-7.43 redfs kernels (6.12, 6.8, RHEL 9.5/9.6) read it. Sofc->alignment_pagesstays 0 on 6.17 and 7.0, and (2) has no effect until that is fixed. @hbirth, there are two options; which do you prefer?align_page_orderat byte 42 for kernel minor >= 43 and at byte 40 below that. Every shipped kernel branch works unchanged.align_page_orderback to byte 40 on 6.17 and 7.0. That takes upstream'srequest_timeoutslot, and has to be carried on every rebase.Ports. 7.0 and 6.12 need the same changes. 6.8 and RHEL 9 have no DLM write path of this shape. Ports are yours, as agreed.
Agent changes:
7e0f0fe3e4c10f24a4-49fe-51da-96c4-4a22a16358c2cd /mnt/linux-redfs-sendfile && claude --resume c10f24a4-49fe-51da-96c4-4a22a16358c28a48273b84c10f24a4-49fe-51da-96c4-4a22a16358c2cd /mnt/linux-redfs-sendfile && claude --resume c10f24a4-49fe-51da-96c4-4a22a16358c24fc2c00acdc10f24a4-49fe-51da-96c4-4a22a16358c2cd /mnt/linux-redfs-sendfile && claude --resume c10f24a4-49fe-51da-96c4-4a22a16358c23d504d10edc10f24a4-49fe-51da-96c4-4a22a16358c2cd /mnt/linux-redfs-keep && claude --resume c10f24a4-49fe-51da-96c4-4a22a16358c2