fs: nfs: Reconnect to the NFS server in TCP mode

Summary:
- I noticed that an NFS connection is automatically dropped.
- Actually, this happens in TCP mode if no traffic happens
  for 600 seconds.
- I confirmed that the NFS client on Ubuntu automatically
  reconnects to the NFS server when an RPC call failed.
- This commit adds the same behavior to fix the issue.

Impact:
- NFS client in TCP mode

Testing:
- Tested with spresense:rndis_smp

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2021-06-28 13:56:21 +09:00 committed by Xiang Xiao
parent 0e76a16545
commit abc2767b0d
1 changed files with 26 additions and 1 deletions

View File

@ -128,9 +128,34 @@ int nfs_request(FAR struct nfsmount *nmp, int procnum,
if (error != 0)
{
ferr("ERROR: rpcclnt_request failed: %d\n", error);
if (error != -ENOTCONN)
{
return error;
}
/* Reconnect */
finfo("Reconnect due to timeout \n");
error = rpcclnt_connect(nmp->nm_rpcclnt);
if (error != 0)
{
return error;
}
/* Send the request again */
error = rpcclnt_request(clnt, procnum, NFS_PROG, NFS_VER3,
request, reqlen, response, resplen);
if (error != 0)
{
return error;
}
}
memcpy(&replyh, response, sizeof(struct nfs_reply_header));
if (replyh.nfs_status != 0)