Skip to content

Commit

Permalink
Handle failed NFS response for zero copy reads
Browse files Browse the repository at this point in the history
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 ab56f5c)
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
  • Loading branch information
Nagendra Tomar authored and sahlberg committed Aug 28, 2024
1 parent 09256df commit 0eba70b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0eba70b

Please sign in to comment.