Re: [PATCH v2 0/2] ceph: serialize O_APPEND writes across clients
From: Xiubo Li
Date: Wed Dec 02 2026 - 07:54:46 EST
Hi Alex,
Thanks for the careful review. I could reproduce all three on a vstart
cluster with the MDS side, two kernel mounts (KASAN + lockdep), and
they are fixed in v3:
> In patch 1, if allocation of a size-bearing cap flush fails,
> __send_cap() advances the ticket without queuing the update. A later
> cap release can then reach the MDS before the size update, so the
> next appender can get the old EOF. Please keep the release behind the
> size update on allocation failure too.
Right. With a test hook that fails the allocation of every third
flush message, v2 lost 4 records after 5 dropped flushes. v3 allocates
a message that flushes dirty caps with __GFP_NOFAIL, so the flush can
no longer be dropped and the later messages stay behind it (the same
hook then only delays the allocation by 20 ms: 136 delayed flushes, no
record lost).
> In patch 2, if the MDS revokes Fx before the waiting appender takes
> its references, try_flush_caps() and flush replay can acknowledge the
> revoke even though ceph_check_caps() would preserve the reserved turn.
> The appender then has to request another turn. Please make both flush
> paths honor the reservation while still allowing the appender to yield.
Right. It needs dirty caps while the turn is reserved, which an mmap
writer on the same client gives (page_mkwrite does not take the inode
lock that the waiting O_APPEND write holds); with an fsync loop next to
it v2 lost the turn on the flush path in every run. v3 adds the
reserved turn caps to "used" in __prep_cap(), so every caller,
ceph_check_caps(), try_flush_caps() and __kick_flushing_caps(), keeps
them; __ceph_append_turn_caps() returns nothing once the write gave the
turn up, so it can still yield.
> Requiring Fx can also make the appender wait when Fw is already
> available. If EOF advances during that wait, the write can exceed
> RLIMIT_FSIZE because the VFS check used the old offset. The old EOF
> adjustment had the same omission. Please enforce the VFS write limits
> against the final append position and count before submitting the write.
Right. With a 4 MiB RLIMIT_FSIZE and the other client appending 1 MiB
chunks across it, v2 let 3 of 582 writes end about 1 MiB past the
limit. v3 calls generic_write_check_limits() for the adjusted
position and count (SIGXFSZ and -EFBIG, or a shorter write), so none
did in 596.
The mmap test also turned up an older problem, which v3 fixes in a new
first patch: ceph_filemap_fault() faults pages in also with Fr only,
and ceph_init_request() lets its read-around through because it has an
rw context, so the neighbouring folios end up in the page cache without
Fc. No Fc revoke ever drops them, and once the client gets Fc and Fb
again a buffered write writes such a stale folio back over the other
client's data. With the turns of this series that happens on every
turn change (62-88 of 1200 records zeroed with an mmap writer, v2 as
well), and none with MADV_RANDOM on the mapping, nor in 3 runs with
well), and none with MADV_RANDOM on the mapping, nor in 3 runs with
v3.
Thanks,
Xiubo
On Mon, 30 Nov 2026 at 17:54, Alex Markuze <amarkuze@xxxxxxxxxx> wrote:
>
> Hi Xiubo,
>
> Thanks for adding the fallback when the auth MDS doesn't support
> APPEND_EXCL.
>
> In patch 1, if allocation of a size-bearing cap flush fails,
> __send_cap() advances the ticket without queuing the update. A later
> cap release can then reach the MDS before the size update, so the
> next appender can get the old EOF. Please keep the release behind the
> size update on allocation failure too.
>
> In patch 2, if the MDS revokes Fx before the waiting appender takes
> its references, try_flush_caps() and flush replay can acknowledge the
> revoke even though ceph_check_caps() would preserve the reserved turn.
> The appender then has to request another turn. Please make both flush
> paths honor the reservation while still allowing the appender to yield.
>
> Requiring Fx can also make the appender wait when Fw is already
> available. If EOF advances during that wait, the write can exceed
> RLIMIT_FSIZE because the VFS check used the old offset. The old EOF
> adjustment had the same omission. Please enforce the VFS write limits
> against the final append position and count before submitting the write.
>
> Thanks,
> Alex