]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/nfsd/xdr4.h
nfsd41: enforce NFS4ERR_SEQUENCE_POS operation order rules for minorversion != 0...
[net-next-2.6.git] / include / linux / nfsd / xdr4.h
CommitLineData
1da177e4
LT
1/*
2 * include/linux/nfsd/xdr4.h
3 *
4 * Server-side types for NFSv4.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 */
38
39#ifndef _LINUX_NFSD_XDR4_H
40#define _LINUX_NFSD_XDR4_H
41
42#include <linux/nfs4.h>
43
44#define NFSD4_MAX_TAGLEN 128
45#define XDR_LEN(n) (((n) + 3) & ~3)
46
ca364317 47struct nfsd4_compound_state {
e354d571
AA
48 struct svc_fh current_fh;
49 struct svc_fh save_fh;
50 struct nfs4_stateowner *replay_owner;
b85d4c01
BH
51 /* For sessions DRC */
52 struct nfsd4_session *session;
53 struct nfsd4_slot *slot;
ca364317
BF
54};
55
1da177e4
LT
56struct nfsd4_change_info {
57 u32 atomic;
58 u32 before_ctime_sec;
59 u32 before_ctime_nsec;
60 u32 after_ctime_sec;
61 u32 after_ctime_nsec;
62};
63
64struct nfsd4_access {
65 u32 ac_req_access; /* request */
66 u32 ac_supported; /* response */
67 u32 ac_resp_access; /* response */
68};
69
70struct nfsd4_close {
71 u32 cl_seqid; /* request */
72 stateid_t cl_stateid; /* request+response */
73 struct nfs4_stateowner * cl_stateowner; /* response */
74};
75
76struct nfsd4_commit {
77 u64 co_offset; /* request */
78 u32 co_count; /* request */
79 nfs4_verifier co_verf; /* response */
80};
81
82struct nfsd4_create {
83 u32 cr_namelen; /* request */
84 char * cr_name; /* request */
85 u32 cr_type; /* request */
86 union { /* request */
87 struct {
88 u32 namelen;
89 char *name;
90 } link; /* NF4LNK */
91 struct {
92 u32 specdata1;
93 u32 specdata2;
94 } dev; /* NF4BLK, NF4CHR */
95 } u;
96 u32 cr_bmval[2]; /* request */
97 struct iattr cr_iattr; /* request */
98 struct nfsd4_change_info cr_cinfo; /* response */
99 struct nfs4_acl *cr_acl;
100};
101#define cr_linklen u.link.namelen
102#define cr_linkname u.link.name
103#define cr_specdata1 u.dev.specdata1
104#define cr_specdata2 u.dev.specdata2
105
106struct nfsd4_delegreturn {
107 stateid_t dr_stateid;
108};
109
110struct nfsd4_getattr {
111 u32 ga_bmval[2]; /* request */
112 struct svc_fh *ga_fhp; /* response */
113};
114
115struct nfsd4_link {
116 u32 li_namelen; /* request */
117 char * li_name; /* request */
118 struct nfsd4_change_info li_cinfo; /* response */
119};
120
121struct nfsd4_lock_denied {
122 clientid_t ld_clientid;
123 struct nfs4_stateowner *ld_sop;
124 u64 ld_start;
125 u64 ld_length;
126 u32 ld_type;
127};
128
129struct nfsd4_lock {
130 /* request */
131 u32 lk_type;
132 u32 lk_reclaim; /* boolean */
133 u64 lk_offset;
134 u64 lk_length;
135 u32 lk_is_new;
136 union {
137 struct {
138 u32 open_seqid;
139 stateid_t open_stateid;
140 u32 lock_seqid;
141 clientid_t clientid;
142 struct xdr_netobj owner;
143 } new;
144 struct {
145 stateid_t lock_stateid;
146 u32 lock_seqid;
147 } old;
148 } v;
149
150 /* response */
151 union {
152 struct {
153 stateid_t stateid;
154 } ok;
155 struct nfsd4_lock_denied denied;
156 } u;
3a65588a
BF
157 /* The lk_replay_owner is the open owner in the open_to_lock_owner
158 * case and the lock owner otherwise: */
159 struct nfs4_stateowner *lk_replay_owner;
1da177e4
LT
160};
161#define lk_new_open_seqid v.new.open_seqid
162#define lk_new_open_stateid v.new.open_stateid
163#define lk_new_lock_seqid v.new.lock_seqid
164#define lk_new_clientid v.new.clientid
165#define lk_new_owner v.new.owner
166#define lk_old_lock_stateid v.old.lock_stateid
167#define lk_old_lock_seqid v.old.lock_seqid
168
169#define lk_rflags u.ok.rflags
170#define lk_resp_stateid u.ok.stateid
171#define lk_denied u.denied
172
173
174struct nfsd4_lockt {
175 u32 lt_type;
176 clientid_t lt_clientid;
177 struct xdr_netobj lt_owner;
178 u64 lt_offset;
179 u64 lt_length;
180 struct nfs4_stateowner * lt_stateowner;
181 struct nfsd4_lock_denied lt_denied;
182};
183
184
185struct nfsd4_locku {
186 u32 lu_type;
187 u32 lu_seqid;
188 stateid_t lu_stateid;
189 u64 lu_offset;
190 u64 lu_length;
191 struct nfs4_stateowner *lu_stateowner;
192};
193
194
195struct nfsd4_lookup {
196 u32 lo_len; /* request */
197 char * lo_name; /* request */
198};
199
200struct nfsd4_putfh {
201 u32 pf_fhlen; /* request */
202 char *pf_fhval; /* request */
203};
204
205struct nfsd4_open {
206 u32 op_claim_type; /* request */
207 struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
208 u32 op_delegate_type; /* request - CLAIM_PREV only */
209 stateid_t op_delegate_stateid; /* request - response */
210 u32 op_create; /* request */
211 u32 op_createmode; /* request */
212 u32 op_bmval[2]; /* request */
213 union { /* request */
214 struct iattr iattr; /* UNCHECKED4,GUARDED4 */
215 nfs4_verifier verf; /* EXCLUSIVE4 */
216 } u;
217 clientid_t op_clientid; /* request */
218 struct xdr_netobj op_owner; /* request */
219 u32 op_seqid; /* request */
220 u32 op_share_access; /* request */
221 u32 op_share_deny; /* request */
222 stateid_t op_stateid; /* response */
7b190fec 223 u32 op_recall; /* recall */
1da177e4
LT
224 struct nfsd4_change_info op_cinfo; /* response */
225 u32 op_rflags; /* response */
226 int op_truncate; /* used during processing */
227 struct nfs4_stateowner *op_stateowner; /* used during processing */
228 struct nfs4_acl *op_acl;
229};
230#define op_iattr u.iattr
231#define op_verf u.verf
232
233struct nfsd4_open_confirm {
234 stateid_t oc_req_stateid /* request */;
235 u32 oc_seqid /* request */;
236 stateid_t oc_resp_stateid /* response */;
237 struct nfs4_stateowner * oc_stateowner; /* response */
238};
239
240struct nfsd4_open_downgrade {
241 stateid_t od_stateid;
242 u32 od_seqid;
243 u32 od_share_access;
244 u32 od_share_deny;
245 struct nfs4_stateowner *od_stateowner;
246};
247
248
249struct nfsd4_read {
250 stateid_t rd_stateid; /* request */
251 u64 rd_offset; /* request */
252 u32 rd_length; /* request */
1da177e4
LT
253 int rd_vlen;
254 struct file *rd_filp;
255
256 struct svc_rqst *rd_rqstp; /* response */
257 struct svc_fh * rd_fhp; /* response */
258};
259
260struct nfsd4_readdir {
261 u64 rd_cookie; /* request */
262 nfs4_verifier rd_verf; /* request */
263 u32 rd_dircount; /* request */
264 u32 rd_maxcount; /* request */
265 u32 rd_bmval[2]; /* request */
266 struct svc_rqst *rd_rqstp; /* response */
267 struct svc_fh * rd_fhp; /* response */
268
269 struct readdir_cd common;
2ebbc012 270 __be32 * buffer;
1da177e4 271 int buflen;
2ebbc012 272 __be32 * offset;
1da177e4
LT
273};
274
275struct nfsd4_release_lockowner {
276 clientid_t rl_clientid;
277 struct xdr_netobj rl_owner;
278};
279struct nfsd4_readlink {
280 struct svc_rqst *rl_rqstp; /* request */
281 struct svc_fh * rl_fhp; /* request */
282};
283
284struct nfsd4_remove {
285 u32 rm_namelen; /* request */
286 char * rm_name; /* request */
287 struct nfsd4_change_info rm_cinfo; /* response */
288};
289
290struct nfsd4_rename {
291 u32 rn_snamelen; /* request */
292 char * rn_sname; /* request */
293 u32 rn_tnamelen; /* request */
294 char * rn_tname; /* request */
295 struct nfsd4_change_info rn_sinfo; /* response */
296 struct nfsd4_change_info rn_tinfo; /* response */
297};
298
dcb488a3
AA
299struct nfsd4_secinfo {
300 u32 si_namelen; /* request */
301 char *si_name; /* request */
302 struct svc_export *si_exp; /* response */
303};
304
1da177e4
LT
305struct nfsd4_setattr {
306 stateid_t sa_stateid; /* request */
307 u32 sa_bmval[2]; /* request */
308 struct iattr sa_iattr; /* request */
309 struct nfs4_acl *sa_acl;
310};
311
312struct nfsd4_setclientid {
313 nfs4_verifier se_verf; /* request */
314 u32 se_namelen; /* request */
315 char * se_name; /* request */
316 u32 se_callback_prog; /* request */
317 u32 se_callback_netid_len; /* request */
318 char * se_callback_netid_val; /* request */
319 u32 se_callback_addr_len; /* request */
320 char * se_callback_addr_val; /* request */
321 u32 se_callback_ident; /* request */
322 clientid_t se_clientid; /* response */
323 nfs4_verifier se_confirm; /* response */
324};
325
326struct nfsd4_setclientid_confirm {
327 clientid_t sc_clientid;
328 nfs4_verifier sc_confirm;
329};
330
331/* also used for NVERIFY */
332struct nfsd4_verify {
333 u32 ve_bmval[2]; /* request */
334 u32 ve_attrlen; /* request */
335 char * ve_attrval; /* request */
336};
337
338struct nfsd4_write {
339 stateid_t wr_stateid; /* request */
340 u64 wr_offset; /* request */
341 u32 wr_stable_how; /* request */
342 u32 wr_buflen; /* request */
1da177e4
LT
343 int wr_vlen;
344
345 u32 wr_bytes_written; /* response */
346 u32 wr_how_written; /* response */
347 nfs4_verifier wr_verifier; /* response */
348};
349
2db134eb 350struct nfsd4_exchange_id {
0733d213
AA
351 nfs4_verifier verifier;
352 struct xdr_netobj clname;
353 u32 flags;
354 clientid_t clientid;
355 u32 seqid;
356 int spa_how;
2db134eb
AA
357};
358
359struct nfsd4_create_session {
360 int foo; /* stub */
361};
362
363struct nfsd4_sequence {
b85d4c01
BH
364 struct nfs4_sessionid sessionid; /* request/response */
365 u32 seqid; /* request/response */
366 u32 slotid; /* request/response */
367 u32 maxslots; /* request/response */
368 u32 cachethis; /* request */
369#if 0
370 u32 target_maxslots; /* response */
371 u32 status_flags; /* response */
372#endif /* not yet */
2db134eb
AA
373};
374
375struct nfsd4_destroy_session {
376 int foo; /* stub */
377};
378
1da177e4
LT
379struct nfsd4_op {
380 int opnum;
b37ad28b 381 __be32 status;
1da177e4
LT
382 union {
383 struct nfsd4_access access;
384 struct nfsd4_close close;
385 struct nfsd4_commit commit;
386 struct nfsd4_create create;
387 struct nfsd4_delegreturn delegreturn;
388 struct nfsd4_getattr getattr;
389 struct svc_fh * getfh;
390 struct nfsd4_link link;
391 struct nfsd4_lock lock;
392 struct nfsd4_lockt lockt;
393 struct nfsd4_locku locku;
394 struct nfsd4_lookup lookup;
395 struct nfsd4_verify nverify;
396 struct nfsd4_open open;
397 struct nfsd4_open_confirm open_confirm;
398 struct nfsd4_open_downgrade open_downgrade;
399 struct nfsd4_putfh putfh;
400 struct nfsd4_read read;
401 struct nfsd4_readdir readdir;
402 struct nfsd4_readlink readlink;
403 struct nfsd4_remove remove;
404 struct nfsd4_rename rename;
405 clientid_t renew;
dcb488a3 406 struct nfsd4_secinfo secinfo;
1da177e4
LT
407 struct nfsd4_setattr setattr;
408 struct nfsd4_setclientid setclientid;
409 struct nfsd4_setclientid_confirm setclientid_confirm;
410 struct nfsd4_verify verify;
411 struct nfsd4_write write;
412 struct nfsd4_release_lockowner release_lockowner;
2db134eb
AA
413
414 /* NFSv4.1 */
415 struct nfsd4_exchange_id exchange_id;
416 struct nfsd4_create_session create_session;
417 struct nfsd4_destroy_session destroy_session;
418 struct nfsd4_sequence sequence;
1da177e4
LT
419 } u;
420 struct nfs4_replay * replay;
421};
422
423struct nfsd4_compoundargs {
424 /* scratch variables for XDR decode */
2ebbc012
AV
425 __be32 * p;
426 __be32 * end;
1da177e4
LT
427 struct page ** pagelist;
428 int pagelen;
2ebbc012
AV
429 __be32 tmp[8];
430 __be32 * tmpp;
1da177e4
LT
431 struct tmpbuf {
432 struct tmpbuf *next;
433 void (*release)(const void *);
434 void *buf;
435 } *to_free;
436
437 struct svc_rqst *rqstp;
438
439 u32 taglen;
440 char * tag;
441 u32 minorversion;
442 u32 opcnt;
443 struct nfsd4_op *ops;
444 struct nfsd4_op iops[8];
445};
446
447struct nfsd4_compoundres {
448 /* scratch variables for XDR encode */
2ebbc012
AV
449 __be32 * p;
450 __be32 * end;
1da177e4
LT
451 struct xdr_buf * xbuf;
452 struct svc_rqst * rqstp;
453
454 u32 taglen;
455 char * tag;
456 u32 opcnt;
e354d571
AA
457 __be32 * tagp; /* tag, opcount encode location */
458 struct nfsd4_compound_state cstate;
1da177e4
LT
459};
460
461#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
462
463static inline void
464set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
465{
466 BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
467 cinfo->atomic = 1;
468 cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
469 cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
40ee5dc6
PS
470 cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
471 cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
1da177e4
LT
472}
473
2ebbc012
AV
474int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
475int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *,
1da177e4 476 struct nfsd4_compoundargs *);
2ebbc012 477int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *,
1da177e4
LT
478 struct nfsd4_compoundres *);
479void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
480void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
b37ad28b
AV
481__be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
482 struct dentry *dentry, __be32 *buffer, int *countp,
406a7ea9 483 u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
b37ad28b 484extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
b591480b 485 struct nfsd4_compound_state *,
1da177e4 486 struct nfsd4_setclientid *setclid);
b37ad28b 487extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
b591480b 488 struct nfsd4_compound_state *,
1da177e4 489 struct nfsd4_setclientid_confirm *setclientid_confirm);
069b6ad4
AA
490extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
491 struct nfsd4_compound_state *,
492struct nfsd4_exchange_id *);
493 extern __be32 nfsd4_create_session(struct svc_rqst *,
494 struct nfsd4_compound_state *,
495 struct nfsd4_create_session *);
496extern __be32 nfsd4_sequence(struct svc_rqst *,
497 struct nfsd4_compound_state *,
498 struct nfsd4_sequence *);
499extern __be32 nfsd4_destroy_session(struct svc_rqst *,
500 struct nfsd4_compound_state *,
501 struct nfsd4_destroy_session *);
b37ad28b
AV
502extern __be32 nfsd4_process_open1(struct nfsd4_open *open);
503extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
1da177e4 504 struct svc_fh *current_fh, struct nfsd4_open *open);
b37ad28b 505extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
a4f1706a 506 struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc);
ca364317
BF
507extern __be32 nfsd4_close(struct svc_rqst *rqstp,
508 struct nfsd4_compound_state *,
a4f1706a 509 struct nfsd4_close *close);
b37ad28b 510extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
a4f1706a
BF
511 struct nfsd4_compound_state *,
512 struct nfsd4_open_downgrade *od);
ca364317 513extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
a4f1706a 514 struct nfsd4_lock *lock);
ca364317
BF
515extern __be32 nfsd4_lockt(struct svc_rqst *rqstp,
516 struct nfsd4_compound_state *,
1da177e4 517 struct nfsd4_lockt *lockt);
ca364317
BF
518extern __be32 nfsd4_locku(struct svc_rqst *rqstp,
519 struct nfsd4_compound_state *,
a4f1706a 520 struct nfsd4_locku *locku);
b37ad28b 521extern __be32
1da177e4 522nfsd4_release_lockowner(struct svc_rqst *rqstp,
b591480b 523 struct nfsd4_compound_state *,
1da177e4
LT
524 struct nfsd4_release_lockowner *rlockowner);
525extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
b37ad28b 526extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
ca364317 527 struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr);
b591480b
BF
528extern __be32 nfsd4_renew(struct svc_rqst *rqstp,
529 struct nfsd4_compound_state *, clientid_t *clid);
1da177e4
LT
530#endif
531
532/*
533 * Local variables:
534 * c-basic-offset: 8
535 * End:
536 */