Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796035880; b=VQbVtSG/j+qOaovNbPi1pgYsDFktZJhcyggPW6LR89Z82M1a2uAdgCEH4t4L2XGImD8W 6UQbIQtJtdkUHZFablof6sj4FOVxOv7/0lUe4wYuzU9IdcAukVE3W7ykKnEvapvvQFZ3b Lf4ueQTmb6SDf6VyU1ev8BRf/xKYnVqYy3vioV7zdgvxUiKrdTSybnvhTUG4+ReYupYHN wFxlDxzKPjbtmYndUdHu5s1bmZR4q+nvzLJwS7N6eNOvbQWV7S3oTjURyRc29PIcqKTCf lKiernftbN9jObixj5waCHKXUjenL+84T5fjfxhrDwuAABU8ldJ58v9rDy6Tx3b7JUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796035880; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=Iv3zN+Tcn1yHKsJ/ern0GC/2iK4IcNsYrGVeSanVzuY=; b=ELldeVZb/i/Lsf3NUZTamPcTGa6UvMpldXU/ufyIIgLU7I1RJoYU+GHD45qPTiicz+Da mQRGIs3X1aZciSRmmW9ATj1J4G41i7MxgYzCxPJtxLXmF+3WPRIaL5RyK7li7XuK8FlQA 2ilnEwAadltZeb2ejVMqSr0my1nE8el0IbFWaB1iHuzHjZkeIIxObz+ygU03gNboBz1H1 +d8EJ/NcuFyi5Xdsw88+C/7dHVts8cW8W1ERDlqtkpcx3cUIpBRgpTEpiMWv3+c3al82h CfhQT7WeUdS8TUEwjPRRekPY5ljXSxXBgj6RY/8unnZ7ka0JMacvg7gRRlfIHuAO3Qg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tDzImZ+t; arc=none smtp.remote-ip=209.85.208.49 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0B59606A320 for ; Mon, 30 Nov 2026 10:51:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A0B59606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tDzImZ+t Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-6b894d9a075so11271918a12.2 for ; Mon, 30 Nov 2026 02:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796035878; x=1796640678; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Iv3zN+Tcn1yHKsJ/ern0GC/2iK4IcNsYrGVeSanVzuY=; b=tDzImZ+ta63jyXYsi3NwasyokG3rovieHzf9tp7dI1DJCWR0YxzP23T8gq4i/flgxb ruE2Uby5zMcinops6uVA43KUYY8rbcv9RUM5Qkj+09ylT8Iq/D4R47Bm3TAS6vmztJtI L4PZUwpMAuaw21PT9qq8IHgTcXwcUYSSE0IDNibuYqmhCMDSX+RMInCBuqjOskq6KOcn ym38vYuad/QxGPCKLG01Acx+JwHeVHZwRziad3xJhtJ3EuyVTWvJsA6KBE/SKGpaG4Eu SDnJtGTATHHDPAC/gvt4zEA++Mw2AOQF5X4FEuK1u09l+V2A0yOxa0tiVYh4JCYsQsXa iMeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796035878; x=1796640678; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Iv3zN+Tcn1yHKsJ/ern0GC/2iK4IcNsYrGVeSanVzuY=; b=O35/MekTFUkLi2C2Vkl6IcV4NMSX8kiGxgn/FSsHAUMKWL0Gt7Z+EOAQsgVkUMmEB7 5/6tvUe0G0ovs3l2jK4fXtvm13ET0W/ma+Ey2jKA0s0af8cl5IuJSInrjvTkPCXiAUYs BRkmr3ufE0LabsHST3qKd48qE/UT8To7dMRMMEGYzYRjKixfJh8jxukmZiYD1n2dkZEr C0Fpg+8k/Wjwtftj0W0XfSvacfezVj1LHNw+B2DyWlHsn/jJpacmVh48bmjYpyaH09KM bY4dfH1ejpSNF3VaNlhJ9S3LeMRWNxnI7rOIZTmqkzqLdf1tHCG9Jr6Nwq//+1DmovP7 NSZw== X-Gm-Message-State: APuU4Z8y+qxa5qMOLwrreRO5DUVvKXq4Mw8Pj6SukLuDHtTrZZ9+ZQmG E7dS1j8xzwtQ2Aq4NHH6Og8KJs6XWfAeMSFmcPmC5R0qVBvO9AoVeZpX X-Gm-Gg: AZFdTZe2f/ioOAGMTrhjrduLHPl8skB6/VohavEScpG50cMg/QK6qNS07T9C3bzQ8Xu ItuWvF3h7PWPKuPAPdKI7pzewXYO3DeqKxIyQOJuoWAfeAXAoYYtF4vJ8vVkatiYEOr7b7bdQLc QmynShRuAReh3UuSspJPXfhWlw1+0AIPYHbuY5RqcbdNfpHROn8vUkhKWMN9kKBUK0ffkli4xtl cPB58KtrkYAZgsrGobcCEYI5gFwVlOELFxYAfld30EYpe5K0RIzlebYOeEKgXwpf6tH8UOsfe1J DqUBLaLhvK1p/a7SVFvLUO6yGcLEWrElnLBvHqF/dObm5K4PFlkhDPcJvQrXD/135ye3E/4fgpp vpNlS7TFYI0kNs4ygPa9TlCy9vmdx4IM3BHfzV+gy75+Mz5R3zjJfXA1f2Mc3Snng18j8a6vLY6 Y+BSjOV67SY9+kG4/H8R1Sl/BQgpT/MN7K/3EiJk80uasackSKLqnrWq87/8hvCZF+M65xOjprk hYAP4eNZZrstiNxockC4CjxmGgKwfRyQ+enVGh5dDdQmAcbOJJFMzr4jsj7R6lVC4jiulKnRSHU DKBgm7YGnl8TEEkXXaiF5/sE+fHOeZiblJ6GA57sjiyS7sa6jKk9hnwGFveJRLy2mOVpY9ECuY8 gdgI32Uk= X-Received: by 2002:a05:6402:d09:b0:6bb:6df:1fc1 with SMTP id 4fb4d7f45d1cf-6bb06df246emr13460122a12.24.1796035877532; Mon, 30 Nov 2026 02:51:17 -0800 (PST) Received: from docker-desktop (host-145-14-240-255.wtvk.pl. [145.14.240.255]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6bb07844211sm7921852a12.6.2026.11.30.02.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 02:51:17 -0800 (PST) From: Marcin Krystianc To: Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: linux-nfs@vger.kernel.org, Marcin Krystianc Subject: [PATCH] SUNRPC: resend a request whose reply asked for a retry Date: Mon, 30 Nov 2026 10:50:45 +0000 Message-ID: <20261130105045.1952667-1-marcin.krystianc@gmail.com> X-Mailer: git-send-email 2.51.0 X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit [BUG] xfstests generic/761 fails over NFSv4 with sec=krb5i. write() on an O_DIRECT file returns EACCES. The test changes the write buffer from a second thread while the write is in flight. With krb5i the client computes the RPCSEC_GSS integrity checksum over the live pages, so some WRITEs reach the server with a checksum that does not match the data. The client is expected to send the request again. It does not. [CAUSE] When rpc_decode_header() gets a reply it treats as possibly garbled, it decrements tk_garb_retry and returns -EAGAIN. call_decode() then calls xprt_conditional_disconnect() when the client has cl_discrtry set, and moves the task to call_encode(). call_encode() encodes only when rpc_task_need_encode() says so. For a task that was already sent with RPC_TASK_NO_RETRANS_TIMEOUT set, as every NFSv4 task is, that requires xprt_request_need_retransmit(), i.e. a connection that has already dropped. The disconnect is only queued on xprtiod, so call_encode() can run before it. The task then skips the encode and the transmit, goes on to call_decode() with rq_reply_bytes_recvd still set, and decodes the same rejected reply again. Two more passes use up tk_garb_retry and the RPC fails without the request being sent a second time. Until commit cc204d01262a ("SUNRPC: Dequeue the request from the receive queue while we're re-encoding"), the -EAGAIN case of call_decode() cleared rq_reply_bytes_recvd itself. That commit moved the clearing into rpc_xdr_encode(), which this path does not reach because rpc_task_need_encode() returns false. Since then the rejected reply is neither cleared nor replaced. [FIX] I have considered the following ideas to solve the problem: - Copy the payload before computing the krb5i checksum The checksum then always matches what is sent, so the server does not reject the WRITE. generic/761 passed 5 of 5 runs with such a copy. But it costs a copy of every krb5i payload. - Clear rq_reply_bytes_recvd in call_decode() again and wait for the disconnect The request would also have to be put back on the receive queue so that the task sleeps. And without cl_discrtry there is no disconnect to wake it. Not tested. - Treat a received reply as a reason to retransmit This is the solution utilized by this patch. rpc_task_need_encode() now also returns true when xprt_request_data_received() says a reply has been received. call_encode() runs with a received reply when rpc_decode_header() rejected that reply. rpc_xdr_encode() clears rq_reply_bytes_recvd, so this only changes the paths that come back to call_encode() after a reply was received. xprt_request_data_received() loses its static qualifier so that clnt.c can call it. The request is encoded again at once, which for krb5i computes a new checksum. It is still sent only after the reconnect: the pending close holds the transport send lock, and xprt_request_transmit() refuses to send while XPRT_CLOSE_WAIT is set. Fixes: cc204d01262a ("SUNRPC: Dequeue the request from the receive queue while we're re-encoding") Signed-off-by: Marcin Krystianc --- diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -397,6 +397,7 @@ int xprt_request_enqueue_receive(struc void xprt_request_wait_receive(struct rpc_task *task); void xprt_request_dequeue_xprt(struct rpc_task *task); bool xprt_request_need_retransmit(struct rpc_task *task); +bool xprt_request_data_received(struct rpc_task *task); void xprt_transmit(struct rpc_task *task); void xprt_end_transmit(struct rpc_task *task); int xprt_adjust_timeout(struct rpc_rqst *req); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2020,6 +2020,8 @@ rpc_task_need_encode(struct rpc_task *ta return test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate) == 0 && (!(task->tk_flags & RPC_TASK_SENT) || !(task->tk_flags & RPC_TASK_NO_RETRANS_TIMEOUT) || + /* the reply was rejected, resend */ + xprt_request_data_received(task) || xprt_request_need_retransmit(task)); } diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1129,7 +1129,7 @@ static void xprt_wait_on_pinned_rqst(str wait_var_event(&req->rq_pin, !xprt_is_pinned_rqst(req)); } -static bool +bool xprt_request_data_received(struct rpc_task *task) { return !test_bit(RPC_TASK_NEED_RECV, &task->tk_runstate) &&