NFS update

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4634 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-04-18 23:31:47 +00:00
parent 1a50ac3d79
commit 6c394ef7a6
11 changed files with 949 additions and 956 deletions

View File

@ -46,6 +46,8 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include "nfs_mount.h"
/****************************************************************************
* Pre-processor Definitions
@ -207,15 +209,15 @@ struct nfsd_args
struct nfsd_srvargs
{
struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
uid_t nsd_uid; /* Effective uid mapped to cred */
uint32_t nsd_haddr; /* IP address of client */
int nsd_authlen; /* Length of auth string (ret) */
unsigned char *nsd_authstr; /* Auth string (ret) */
int nsd_verflen; /* and the verifier */
struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
uid_t nsd_uid; /* Effective uid mapped to cred */
uint32_t nsd_haddr; /* IP address of client */
int nsd_authlen; /* Length of auth string (ret) */
unsigned char *nsd_authstr; /* Auth string (ret) */
int nsd_verflen; /* and the verifier */
unsigned char *nsd_verfstr;
struct timeval nsd_timestamp; /* timestamp from verifier */
uint32_t nsd_ttl; /* credential ttl (sec) */
uint32_t nsd_ttl; /* credential ttl (sec) */
};
/* Stats structure */
@ -258,10 +260,6 @@ struct nfsstats
uint64_t srvvop_writes;
};
/****************************************************************************
* Public Types
****************************************************************************/
/* The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
* What should be in this set is open to debate, but I believe that since
* I/O system calls on ufs are never interrupted by signals the set should
@ -336,19 +334,25 @@ struct nfsrv_descript
/****************************************************************************
* Public Data
****************************************************************************/
/*
extern int nfs_niothreads;
extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
extern int nfssvc_sockhead_flag;
extern struct pool nfsreqpl;
extern struct pool nfs_node_pool;
extern TAILQ_HEAD(nfsdhead, nfsd) nfsd_head;
extern int nfsd_head_flag;
*/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN void nfs_semtake(struct nfsmount *nmp);
EXTERN void nfs_semgive(struct nfsmount *nmp);
EXTERN int nfs_checkmount(struct nfsmount *nmp);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* _NFS_NFS_H */

View File

@ -85,6 +85,11 @@
#define NFSMNT_NOLOCKD 0x00400000 /* Locks are local */
#define NFSMNT_NFSV4 0x00800000 /* Use NFS Version 4 protocol */
#define NFSMNT_HASWRITEVERF 0x01000000 /* NFSv4 Write verifier */
#define NFSMNT_GOTFSINFO 0x00000004 /* Got the V3 fsinfo */
#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */
#define NFSMNT_NOAC 0x00080000 /* Turn off attribute cache */
#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
/****************************************************************************
* Public Types
@ -94,24 +99,28 @@
struct nfs_args
{
int version; /* args structure version number */
int version; /* args structure version number */
struct sockaddr *addr; /* file server address */
int addrlen; /* length of address */
int sotype; /* Socket type */
int proto; /* and Protocol */
nfsfh_t *fh; /* File handle to be mounted */
int fhsize; /* Size, in bytes, of fh */
int flags; /* flags */
int wsize; /* write size in bytes */
int rsize; /* read size in bytes */
int readdirsize; /* readdir size in bytes */
int timeo; /* initial timeout in .1 secs */
int retrans; /* times to retry send */
int maxgrouplist; /* Max. size of group list */
int readahead; /* # of blocks to readahead */
int leaseterm; /* Term (sec) of lease */
int deadthresh; /* Retrans threshold */
int addrlen; /* length of address */
int sotype; /* Socket type */
int proto; /* and Protocol */
nfsfh_t fh; /* File handle to be mounted */
int fhsize; /* Size, in bytes, of fh */
int flags; /* flags */
int wsize; /* write size in bytes */
int rsize; /* read size in bytes */
int readdirsize; /* readdir size in bytes */
int timeo; /* initial timeout in .1 secs */
int retrans; /* times to retry send */
int maxgrouplist; /* Max. size of group list */
int readahead; /* # of blocks to readahead */
int leaseterm; /* Term (sec) of lease */
int deadthresh; /* Retrans threshold */
char *hostname; /* server's name */
int acregmin; /* cache attrs for reg files min time */
int acregmax; /* cache attrs for reg files max time */
int acdirmin; /* cache attrs for dirs min time */
int acdirmax; /* cache attrs for dirs max time */
};
#endif /* __FS_NFS_NFS_ARGS_H */

View File

@ -97,7 +97,7 @@ struct nfsmount
int nm_acdirmax; /* Directory attr cache max lifetime */
int nm_acregmin; /* Reg file attr cache min lifetime */
int nm_acregmax; /* Reg file attr cache max lifetime */
unsigned char nm_verf[NFSX_V3WRITEVERF]; /* V3 write verifier */
unsigned char *nm_verf; /* V3 write verifier */
//char nm_mntonname[90]; /* directory on which mounted */
//uint8_t *nm_buffer; /* This is an allocated buffer to hold one sector*/
};

View File

@ -80,6 +80,14 @@
#define VTONFS(vp) ((struct nfsnode *)(vp)->f_priv)
#define NFSTOV(np) ((np)->n_vnode)
#define n_atim n_un1.nf_atim
#define n_mtim n_un2.nf_mtim
#define n_sillyrename n_un3.nf_silly
#define n_cookieverf n_un1.nd_cookieverf
#define n4_cookieverf n_un1.nd4_cookieverf
#define n_direofoffset n_un2.nd_direof
#define n_cookies n_un3.nd_cook
/****************************************************************************
* Public Types
****************************************************************************/
@ -119,7 +127,7 @@ struct nfsnode
time_t n_attrstamp; /* Attr. cache timestamp */
struct timespec n_mtime; /* Prev modify time. */
time_t n_ctime; /* Prev create time. */
nfsfh_t *n_fhp; /* NFS File Handle */
nfsfh_t n_fhp; /* NFS File Handle */
struct inode *n_inode; /* associated inode */
int n_error; /* Save write error value */
union
@ -130,7 +138,7 @@ struct nfsnode
union
{
struct timespec nf_mtim;
off_t nd_direoffset; /* Directory EOF offset cache */
off_t nd_direof; /* Directory EOF offset cache */
} n_un2;
short n_fhsize; /* size in bytes, of fh */
short n_flag; /* Flag for locking.. */

View File

@ -57,20 +57,21 @@
* Specification"
*/
#define NFS_PORT 2049
#define NFS_PROG 100003
#define NFS_VER2 2
#define NFS_VER3 3
#define NFS_VER4 4
#define NFS_V2MAXDATA 8192
#define NFS_MAXDGRAMDATA 32768
#define NFS_MAXDATA MAXBSIZE
#define NFS_MAXPATHLEN 1024
#define NFS_MAXNAMLEN 255
#define NFS_MAXPKTHDR 404
#define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA)
#define NFS_MINPACKET 20
#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
#define NFS_PORT 2049
#define NFS_PROG 100003
#define NFS_VER2 2
#define NFS_VER3 3
#define NFS_VER4 4
#define NFS_V2MAXDATA 8192
#define NFS_MAXDGRAMDATA 32768
#define MAXBSIZE 64000
#define NFS_MAXDATA MAXBSIZE
#define NFS_MAXPATHLEN 1024
#define NFS_MAXNAMLEN 255
#define NFS_MAXPKTHDR 404
#define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA)
#define NFS_MINPACKET 20
#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
/* Stat numbers for rpc returns (version 2 and 3) */
@ -108,21 +109,20 @@
#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
#define NFSERR_RETVOID 0x20000000 /* Return void, not error */
#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error
*/
#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */
#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
/* Sizes in bytes of various nfs rpc components */
#define NFSX_UNSIGNED 4
#define NFSX_UNSIGNED 4
/* specific to NFS Version 2 */
#define NFSX_V2FH 32
#define NFSX_V2FATTR 68
#define NFSX_V2SATTR 32
#define NFSX_V2COOKIE 4
#define NFSX_V2STATFS 20
#define NFSX_V2FH 32
#define NFSX_V2FATTR 68
#define NFSX_V2SATTR 32
#define NFSX_V2COOKIE 4
#define NFSX_V2STATFS 20
/* specific to NFS Version 3 */
@ -235,6 +235,7 @@
#define NFSV3FSINFO_CANSETTIME 0x10
/* Conversion macros */
#define vtonfsv2_mode(t,m) \
txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
MAKEIMODE((t), (m)))
@ -274,7 +275,7 @@ typedef enum
typedef struct
{
int32_t val[2];
} fsid_t; /* file system id type */
} fsid_t; /* file system id type */
/* File identifier.
* These are unique per filesystem on a single machine.
@ -282,17 +283,17 @@ typedef struct
struct fid
{
unsigned short fid_len; /* length of data in bytes */
unsigned short fid_reserved; /* force longword alignment */
char fid_data[MAXFIDSZ]; /* data (variable length) */
unsigned short fid_len; /* length of data in bytes */
unsigned short fid_reserved; /* force longword alignment */
char fid_data[MAXFIDSZ]; /* data (variable length) */
};
/* Generic file handle */
struct fhandle
{
fsid_t fh_fsid; /* File system id of mount point */
struct fid fh_fid; /* File sys specific id */
fsid_t fh_fsid; /* File system id of mount point */
struct fid fh_fid; /* File sys specific id */
};
typedef struct fhandle fhandle_t;
@ -500,7 +501,7 @@ struct wcc_data
struct diropargs3
{
nfsfh_t dir;
const char name;
const char *name;
};
struct CREATE3args
@ -528,7 +529,7 @@ struct READ3resok
struct nfs_fattr file_attributes;
uint32_t count;
bool eof;
const char data;
const char *data;
};
enum stable_how
@ -544,7 +545,7 @@ struct WRITE3args
uint64_t offset;
uint32_t count;
enum stable_how stable;
const char data;
const char *data;
};
struct WRITE3resok
@ -552,7 +553,7 @@ struct WRITE3resok
struct wcc_data file_wcc;
uint32_t count;
enum stable_how committed;
unsigned char verf;
unsigned char *verf;
};
struct REMOVE3args

View File

@ -107,7 +107,7 @@ int nfsx_connect(struct nfsmount *nmp)
return EFAULT;
}
rpc = &nmp->nm_rpcclnt;
rpc = nmp->nm_rpcclnt;
rpc->rc_prog = &nfs3_program;
@ -125,7 +125,7 @@ int nfsx_connect(struct nfsmount *nmp)
rpc->rc_authtype = RPCAUTH_NULL; /* for now */
//rpc->rc_servername = nmp->nm_mountp->mnt_stat.f_mntfromname;
rpc->rc_name = (struct sockaddr *)nmp->nm_nam;
rpc->rc_name = nmp->nm_nam;
rpc->rc_sotype = nmp->nm_sotype;
rpc->rc_soproto = nmp->nm_soproto;
@ -153,26 +153,24 @@ int nfsx_connect(struct nfsmount *nmp)
void nfsx_disconnect(struct nfsmount *nmp)
{
rpcclnt_disconnect(&nmp->nm_rpcclnt);
rpcclnt_disconnect(nmp->nm_rpcclnt);
}
#ifdef CONFIG_NFS_TCPIP
void nfsx_safedisconnect(struct nfsmount *nmp)
{
rpcclnt_safedisconnect(&nmp->nm_rpcclnt);
rpcclnt_safedisconnect(nmp->nm_rpcclnt);
}
#endif
int nfsx_request_xx(struct nfsmount *nm, int procnum, void *datain, void *dataout)
int nfsx_request_xx(struct nfsmount *nmp, int procnum, void *datain, void *dataout)
{
int error;
struct nfsmount *nmp;
struct rpcclnt *clnt;
struct rpc_reply *reply;
struct rpc_reply *reply = NULL;
int trylater_delay;
nmp = nm;
clnt = &nmp->nm_rpcclnt;
clnt = nmp->nm_rpcclnt;
tryagain:
@ -227,5 +225,5 @@ out:
int nfsx_nmcancelreqs(struct nfsmount *nmp)
{
return rpcclnt_cancelreqs(&nmp->nm_rpcclnt);
return rpcclnt_cancelreqs(nmp->nm_rpcclnt);
}

View File

@ -42,28 +42,42 @@
* Pre-processor definitions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int nfsx_connect(struct nfsmount *);
void nfsx_disconnect(struct nfsmount *);
#ifdef CONFIG_NFS_TCPIP
int nfsx_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
void nfsx_safedisconnect(struct nfsmount *);
#define nfs_safedisconnect nfsx_safedisconnect
#endif
int nfsx_request_xx(struct nfsmount *, int, void*, void*);
int nfsx_nmcancelreqs(struct nfsmount *);
#define nfs_connect nfs_connect_nfsx
#define nfs_disconnect nfs_disconnect_nfsx
#define nfs_nmcancelreqs nfsx_nmcancelreqs
#define nfs_connect(nmp) nfs_connect_nfsx (nmp)
#define nfs_disconnect(nmp) nfs_disconnect_nfsx(nmp)
#define nfs_nmcancelreqs (nmp) nfsx_nmcancelreqs(nmp)
#define nfsx_request(nmp, m, i, o) \
nfsx_request_xx(nmp, m, i, o)
#ifdef CONFIG_NFS_TCPIP
# define nfs_sigintr nfs_sigintr_nfsx
#define nfs_safedisconnect nfsx_safedisconnect
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN void nfs_init(void);
EXTERN int nfsx_connect(struct nfsmount *);
EXTERN void nfsx_disconnect(struct nfsmount *);
#ifdef CONFIG_NFS_TCPIP
EXTERN int nfsx_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
EXTERN void nfsx_safedisconnect(struct nfsmount *);
#endif
EXTERN int nfsx_request_xx(struct nfsmount *, int, void*, void*);
EXTERN int nfsx_nmcancelreqs(struct nfsmount *);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __FS_NFS_NFS_SOCKET_H */

File diff suppressed because it is too large Load Diff

View File

@ -111,12 +111,12 @@ struct rpctask
struct rpcclnt *r_rpcclnt;
uint32_t r_xid;
int r_flags; /* flags on request, see below */
int r_retry; /* max retransmission count */
int r_rexmit; /* current retrans count */
int r_timer; /* tick counter on reply */
int r_procnum; /* NFS procedure number */
int r_rtt; /* RTT for rpc */
int r_flags; /* flags on request, see below */
int r_retry; /* max retransmission count */
int r_rexmit; /* current retrans count */
int r_timer; /* tick counter on reply */
int r_procnum; /* NFS procedure number */
int r_rtt; /* RTT for rpc */
};
/* Generic RPC headers */
@ -233,18 +233,10 @@ struct rpcclnt
* Public Function Prototypes
****************************************************************************/
/*
void rpcclnt_create(struct rpcclnt ** rpc);
void rpcclnt_destroy(struct rpcclnt * rpc);
#define rpcclnt_get(X) rpcclnt_create(&(X))
#define rpcclnt_put(X) rpcclnt_destroy(X)
*/
void rpcclnt_init(void);
//void rpcclnt_uninit(void);
int rpcclnt_setup(struct rpcclnt *, struct rpc_program *, struct sockaddr *, int, int, struct rpc_auth_info *, int, int, int);
//int rpcclnt_setup(struct rpcclnt *, struct rpc_program *, struct sockaddr *, int, int, struct rpc_auth_info *, int, int, int);
int rpcclnt_connect(struct rpcclnt *);
int rpcclnt_reconnect(struct rpctask *);
void rpcclnt_disconnect(struct rpcclnt *);
@ -252,4 +244,5 @@ void rpcclnt_safedisconnect(struct rpcclnt *);
int rpcclnt_request(struct rpcclnt *, int, struct rpc_reply *, void *);
int rpcclnt_cancelreqs(struct rpcclnt *);
#endif /* _RPCCLNT_H_ */

View File

@ -549,7 +549,6 @@ static int rpcclnt_receive(struct rpctask *rep, struct sockaddr *aname,
* until ours is found.
*/
/* ARGSUSED */
static int
rpcclnt_reply(struct rpctask *myrep, struct rpc_call *call,
struct rpc_reply *reply)

View File

@ -49,6 +49,8 @@
* Included Files
****************************************************************************/
#include <arpa/inet.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -86,6 +88,11 @@
(t)->tv_nsec = ntohl(((struct nfsv3_time *)(f))->nfsv3_nsec); \
}
#define fxdr_nfsv3time2(f, t) { \
(t)->nfsv3_sec = ntohl(((struct nfsv3_time *)(f))->nfsv3_sec); \
(t)->nfsv3_nsec = ntohl(((struct nfsv3_time *)(f))->nfsv3_nsec); \
}
#define txdr_nfsv3time(f, t) { \
((struct nfsv3_time *)(t))->nfsv3_sec = htonl((f)->tv_sec); \
((struct nfsv3_time *)(t))->nfsv3_nsec = htonl((f)->tv_nsec); \