forked from Archive/PX4-Autopilot
NFS update
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4835 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
parent
d4ed73cdad
commit
d2ec24d6c3
|
@ -113,34 +113,15 @@
|
||||||
#define NFSSVC_AUTHINFAIL 0x080
|
#define NFSSVC_AUTHINFAIL 0x080
|
||||||
#define NFSSVC_MNTD 0x100
|
#define NFSSVC_MNTD 0x100
|
||||||
|
|
||||||
/* Socket errors ignored for connectionless sockets??
|
/* On fast networks, the estimator will try to reduce the timeout lower than
|
||||||
* For now, ignore them all
|
* the latency of the server's disks, which results in too many timeouts, so
|
||||||
*/
|
* cap the lower bound.
|
||||||
|
|
||||||
#define NFSIGNORE_SOERROR(s, e) \
|
|
||||||
((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
|
|
||||||
((s) & PR_CONNREQUIRED) == 0)
|
|
||||||
|
|
||||||
/* Flag values for r_flags */
|
|
||||||
|
|
||||||
#define R_TIMING 0x01/* timing request (in mntp) */
|
|
||||||
#define R_SENT 0x02/* request has been sent */
|
|
||||||
#define R_SOFTTERM 0x04/* soft mnt, too many retries */
|
|
||||||
#define R_INTR 0x08/* intr mnt, signal pending */
|
|
||||||
#define R_SOCKERR 0x10/* Fatal error on socket */
|
|
||||||
#define R_TPRINTFMSG 0x20/* Did a tprintf msg. */
|
|
||||||
#define R_MUSTRESEND 0x40/* Must resend request */
|
|
||||||
|
|
||||||
/* On fast networks, the estimator will try to reduce the
|
|
||||||
* timeout lower than the latency of the server's disks,
|
|
||||||
* which results in too many timeouts, so cap the lower
|
|
||||||
* bound.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NFS_MINRTO (NFS_HZ >> 2)
|
#define NFS_MINRTO (NFS_HZ >> 2)
|
||||||
|
|
||||||
/* Keep the RTO from increasing to unreasonably large values
|
/* Keep the RTO from increasing to unreasonably large values when a server is
|
||||||
* when a server is not responding.
|
* not responding.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NFS_MAXRTO (20 * NFS_HZ)
|
#define NFS_MAXRTO (20 * NFS_HZ)
|
||||||
|
|
|
@ -73,11 +73,6 @@
|
||||||
* Private Variables
|
* Private Variables
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static struct rpc_program nfs3_program =
|
|
||||||
{
|
|
||||||
NFS_PROG, NFS_VER3, "NFSv3"
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Variables
|
* Public Variables
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -129,31 +124,14 @@ int nfs_connect(struct nfsmount *nmp)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpc->rc_prog = &nfs3_program;
|
|
||||||
|
|
||||||
fvdbg("Connecting\n");
|
fvdbg("Connecting\n");
|
||||||
|
|
||||||
/* Translate nfsmnt flags -> rpcclnt flags */
|
/* Translate nfsmnt flags -> rpcclnt flags */
|
||||||
|
|
||||||
rpc->rc_flag = 0;
|
|
||||||
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, SOFT);
|
|
||||||
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, INT);
|
|
||||||
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, NOCONN);
|
|
||||||
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, DUMBTIMR);
|
|
||||||
|
|
||||||
rpc->rc_authtype = RPCAUTH_NULL; /* for now */
|
|
||||||
rpc->rc_path = nmp->nm_path;
|
rpc->rc_path = nmp->nm_path;
|
||||||
rpc->rc_name = &nmp->nm_nam;
|
rpc->rc_name = &nmp->nm_nam;
|
||||||
|
|
||||||
rpc->rc_sotype = nmp->nm_sotype;
|
rpc->rc_sotype = nmp->nm_sotype;
|
||||||
rpc->rc_soproto = nmp->nm_soproto;
|
rpc->rc_soproto = nmp->nm_soproto;
|
||||||
rpc->rc_timeo = nmp->nm_timeo;
|
|
||||||
rpc->rc_retry = nmp->nm_retry;
|
|
||||||
|
|
||||||
/* V3 needs to use this */
|
|
||||||
|
|
||||||
rpc->rc_proctlen = 0;
|
|
||||||
rpc->rc_proct = NULL;
|
|
||||||
|
|
||||||
nmp->nm_rpcclnt = rpc;
|
nmp->nm_rpcclnt = rpc;
|
||||||
|
|
||||||
|
@ -167,13 +145,6 @@ void nfs_disconnect(struct nfsmount *nmp)
|
||||||
rpcclnt_disconnect(nmp->nm_rpcclnt);
|
rpcclnt_disconnect(nmp->nm_rpcclnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NFS_TCPIP
|
|
||||||
void nfs_safedisconnect(struct nfsmount *nmp)
|
|
||||||
{
|
|
||||||
rpcclnt_safedisconnect(nmp->nm_rpcclnt);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int nfs_request(struct nfsmount *nmp, int procnum,
|
int nfs_request(struct nfsmount *nmp, int procnum,
|
||||||
FAR const void *request, size_t reqlen,
|
FAR const void *request, size_t reqlen,
|
||||||
FAR void *response, size_t resplen)
|
FAR void *response, size_t resplen)
|
||||||
|
@ -184,9 +155,8 @@ int nfs_request(struct nfsmount *nmp, int procnum,
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
tryagain:
|
tryagain:
|
||||||
error = rpcclnt_request(clnt, procnum, nmp->nm_rpcclnt->rc_prog->prog_id,
|
error = rpcclnt_request(clnt, procnum, NFS_PROG, NFS_VER3,
|
||||||
nmp->nm_rpcclnt->rc_prog->prog_version, request, reqlen,
|
request, reqlen, response, resplen);
|
||||||
response, resplen);
|
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
fdbg("ERROR: rpcclnt_request failed: %d\n", error);
|
fdbg("ERROR: rpcclnt_request failed: %d\n", error);
|
||||||
|
@ -227,35 +197,10 @@ tryagain:
|
||||||
goto tryagain;
|
goto tryagain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for a stale file handle. We don't do anything special
|
fdbg("ERROR: NFS error %d from server\n", error);
|
||||||
* a stale handle other than report a special debug error message.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (error == ESTALE)
|
|
||||||
{
|
|
||||||
fdbg("ERROR %s: ESTALE on mount from server\n",
|
|
||||||
nmp->nm_rpcclnt->rc_prog->prog_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fdbg("ERROR %s: unknown error %d from server\n",
|
|
||||||
nmp->nm_rpcclnt->rc_prog->prog_name, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
fvdbg("NFS_SUCCESS\n");
|
fvdbg("NFS_SUCCESS\n");
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef COMP
|
|
||||||
#ifdef COMP
|
|
||||||
|
|
||||||
/* Terminate any outstanding RPCs. */
|
|
||||||
|
|
||||||
int nfs_nmcancelreqs(struct nfsmount *nmp)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -57,16 +57,10 @@ extern "C" {
|
||||||
EXTERN void nfs_init(void);
|
EXTERN void nfs_init(void);
|
||||||
EXTERN int nfs_connect(struct nfsmount *nmp);
|
EXTERN int nfs_connect(struct nfsmount *nmp);
|
||||||
EXTERN void nfs_disconnect(struct nfsmount *nmp);
|
EXTERN void nfs_disconnect(struct nfsmount *nmp);
|
||||||
#ifdef CONFIG_NFS_TCPIP
|
|
||||||
EXTERN void nfs_safedisconnect(struct nfsmount *nmp);
|
|
||||||
#endif
|
|
||||||
EXTERN int nfs_request(struct nfsmount *nmp, int procnum,
|
EXTERN int nfs_request(struct nfsmount *nmp, int procnum,
|
||||||
FAR const void *request, size_t reqlen,
|
FAR const void *request, size_t reqlen,
|
||||||
FAR void *response, size_t resplen);
|
FAR void *response, size_t resplen);
|
||||||
#undef COMP
|
|
||||||
#ifdef COMP
|
|
||||||
EXTERN int nfs_nmcancelreqs(struct nfsmount *nmp);
|
|
||||||
#endif
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/nfs/RPC.h
|
* fs/nfs/rpc.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
* Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved.
|
* Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved.
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
#define RPCAKN_FULLNAME 0
|
#define RPCAKN_FULLNAME 0
|
||||||
#define RPCAKN_NICKNAME 1
|
#define RPCAKN_NICKNAME 1
|
||||||
|
|
||||||
/* Rpc Constants */
|
/* RPC Constants */
|
||||||
|
|
||||||
#define RPC_CALL 0
|
#define RPC_CALL 0
|
||||||
#define RPC_REPLY 1
|
#define RPC_REPLY 1
|
||||||
|
@ -184,28 +184,13 @@
|
||||||
|
|
||||||
/* Flag values for r_flags */
|
/* Flag values for r_flags */
|
||||||
|
|
||||||
#define TASK_TIMING (1 << 0) /* timing request (in mntp) */
|
#define RPCCALL_MUSTRESEND (1 << 0) /* Must resend request */
|
||||||
#define TASK_SENT (1 << 1) /* request has been sent */
|
|
||||||
#define TASK_SOFTTERM (1 << 2) /* soft mnt, too many retries */
|
|
||||||
#define TASK_INTR (1 << 3) /* intr mnt, signal pending */
|
|
||||||
#define TASK_SOCKERR (1 << 4) /* Fatal error on socket */
|
|
||||||
#define TASK_TPRINTFMSG (1 << 5) /* Did a tprintf msg. */
|
|
||||||
#define TASK_MUSTRESEND (1 << 6) /* Must resend request */
|
|
||||||
#define TASK_GETONEREP (1 << 7) /* Probe for one reply only */
|
|
||||||
|
|
||||||
#define RPC_HZ (CLOCKS_PER_SEC / rpcclnt_ticks) /* Ticks/sec */
|
#define RPC_HZ (CLOCKS_PER_SEC / rpcclnt_ticks) /* Ticks/sec */
|
||||||
#define RPC_TIMEO (1 * RPC_HZ) /* Default timeout = 1 second */
|
#define RPC_TIMEO (1 * RPC_HZ) /* Default timeout = 1 second */
|
||||||
|
|
||||||
#define RPC_MAXREXMIT 100 /* Stop counting after this many */
|
#define RPC_MAXREXMIT 100 /* Stop counting after this many */
|
||||||
|
|
||||||
#define RPCIGNORE_SOERROR(s, e) \
|
|
||||||
((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK)
|
|
||||||
|
|
||||||
#define RPCINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
|
|
||||||
sigmask(SIGHUP)|sigmask(SIGQUIT))
|
|
||||||
|
|
||||||
#define RPCMADV(m, s) (m)->m_data += (s)
|
|
||||||
|
|
||||||
#define RPCAUTH_ROOTCREDS NULL
|
#define RPCAUTH_ROOTCREDS NULL
|
||||||
|
|
||||||
#define RPCCLNTINT_SIGMASK(set) \
|
#define RPCCLNTINT_SIGMASK(set) \
|
||||||
|
@ -230,7 +215,6 @@ struct rpcstats
|
||||||
int rpcretries;
|
int rpcretries;
|
||||||
int rpcrequests;
|
int rpcrequests;
|
||||||
int rpctimeouts;
|
int rpctimeouts;
|
||||||
int rpcunexpected;
|
|
||||||
int rpcinvalid;
|
int rpcinvalid;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -496,29 +480,6 @@ struct rpc_reply_getattr
|
||||||
struct nfs_fattr attr;
|
struct nfs_fattr attr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* RPC Client connection context. One allocated on every NFS mount.
|
|
||||||
* Holds RPC specific information for mount.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct rpc_program
|
|
||||||
{
|
|
||||||
uint32_t prog_id;
|
|
||||||
uint32_t prog_version;
|
|
||||||
char *prog_name;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rpctask
|
|
||||||
{
|
|
||||||
dq_entry_t r_chain;
|
|
||||||
struct rpcclnt *r_rpcclnt;
|
|
||||||
uint32_t r_xid;
|
|
||||||
uint8_t r_flags; /* flags on request, see below */
|
|
||||||
int8_t r_retry; /* max retransmission count */
|
|
||||||
int8_t r_rexmit; /* current retrans count */
|
|
||||||
uint8_t r_procnum; /* NFS procedure number */
|
|
||||||
int8_t r_rtt; /* RTT for RPC */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rpcclnt
|
struct rpcclnt
|
||||||
{
|
{
|
||||||
nfsfh_t rc_fh; /* File handle of root dir */
|
nfsfh_t rc_fh; /* File handle of root dir */
|
||||||
|
@ -527,35 +488,23 @@ struct rpcclnt
|
||||||
struct sockaddr *rc_name;
|
struct sockaddr *rc_name;
|
||||||
struct socket *rc_so; /* RPC socket */
|
struct socket *rc_so; /* RPC socket */
|
||||||
|
|
||||||
uint8_t rc_flag; /* For RPCCLNT_* flags */
|
uint8_t rc_clntflags; /* For RPCCLNT_* flags */
|
||||||
uint8_t rc_sotype; /* Type of socket */
|
uint8_t rc_sotype; /* Type of socket */
|
||||||
uint8_t rc_soproto; /* and protocol */
|
uint8_t rc_soproto; /* and protocol */
|
||||||
uint8_t rc_soflags; /* pr_flags for socket protocol */
|
|
||||||
uint8_t rc_retry; /* Max retries */
|
|
||||||
uint8_t rc_timeo; /* Init timer for NFSMNT_DUMBTIMR */
|
|
||||||
|
|
||||||
int rc_srtt[4]; /* Timers for rpcs */
|
/* These describe the current RPC call */
|
||||||
int rc_sdrtt[4];
|
|
||||||
int rc_sent; /* Request send count */
|
|
||||||
int rc_cwnd; /* Request send window */
|
|
||||||
int rc_timeouts; /* Request timeouts */
|
|
||||||
int rc_authtype; /* Authenticator type */
|
|
||||||
//int rc_deadthresh; /* Threshold of timeouts-->dead server*/
|
|
||||||
|
|
||||||
/* authentication: */
|
uint8_t rc_callflags; /* For RPCCALL_* flags */
|
||||||
/* currently can be RPCAUTH_NULL, RPCAUTH_KERBV4, RPCAUTH_UNIX */
|
|
||||||
/* should be kept in XDR form */
|
/* Authentication: Can be RPCAUTH_NULL, RPCAUTH_KERBV4, RPCAUTH_UNIX
|
||||||
|
* Should be kept in XDR form
|
||||||
|
*/
|
||||||
|
|
||||||
/* RPCAUTH_UNIX */
|
/* RPCAUTH_UNIX */
|
||||||
#ifdef CONFIG_NFS_UNIX_AUTH
|
#ifdef CONFIG_NFS_UNIX_AUTH
|
||||||
struct rpc_auth_info rc_oldauth; /* authentication */
|
struct rpc_auth_info rc_oldauth; /* authentication */
|
||||||
void *rc_auth;
|
void *rc_auth;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct rpc_program *rc_prog;
|
|
||||||
|
|
||||||
int rc_proctlen; /* if == 0 then rc_proct == NULL */
|
|
||||||
int *rc_proct;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -563,18 +512,13 @@ struct rpcclnt
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void rpcclnt_init(void);
|
void rpcclnt_init(void);
|
||||||
int rpcclnt_connect(struct rpcclnt *RPC);
|
int rpcclnt_connect(FAR struct rpcclnt *rpc);
|
||||||
int rpcclnt_reconnect(struct rpctask *rep);
|
int rpcclnt_reconnect(FAR struct rpcclnt *rpc);
|
||||||
void rpcclnt_disconnect(struct rpcclnt *RPC);
|
void rpcclnt_disconnect(FAR struct rpcclnt *rpc);
|
||||||
int rpcclnt_umount(struct rpcclnt *RPC);
|
int rpcclnt_umount(FAR struct rpcclnt *rpc);
|
||||||
void rpcclnt_safedisconnect(struct rpcclnt *RPC);
|
void rpcclnt_safedisconnect(FAR struct rpcclnt *rpc);
|
||||||
int rpcclnt_request(FAR struct rpcclnt *RPC, int procnum, int prog, int version,
|
int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog, int version,
|
||||||
FAR const void *request, size_t reqlen,
|
FAR const void *request, size_t reqlen,
|
||||||
FAR void *response, size_t resplen);
|
FAR void *response, size_t resplen);
|
||||||
|
|
||||||
#undef COMP
|
|
||||||
#ifdef COMP
|
|
||||||
int rpcclnt_cancelreqs(struct rpcclnt *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __FS_NFS_RPC_H */
|
#endif /* __FS_NFS_RPC_H */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue