NFS update

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4835 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-06-12 21:59:00 +00:00
parent d4ed73cdad
commit d2ec24d6c3
5 changed files with 252 additions and 1149 deletions

View File

@ -113,34 +113,15 @@
#define NFSSVC_AUTHINFAIL 0x080
#define NFSSVC_MNTD 0x100
/* Socket errors ignored for connectionless sockets??
* For now, ignore them all
*/
#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.
/* 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)
/* Keep the RTO from increasing to unreasonably large values
* when a server is not responding.
/* Keep the RTO from increasing to unreasonably large values when a server is
* not responding.
*/
#define NFS_MAXRTO (20 * NFS_HZ)
@ -150,16 +131,16 @@
/* Bits for "ns_flag" */
#define SLP_VALID 0x01/* connection is usable */
#define SLP_DOREC 0x02/* receive operation required */
#define SLP_NEEDQ 0x04/* connection has data to queue from socket */
#define SLP_DISCONN 0x08/* connection is closed */
#define SLP_GETSTREAM 0x10/* extracting RPC from TCP connection */
#define SLP_LASTFRAG 0x20/* last fragment received on TCP connection */
#define SLP_ALLFLAGS 0xff/* convenience */
#define SLP_VALID 0x01 /* connection is usable */
#define SLP_DOREC 0x02 /* receive operation required */
#define SLP_NEEDQ 0x04 /* connection has data to queue from socket */
#define SLP_DISCONN 0x08 /* connection is closed */
#define SLP_GETSTREAM 0x10 /* extracting RPC from TCP connection */
#define SLP_LASTFRAG 0x20 /* last fragment received on TCP connection */
#define SLP_ALLFLAGS 0xff /* convenience */
#define SLP_INIT 0x01/* NFS data undergoing initialization */
#define SLP_WANTINIT 0x02/* thread waiting on NFS initialization */
#define SLP_INIT 0x01 /* NFS data undergoing initialization */
#define SLP_WANTINIT 0x02 /* thread waiting on NFS initialization */
/* Bits for "nfsd_flag" */

View File

@ -73,11 +73,6 @@
* Private Variables
****************************************************************************/
static struct rpc_program nfs3_program =
{
NFS_PROG, NFS_VER3, "NFSv3"
};
/****************************************************************************
* Public Variables
****************************************************************************/
@ -129,31 +124,14 @@ int nfs_connect(struct nfsmount *nmp)
return ENOMEM;
}
rpc->rc_prog = &nfs3_program;
fvdbg("Connecting\n");
/* 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_name = &nmp->nm_nam;
rpc->rc_sotype = nmp->nm_sotype;
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;
@ -167,13 +145,6 @@ void nfs_disconnect(struct nfsmount *nmp)
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,
FAR const void *request, size_t reqlen,
FAR void *response, size_t resplen)
@ -184,9 +155,8 @@ int nfs_request(struct nfsmount *nmp, int procnum,
int error;
tryagain:
error = rpcclnt_request(clnt, procnum, nmp->nm_rpcclnt->rc_prog->prog_id,
nmp->nm_rpcclnt->rc_prog->prog_version, request, reqlen,
response, resplen);
error = rpcclnt_request(clnt, procnum, NFS_PROG, NFS_VER3,
request, reqlen, response, resplen);
if (error != 0)
{
fdbg("ERROR: rpcclnt_request failed: %d\n", error);
@ -227,35 +197,10 @@ tryagain:
goto tryagain;
}
/* Check for a stale file handle. We don't do anything special
* 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);
}
fdbg("ERROR: NFS error %d from server\n", error);
return error;
}
fvdbg("NFS_SUCCESS\n");
return OK;
}
#undef COMP
#ifdef COMP
/* Terminate any outstanding RPCs. */
int nfs_nmcancelreqs(struct nfsmount *nmp)
{
return 0;
}
#endif

View File

@ -57,16 +57,10 @@ extern "C" {
EXTERN void nfs_init(void);
EXTERN int nfs_connect(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,
FAR const void *request, size_t reqlen,
FAR void *response, size_t resplen);
#undef COMP
#ifdef COMP
EXTERN int nfs_nmcancelreqs(struct nfsmount *nmp);
#endif
#undef EXTERN
#if defined(__cplusplus)
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* fs/nfs/RPC.h
* fs/nfs/rpc.h
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved.
@ -101,7 +101,7 @@
#define RPCAKN_FULLNAME 0
#define RPCAKN_NICKNAME 1
/* Rpc Constants */
/* RPC Constants */
#define RPC_CALL 0
#define RPC_REPLY 1
@ -184,28 +184,13 @@
/* Flag values for r_flags */
#define TASK_TIMING (1 << 0) /* timing request (in mntp) */
#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 RPCCALL_MUSTRESEND (1 << 0) /* Must resend request */
#define RPC_HZ (CLOCKS_PER_SEC / rpcclnt_ticks) /* Ticks/sec */
#define RPC_TIMEO (1 * RPC_HZ) /* Default timeout = 1 second */
#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 RPCCLNTINT_SIGMASK(set) \
@ -230,7 +215,6 @@ struct rpcstats
int rpcretries;
int rpcrequests;
int rpctimeouts;
int rpcunexpected;
int rpcinvalid;
};
#endif
@ -496,29 +480,6 @@ struct rpc_reply_getattr
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
{
nfsfh_t rc_fh; /* File handle of root dir */
@ -527,35 +488,23 @@ struct rpcclnt
struct sockaddr *rc_name;
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_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 */
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*/
/* These describe the current RPC call */
/* authentication: */
/* currently can be RPCAUTH_NULL, RPCAUTH_KERBV4, RPCAUTH_UNIX */
/* should be kept in XDR form */
uint8_t rc_callflags; /* For RPCCALL_* flags */
/* Authentication: Can be RPCAUTH_NULL, RPCAUTH_KERBV4, RPCAUTH_UNIX
* Should be kept in XDR form
*/
/* RPCAUTH_UNIX */
#ifdef CONFIG_NFS_UNIX_AUTH
struct rpc_auth_info rc_oldauth; /* authentication */
void *rc_auth;
#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);
int rpcclnt_connect(struct rpcclnt *RPC);
int rpcclnt_reconnect(struct rpctask *rep);
void rpcclnt_disconnect(struct rpcclnt *RPC);
int rpcclnt_umount(struct rpcclnt *RPC);
void rpcclnt_safedisconnect(struct rpcclnt *RPC);
int rpcclnt_request(FAR struct rpcclnt *RPC, int procnum, int prog, int version,
int rpcclnt_connect(FAR struct rpcclnt *rpc);
int rpcclnt_reconnect(FAR struct rpcclnt *rpc);
void rpcclnt_disconnect(FAR struct rpcclnt *rpc);
int rpcclnt_umount(FAR struct rpcclnt *rpc);
void rpcclnt_safedisconnect(FAR struct rpcclnt *rpc);
int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog, int version,
FAR const void *request, size_t reqlen,
FAR void *response, size_t resplen);
#undef COMP
#ifdef COMP
int rpcclnt_cancelreqs(struct rpcclnt *);
#endif
#endif /* __FS_NFS_RPC_H */

File diff suppressed because it is too large Load Diff