* mount: fail the write when the swap file chunk cannot be created
#7957 added a nil check after NewSwapFileChunk so a failed swap file
creation returns an error instead of panicking. The result was assigned
to pageChunk, a PageChunk interface, before the check, and an interface
holding a nil *SwapFileChunk is not nil, so the check never fired:
SaveDataAt stored the nil chunk and panicked in WriteDataAt.
Check the *SwapFileChunk before converting it. The new test points the
swap directory below a regular file; on master it panics in
SwapFileChunk.WriteDataAt.
Signed-off-by: anant <170962632+antcybersec@users.noreply.github.com>
* mount: grow the file only after its write is buffered
Write set the new size, times, pending append offset and uncommitted
bytes before AddPage. When AddPage failed (now that a swap file chunk
that cannot be created returns an error), the write was reported as
failed but the larger size stayed on the handle's entry, so the next
flush published it with a hole where the data should be.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: report a partly buffered write as a short write
PageWriter.AddPage fills one chunk at a time, so when a later chunk
cannot be created the earlier chunks already hold their bytes. Return
how much was buffered, and let Write grow the size and times over that
prefix and report it, instead of failing the whole write while the
prefix still reaches the next flush.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: report the bytes a failed copy_file_range already buffered
A streaming copy whose page fails partway returned an error even though
earlier pages, or the start of the failing one, were already buffered and
would reach the next flush with the destination size left short. Count
the buffered bytes, grow the destination over them, and return them as a
short copy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: free the copy test's destination pages
The buffered memory chunk counts toward the process-wide memory chunk
ceiling, so repeated runs of the test pushed later ones onto the
unusable swap directory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: count only the bytes a swap chunk stored
A swap chunk whose file write fails stores a prefix or nothing, but
SaveDataAt returned no error and AddPage counted the whole span as
buffered. SaveDataAt now reports the short write, and AddPage passes the
stored count up so a write is never acknowledged past it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: fail a partly buffered writeback write
Kernel writeback ignores the count in a WRITE reply, so a short write
there drops the unbuffered rest without an error. A write flagged as
page-cache writeback now keeps its buffered prefix but returns the
error, which the kernel reports on fsync.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Signed-off-by: anant <170962632+antcybersec@users.noreply.github.com>
Co-authored-by: anant <170962632+antcybersec@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Concurrent writers to one file from different mounts require -dlm; without it, a conflicting write fails with EIO and the file may refuse further appends until reopened after the cache drops.