diff options
| author | Paulo Alcantara <pc@manguebit.org> | 2026-10-29 13:37:17 -0300 |
|---|---|---|
| committer | Paulo Alcantara <pc@manguebit.org> | 2026-11-11 13:50:58 -0300 |
| commit | 59d223256f5912263a1a8d2b5b0c5abf9542cf7d (patch) | |
| tree | 2bcf2d64a87e48ea25372af06352ab1771ac59df /tools/perf/scripts/python | |
| parent | 64db0dc1f3e689145e698bc1b20ee70b1724b945 (diff) | |
smb: client: retry writeback after losing the connection, share or handle
Writeback still fails, dropping its data, when a write gets back an
error that only means the client lost track of the server for a while:
- -EHOSTDOWN from smb2_reconnect() when a soft mount's server stays
unreachable for longer than the reconnect wait, or from
STATUS_HOST_UNREACHABLE,
- -EREMCHG from STATUS_NETWORK_NAME_DELETED, for which the receive path
already marks the tcon for reconnect,
- -EBADF from STATUS_FILE_CLOSED or STATUS_INVALID_HANDLE, e.g. after
the server lost a durable handle,
- -ENETRESET and -ESHUTDOWN from STATUS_CONNECTION_RESET and
STATUS_REMOTE_DISCONNECT,
- any replayable error on SMB1, whose async write never retries them,
while it retries writes cut short by a reconnect forever, regardless
of soft mounts.
Reopening the handle needed by a read or write is worse:
cifs_prepare_write() and cifs_issue_read() retry cifs_reopen_file() only
on -EAGAIN, with no limit and no delay, and fail on anything else. A
server failing the reopen with a status mapped to -EAGAIN, such as
STATUS_INSUFFICIENT_RESOURCES, makes them spin forever, past umount -f
and, when netfs retries from a worker, with no signal to stop them,
while any of the errors above fails writeback right away.
Retry writeback failing with any of these, as already done for
interrupts and allocation failures, with backoff and giving up on umount
-f. On -EBADF, have the retry mark the handle invalid, so that it gets
reopened, unless it got reopened since the write was issued: a late
-EBADF would otherwise get the new handle replaced too, leaving it open
on the server along with any byte-range locks pushed to it. Subrequests
of the same request can fail -EBADF concurrently on different channels,
so record the bad reopen generation atomically (keeping the newest),
decide the invalidation under the handle lock, and have a reopen publish
its new fid before its generation so a -EBADF is attributed to the fid
that was actually sent.
When writeback finally gives up on any of these errors, record -EIO for
it instead, so that fsync(2) and close(2) don't return transient or
internal errors such as -EAGAIN or -ERESTARTSYS.
Retry reopens as the read or write needing them gets retried: as above
for writeback, otherwise per the hard and retrans mount options on
replayable errors, with backoff and giving up on umount -f. If any
channel of the session got reconnected meanwhile, retry once regardless,
as the reconnect may be what failed the reopen; the next attempt waits
for the reconnect to finish. Never retry reopens on interrupts or once
the task is dying, so that dying tasks don't spin there; for writeback,
issue the subrequest without credits instead, as done for dying tasks,
so that it gets retried from the netfs collector, where no signals are
pending.
Don't reopen for requests that predate a umount -f either, unless it is
a first attempt on a connected server, as with issuing them. Once a
reopen for writeback gives up, fail the other subrequests of the
request right away, rather than each waiting out a retry window of its
own.
Reopen handles for reads in prepare, before acquiring credits, as
already done for writes, so that reads don't hold credits across a
reopen. A read whose handle or credits went stale before it could be
sent is retried regardless of mount options, after the backoff, so that
prepare reopens and takes fresh credits; check a write's credits the
same way.
Fixes: 69c3c023af25 ("cifs: Implement netfslib hooks")
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
