From 0eba70b78a097dab5cb7bdbe988e9d008ca1b98b Mon Sep 17 00:00:00 2001 From: Nagendra Tomar Date: Fri, 23 Aug 2024 05:13:49 +0000 Subject: [PATCH] Handle failed NFS response for zero copy reads Currently we go ahead and try to read the data which causes it to fail and initiates a reconnect. Caller never gets a response for such failed READ pdus. (cherry picked from commit ab56f5c7c16ff985448117c13b5d01a37cfb4999) Signed-off-by: Ronnie Sahlberg --- lib/socket.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/socket.c b/lib/socket.c index da06b15e..c8b39e5f 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -840,6 +840,17 @@ rpc_read_from_socket(struct rpc_context *rpc) #endif /* HAVE_LIBKRB5 */ /* We do not have rpc->pdu for server context */ if (rpc->pdu && rpc->pdu->free_zdr) { + if (rpc->program == NFS_PROGRAM && rpc->version == NFS_V3) { + /* + * If the READ failed, bail out here as there is no + * data. + */ + const READ3res *res = (READ3res *) rpc->pdu->zdr_decode_buf; + if (res->status != NFS3_OK) { + goto payload_finished; + } + } + /* * We are doing zero-copy read. * pdu->read_count is the amount of read data returned by @@ -895,9 +906,7 @@ rpc_read_from_socket(struct rpc_context *rpc) continue; } } -#ifdef HAVE_LIBKRB5 payload_finished: -#endif /* HAVE_LIBKRB5 */ if (rpc->fragments) { free(rpc->buf); rpc->buf = NULL;