summaryrefslogtreecommitdiffstats
path: root/sys/nfs4client/nfs4.h
blob: 4bcc6a7f31214af005d6834db0625d759e1995a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/* $FreeBSD$ */
/* $Id: nfs4.h,v 1.25 2003/11/05 14:58:58 rees Exp $ */

/*-
 * copyright (c) 2003
 * the regents of the university of michigan
 * all rights reserved
 * 
 * permission is granted to use, copy, create derivative works and redistribute
 * this software and such derivative works for any purpose, so long as the name
 * of the university of michigan is not used in any advertising or publicity
 * pertaining to the use or distribution of this software without specific,
 * written prior authorization.  if the above copyright notice or any other
 * identification of the university of michigan is included in any copy of any
 * portion of this software, then the disclaimer below must also be included.
 * 
 * this software is provided as is, without representation from the university
 * of michigan as to its fitness for any purpose, and without warranty by the
 * university of michigan of any kind, either express or implied, including
 * without limitation the implied warranties of merchantability and fitness for
 * a particular purpose. the regents of the university of michigan shall not be
 * liable for any damages, including special, indirect, incidental, or
 * consequential damages, with respect to any claim arising out of or in
 * connection with the use of the software, even if it has been or is hereafter
 * advised of the possibility of such damages.
 */

#ifndef _NFS4CLIENT_NFS4_H
#define _NFS4CLIENT_NFS4_H

#define NFS4_USE_RPCCLNT

#define NFS4_MINOR_VERSION		0
#define NFS_PORT			2049
#define NFS4_DEF_FILE_IO_BUFFER_SIZE	4096
#define NFS4_MAX_FILE_IO_BUFFER_SIZE	32768
#define NFS4_DEF_MAXFILESIZE		0xffffffff
#define NFS4_SUPER_MAGIC		0xF00BA4

#define NFS4FS_SILLY_RENAME		1
#define NFS4FS_STRICT_LOCKING		1
#define NFS4FS_RETRY_OLD_STATEID	1
#define NFS4FS_MIN_LEASE		(1 * hz)
#define NFS4FS_DEFAULT_LEASE		(30 * hz)
#define NFS4FS_MAX_LEASE		(120 * hz)
#define NFS4FS_RETRY_MIN_DELAY		(hz >> 4)
#define NFS4FS_RETRY_MAX_DELAY		(hz << 3)
#define NFS4FS_SEMAPHORE_DELAY		(hz >> 4)
#define NFS4FS_GRACE_DELAY		(hz * 5)
#define NFS4FS_OLD_STATEID_DELAY	(hz >> 3)
#define NFS4FS_OP_MAX			10


#define NFS4_BUFSIZE			8192
#define NFS4FS_MAX_IOV			10
#define NFS4_SETCLIENTID_MAXTRIES	5
#define NFS4_READDIR_MAXTRIES		5
#define NFS4_MAXIO			4
#define NFS4_MAX_REQUEST_SOFT		192
#define NFS4_MAX_REQUEST_HARD		256
#define NFS4_MAXCOMMIT			64
#define NFS4_READ_DELAY			(2 * HZ)
#define NFS4_WRITEBACK_DELAY		(5 * HZ)
#define NFS4_WRITEBACK_LOCKDELAY	(60 * HZ)
#define NFS4_COMMIT_DELAY		(5 * HZ)
#define RPC_SLACK_SPACE			512


struct nfs4_compound {
	char	       *tag;

	int		req_nops;
	uint32_t       *req_nopsp;
	uint32_t       *req_seqidp;
	uint32_t       *req_stateidp[NFS4_MAXIO];
	uint32_t	req_nstateid;

	u_int		seqidused;

	int		rep_status;
	int		rep_nops;

	struct nfs4_fctx *fcp;

	struct vnode   *curvp;
	struct vnode   *savevp;

	struct nfsmount *nmp;
};

struct nfs4_fdata {
	struct nfsnode *fd_n;
	pid_t		fd_pid;
};

struct nfs4_oparg_putfh {
	/* filled in by caller */
/*	  struct dentry *dentry;*/

	/* filled in by setup routine */
/*	  nfs_opnum4 op;*/
	uint32_t	fh_len;
	nfsfh_t		fh_val;
	int		nlookups;
};

struct nfs4_oparg_getattr {
	struct vnode   *vp;
	nfsv4bitmap    *bm;
	struct nfsv4_fattr fa;
};

struct nfs4_oparg_getfh {
	uint32_t	fh_len;
	nfsfh_t		fh_val;
	struct vnode   *vp;
};

struct nfs4_oparg_lookup {
	const char     *name;
	uint32_t	namelen;
	struct vnode   *vp;
};

struct nfs4_oparg_setclientid {
	struct nfsmount *np;
	uint32_t	namelen;
	char	       *name;
	char	       *cb_netid;
	uint32_t	cb_netidlen;
	char	       *cb_univaddr;
	uint32_t	cb_univaddrlen;
	uint32_t	cb_prog;

	uint64_t	clientid;
	u_char		verf[NFSX_V4VERF];
};

struct nfs4_oparg_access {
	uint32_t	mode;
	uint32_t	rmode;
	uint32_t	supported;
};

struct nfs4_oparg_open {
	uint32_t	flags;
	uint32_t	rflags;

	nfsv4cltype	ctype;
	struct vattr   *vap;
	struct componentname *cnp;

	struct nfs4_fctx *fcp;

	char		stateid[NFSX_V4STATEID];
};

struct nfs4_oparg_read {
	uint64_t	off;
	uint32_t	maxcnt;
	uint32_t	eof;
	uint32_t	retlen;
	struct uio     *uiop;
	struct nfs4_fctx *fcp;
};

struct nfs4_oparg_write {
	uint64_t	off;
	uint32_t	stable;
	uint32_t	cnt;
	uint32_t	retlen;
	uint32_t	committed;
	struct uio     *uiop;
	u_char		wverf[NFSX_V4VERF];
	struct nfs4_fctx *fcp;
};

struct nfs4_oparg_commit {
	uint32_t	len;
	off_t		start;

	u_char		verf[NFSX_V4VERF];
};

struct nfs4_oparg_readdir {
	uint32_t	cnt;
	nfsv4bitmap    *bm;
	uint64_t	cookie;
	u_char		verf[NFSX_V4VERF];
};

struct nfs4_oparg_create {
	nfstype		type;
	char	       *linktext;
	char	       *name;
	uint32_t	namelen;
	struct vattr   *vap;
};

struct nfs4_oparg_rename {
	const char     *fname;
	uint32_t	fnamelen;
	const char     *tname;
	uint32_t	tnamelen;
};

struct nfs4_oparg_link {
	const char     *name;
	uint32_t	namelen;
};

/*
 * Lockowner
 */
struct nfs4_lowner {
	uint32_t	lo_cnt;
	uint32_t	lo_seqid;
	uint32_t	lo_id;
};

#define NFS4_SEQIDMUTATINGERROR(err)		\
(((err) != NFSERR_STALE_CLIENTID) &&		\
 ((err) != NFSERR_BAD_SEQID) &&			\
 ((err) != NFSERR_STALE_STATEID) &&		\
 ((err) != NFSERR_BAD_STATEID))

/* Standard bitmasks */
extern nfsv4bitmap nfsv4_fsinfobm;
extern nfsv4bitmap nfsv4_fsattrbm;
extern nfsv4bitmap nfsv4_getattrbm;
extern nfsv4bitmap nfsv4_readdirbm;

vfs_init_t nfs4_init;
vfs_uninit_t nfs4_uninit;

uint32_t nfs_v4fileid4_to_fileid(uint64_t);

int	nfs4_readrpc(struct vnode *, struct uio *, struct ucred *);
int	nfs4_writerpc(struct vnode *, struct uio *, struct ucred *, int *,
	    int *);
int	nfs4_commit(struct vnode *vp, u_quad_t offset, int cnt,
	    struct ucred *cred, struct thread *td);
int	nfs4_readdirrpc(struct vnode *, struct uio *, struct ucred *);
int	nfs4_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
int	nfs4_sigintr(struct nfsmount *, struct nfsreq *, struct thread *);
int	nfs4_writebp(struct buf *, int, struct thread *);
int	nfs4_request(struct vnode *, struct mbuf *, int, struct thread *,
	    struct ucred *, struct mbuf **, struct mbuf **, caddr_t *);
int	nfs4_request_mnt(struct nfsmount *, struct mbuf *, int, struct thread *,
	    struct ucred *, struct mbuf **, struct mbuf **, caddr_t *);
int	nfs4_connect(struct nfsmount *);
void	nfs4_disconnect(struct nfsmount *);
void	nfs4_safedisconnect(struct nfsmount *);
int	nfs4_nmcancelreqs(struct nfsmount *);

void	nfs_v4initcompound(struct nfs4_compound *);
int	nfs_v4postop(struct nfs4_compound *, int);
int	nfs_v4handlestatus(int, struct nfs4_compound *);

#endif /* _NFS4CLIENT_NFS4_H */
OpenPOWER on IntegriCloud