* 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>
* mount: keep retrying writeback chunk uploads through a volume outage
With -writebackCache, close() returns before the data is uploaded. When
the volume servers stay unreachable past the upload's own retry (~20 s),
the chunk was dropped and the file never appeared, with no error to the
application. Retry transient upload errors with the same bytes until they
succeed, unless the dirty pages were discarded. Permanent errors and the
synchronous mode keep failing as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: test writeback upload retries and the cases that still fail
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* operation: keep the filer's read-only verdict on assign failures
UploadWithRetry flattened AssignVolumeResponse errors into a string, so
callers could not tell a read-only rule from an outage. Wrap the filer's
coded error so errors.Is(err, filer_pb.ErrReadOnly) works; the message is
unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: retry writeback uploads the upload layer reassigns, never read-only
A filer proxy that cannot reach the volume answers 500 with an empty
body, which util.IsTransientError does not match, so that outage still
dropped the chunk. Also retry what operation.ShouldReassignUpload takes.
A read-only rule stays final even when its path or message contains a
transient word such as "unavailable".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: stop a writeback upload once its dirty pages are discarded
Destroy() was only seen after a failed attempt, so a truncate during the
retry wait still started another upload, and a chunk that finished after
its pages were replaced was attached to the new content. Check before
each attempt, and drop the chunk instead of attaching it; volume.fsck
reclaims it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep Destroy from slipping between the discard check and the append
truncateEntry destroys the pages and then installs the new entry, so a
Destroy landing after the check but before AddChunks put the old chunk
into the replacing entry. Hold one lock across the check and the append,
and take it in Destroy while setting the flag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: leave the Windows interrupt drain to the capped filesystem hook
Interrupt hooks run in reverse registration order, so the Windows hook ran
before the filesystem hook and waited on pending writeback flushes without a
bound. With writeback uploads now retrying through an outage, Ctrl-C could
wait until the volume servers came back. Unmount only, as on Linux, and let
the filesystem hook drain for at most 30 s and keep the write cache.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: test a writeback upload whose assign keeps timing out
With every volume server gone the assign RPC times out until the filer
client gives up; that error must be retried like a refused upload.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
When every volume is full, a chunk upload fails only after the assign
retry budget, the failed chunk's data is dropped, and the mount kept
accepting writes anyway. cp would crawl for hours pushing the rest of
the file through a pipeline that could not persist it, and only close()
reported an error - a generic EIO.
Poison the file handle on the first failed chunk upload so subsequent
writes fail immediately, and map "no writable volumes" / "no free
volumes" upload errors to ENOSPC so the writing process aborts with
"No space left on device". Also guard lastErr with a mutex: it was
written concurrently by uploader goroutines, and keep the first error
so later failures do not mask the root cause.