Repository navigation
Conversation
achhenderson
left a comment
There was a problem hiding this comment.
I found this while testing the 6.8 ports of #288 and #289 on top of this PR's head.
6da6b89 needs c5f0e22 to avoid hangs with the writeback cache
On Ubuntu 6.8.0-149 with redfs.ko built from 7326b13 and a mount with the writeback cache (the way CI mounts), a buffered write followed by almost anything hangs:
- my 18-check smoke test hangs in its first check (a 64 MiB buffered write);
- a reproducer that writes, maps, stores and truncates hung in 12 of 12 runs, in
fstat()when the file already existed and inftruncate()when it was new.
It happens with redfsd from release/2.5 with and without the RED-54533 fix. Without the writeback cache nothing hangs.
Where things sit (first hang, the fstat() shape):
application: vfs_fstat -> fuse_getattr -> fuse_update_get_attr -> fuse_do_statx -> request_wait_answer
rfs_inval_0: fuse_dev_do_write -> fuse_reverse_inval_inode -> sync_inode_metadata -> write_inode
-> fuse_write_inode -> fuse_flush_times -> fuse_simple_request -> request_wait_answer
redfsd: the getattr and the SETATTR from fuse_flush_times() never finish
The notify handler is waiting for a SETATTR that it sent itself, while the server is waiting for that notify to return.
Cause: FATTR_WRITEBACK is not on 6.8
6da6b89 ("fuse: flush dirty times when a whole-file DLM revoke drops the write grant") sends the times from inside fuse_reverse_inval_inode() and relies on the server letting "the WRITEBACK SETATTR's CW past the pending conflicting lock". On 6.17 and 6.12 fuse_flush_times() marks that request with FATTR_WRITEBACK (c5f0e22, "fuse: mark writeback-initiated SETATTR with FATTR_WRITEBACK"). 6.8 does not have that commit and this PR does not bring it, so the SETATTR goes out unmarked.
redfs.ko built from |
writeback cache: reproducer | smoke test |
|---|---|---|
| 6.8 branch tip (6c84e67) | 3 of 3 runs clean | 18 of 18 |
| this PR's head (7326b13) | hangs, 12 of 12 runs | hangs in the first check |
| head with 6da6b89 reverted | 4 of 4 runs clean | 18 of 18 |
| head plus a port of c5f0e22 | 4 of 4 runs clean | 18 of 18 |
| 6.17 branch tip (has both commits) | 11 of 11 runs clean | not run |
So the series needs c5f0e22, before the time-stamp commits. It cherry-picks onto the head with one conflict, in the INIT flag list of fuse_new_init(): 6.8 does not have FUSE_HAS_RESEND, FUSE_ALLOW_IDMAP and FUSE_REQUEST_TIMEOUT there, so the 6.8 list stays and only FUSE_SETATTR_WRITEBACK is added. Bit 58 is free on 6.8.
A question rather than a finding: a server that does not negotiate FUSE_SETATTR_WRITEBACK would get the same unmarked SETATTR from the notify handler on 6.17 and 6.12 too. Should the flush in fuse_reverse_inval_inode() depend on fc->setattr_writeback? I could not test that case.
What else I ran on the head plus the c5f0e22 port
93 tests of the CI pass list (the ones that take under 30 s, plus generic/029 and 030), with the writeback cache, against the same run on the branch tip:
- 89 pass on both.
- generic/113 hangs on both, so it is not from this PR (next section).
- The remaining failures are the harness's "daemon exists but mount point does not" check: generic/465 on both, 568 on the tip only, 123 on the PR only (right after the aborted 113).
I have not reviewed the other 20 commits line by line, so this is a test report more than a code review. One nit: b7b81a1 still has the subject prefix "Linux 6.12:fuse:".
Separate from this PR: generic/113 hangs on 6.8 with the writeback cache
This one is on the branch tip as it is, which is the source of the packaged 6.8 module. generic/113 (aio-stress) hung in 8 of 13 runs with the writeback cache (2 of 5 with the RED-54533 fix in redfsd, 6 of 8 without it) and in 0 of 8 without the cache. On 7.0 and 6.12 it passed 12 of 12 runs each with the cache. With this PR plus the c5f0e22 port it hung in the one run I made.
It always stops in the test's second step, aio-stress -t 20 -s 10m (20 threads doing buffered AIO writes, one file each), in one of two shapes:
- Six of the eight hangs on the tip: all four notify threads in
fuse_reverse_inval_inode(), inpercpu_down_write()on the coherency gate; 12 to 15 writers inbalance_dirty_pages()underfuse_cache_write_iter(), which holds the read side of the gate there; the other writers waiting for a statx. At redfsd one SETATTR and four to six getattrs never finish. In the hang where the flusher was captured, it was infuse_write_inode() -> fuse_flush_times()waiting for a SETATTR. - The other two (both without the RED-54533 fix), and the run with this PR plus the port: the notify threads are past the gate and wait for writeback of a folio (
fuse_launder_folio() -> folio_wait_writeback()on the tip); the writers wait for a statx, a DLM lock request or a direct write. At redfsd 12 to 16 getattrs and three or four lock requests never finish.
This is not the client-eviction case of RED-54188. In every one of these hangs redfsd stayed up, was not evicted and kept answering the servers (no ping failed during any of them), and aborting the connection, by redfsd's watchdog after 600 s or by hand, ended the hang.
Two things that may help: the blocking write side of the gate (d398cdf) is only on 6.8, where 6.12, 6.17 and 7.0 have the range lock; and on 6.8 each of the last eight runs with the cache, hanging or not, logged "latched to direct IO on invalidation notify storm", which 6.12 and 7.0 did not do once in ten runs each. I have not established the cause. Kernel stacks, hung-task reports and redfsd trace dumps of the hangs are saved.
Our 6.8 ports
The 6.8 ports of #288 (truncate with dirty mapped pages) and #289 (OFD and flock unlock at the last close) are ready and pass their reproducers on the branch tip and on top of this head. The truncate port adds a block in fuse_do_setattr() at the place where 95babd7 adds one, so the two conflict textually; both blocks stay. To keep this PR from having to rebase, I will send the 6.8 ports after it is merged, on top of it. The 6.17 and 6.12 ports are in #292, #293, #294 and #295.
|
@achhenderson Thanks! Will fix ASAP |
7326b13 to
c0aa203
Compare
fuse_write_inode() -> fuse_flush_times() pushes out the mtime/ctime that the kernel owns locally while the writeback cache is on. On the wire that request is indistinguishable from a userspace "touch -m": both arrive as SETATTR with FATTR_MTIME | FATTR_CTIME | FATTR_FH, because trust_local_cmtime makes iattr_to_fattr() send CTIME whenever the writeback cache is enabled. A server that wants to handle a cache flush differently from an explicit attribute change - skipping a cluster-wide lock, merging rather than overwriting - has no way to tell them apart. Add FATTR_WRITEBACK, a control bit in fuse_setattr_in.valid alongside the existing non-attribute bits FATTR_FH, FATTR_LOCKOWNER and FATTR_KILL_SUIDGID. It selects no attribute, it only states that the request originates from writeback. Bit 30 is used rather than the next free one. libfuse mirrors the wire bits into its own FUSE_SET_ATTR_* namespace, where bits 12 to 17 are already taken by library-internal flags, and it masks incoming requests against that namespace; a bit picked from the low end would collide there and need translating on the way in. Bit 30 is free on both sides and clear of the sign bit of the int that the libfuse setattr operation takes, so one value works end to end. The bit is negotiated at INIT time with FUSE_SETATTR_WRITEBACK and is only set on a connection whose server asked for it, so servers that do not know the bit never receive it. Only ->write_inode() is marked. The other kernel-initiated SETATTR, fuse_do_truncate() rolling back a failed extending direct-IO write, is deliberately left unmarked: it is a size correction rather than an attribute writeback, and conflating the two would make the flag ambiguous. 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>
A shared mapping can write past EOF within the last folio, and nothing owns those bytes until the file grows over them. iomap zeroes them from iomap_write_end() and 6.13 from pagecache_isize_extended(); this base does neither, and the classic write path never touches a folio its write does not land in. A write, a direct write, a fallocate or a truncate extending the file then exposed them. Zero the exposed part of the old EOF folio before the new size is published, under the folio lock and only while i_size still is what was read. A concurrent writer filling the gap moves i_size under fi->lock from behind the same folio lock, so the check keeps its data out of the zeroing, and it zeroed its own gap before moving the size. Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
…OF under DLM With the writeback cache and DLM, ior-hard (47008-byte transfers into one shared file from several clients) reads back zeros in pages that ranks on two client nodes share. Under DLM the local i_size is only this node's view: a write refreshes STATX_MODE, not the size, and the grant does not carry it. Once another node has extended the file, two paths trust the stale size and zero that node's bytes, and writeback sends the zeros over them once this node's i_size covers the folio. fuse_write_begin() skips the read-modify-write READ for a partial folio that starts at or past the local i_size and zero-fills it instead. Under DLM, read it. The write grant is page-aligned and was granted only after the previous holder's revoke flushed the page, so the read is coherent, and a true hole still reads back as zeros. It adds no new kind of wait under the LOCKED range: the same READ is already issued for every partial folio inside the known size. The cost is at most two READs per write beyond the local i_size. fuse_zero_eof_gap() zeroes the cached old-EOF folio from the local i_size to its end before an extending write, assuming the server's side of that gap is a hole. Under DLM a folio read from the server can hold another node's bytes there, and the read above makes that common. The bytes this function exists to clear can only come from a shared writable mapping, so add FUSE_I_SHARED_WRITE_MMAP, set in fuse_file_mmap() for such a mapping and never cleared, and skip the zeroing under DLM with the writeback cache unless it is set. A file both mapped shared-writable and written from several nodes keeps the old behavioour. [hbi: adapted to the page-based fuse_write_begin() of 6.8] Signed-off-by: <Yong Ze Chen> <yochen@ddn.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fuse: send O_DIRECT writes direct under DLM with writeback cache An O_DIRECT write on an inode in caching mode, for example after fcntl(F_SETFL, O_DIRECT) on a file opened without it, went through fuse_cache_write_iter(). Under DLM with the writeback cache it took a DLM write grant and a LOCKED range lock, then called generic_file_direct_write(), then the server takes the DLM lock for it itself. That may revoke this client's grant, and the NOTIFY_INVAL_INODE that follows waits in fuse_range_lock_acquire_locked() for the range lock held by the writer. The writer is waiting for the WRITE reply, so neither side makes progress, and writers on other clients hang in fuse_get_dlm_lock() behind the grant that is never released. Send these writes to fuse_direct_write_iter() together with the forced direct IO case. That path takes neither a DLM grant nor a range lock, and the server locks the range for the WRITE as it does for FOPEN_DIRECT_IO files. fuse_direct_write_iter() did not write back dirty folios unless the file was opened with FOPEN_DIRECT_IO. Its invalidation after the write would then launder stale dirty folios over the data just written. It now writes back the range under the inode lock, after generic_write_checks() has fixed the final position, as generic_file_direct_write() does. Doing it under the inode lock keeps a concurrent buffered writer from dirtying the range again before the WRITE is sent. FOPEN_DIRECT_IO files skip this step since fuse_direct_io() already flushes for them. [hbi: noble has the coherency gate where 6.17 has the range lock] Signed-off-by: Hai Zhong Zhou <hazhou@ddn.com>
With the writeback cache and DLM, a truncate on the server revokes this client's locks. The NOTIFY_INVAL_INODE that follows then has to write back any folio that is still dirty. Those writes are held by the server behind the same truncate, and the truncate waits for the invalidate to finish, so the two wait on each other. Write the dirty folios back before the server sees the truncate, in both places that send one: the atomic O_TRUNC case in fuse_open() and a truncating SETATTR in fuse_do_setattr(). Both are limited to the writeback cache with DLM, the only configuration that revokes locks on truncate. In fuse_open() the flush runs under i_rwsem, before the full-range write lock is taken, so cached writers cannot dirty the file again before the OPEN. This writes back data that the truncate is about to discard, which costs some I/O. Dropping the pages first is not safe, because the revoke and the invalidate still need a clean cache. Later we need to work with DLM to optimize the performance of such truncate. [hbi: no O_TRUNC range lock on noble, the open flush tests is_wb_truncate && fc->dlm] Signed-off-by: Hai Zhong Zhou <hazhou@ddn.com>
With the writeback cache and DLM, a revoke from the server reaches fuse_reverse_inval_inode(), which takes the LOCKED range lock and calls invalidate_inode_pages2_range() on the revoked range. Dirty folios in that range are then written back one at a time through launder_folio, each with its own synchronous WRITE, and the server keeps the conflicting grant until the last one completes. Write grants can cover gigabytes (the server widens them toward end of file), so on ior-hard (47008-byte transfers into one shared file) a single revoke took 8 to 16 seconds, and every rank on every other node that needed a lock in that range waited for it. The node that kept its grant ran far ahead, and the io500 stonewall wearout then made every rank catch up to it. Write the range back with filemap_fdatawrite_range() before the invalidate, so the dirty folios go out as normal batched writeback. The LOCKED range lock already keeps cached writers out of the range, so nothing can dirty it again before the invalidate; anything still dirty is laundered as before. The writeback path takes neither the range lock nor a DLM lock, so flushing while holding the range lock cannot deadlock. When the inode is latched to direct IO the whole mapping is dropped, so the whole mapping is written back. The end of the range is clamped to LLONG_MAX so a large offset and length from the server cannot overflow. The wait uses filemap_fdatawait_range_keep_errors() rather than filemap_write_and_wait_range(): the latter ends in filemap_check_errors(), which clears AS_EIO/AS_ENOSPC, and fuse_flush() reads only those flags, so a write-back error during a revoke would never reach close(). A failure is also logged, ratelimited, since the revoke itself has nowhere to return it. Only the DLM + writeback-cache path flushes first. That is the path whose revokes arrive under contention with large dirty ranges, and it already holds the LOCKED range lock that keeps the flush and the invalidate consistent. Other invalidations keep the old behaviour. Measured on 6.12 (Rocky 10, 6.12.0-211.16.1.el10_2.0.1), the redfs.ko build of this change, smc-a9 clients, 32 ranks per node, ior-hard write. A 60 s run on 6 nodes went from 94 to 2066 transfers for the slowest rank, and no DLM lock request waited 8 s or more (96 to 116 per trailing node before). io500 ior-hard-write on 20 nodes took 1675 s at 0.593 GiB/s, against 12508 s at 0.423 GiB/s without it. [hbi: noble flushes under the coherency gate's write side, which writeback never takes] Signed-off-by: Yong Ze Chen <yochen@ddn.com>
This reverts commit a757b2d. Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
An O_TRUNC open stamped mtime and ctime from the local clock after the server had truncated and stamped the file on FUSE_OPEN. The local stamp dirtied the inode, was flushed back to the server in a SETATTR and, with the writeback cache, outlived every later reply from the server. The page cache is empty after the truncate, so nothing local is newer than the server's stamps. Take them from the attributes the open fetched with it where the server supports the compound, and otherwise from a statx on the file handle asking for the two stamps alone, so the server computes neither size nor blocks; a server without statx answers a GETATTR. Set them directly: fuse_change_attributes() keeps the cached stamps for a writeback inode and drops a reply an update since has overtaken. A failed request leaves the attributes invalidated for the next stat. [hbi: noble has no ff->args; the open's attributes are kept in ff->release_args] Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
With the writeback cache, unlink updates the inode's ctime and fuse_update_ctime_in_cache() writes it out at once, so ->write_inode sends a WRITEBACK SETATTR for the inode the unlink just removed. When the file was not open anywhere, the server deleted the iattr and the object attributes in the unlink, and this SETATTR arrives about a millisecond later. The server serves a writeback SETATTR without waiting on other locks and writes back its cached copy of the attributes, which re-creates both on the server with no name pointing at them. rfs_debug then reports the inode as a leaked resource. Skip the times flush when the inode has no names left and this node holds no writable open on it. Without such an open this node wrote nothing whose times matter, the only dirty time is the ctime of the unlink itself, and the server may already have deleted the inode. A writable open on this node keeps the server's inode alive until the last close, so an unlinked file still being written keeps sending its times, and other nodes go on seeing them. An O_TMPFILE inode also has nlink 0 but can still be linked, so I_LINKABLE inodes are flushed as before. Signed-off-by: Hai Zhong Zhou <hazhou@ddn.com> (cherry picked from commit c8a44f8)
On a writeback cache mount, the kernel owns cmtime, so iattr_to_fattr() never sent FATTR_MTIME_NOW. A "now" utimes sent the client's coarse current_time() as a plain mtime value, plus the client's ctime. A file's other times come from the server's clock, so when the client clock ran behind the server's, utimensat(UTIME_NOW) right after create could set an mtime no later than the create time, and mtime did not advance or moved backwards. atime was always sent with FATTR_ATIME_NOW and stayed on the server's clock. With DLM, the server is already the authority for these times, see fuse_get_cache_mask() returns 0, so fuse_do_setattr() replaces the locally set mtime and ctime with the server's reply anyway. So for a request without ATTR_MTIME_SET on a DLM mount, the kernel now sends FATTR_MTIME_NOW and leaves out FATTR_CTIME. The serer stamps both with its own clock, as it does for ctime whenever FUSE_SETATTR_CTIME is absent, and the reply brings those values back to the inode. Explicit times and non-DLM mounts are unchanged, ftruncate() on a DLM writeback mount also takes this path, since it changes mtime without ATTR_MTIME_SET. Now the remaining part is cache writes still stamp mtime with the client clock, as we have no way to know the server's time at the time of dirtying page cache. (imported from commit f0e5ca7)
With the writeback cache the kernel stamped mtime and ctime for every change and flushed them to the server, which stamps those changes itself. Set S_NOCMTIME on all inodes and stamp only when a buffered write or page_mkwrite dirties the page cache, since the server does not see that data until writeback. All other changes leave the times to the server. Without DLM, keep the cached times over a server reply only while the mapping is dirty, or the server's stamps would never reach the inode. A SETATTR reply always sets them. [hbi: hand port; noble has no fuse_attr_cache_mask(), fuse_get_cache_mask() keeps the times only while the mapping is dirty for DLM too] Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
…grant Under DLM with the writeback cache, a write takes a write grant, which holds the sattr lock in CW, and file_update_time() only marks the inode's times dirty. When another request needs sattr PR, for example a stat on this or another node, fuse_reverse_inval_inode() writes back and drops the pages, but the dirty times survive the revoke. Close or the flusher sends them later as a WRITEBACK SETATTR. By then this node may hold sattr PR again, and the server has to revoke this node's own PR to grant the SETATTR's CW. In RED-52104 that revoke queued on the node's invalidation thread behind a stuck page-cache invalidation, and the SETATTR hung for more than ten minutes holding an RPC credit. A sattr revoke always reaches the kernel as a whole-file invalidation. Times are dirtied only under a write grant, so dirty times at a whole-file revoke mean the CW being revoked is this node's. Send them with sync_inode_metadata() after the pages are written back and dropped, while the range lock is still held. The server still sees this node's CW as granted, so the SETATTR's CW is granted past the pending conflicting lock instead of waiting for it, and the node that asked for PR sees this node's times. [hbi: noble flushes under the coherency gate's write side] Signed-off-by: Hai Zhong Zhou <hazhou@ddn.com> (imported from commit 9973e48)
Under DLM the server owns the size, blocks, mtime and ctime of a file another node writes through its writeback cache. To answer a statx exactly, it has to revoke or downgrade that node's write grant, forcing a flush and a later re-acquire. A plain ls -l, find or monitoring agent on one node can so keep breaking the grant of a writer on another. Add FUSE_STATX_LIGHT to fuse_statx_in.sx_flags, telling the server that the caller does not need cluster-coherent size, blocks and timestamps and that it may answer from its current values without recalling locks. It is only sent with the writeback cache on, for a user stat() of a regular file without AT_STATX_FORCE_SYNC. Internal attribute updates (SEEK_END, O_APPEND, EOF checks, permission checks, setattr) keep sending full requests. A light reply with a zero attr_valid may lag behind writes, so it does not update the inode: a stale size must not shrink i_size or the page cache, and i_time, inval_mask and FUSE_I_DLM_LOCKED stay as they were. It only fills the kstat, taking the larger size and the later mtime/ctime of the reply and the inode, so this node still sees its own unflushed writes. A non-zero attr_valid says the values are coherent: the reply updates the inode and is cached like a full one. Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
A read served from the page cache never reaches the server, so the server cannot update atime for it. Record on the inode a cached read(2), splice, sendfile or read fault, unless the file has O_NOATIME. A FUSE_READ, a DLM read lock request, a write, truncate, fallocate or an explicit atime set clears the record. The first release after it reports it with FUSE_RELEASE_CACHED_READ and clears it, so the server stamps atime at release. Signed-off-by: Yan, Zheng <zyan@ddn.com> Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
fuse_writepage_need_send() tests the next alignment against wbc->range_end, a page index against a byte offset, so a ranged writeback never ends a request at the last alignment boundary before the range end. Convert the bound to a page index as the 6.17 tree does. Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
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. [hbi: noble has no uring_critical and no write_flags argument] 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. [hbi: noble has no critical entries and no FUSE_WRITE_CACHE piece here, so with the writeback cache it always keeps a single piece in flight] Signed-off-by: Sven Oehme <soehme@ddn.com> Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
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>
…er DLM A write that drops suid/sgid on a writeback inode under DLM went to the writethrough path, holding the coherency gate across a WRITE without FUSE_WRITE_CACHE. The server takes the DLM lock for such a write and may revoke a grant of this node first; the NOTIFY_INVAL_INODE for that waits on the gate's write side, and the write waits for the server. Without handle_killpriv_v2 the write stayed on the writeback path, where file_remove_privs() sends a SETATTR with the gate held. As on 6.17, send every such write under DLM through the writethrough path, which holds no grant, and do not take the gate there. The forced-DIO latch is re-checked under the inode lock. Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
c0aa203 to
47bc06b
Compare
|
ran xfstest on pure FUSE: This looks OK to me 029 and 030 fail due to some different formatting of the output, not due to kernel related reasons |
achhenderson
left a comment
There was a problem hiding this comment.
Looks good now, thanks Horst!
fuse: sync noble 6.8 with 6.17 (DLM fixes, time stamps, RED-54742)
Ports to the 6.8 base; adaptations are in the [hbi: ...] lines.
EOF, O_DIRECT writes sent direct, flush before truncate and before a
revoke's invalidate.
dirtied in the page cache. Reverts the SETATTR stamping patch.
support).
buffered writes; killable waits.
suid-dropping write under DLM.