aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/nfsd
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/nfsd')
-rw-r--r--include/linux/nfsd/cache.h86
-rw-r--r--include/linux/nfsd/export.h19
-rw-r--r--include/linux/nfsd/nfsd.h424
-rw-r--r--include/linux/nfsd/nfsfh.h206
-rw-r--r--include/linux/nfsd/state.h404
-rw-r--r--include/linux/nfsd/syscall.h8
-rw-r--r--include/linux/nfsd/xdr.h177
-rw-r--r--include/linux/nfsd/xdr3.h346
-rw-r--r--include/linux/nfsd/xdr4.h563
9 files changed, 17 insertions, 2216 deletions
diff --git a/include/linux/nfsd/cache.h b/include/linux/nfsd/cache.h
deleted file mode 100644
index 3a3f58934f5e..000000000000
--- a/include/linux/nfsd/cache.h
+++ /dev/null
@@ -1,86 +0,0 @@
1/*
2 * include/linux/nfsd/cache.h
3 *
4 * Request reply cache. This was heavily inspired by the
5 * implementation in 4.3BSD/4.4BSD.
6 *
7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef NFSCACHE_H
11#define NFSCACHE_H
12
13#include <linux/in.h>
14#include <linux/uio.h>
15
16/*
17 * Representation of a reply cache entry.
18 */
19struct svc_cacherep {
20 struct hlist_node c_hash;
21 struct list_head c_lru;
22
23 unsigned char c_state, /* unused, inprog, done */
24 c_type, /* status, buffer */
25 c_secure : 1; /* req came from port < 1024 */
26 struct sockaddr_in c_addr;
27 __be32 c_xid;
28 u32 c_prot;
29 u32 c_proc;
30 u32 c_vers;
31 unsigned long c_timestamp;
32 union {
33 struct kvec u_vec;
34 __be32 u_status;
35 } c_u;
36};
37
38#define c_replvec c_u.u_vec
39#define c_replstat c_u.u_status
40
41/* cache entry states */
42enum {
43 RC_UNUSED,
44 RC_INPROG,
45 RC_DONE
46};
47
48/* return values */
49enum {
50 RC_DROPIT,
51 RC_REPLY,
52 RC_DOIT,
53 RC_INTR
54};
55
56/*
57 * Cache types.
58 * We may want to add more types one day, e.g. for diropres and
59 * attrstat replies. Using cache entries with fixed length instead
60 * of buffer pointers may be more efficient.
61 */
62enum {
63 RC_NOCACHE,
64 RC_REPLSTAT,
65 RC_REPLBUFF,
66};
67
68/*
69 * If requests are retransmitted within this interval, they're dropped.
70 */
71#define RC_DELAY (HZ/5)
72
73int nfsd_reply_cache_init(void);
74void nfsd_reply_cache_shutdown(void);
75int nfsd_cache_lookup(struct svc_rqst *, int);
76void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
77
78#ifdef CONFIG_NFSD_V4
79void nfsd4_set_statp(struct svc_rqst *rqstp, __be32 *statp);
80#else /* CONFIG_NFSD_V4 */
81static inline void nfsd4_set_statp(struct svc_rqst *rqstp, __be32 *statp)
82{
83}
84#endif /* CONFIG_NFSD_V4 */
85
86#endif /* NFSCACHE_H */
diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h
index a6d9ef2bb34a..8ae78a61eea4 100644
--- a/include/linux/nfsd/export.h
+++ b/include/linux/nfsd/export.h
@@ -12,7 +12,7 @@
12 12
13# include <linux/types.h> 13# include <linux/types.h>
14#ifdef __KERNEL__ 14#ifdef __KERNEL__
15# include <linux/in.h> 15# include <linux/nfsd/nfsfh.h>
16#endif 16#endif
17 17
18/* 18/*
@@ -39,11 +39,23 @@
39#define NFSEXP_FSID 0x2000 39#define NFSEXP_FSID 0x2000
40#define NFSEXP_CROSSMOUNT 0x4000 40#define NFSEXP_CROSSMOUNT 0x4000
41#define NFSEXP_NOACL 0x8000 /* reserved for possible ACL related use */ 41#define NFSEXP_NOACL 0x8000 /* reserved for possible ACL related use */
42#define NFSEXP_ALLFLAGS 0xFE3F 42/*
43 * The NFSEXP_V4ROOT flag causes the kernel to give access only to NFSv4
44 * clients, and only to the single directory that is the root of the
45 * export; further lookup and readdir operations are treated as if every
46 * subdirectory was a mountpoint, and ignored if they are not themselves
47 * exported. This is used by nfsd and mountd to construct the NFSv4
48 * pseudofilesystem, which provides access only to paths leading to each
49 * exported filesystem.
50 */
51#define NFSEXP_V4ROOT 0x10000
52/* All flags that we claim to support. (Note we don't support NOACL.) */
53#define NFSEXP_ALLFLAGS 0x17E3F
43 54
44/* The flags that may vary depending on security flavor: */ 55/* The flags that may vary depending on security flavor: */
45#define NFSEXP_SECINFO_FLAGS (NFSEXP_READONLY | NFSEXP_ROOTSQUASH \ 56#define NFSEXP_SECINFO_FLAGS (NFSEXP_READONLY | NFSEXP_ROOTSQUASH \
46 | NFSEXP_ALLSQUASH) 57 | NFSEXP_ALLSQUASH \
58 | NFSEXP_INSECURE_PORT)
47 59
48#ifdef __KERNEL__ 60#ifdef __KERNEL__
49 61
@@ -108,7 +120,6 @@ struct svc_expkey {
108 struct path ek_path; 120 struct path ek_path;
109}; 121};
110 122
111#define EX_SECURE(exp) (!((exp)->ex_flags & NFSEXP_INSECURE_PORT))
112#define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC)) 123#define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
113#define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE) 124#define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE)
114#define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES) 125#define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)
diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h
deleted file mode 100644
index 510ffdd5020e..000000000000
--- a/include/linux/nfsd/nfsd.h
+++ /dev/null
@@ -1,424 +0,0 @@
1/*
2 * linux/include/linux/nfsd/nfsd.h
3 *
4 * Hodge-podge collection of knfsd-related stuff.
5 * I will sort this out later.
6 *
7 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef LINUX_NFSD_NFSD_H
11#define LINUX_NFSD_NFSD_H
12
13#include <linux/types.h>
14#include <linux/unistd.h>
15#include <linux/fs.h>
16#include <linux/posix_acl.h>
17#include <linux/mount.h>
18
19#include <linux/nfsd/debug.h>
20#include <linux/nfsd/nfsfh.h>
21#include <linux/nfsd/export.h>
22#include <linux/nfsd/stats.h>
23/*
24 * nfsd version
25 */
26#define NFSD_SUPPORTED_MINOR_VERSION 1
27
28/*
29 * Flags for nfsd_permission
30 */
31#define NFSD_MAY_NOP 0
32#define NFSD_MAY_EXEC 1 /* == MAY_EXEC */
33#define NFSD_MAY_WRITE 2 /* == MAY_WRITE */
34#define NFSD_MAY_READ 4 /* == MAY_READ */
35#define NFSD_MAY_SATTR 8
36#define NFSD_MAY_TRUNC 16
37#define NFSD_MAY_LOCK 32
38#define NFSD_MAY_OWNER_OVERRIDE 64
39#define NFSD_MAY_LOCAL_ACCESS 128 /* IRIX doing local access check on device special file*/
40#define NFSD_MAY_BYPASS_GSS_ON_ROOT 256
41
42#define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE)
43#define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC)
44
45/*
46 * Callback function for readdir
47 */
48struct readdir_cd {
49 __be32 err; /* 0, nfserr, or nfserr_eof */
50};
51typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int);
52
53extern struct svc_program nfsd_program;
54extern struct svc_version nfsd_version2, nfsd_version3,
55 nfsd_version4;
56extern u32 nfsd_supported_minorversion;
57extern struct mutex nfsd_mutex;
58extern struct svc_serv *nfsd_serv;
59extern spinlock_t nfsd_drc_lock;
60extern unsigned int nfsd_drc_max_mem;
61extern unsigned int nfsd_drc_mem_used;
62
63extern const struct seq_operations nfs_exports_op;
64
65/*
66 * Function prototypes.
67 */
68int nfsd_svc(unsigned short port, int nrservs);
69int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp);
70
71int nfsd_nrthreads(void);
72int nfsd_nrpools(void);
73int nfsd_get_nrthreads(int n, int *);
74int nfsd_set_nrthreads(int n, int *);
75
76/* nfsd/vfs.c */
77int fh_lock_parent(struct svc_fh *, struct dentry *);
78int nfsd_racache_init(int);
79void nfsd_racache_shutdown(void);
80int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
81 struct svc_export **expp);
82__be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *,
83 const char *, unsigned int, struct svc_fh *);
84__be32 nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *,
85 const char *, unsigned int,
86 struct svc_export **, struct dentry **);
87__be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *,
88 struct iattr *, int, time_t);
89#ifdef CONFIG_NFSD_V4
90__be32 nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *,
91 struct nfs4_acl *);
92int nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **);
93#endif /* CONFIG_NFSD_V4 */
94__be32 nfsd_create(struct svc_rqst *, struct svc_fh *,
95 char *name, int len, struct iattr *attrs,
96 int type, dev_t rdev, struct svc_fh *res);
97#ifdef CONFIG_NFSD_V3
98__be32 nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
99__be32 nfsd_create_v3(struct svc_rqst *, struct svc_fh *,
100 char *name, int len, struct iattr *attrs,
101 struct svc_fh *res, int createmode,
102 u32 *verifier, int *truncp, int *created);
103__be32 nfsd_commit(struct svc_rqst *, struct svc_fh *,
104 loff_t, unsigned long);
105#endif /* CONFIG_NFSD_V3 */
106__be32 nfsd_open(struct svc_rqst *, struct svc_fh *, int,
107 int, struct file **);
108void nfsd_close(struct file *);
109__be32 nfsd_read(struct svc_rqst *, struct svc_fh *, struct file *,
110 loff_t, struct kvec *, int, unsigned long *);
111__be32 nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *,
112 loff_t, struct kvec *,int, unsigned long *, int *);
113__be32 nfsd_readlink(struct svc_rqst *, struct svc_fh *,
114 char *, int *);
115__be32 nfsd_symlink(struct svc_rqst *, struct svc_fh *,
116 char *name, int len, char *path, int plen,
117 struct svc_fh *res, struct iattr *);
118__be32 nfsd_link(struct svc_rqst *, struct svc_fh *,
119 char *, int, struct svc_fh *);
120__be32 nfsd_rename(struct svc_rqst *,
121 struct svc_fh *, char *, int,
122 struct svc_fh *, char *, int);
123__be32 nfsd_remove(struct svc_rqst *,
124 struct svc_fh *, char *, int);
125__be32 nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
126 char *name, int len);
127int nfsd_truncate(struct svc_rqst *, struct svc_fh *,
128 unsigned long size);
129__be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *,
130 loff_t *, struct readdir_cd *, filldir_t);
131__be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *,
132 struct kstatfs *, int access);
133
134int nfsd_notify_change(struct inode *, struct iattr *);
135__be32 nfsd_permission(struct svc_rqst *, struct svc_export *,
136 struct dentry *, int);
137int nfsd_sync_dir(struct dentry *dp);
138
139#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
140#ifdef CONFIG_NFSD_V2_ACL
141extern struct svc_version nfsd_acl_version2;
142#else
143#define nfsd_acl_version2 NULL
144#endif
145#ifdef CONFIG_NFSD_V3_ACL
146extern struct svc_version nfsd_acl_version3;
147#else
148#define nfsd_acl_version3 NULL
149#endif
150struct posix_acl *nfsd_get_posix_acl(struct svc_fh *, int);
151int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *);
152#endif
153
154enum vers_op {NFSD_SET, NFSD_CLEAR, NFSD_TEST, NFSD_AVAIL };
155int nfsd_vers(int vers, enum vers_op change);
156int nfsd_minorversion(u32 minorversion, enum vers_op change);
157void nfsd_reset_versions(void);
158int nfsd_create_serv(void);
159
160extern int nfsd_max_blksize;
161
162/*
163 * NFSv4 State
164 */
165#ifdef CONFIG_NFSD_V4
166extern unsigned int max_delegations;
167int nfs4_state_init(void);
168void nfsd4_free_slabs(void);
169int nfs4_state_start(void);
170void nfs4_state_shutdown(void);
171time_t nfs4_lease_time(void);
172void nfs4_reset_lease(time_t leasetime);
173int nfs4_reset_recoverydir(char *recdir);
174#else
175static inline int nfs4_state_init(void) { return 0; }
176static inline void nfsd4_free_slabs(void) { }
177static inline int nfs4_state_start(void) { return 0; }
178static inline void nfs4_state_shutdown(void) { }
179static inline time_t nfs4_lease_time(void) { return 0; }
180static inline void nfs4_reset_lease(time_t leasetime) { }
181static inline int nfs4_reset_recoverydir(char *recdir) { return 0; }
182#endif
183
184/*
185 * lockd binding
186 */
187void nfsd_lockd_init(void);
188void nfsd_lockd_shutdown(void);
189
190
191/*
192 * These macros provide pre-xdr'ed values for faster operation.
193 */
194#define nfs_ok cpu_to_be32(NFS_OK)
195#define nfserr_perm cpu_to_be32(NFSERR_PERM)
196#define nfserr_noent cpu_to_be32(NFSERR_NOENT)
197#define nfserr_io cpu_to_be32(NFSERR_IO)
198#define nfserr_nxio cpu_to_be32(NFSERR_NXIO)
199#define nfserr_eagain cpu_to_be32(NFSERR_EAGAIN)
200#define nfserr_acces cpu_to_be32(NFSERR_ACCES)
201#define nfserr_exist cpu_to_be32(NFSERR_EXIST)
202#define nfserr_xdev cpu_to_be32(NFSERR_XDEV)
203#define nfserr_nodev cpu_to_be32(NFSERR_NODEV)
204#define nfserr_notdir cpu_to_be32(NFSERR_NOTDIR)
205#define nfserr_isdir cpu_to_be32(NFSERR_ISDIR)
206#define nfserr_inval cpu_to_be32(NFSERR_INVAL)
207#define nfserr_fbig cpu_to_be32(NFSERR_FBIG)
208#define nfserr_nospc cpu_to_be32(NFSERR_NOSPC)
209#define nfserr_rofs cpu_to_be32(NFSERR_ROFS)
210#define nfserr_mlink cpu_to_be32(NFSERR_MLINK)
211#define nfserr_opnotsupp cpu_to_be32(NFSERR_OPNOTSUPP)
212#define nfserr_nametoolong cpu_to_be32(NFSERR_NAMETOOLONG)
213#define nfserr_notempty cpu_to_be32(NFSERR_NOTEMPTY)
214#define nfserr_dquot cpu_to_be32(NFSERR_DQUOT)
215#define nfserr_stale cpu_to_be32(NFSERR_STALE)
216#define nfserr_remote cpu_to_be32(NFSERR_REMOTE)
217#define nfserr_wflush cpu_to_be32(NFSERR_WFLUSH)
218#define nfserr_badhandle cpu_to_be32(NFSERR_BADHANDLE)
219#define nfserr_notsync cpu_to_be32(NFSERR_NOT_SYNC)
220#define nfserr_badcookie cpu_to_be32(NFSERR_BAD_COOKIE)
221#define nfserr_notsupp cpu_to_be32(NFSERR_NOTSUPP)
222#define nfserr_toosmall cpu_to_be32(NFSERR_TOOSMALL)
223#define nfserr_serverfault cpu_to_be32(NFSERR_SERVERFAULT)
224#define nfserr_badtype cpu_to_be32(NFSERR_BADTYPE)
225#define nfserr_jukebox cpu_to_be32(NFSERR_JUKEBOX)
226#define nfserr_denied cpu_to_be32(NFSERR_DENIED)
227#define nfserr_deadlock cpu_to_be32(NFSERR_DEADLOCK)
228#define nfserr_expired cpu_to_be32(NFSERR_EXPIRED)
229#define nfserr_bad_cookie cpu_to_be32(NFSERR_BAD_COOKIE)
230#define nfserr_same cpu_to_be32(NFSERR_SAME)
231#define nfserr_clid_inuse cpu_to_be32(NFSERR_CLID_INUSE)
232#define nfserr_stale_clientid cpu_to_be32(NFSERR_STALE_CLIENTID)
233#define nfserr_resource cpu_to_be32(NFSERR_RESOURCE)
234#define nfserr_moved cpu_to_be32(NFSERR_MOVED)
235#define nfserr_nofilehandle cpu_to_be32(NFSERR_NOFILEHANDLE)
236#define nfserr_minor_vers_mismatch cpu_to_be32(NFSERR_MINOR_VERS_MISMATCH)
237#define nfserr_share_denied cpu_to_be32(NFSERR_SHARE_DENIED)
238#define nfserr_stale_stateid cpu_to_be32(NFSERR_STALE_STATEID)
239#define nfserr_old_stateid cpu_to_be32(NFSERR_OLD_STATEID)
240#define nfserr_bad_stateid cpu_to_be32(NFSERR_BAD_STATEID)
241#define nfserr_bad_seqid cpu_to_be32(NFSERR_BAD_SEQID)
242#define nfserr_symlink cpu_to_be32(NFSERR_SYMLINK)
243#define nfserr_not_same cpu_to_be32(NFSERR_NOT_SAME)
244#define nfserr_restorefh cpu_to_be32(NFSERR_RESTOREFH)
245#define nfserr_attrnotsupp cpu_to_be32(NFSERR_ATTRNOTSUPP)
246#define nfserr_bad_xdr cpu_to_be32(NFSERR_BAD_XDR)
247#define nfserr_openmode cpu_to_be32(NFSERR_OPENMODE)
248#define nfserr_locks_held cpu_to_be32(NFSERR_LOCKS_HELD)
249#define nfserr_op_illegal cpu_to_be32(NFSERR_OP_ILLEGAL)
250#define nfserr_grace cpu_to_be32(NFSERR_GRACE)
251#define nfserr_no_grace cpu_to_be32(NFSERR_NO_GRACE)
252#define nfserr_reclaim_bad cpu_to_be32(NFSERR_RECLAIM_BAD)
253#define nfserr_badname cpu_to_be32(NFSERR_BADNAME)
254#define nfserr_cb_path_down cpu_to_be32(NFSERR_CB_PATH_DOWN)
255#define nfserr_locked cpu_to_be32(NFSERR_LOCKED)
256#define nfserr_wrongsec cpu_to_be32(NFSERR_WRONGSEC)
257#define nfserr_badiomode cpu_to_be32(NFS4ERR_BADIOMODE)
258#define nfserr_badlayout cpu_to_be32(NFS4ERR_BADLAYOUT)
259#define nfserr_bad_session_digest cpu_to_be32(NFS4ERR_BAD_SESSION_DIGEST)
260#define nfserr_badsession cpu_to_be32(NFS4ERR_BADSESSION)
261#define nfserr_badslot cpu_to_be32(NFS4ERR_BADSLOT)
262#define nfserr_complete_already cpu_to_be32(NFS4ERR_COMPLETE_ALREADY)
263#define nfserr_conn_not_bound_to_session cpu_to_be32(NFS4ERR_CONN_NOT_BOUND_TO_SESSION)
264#define nfserr_deleg_already_wanted cpu_to_be32(NFS4ERR_DELEG_ALREADY_WANTED)
265#define nfserr_back_chan_busy cpu_to_be32(NFS4ERR_BACK_CHAN_BUSY)
266#define nfserr_layouttrylater cpu_to_be32(NFS4ERR_LAYOUTTRYLATER)
267#define nfserr_layoutunavailable cpu_to_be32(NFS4ERR_LAYOUTUNAVAILABLE)
268#define nfserr_nomatching_layout cpu_to_be32(NFS4ERR_NOMATCHING_LAYOUT)
269#define nfserr_recallconflict cpu_to_be32(NFS4ERR_RECALLCONFLICT)
270#define nfserr_unknown_layouttype cpu_to_be32(NFS4ERR_UNKNOWN_LAYOUTTYPE)
271#define nfserr_seq_misordered cpu_to_be32(NFS4ERR_SEQ_MISORDERED)
272#define nfserr_sequence_pos cpu_to_be32(NFS4ERR_SEQUENCE_POS)
273#define nfserr_req_too_big cpu_to_be32(NFS4ERR_REQ_TOO_BIG)
274#define nfserr_rep_too_big cpu_to_be32(NFS4ERR_REP_TOO_BIG)
275#define nfserr_rep_too_big_to_cache cpu_to_be32(NFS4ERR_REP_TOO_BIG_TO_CACHE)
276#define nfserr_retry_uncached_rep cpu_to_be32(NFS4ERR_RETRY_UNCACHED_REP)
277#define nfserr_unsafe_compound cpu_to_be32(NFS4ERR_UNSAFE_COMPOUND)
278#define nfserr_too_many_ops cpu_to_be32(NFS4ERR_TOO_MANY_OPS)
279#define nfserr_op_not_in_session cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION)
280#define nfserr_hash_alg_unsupp cpu_to_be32(NFS4ERR_HASH_ALG_UNSUPP)
281#define nfserr_clientid_busy cpu_to_be32(NFS4ERR_CLIENTID_BUSY)
282#define nfserr_pnfs_io_hole cpu_to_be32(NFS4ERR_PNFS_IO_HOLE)
283#define nfserr_seq_false_retry cpu_to_be32(NFS4ERR_SEQ_FALSE_RETRY)
284#define nfserr_bad_high_slot cpu_to_be32(NFS4ERR_BAD_HIGH_SLOT)
285#define nfserr_deadsession cpu_to_be32(NFS4ERR_DEADSESSION)
286#define nfserr_encr_alg_unsupp cpu_to_be32(NFS4ERR_ENCR_ALG_UNSUPP)
287#define nfserr_pnfs_no_layout cpu_to_be32(NFS4ERR_PNFS_NO_LAYOUT)
288#define nfserr_not_only_op cpu_to_be32(NFS4ERR_NOT_ONLY_OP)
289#define nfserr_wrong_cred cpu_to_be32(NFS4ERR_WRONG_CRED)
290#define nfserr_wrong_type cpu_to_be32(NFS4ERR_WRONG_TYPE)
291#define nfserr_dirdeleg_unavail cpu_to_be32(NFS4ERR_DIRDELEG_UNAVAIL)
292#define nfserr_reject_deleg cpu_to_be32(NFS4ERR_REJECT_DELEG)
293#define nfserr_returnconflict cpu_to_be32(NFS4ERR_RETURNCONFLICT)
294#define nfserr_deleg_revoked cpu_to_be32(NFS4ERR_DELEG_REVOKED)
295
296/* error codes for internal use */
297/* if a request fails due to kmalloc failure, it gets dropped.
298 * Client should resend eventually
299 */
300#define nfserr_dropit cpu_to_be32(30000)
301/* end-of-file indicator in readdir */
302#define nfserr_eof cpu_to_be32(30001)
303/* replay detected */
304#define nfserr_replay_me cpu_to_be32(11001)
305/* nfs41 replay detected */
306#define nfserr_replay_cache cpu_to_be32(11002)
307
308/* Check for dir entries '.' and '..' */
309#define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.'))
310
311/*
312 * Time of server startup
313 */
314extern struct timeval nfssvc_boot;
315
316#ifdef CONFIG_NFSD_V4
317
318/* before processing a COMPOUND operation, we have to check that there
319 * is enough space in the buffer for XDR encode to succeed. otherwise,
320 * we might process an operation with side effects, and be unable to
321 * tell the client that the operation succeeded.
322 *
323 * COMPOUND_SLACK_SPACE - this is the minimum bytes of buffer space
324 * needed to encode an "ordinary" _successful_ operation. (GETATTR,
325 * READ, READDIR, and READLINK have their own buffer checks.) if we
326 * fall below this level, we fail the next operation with NFS4ERR_RESOURCE.
327 *
328 * COMPOUND_ERR_SLACK_SPACE - this is the minimum bytes of buffer space
329 * needed to encode an operation which has failed with NFS4ERR_RESOURCE.
330 * care is taken to ensure that we never fall below this level for any
331 * reason.
332 */
333#define COMPOUND_SLACK_SPACE 140 /* OP_GETFH */
334#define COMPOUND_ERR_SLACK_SPACE 12 /* OP_SETATTR */
335
336#define NFSD_LEASE_TIME (nfs4_lease_time())
337#define NFSD_LAUNDROMAT_MINTIMEOUT 10 /* seconds */
338
339/*
340 * The following attributes are currently not supported by the NFSv4 server:
341 * ARCHIVE (deprecated anyway)
342 * HIDDEN (unlikely to be supported any time soon)
343 * MIMETYPE (unlikely to be supported any time soon)
344 * QUOTA_* (will be supported in a forthcoming patch)
345 * SYSTEM (unlikely to be supported any time soon)
346 * TIME_BACKUP (unlikely to be supported any time soon)
347 * TIME_CREATE (unlikely to be supported any time soon)
348 */
349#define NFSD4_SUPPORTED_ATTRS_WORD0 \
350(FATTR4_WORD0_SUPPORTED_ATTRS | FATTR4_WORD0_TYPE | FATTR4_WORD0_FH_EXPIRE_TYPE \
351 | FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE | FATTR4_WORD0_LINK_SUPPORT \
352 | FATTR4_WORD0_SYMLINK_SUPPORT | FATTR4_WORD0_NAMED_ATTR | FATTR4_WORD0_FSID \
353 | FATTR4_WORD0_UNIQUE_HANDLES | FATTR4_WORD0_LEASE_TIME | FATTR4_WORD0_RDATTR_ERROR \
354 | FATTR4_WORD0_ACLSUPPORT | FATTR4_WORD0_CANSETTIME | FATTR4_WORD0_CASE_INSENSITIVE \
355 | FATTR4_WORD0_CASE_PRESERVING | FATTR4_WORD0_CHOWN_RESTRICTED \
356 | FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FILEID | FATTR4_WORD0_FILES_AVAIL \
357 | FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_HOMOGENEOUS \
358 | FATTR4_WORD0_MAXFILESIZE | FATTR4_WORD0_MAXLINK | FATTR4_WORD0_MAXNAME \
359 | FATTR4_WORD0_MAXREAD | FATTR4_WORD0_MAXWRITE | FATTR4_WORD0_ACL)
360
361#define NFSD4_SUPPORTED_ATTRS_WORD1 \
362(FATTR4_WORD1_MODE | FATTR4_WORD1_NO_TRUNC | FATTR4_WORD1_NUMLINKS \
363 | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP | FATTR4_WORD1_RAWDEV \
364 | FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | FATTR4_WORD1_SPACE_TOTAL \
365 | FATTR4_WORD1_SPACE_USED | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_ACCESS_SET \
366 | FATTR4_WORD1_TIME_DELTA | FATTR4_WORD1_TIME_METADATA \
367 | FATTR4_WORD1_TIME_MODIFY | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)
368
369#define NFSD4_SUPPORTED_ATTRS_WORD2 0
370
371#define NFSD4_1_SUPPORTED_ATTRS_WORD0 \
372 NFSD4_SUPPORTED_ATTRS_WORD0
373
374#define NFSD4_1_SUPPORTED_ATTRS_WORD1 \
375 NFSD4_SUPPORTED_ATTRS_WORD1
376
377#define NFSD4_1_SUPPORTED_ATTRS_WORD2 \
378 (NFSD4_SUPPORTED_ATTRS_WORD2 | FATTR4_WORD2_SUPPATTR_EXCLCREAT)
379
380static inline u32 nfsd_suppattrs0(u32 minorversion)
381{
382 return minorversion ? NFSD4_1_SUPPORTED_ATTRS_WORD0
383 : NFSD4_SUPPORTED_ATTRS_WORD0;
384}
385
386static inline u32 nfsd_suppattrs1(u32 minorversion)
387{
388 return minorversion ? NFSD4_1_SUPPORTED_ATTRS_WORD1
389 : NFSD4_SUPPORTED_ATTRS_WORD1;
390}
391
392static inline u32 nfsd_suppattrs2(u32 minorversion)
393{
394 return minorversion ? NFSD4_1_SUPPORTED_ATTRS_WORD2
395 : NFSD4_SUPPORTED_ATTRS_WORD2;
396}
397
398/* These will return ERR_INVAL if specified in GETATTR or READDIR. */
399#define NFSD_WRITEONLY_ATTRS_WORD1 \
400(FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET)
401
402/* These are the only attrs allowed in CREATE/OPEN/SETATTR. */
403#define NFSD_WRITEABLE_ATTRS_WORD0 \
404(FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL )
405#define NFSD_WRITEABLE_ATTRS_WORD1 \
406(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \
407 | FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET)
408#define NFSD_WRITEABLE_ATTRS_WORD2 0
409
410#define NFSD_SUPPATTR_EXCLCREAT_WORD0 \
411 NFSD_WRITEABLE_ATTRS_WORD0
412/*
413 * we currently store the exclusive create verifier in the v_{a,m}time
414 * attributes so the client can't set these at create time using EXCLUSIVE4_1
415 */
416#define NFSD_SUPPATTR_EXCLCREAT_WORD1 \
417 (NFSD_WRITEABLE_ATTRS_WORD1 & \
418 ~(FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET))
419#define NFSD_SUPPATTR_EXCLCREAT_WORD2 \
420 NFSD_WRITEABLE_ATTRS_WORD2
421
422#endif /* CONFIG_NFSD_V4 */
423
424#endif /* LINUX_NFSD_NFSD_H */
diff --git a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
index 8f641c908450..65e333afaee4 100644
--- a/include/linux/nfsd/nfsfh.h
+++ b/include/linux/nfsd/nfsfh.h
@@ -16,11 +16,9 @@
16 16
17# include <linux/types.h> 17# include <linux/types.h>
18#ifdef __KERNEL__ 18#ifdef __KERNEL__
19# include <linux/string.h> 19# include <linux/sunrpc/svc.h>
20# include <linux/fs.h>
21#endif 20#endif
22#include <linux/nfsd/const.h> 21#include <linux/nfsd/const.h>
23#include <linux/nfsd/debug.h>
24 22
25/* 23/*
26 * This is the old "dentry style" Linux NFSv2 file handle. 24 * This is the old "dentry style" Linux NFSv2 file handle.
@@ -164,208 +162,6 @@ typedef struct svc_fh {
164 162
165} svc_fh; 163} svc_fh;
166 164
167enum nfsd_fsid {
168 FSID_DEV = 0,
169 FSID_NUM,
170 FSID_MAJOR_MINOR,
171 FSID_ENCODE_DEV,
172 FSID_UUID4_INUM,
173 FSID_UUID8,
174 FSID_UUID16,
175 FSID_UUID16_INUM,
176};
177
178enum fsid_source {
179 FSIDSOURCE_DEV,
180 FSIDSOURCE_FSID,
181 FSIDSOURCE_UUID,
182};
183extern enum fsid_source fsid_source(struct svc_fh *fhp);
184
185
186/* This might look a little large to "inline" but in all calls except
187 * one, 'vers' is constant so moste of the function disappears.
188 */
189static inline void mk_fsid(int vers, u32 *fsidv, dev_t dev, ino_t ino,
190 u32 fsid, unsigned char *uuid)
191{
192 u32 *up;
193 switch(vers) {
194 case FSID_DEV:
195 fsidv[0] = htonl((MAJOR(dev)<<16) |
196 MINOR(dev));
197 fsidv[1] = ino_t_to_u32(ino);
198 break;
199 case FSID_NUM:
200 fsidv[0] = fsid;
201 break;
202 case FSID_MAJOR_MINOR:
203 fsidv[0] = htonl(MAJOR(dev));
204 fsidv[1] = htonl(MINOR(dev));
205 fsidv[2] = ino_t_to_u32(ino);
206 break;
207
208 case FSID_ENCODE_DEV:
209 fsidv[0] = new_encode_dev(dev);
210 fsidv[1] = ino_t_to_u32(ino);
211 break;
212
213 case FSID_UUID4_INUM:
214 /* 4 byte fsid and inode number */
215 up = (u32*)uuid;
216 fsidv[0] = ino_t_to_u32(ino);
217 fsidv[1] = up[0] ^ up[1] ^ up[2] ^ up[3];
218 break;
219
220 case FSID_UUID8:
221 /* 8 byte fsid */
222 up = (u32*)uuid;
223 fsidv[0] = up[0] ^ up[2];
224 fsidv[1] = up[1] ^ up[3];
225 break;
226
227 case FSID_UUID16:
228 /* 16 byte fsid - NFSv3+ only */
229 memcpy(fsidv, uuid, 16);
230 break;
231
232 case FSID_UUID16_INUM:
233 /* 8 byte inode and 16 byte fsid */
234 *(u64*)fsidv = (u64)ino;
235 memcpy(fsidv+2, uuid, 16);
236 break;
237 default: BUG();
238 }
239}
240
241static inline int key_len(int type)
242{
243 switch(type) {
244 case FSID_DEV: return 8;
245 case FSID_NUM: return 4;
246 case FSID_MAJOR_MINOR: return 12;
247 case FSID_ENCODE_DEV: return 8;
248 case FSID_UUID4_INUM: return 8;
249 case FSID_UUID8: return 8;
250 case FSID_UUID16: return 16;
251 case FSID_UUID16_INUM: return 24;
252 default: return 0;
253 }
254}
255
256/*
257 * Shorthand for dprintk()'s
258 */
259extern char * SVCFH_fmt(struct svc_fh *fhp);
260
261/*
262 * Function prototypes
263 */
264__be32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int);
265__be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *);
266__be32 fh_update(struct svc_fh *);
267void fh_put(struct svc_fh *);
268
269static __inline__ struct svc_fh *
270fh_copy(struct svc_fh *dst, struct svc_fh *src)
271{
272 WARN_ON(src->fh_dentry || src->fh_locked);
273
274 *dst = *src;
275 return dst;
276}
277
278static inline void
279fh_copy_shallow(struct knfsd_fh *dst, struct knfsd_fh *src)
280{
281 dst->fh_size = src->fh_size;
282 memcpy(&dst->fh_base, &src->fh_base, src->fh_size);
283}
284
285static __inline__ struct svc_fh *
286fh_init(struct svc_fh *fhp, int maxsize)
287{
288 memset(fhp, 0, sizeof(*fhp));
289 fhp->fh_maxsize = maxsize;
290 return fhp;
291}
292
293#ifdef CONFIG_NFSD_V3
294/*
295 * Fill in the pre_op attr for the wcc data
296 */
297static inline void
298fill_pre_wcc(struct svc_fh *fhp)
299{
300 struct inode *inode;
301
302 inode = fhp->fh_dentry->d_inode;
303 if (!fhp->fh_pre_saved) {
304 fhp->fh_pre_mtime = inode->i_mtime;
305 fhp->fh_pre_ctime = inode->i_ctime;
306 fhp->fh_pre_size = inode->i_size;
307 fhp->fh_pre_change = inode->i_version;
308 fhp->fh_pre_saved = 1;
309 }
310}
311
312extern void fill_post_wcc(struct svc_fh *);
313#else
314#define fill_pre_wcc(ignored)
315#define fill_post_wcc(notused)
316#endif /* CONFIG_NFSD_V3 */
317
318
319/*
320 * Lock a file handle/inode
321 * NOTE: both fh_lock and fh_unlock are done "by hand" in
322 * vfs.c:nfsd_rename as it needs to grab 2 i_mutex's at once
323 * so, any changes here should be reflected there.
324 */
325
326static inline void
327fh_lock_nested(struct svc_fh *fhp, unsigned int subclass)
328{
329 struct dentry *dentry = fhp->fh_dentry;
330 struct inode *inode;
331
332 dfprintk(FILEOP, "nfsd: fh_lock(%s) locked = %d\n",
333 SVCFH_fmt(fhp), fhp->fh_locked);
334
335 BUG_ON(!dentry);
336
337 if (fhp->fh_locked) {
338 printk(KERN_WARNING "fh_lock: %s/%s already locked!\n",
339 dentry->d_parent->d_name.name, dentry->d_name.name);
340 return;
341 }
342
343 inode = dentry->d_inode;
344 mutex_lock_nested(&inode->i_mutex, subclass);
345 fill_pre_wcc(fhp);
346 fhp->fh_locked = 1;
347}
348
349static inline void
350fh_lock(struct svc_fh *fhp)
351{
352 fh_lock_nested(fhp, I_MUTEX_NORMAL);
353}
354
355/*
356 * Unlock a file handle/inode
357 */
358static inline void
359fh_unlock(struct svc_fh *fhp)
360{
361 BUG_ON(!fhp->fh_dentry);
362
363 if (fhp->fh_locked) {
364 fill_post_wcc(fhp);
365 mutex_unlock(&fhp->fh_dentry->d_inode->i_mutex);
366 fhp->fh_locked = 0;
367 }
368}
369#endif /* __KERNEL__ */ 165#endif /* __KERNEL__ */
370 166
371 167
diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
deleted file mode 100644
index b38d11324189..000000000000
--- a/include/linux/nfsd/state.h
+++ /dev/null
@@ -1,404 +0,0 @@
1/*
2 * linux/include/nfsd/state.h
3 *
4 * Copyright (c) 2001 The Regents of the University of Michigan.
5 * All rights reserved.
6 *
7 * Kendrick Smith <kmsmith@umich.edu>
8 * Andy Adamson <andros@umich.edu>
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 */
36
37#ifndef _NFSD4_STATE_H
38#define _NFSD4_STATE_H
39
40#include <linux/list.h>
41#include <linux/kref.h>
42#include <linux/sunrpc/clnt.h>
43
44typedef struct {
45 u32 cl_boot;
46 u32 cl_id;
47} clientid_t;
48
49typedef struct {
50 u32 so_boot;
51 u32 so_stateownerid;
52 u32 so_fileid;
53} stateid_opaque_t;
54
55typedef struct {
56 u32 si_generation;
57 stateid_opaque_t si_opaque;
58} stateid_t;
59#define si_boot si_opaque.so_boot
60#define si_stateownerid si_opaque.so_stateownerid
61#define si_fileid si_opaque.so_fileid
62
63struct nfsd4_cb_sequence {
64 /* args/res */
65 u32 cbs_minorversion;
66 struct nfs4_client *cbs_clp;
67};
68
69struct nfs4_delegation {
70 struct list_head dl_perfile;
71 struct list_head dl_perclnt;
72 struct list_head dl_recall_lru; /* delegation recalled */
73 atomic_t dl_count; /* ref count */
74 struct nfs4_client *dl_client;
75 struct nfs4_file *dl_file;
76 struct file_lock *dl_flock;
77 struct file *dl_vfs_file;
78 u32 dl_type;
79 time_t dl_time;
80/* For recall: */
81 u32 dl_ident;
82 stateid_t dl_stateid;
83 struct knfsd_fh dl_fh;
84 int dl_retries;
85};
86
87/* client delegation callback info */
88struct nfs4_cb_conn {
89 /* SETCLIENTID info */
90 struct sockaddr_storage cb_addr;
91 size_t cb_addrlen;
92 u32 cb_prog;
93 u32 cb_minorversion;
94 u32 cb_ident; /* minorversion 0 only */
95 /* RPC client info */
96 atomic_t cb_set; /* successful CB_NULL call */
97 struct rpc_clnt * cb_client;
98};
99
100/* Maximum number of slots per session. 160 is useful for long haul TCP */
101#define NFSD_MAX_SLOTS_PER_SESSION 160
102/* Maximum number of operations per session compound */
103#define NFSD_MAX_OPS_PER_COMPOUND 16
104/* Maximum session per slot cache size */
105#define NFSD_SLOT_CACHE_SIZE 1024
106/* Maximum number of NFSD_SLOT_CACHE_SIZE slots per session */
107#define NFSD_CACHE_SIZE_SLOTS_PER_SESSION 32
108#define NFSD_MAX_MEM_PER_SESSION \
109 (NFSD_CACHE_SIZE_SLOTS_PER_SESSION * NFSD_SLOT_CACHE_SIZE)
110
111struct nfsd4_slot {
112 bool sl_inuse;
113 bool sl_cachethis;
114 u16 sl_opcnt;
115 u32 sl_seqid;
116 __be32 sl_status;
117 u32 sl_datalen;
118 char sl_data[];
119};
120
121struct nfsd4_channel_attrs {
122 u32 headerpadsz;
123 u32 maxreq_sz;
124 u32 maxresp_sz;
125 u32 maxresp_cached;
126 u32 maxops;
127 u32 maxreqs;
128 u32 nr_rdma_attrs;
129 u32 rdma_attrs;
130};
131
132struct nfsd4_create_session {
133 clientid_t clientid;
134 struct nfs4_sessionid sessionid;
135 u32 seqid;
136 u32 flags;
137 struct nfsd4_channel_attrs fore_channel;
138 struct nfsd4_channel_attrs back_channel;
139 u32 callback_prog;
140 u32 uid;
141 u32 gid;
142};
143
144/* The single slot clientid cache structure */
145struct nfsd4_clid_slot {
146 u32 sl_seqid;
147 __be32 sl_status;
148 struct nfsd4_create_session sl_cr_ses;
149};
150
151struct nfsd4_session {
152 struct kref se_ref;
153 struct list_head se_hash; /* hash by sessionid */
154 struct list_head se_perclnt;
155 u32 se_flags;
156 struct nfs4_client *se_client; /* for expire_client */
157 struct nfs4_sessionid se_sessionid;
158 struct nfsd4_channel_attrs se_fchannel;
159 struct nfsd4_channel_attrs se_bchannel;
160 struct nfsd4_slot *se_slots[]; /* forward channel slots */
161};
162
163static inline void
164nfsd4_put_session(struct nfsd4_session *ses)
165{
166 extern void free_session(struct kref *kref);
167 kref_put(&ses->se_ref, free_session);
168}
169
170static inline void
171nfsd4_get_session(struct nfsd4_session *ses)
172{
173 kref_get(&ses->se_ref);
174}
175
176/* formatted contents of nfs4_sessionid */
177struct nfsd4_sessionid {
178 clientid_t clientid;
179 u32 sequence;
180 u32 reserved;
181};
182
183#define HEXDIR_LEN 33 /* hex version of 16 byte md5 of cl_name plus '\0' */
184
185/*
186 * struct nfs4_client - one per client. Clientids live here.
187 * o Each nfs4_client is hashed by clientid.
188 *
189 * o Each nfs4_clients is also hashed by name
190 * (the opaque quantity initially sent by the client to identify itself).
191 *
192 * o cl_perclient list is used to ensure no dangling stateowner references
193 * when we expire the nfs4_client
194 */
195struct nfs4_client {
196 struct list_head cl_idhash; /* hash by cl_clientid.id */
197 struct list_head cl_strhash; /* hash by cl_name */
198 struct list_head cl_openowners;
199 struct list_head cl_delegations;
200 struct list_head cl_lru; /* tail queue */
201 struct xdr_netobj cl_name; /* id generated by client */
202 char cl_recdir[HEXDIR_LEN]; /* recovery dir */
203 nfs4_verifier cl_verifier; /* generated by client */
204 time_t cl_time; /* time of last lease renewal */
205 struct sockaddr_storage cl_addr; /* client ipaddress */
206 u32 cl_flavor; /* setclientid pseudoflavor */
207 char *cl_principal; /* setclientid principal name */
208 struct svc_cred cl_cred; /* setclientid principal */
209 clientid_t cl_clientid; /* generated by server */
210 nfs4_verifier cl_confirm; /* generated by server */
211 struct nfs4_cb_conn cl_cb_conn; /* callback info */
212 atomic_t cl_count; /* ref count */
213 u32 cl_firststate; /* recovery dir creation */
214
215 /* for nfs41 */
216 struct list_head cl_sessions;
217 struct nfsd4_clid_slot cl_cs_slot; /* create_session slot */
218 u32 cl_exchange_flags;
219 struct nfs4_sessionid cl_sessionid;
220
221 /* for nfs41 callbacks */
222 /* We currently support a single back channel with a single slot */
223 unsigned long cl_cb_slot_busy;
224 u32 cl_cb_seq_nr;
225 struct svc_xprt *cl_cb_xprt; /* 4.1 callback transport */
226 struct rpc_wait_queue cl_cb_waitq; /* backchannel callers may */
227 /* wait here for slots */
228};
229
230/* struct nfs4_client_reset
231 * one per old client. Populates reset_str_hashtbl. Filled from conf_id_hashtbl
232 * upon lease reset, or from upcall to state_daemon (to read in state
233 * from non-volitile storage) upon reboot.
234 */
235struct nfs4_client_reclaim {
236 struct list_head cr_strhash; /* hash by cr_name */
237 char cr_recdir[HEXDIR_LEN]; /* recover dir */
238};
239
240static inline void
241update_stateid(stateid_t *stateid)
242{
243 stateid->si_generation++;
244}
245
246/* A reasonable value for REPLAY_ISIZE was estimated as follows:
247 * The OPEN response, typically the largest, requires
248 * 4(status) + 8(stateid) + 20(changeinfo) + 4(rflags) + 8(verifier) +
249 * 4(deleg. type) + 8(deleg. stateid) + 4(deleg. recall flag) +
250 * 20(deleg. space limit) + ~32(deleg. ace) = 112 bytes
251 */
252
253#define NFSD4_REPLAY_ISIZE 112
254
255/*
256 * Replay buffer, where the result of the last seqid-mutating operation
257 * is cached.
258 */
259struct nfs4_replay {
260 __be32 rp_status;
261 unsigned int rp_buflen;
262 char *rp_buf;
263 unsigned intrp_allocated;
264 struct knfsd_fh rp_openfh;
265 char rp_ibuf[NFSD4_REPLAY_ISIZE];
266};
267
268/*
269* nfs4_stateowner can either be an open_owner, or a lock_owner
270*
271* so_idhash: stateid_hashtbl[] for open owner, lockstateid_hashtbl[]
272* for lock_owner
273* so_strhash: ownerstr_hashtbl[] for open_owner, lock_ownerstr_hashtbl[]
274* for lock_owner
275* so_perclient: nfs4_client->cl_perclient entry - used when nfs4_client
276* struct is reaped.
277* so_perfilestate: heads the list of nfs4_stateid (either open or lock)
278* and is used to ensure no dangling nfs4_stateid references when we
279* release a stateowner.
280* so_perlockowner: (open) nfs4_stateid->st_perlockowner entry - used when
281* close is called to reap associated byte-range locks
282* so_close_lru: (open) stateowner is placed on this list instead of being
283* reaped (when so_perfilestate is empty) to hold the last close replay.
284* reaped by laundramat thread after lease period.
285*/
286struct nfs4_stateowner {
287 struct kref so_ref;
288 struct list_head so_idhash; /* hash by so_id */
289 struct list_head so_strhash; /* hash by op_name */
290 struct list_head so_perclient;
291 struct list_head so_stateids;
292 struct list_head so_perstateid; /* for lockowners only */
293 struct list_head so_close_lru; /* tail queue */
294 time_t so_time; /* time of placement on so_close_lru */
295 int so_is_open_owner; /* 1=openowner,0=lockowner */
296 u32 so_id;
297 struct nfs4_client * so_client;
298 /* after increment in ENCODE_SEQID_OP_TAIL, represents the next
299 * sequence id expected from the client: */
300 u32 so_seqid;
301 struct xdr_netobj so_owner; /* open owner name */
302 int so_confirmed; /* successful OPEN_CONFIRM? */
303 struct nfs4_replay so_replay;
304};
305
306/*
307* nfs4_file: a file opened by some number of (open) nfs4_stateowners.
308* o fi_perfile list is used to search for conflicting
309* share_acces, share_deny on the file.
310*/
311struct nfs4_file {
312 atomic_t fi_ref;
313 struct list_head fi_hash; /* hash by "struct inode *" */
314 struct list_head fi_stateids;
315 struct list_head fi_delegations;
316 struct inode *fi_inode;
317 u32 fi_id; /* used with stateowner->so_id
318 * for stateid_hashtbl hash */
319 bool fi_had_conflict;
320};
321
322/*
323* nfs4_stateid can either be an open stateid or (eventually) a lock stateid
324*
325* (open)nfs4_stateid: one per (open)nfs4_stateowner, nfs4_file
326*
327* st_hash: stateid_hashtbl[] entry or lockstateid_hashtbl entry
328* st_perfile: file_hashtbl[] entry.
329* st_perfile_state: nfs4_stateowner->so_perfilestate
330* st_perlockowner: (open stateid) list of lock nfs4_stateowners
331* st_access_bmap: used only for open stateid
332* st_deny_bmap: used only for open stateid
333* st_openstp: open stateid lock stateid was derived from
334*
335* XXX: open stateids and lock stateids have diverged sufficiently that
336* we should consider defining separate structs for the two cases.
337*/
338
339struct nfs4_stateid {
340 struct list_head st_hash;
341 struct list_head st_perfile;
342 struct list_head st_perstateowner;
343 struct list_head st_lockowners;
344 struct nfs4_stateowner * st_stateowner;
345 struct nfs4_file * st_file;
346 stateid_t st_stateid;
347 struct file * st_vfs_file;
348 unsigned long st_access_bmap;
349 unsigned long st_deny_bmap;
350 struct nfs4_stateid * st_openstp;
351};
352
353/* flags for preprocess_seqid_op() */
354#define HAS_SESSION 0x00000001
355#define CONFIRM 0x00000002
356#define OPEN_STATE 0x00000004
357#define LOCK_STATE 0x00000008
358#define RD_STATE 0x00000010
359#define WR_STATE 0x00000020
360#define CLOSE_STATE 0x00000040
361
362#define seqid_mutating_err(err) \
363 (((err) != nfserr_stale_clientid) && \
364 ((err) != nfserr_bad_seqid) && \
365 ((err) != nfserr_stale_stateid) && \
366 ((err) != nfserr_bad_stateid))
367
368struct nfsd4_compound_state;
369
370extern __be32 nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
371 stateid_t *stateid, int flags, struct file **filp);
372extern void nfs4_lock_state(void);
373extern void nfs4_unlock_state(void);
374extern int nfs4_in_grace(void);
375extern __be32 nfs4_check_open_reclaim(clientid_t *clid);
376extern void put_nfs4_client(struct nfs4_client *clp);
377extern void nfs4_free_stateowner(struct kref *kref);
378extern int set_callback_cred(void);
379extern void nfsd4_probe_callback(struct nfs4_client *clp);
380extern void nfsd4_cb_recall(struct nfs4_delegation *dp);
381extern void nfs4_put_delegation(struct nfs4_delegation *dp);
382extern __be32 nfs4_make_rec_clidname(char *clidname, struct xdr_netobj *clname);
383extern void nfsd4_init_recdir(char *recdir_name);
384extern int nfsd4_recdir_load(void);
385extern void nfsd4_shutdown_recdir(void);
386extern int nfs4_client_to_reclaim(const char *name);
387extern int nfs4_has_reclaimed_state(const char *name, bool use_exchange_id);
388extern void nfsd4_recdir_purge_old(void);
389extern int nfsd4_create_clid_dir(struct nfs4_client *clp);
390extern void nfsd4_remove_clid_dir(struct nfs4_client *clp);
391
392static inline void
393nfs4_put_stateowner(struct nfs4_stateowner *so)
394{
395 kref_put(&so->so_ref, nfs4_free_stateowner);
396}
397
398static inline void
399nfs4_get_stateowner(struct nfs4_stateowner *so)
400{
401 kref_get(&so->so_ref);
402}
403
404#endif /* NFSD4_STATE_H */
diff --git a/include/linux/nfsd/syscall.h b/include/linux/nfsd/syscall.h
index 7a3b565b898f..812bc1e160dc 100644
--- a/include/linux/nfsd/syscall.h
+++ b/include/linux/nfsd/syscall.h
@@ -9,14 +9,8 @@
9#ifndef NFSD_SYSCALL_H 9#ifndef NFSD_SYSCALL_H
10#define NFSD_SYSCALL_H 10#define NFSD_SYSCALL_H
11 11
12# include <linux/types.h> 12#include <linux/types.h>
13#ifdef __KERNEL__
14# include <linux/in.h>
15#endif
16#include <linux/posix_types.h>
17#include <linux/nfsd/const.h>
18#include <linux/nfsd/export.h> 13#include <linux/nfsd/export.h>
19#include <linux/nfsd/nfsfh.h>
20 14
21/* 15/*
22 * Version of the syscall interface 16 * Version of the syscall interface
diff --git a/include/linux/nfsd/xdr.h b/include/linux/nfsd/xdr.h
deleted file mode 100644
index a0132ef58f21..000000000000
--- a/include/linux/nfsd/xdr.h
+++ /dev/null
@@ -1,177 +0,0 @@
1/*
2 * linux/include/linux/nfsd/xdr.h
3 *
4 * XDR types for nfsd. This is mainly a typing exercise.
5 */
6
7#ifndef LINUX_NFSD_H
8#define LINUX_NFSD_H
9
10#include <linux/fs.h>
11#include <linux/vfs.h>
12#include <linux/nfs.h>
13
14struct nfsd_fhandle {
15 struct svc_fh fh;
16};
17
18struct nfsd_sattrargs {
19 struct svc_fh fh;
20 struct iattr attrs;
21};
22
23struct nfsd_diropargs {
24 struct svc_fh fh;
25 char * name;
26 unsigned int len;
27};
28
29struct nfsd_readargs {
30 struct svc_fh fh;
31 __u32 offset;
32 __u32 count;
33 int vlen;
34};
35
36struct nfsd_writeargs {
37 svc_fh fh;
38 __u32 offset;
39 int len;
40 int vlen;
41};
42
43struct nfsd_createargs {
44 struct svc_fh fh;
45 char * name;
46 unsigned int len;
47 struct iattr attrs;
48};
49
50struct nfsd_renameargs {
51 struct svc_fh ffh;
52 char * fname;
53 unsigned int flen;
54 struct svc_fh tfh;
55 char * tname;
56 unsigned int tlen;
57};
58
59struct nfsd_readlinkargs {
60 struct svc_fh fh;
61 char * buffer;
62};
63
64struct nfsd_linkargs {
65 struct svc_fh ffh;
66 struct svc_fh tfh;
67 char * tname;
68 unsigned int tlen;
69};
70
71struct nfsd_symlinkargs {
72 struct svc_fh ffh;
73 char * fname;
74 unsigned int flen;
75 char * tname;
76 unsigned int tlen;
77 struct iattr attrs;
78};
79
80struct nfsd_readdirargs {
81 struct svc_fh fh;
82 __u32 cookie;
83 __u32 count;
84 __be32 * buffer;
85};
86
87struct nfsd_attrstat {
88 struct svc_fh fh;
89 struct kstat stat;
90};
91
92struct nfsd_diropres {
93 struct svc_fh fh;
94 struct kstat stat;
95};
96
97struct nfsd_readlinkres {
98 int len;
99};
100
101struct nfsd_readres {
102 struct svc_fh fh;
103 unsigned long count;
104 struct kstat stat;
105};
106
107struct nfsd_readdirres {
108 int count;
109
110 struct readdir_cd common;
111 __be32 * buffer;
112 int buflen;
113 __be32 * offset;
114};
115
116struct nfsd_statfsres {
117 struct kstatfs stats;
118};
119
120/*
121 * Storage requirements for XDR arguments and results.
122 */
123union nfsd_xdrstore {
124 struct nfsd_sattrargs sattr;
125 struct nfsd_diropargs dirop;
126 struct nfsd_readargs read;
127 struct nfsd_writeargs write;
128 struct nfsd_createargs create;
129 struct nfsd_renameargs rename;
130 struct nfsd_linkargs link;
131 struct nfsd_symlinkargs symlink;
132 struct nfsd_readdirargs readdir;
133};
134
135#define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore)
136
137
138int nfssvc_decode_void(struct svc_rqst *, __be32 *, void *);
139int nfssvc_decode_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *);
140int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *,
141 struct nfsd_sattrargs *);
142int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *,
143 struct nfsd_diropargs *);
144int nfssvc_decode_readargs(struct svc_rqst *, __be32 *,
145 struct nfsd_readargs *);
146int nfssvc_decode_writeargs(struct svc_rqst *, __be32 *,
147 struct nfsd_writeargs *);
148int nfssvc_decode_createargs(struct svc_rqst *, __be32 *,
149 struct nfsd_createargs *);
150int nfssvc_decode_renameargs(struct svc_rqst *, __be32 *,
151 struct nfsd_renameargs *);
152int nfssvc_decode_readlinkargs(struct svc_rqst *, __be32 *,
153 struct nfsd_readlinkargs *);
154int nfssvc_decode_linkargs(struct svc_rqst *, __be32 *,
155 struct nfsd_linkargs *);
156int nfssvc_decode_symlinkargs(struct svc_rqst *, __be32 *,
157 struct nfsd_symlinkargs *);
158int nfssvc_decode_readdirargs(struct svc_rqst *, __be32 *,
159 struct nfsd_readdirargs *);
160int nfssvc_encode_void(struct svc_rqst *, __be32 *, void *);
161int nfssvc_encode_attrstat(struct svc_rqst *, __be32 *, struct nfsd_attrstat *);
162int nfssvc_encode_diropres(struct svc_rqst *, __be32 *, struct nfsd_diropres *);
163int nfssvc_encode_readlinkres(struct svc_rqst *, __be32 *, struct nfsd_readlinkres *);
164int nfssvc_encode_readres(struct svc_rqst *, __be32 *, struct nfsd_readres *);
165int nfssvc_encode_statfsres(struct svc_rqst *, __be32 *, struct nfsd_statfsres *);
166int nfssvc_encode_readdirres(struct svc_rqst *, __be32 *, struct nfsd_readdirres *);
167
168int nfssvc_encode_entry(void *, const char *name,
169 int namlen, loff_t offset, u64 ino, unsigned int);
170
171int nfssvc_release_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *);
172
173/* Helper functions for NFSv2 ACL code */
174__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp);
175__be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp);
176
177#endif /* LINUX_NFSD_H */
diff --git a/include/linux/nfsd/xdr3.h b/include/linux/nfsd/xdr3.h
deleted file mode 100644
index 421eddd65a25..000000000000
--- a/include/linux/nfsd/xdr3.h
+++ /dev/null
@@ -1,346 +0,0 @@
1/*
2 * linux/include/linux/nfsd/xdr3.h
3 *
4 * XDR types for NFSv3 in nfsd.
5 *
6 * Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_NFSD_XDR3_H
10#define _LINUX_NFSD_XDR3_H
11
12#include <linux/nfsd/xdr.h>
13
14struct nfsd3_sattrargs {
15 struct svc_fh fh;
16 struct iattr attrs;
17 int check_guard;
18 time_t guardtime;
19};
20
21struct nfsd3_diropargs {
22 struct svc_fh fh;
23 char * name;
24 unsigned int len;
25};
26
27struct nfsd3_accessargs {
28 struct svc_fh fh;
29 unsigned int access;
30};
31
32struct nfsd3_readargs {
33 struct svc_fh fh;
34 __u64 offset;
35 __u32 count;
36 int vlen;
37};
38
39struct nfsd3_writeargs {
40 svc_fh fh;
41 __u64 offset;
42 __u32 count;
43 int stable;
44 __u32 len;
45 int vlen;
46};
47
48struct nfsd3_createargs {
49 struct svc_fh fh;
50 char * name;
51 unsigned int len;
52 int createmode;
53 struct iattr attrs;
54 __be32 * verf;
55};
56
57struct nfsd3_mknodargs {
58 struct svc_fh fh;
59 char * name;
60 unsigned int len;
61 __u32 ftype;
62 __u32 major, minor;
63 struct iattr attrs;
64};
65
66struct nfsd3_renameargs {
67 struct svc_fh ffh;
68 char * fname;
69 unsigned int flen;
70 struct svc_fh tfh;
71 char * tname;
72 unsigned int tlen;
73};
74
75struct nfsd3_readlinkargs {
76 struct svc_fh fh;
77 char * buffer;
78};
79
80struct nfsd3_linkargs {
81 struct svc_fh ffh;
82 struct svc_fh tfh;
83 char * tname;
84 unsigned int tlen;
85};
86
87struct nfsd3_symlinkargs {
88 struct svc_fh ffh;
89 char * fname;
90 unsigned int flen;
91 char * tname;
92 unsigned int tlen;
93 struct iattr attrs;
94};
95
96struct nfsd3_readdirargs {
97 struct svc_fh fh;
98 __u64 cookie;
99 __u32 dircount;
100 __u32 count;
101 __be32 * verf;
102 __be32 * buffer;
103};
104
105struct nfsd3_commitargs {
106 struct svc_fh fh;
107 __u64 offset;
108 __u32 count;
109};
110
111struct nfsd3_getaclargs {
112 struct svc_fh fh;
113 int mask;
114};
115
116struct posix_acl;
117struct nfsd3_setaclargs {
118 struct svc_fh fh;
119 int mask;
120 struct posix_acl *acl_access;
121 struct posix_acl *acl_default;
122};
123
124struct nfsd3_attrstat {
125 __be32 status;
126 struct svc_fh fh;
127 struct kstat stat;
128};
129
130/* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */
131struct nfsd3_diropres {
132 __be32 status;
133 struct svc_fh dirfh;
134 struct svc_fh fh;
135};
136
137struct nfsd3_accessres {
138 __be32 status;
139 struct svc_fh fh;
140 __u32 access;
141};
142
143struct nfsd3_readlinkres {
144 __be32 status;
145 struct svc_fh fh;
146 __u32 len;
147};
148
149struct nfsd3_readres {
150 __be32 status;
151 struct svc_fh fh;
152 unsigned long count;
153 int eof;
154};
155
156struct nfsd3_writeres {
157 __be32 status;
158 struct svc_fh fh;
159 unsigned long count;
160 int committed;
161};
162
163struct nfsd3_renameres {
164 __be32 status;
165 struct svc_fh ffh;
166 struct svc_fh tfh;
167};
168
169struct nfsd3_linkres {
170 __be32 status;
171 struct svc_fh tfh;
172 struct svc_fh fh;
173};
174
175struct nfsd3_readdirres {
176 __be32 status;
177 struct svc_fh fh;
178 int count;
179 __be32 verf[2];
180
181 struct readdir_cd common;
182 __be32 * buffer;
183 int buflen;
184 __be32 * offset;
185 __be32 * offset1;
186 struct svc_rqst * rqstp;
187
188};
189
190struct nfsd3_fsstatres {
191 __be32 status;
192 struct kstatfs stats;
193 __u32 invarsec;
194};
195
196struct nfsd3_fsinfores {
197 __be32 status;
198 __u32 f_rtmax;
199 __u32 f_rtpref;
200 __u32 f_rtmult;
201 __u32 f_wtmax;
202 __u32 f_wtpref;
203 __u32 f_wtmult;
204 __u32 f_dtpref;
205 __u64 f_maxfilesize;
206 __u32 f_properties;
207};
208
209struct nfsd3_pathconfres {
210 __be32 status;
211 __u32 p_link_max;
212 __u32 p_name_max;
213 __u32 p_no_trunc;
214 __u32 p_chown_restricted;
215 __u32 p_case_insensitive;
216 __u32 p_case_preserving;
217};
218
219struct nfsd3_commitres {
220 __be32 status;
221 struct svc_fh fh;
222};
223
224struct nfsd3_getaclres {
225 __be32 status;
226 struct svc_fh fh;
227 int mask;
228 struct posix_acl *acl_access;
229 struct posix_acl *acl_default;
230};
231
232/* dummy type for release */
233struct nfsd3_fhandle_pair {
234 __u32 dummy;
235 struct svc_fh fh1;
236 struct svc_fh fh2;
237};
238
239/*
240 * Storage requirements for XDR arguments and results.
241 */
242union nfsd3_xdrstore {
243 struct nfsd3_sattrargs sattrargs;
244 struct nfsd3_diropargs diropargs;
245 struct nfsd3_readargs readargs;
246 struct nfsd3_writeargs writeargs;
247 struct nfsd3_createargs createargs;
248 struct nfsd3_renameargs renameargs;
249 struct nfsd3_linkargs linkargs;
250 struct nfsd3_symlinkargs symlinkargs;
251 struct nfsd3_readdirargs readdirargs;
252 struct nfsd3_diropres diropres;
253 struct nfsd3_accessres accessres;
254 struct nfsd3_readlinkres readlinkres;
255 struct nfsd3_readres readres;
256 struct nfsd3_writeres writeres;
257 struct nfsd3_renameres renameres;
258 struct nfsd3_linkres linkres;
259 struct nfsd3_readdirres readdirres;
260 struct nfsd3_fsstatres fsstatres;
261 struct nfsd3_fsinfores fsinfores;
262 struct nfsd3_pathconfres pathconfres;
263 struct nfsd3_commitres commitres;
264 struct nfsd3_getaclres getaclres;
265};
266
267#define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore)
268
269int nfs3svc_decode_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *);
270int nfs3svc_decode_sattrargs(struct svc_rqst *, __be32 *,
271 struct nfsd3_sattrargs *);
272int nfs3svc_decode_diropargs(struct svc_rqst *, __be32 *,
273 struct nfsd3_diropargs *);
274int nfs3svc_decode_accessargs(struct svc_rqst *, __be32 *,
275 struct nfsd3_accessargs *);
276int nfs3svc_decode_readargs(struct svc_rqst *, __be32 *,
277 struct nfsd3_readargs *);
278int nfs3svc_decode_writeargs(struct svc_rqst *, __be32 *,
279 struct nfsd3_writeargs *);
280int nfs3svc_decode_createargs(struct svc_rqst *, __be32 *,
281 struct nfsd3_createargs *);
282int nfs3svc_decode_mkdirargs(struct svc_rqst *, __be32 *,
283 struct nfsd3_createargs *);
284int nfs3svc_decode_mknodargs(struct svc_rqst *, __be32 *,
285 struct nfsd3_mknodargs *);
286int nfs3svc_decode_renameargs(struct svc_rqst *, __be32 *,
287 struct nfsd3_renameargs *);
288int nfs3svc_decode_readlinkargs(struct svc_rqst *, __be32 *,
289 struct nfsd3_readlinkargs *);
290int nfs3svc_decode_linkargs(struct svc_rqst *, __be32 *,
291 struct nfsd3_linkargs *);
292int nfs3svc_decode_symlinkargs(struct svc_rqst *, __be32 *,
293 struct nfsd3_symlinkargs *);
294int nfs3svc_decode_readdirargs(struct svc_rqst *, __be32 *,
295 struct nfsd3_readdirargs *);
296int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __be32 *,
297 struct nfsd3_readdirargs *);
298int nfs3svc_decode_commitargs(struct svc_rqst *, __be32 *,
299 struct nfsd3_commitargs *);
300int nfs3svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
301int nfs3svc_encode_attrstat(struct svc_rqst *, __be32 *,
302 struct nfsd3_attrstat *);
303int nfs3svc_encode_wccstat(struct svc_rqst *, __be32 *,
304 struct nfsd3_attrstat *);
305int nfs3svc_encode_diropres(struct svc_rqst *, __be32 *,
306 struct nfsd3_diropres *);
307int nfs3svc_encode_accessres(struct svc_rqst *, __be32 *,
308 struct nfsd3_accessres *);
309int nfs3svc_encode_readlinkres(struct svc_rqst *, __be32 *,
310 struct nfsd3_readlinkres *);
311int nfs3svc_encode_readres(struct svc_rqst *, __be32 *, struct nfsd3_readres *);
312int nfs3svc_encode_writeres(struct svc_rqst *, __be32 *, struct nfsd3_writeres *);
313int nfs3svc_encode_createres(struct svc_rqst *, __be32 *,
314 struct nfsd3_diropres *);
315int nfs3svc_encode_renameres(struct svc_rqst *, __be32 *,
316 struct nfsd3_renameres *);
317int nfs3svc_encode_linkres(struct svc_rqst *, __be32 *,
318 struct nfsd3_linkres *);
319int nfs3svc_encode_readdirres(struct svc_rqst *, __be32 *,
320 struct nfsd3_readdirres *);
321int nfs3svc_encode_fsstatres(struct svc_rqst *, __be32 *,
322 struct nfsd3_fsstatres *);
323int nfs3svc_encode_fsinfores(struct svc_rqst *, __be32 *,
324 struct nfsd3_fsinfores *);
325int nfs3svc_encode_pathconfres(struct svc_rqst *, __be32 *,
326 struct nfsd3_pathconfres *);
327int nfs3svc_encode_commitres(struct svc_rqst *, __be32 *,
328 struct nfsd3_commitres *);
329
330int nfs3svc_release_fhandle(struct svc_rqst *, __be32 *,
331 struct nfsd3_attrstat *);
332int nfs3svc_release_fhandle2(struct svc_rqst *, __be32 *,
333 struct nfsd3_fhandle_pair *);
334int nfs3svc_encode_entry(void *, const char *name,
335 int namlen, loff_t offset, u64 ino,
336 unsigned int);
337int nfs3svc_encode_entry_plus(void *, const char *name,
338 int namlen, loff_t offset, u64 ino,
339 unsigned int);
340/* Helper functions for NFSv3 ACL code */
341__be32 *nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p,
342 struct svc_fh *fhp);
343__be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp);
344
345
346#endif /* _LINUX_NFSD_XDR3_H */
diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
deleted file mode 100644
index 73164c2b3d29..000000000000
--- a/include/linux/nfsd/xdr4.h
+++ /dev/null
@@ -1,563 +0,0 @@
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
47struct nfsd4_compound_state {
48 struct svc_fh current_fh;
49 struct svc_fh save_fh;
50 struct nfs4_stateowner *replay_owner;
51 /* For sessions DRC */
52 struct nfsd4_session *session;
53 struct nfsd4_slot *slot;
54 __be32 *datap;
55 size_t iovlen;
56 u32 minorversion;
57 u32 status;
58};
59
60static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs)
61{
62 return cs->slot != NULL;
63}
64
65struct nfsd4_change_info {
66 u32 atomic;
67 bool change_supported;
68 u32 before_ctime_sec;
69 u32 before_ctime_nsec;
70 u64 before_change;
71 u32 after_ctime_sec;
72 u32 after_ctime_nsec;
73 u64 after_change;
74};
75
76struct nfsd4_access {
77 u32 ac_req_access; /* request */
78 u32 ac_supported; /* response */
79 u32 ac_resp_access; /* response */
80};
81
82struct nfsd4_close {
83 u32 cl_seqid; /* request */
84 stateid_t cl_stateid; /* request+response */
85 struct nfs4_stateowner * cl_stateowner; /* response */
86};
87
88struct nfsd4_commit {
89 u64 co_offset; /* request */
90 u32 co_count; /* request */
91 nfs4_verifier co_verf; /* response */
92};
93
94struct nfsd4_create {
95 u32 cr_namelen; /* request */
96 char * cr_name; /* request */
97 u32 cr_type; /* request */
98 union { /* request */
99 struct {
100 u32 namelen;
101 char *name;
102 } link; /* NF4LNK */
103 struct {
104 u32 specdata1;
105 u32 specdata2;
106 } dev; /* NF4BLK, NF4CHR */
107 } u;
108 u32 cr_bmval[3]; /* request */
109 struct iattr cr_iattr; /* request */
110 struct nfsd4_change_info cr_cinfo; /* response */
111 struct nfs4_acl *cr_acl;
112};
113#define cr_linklen u.link.namelen
114#define cr_linkname u.link.name
115#define cr_specdata1 u.dev.specdata1
116#define cr_specdata2 u.dev.specdata2
117
118struct nfsd4_delegreturn {
119 stateid_t dr_stateid;
120};
121
122struct nfsd4_getattr {
123 u32 ga_bmval[3]; /* request */
124 struct svc_fh *ga_fhp; /* response */
125};
126
127struct nfsd4_link {
128 u32 li_namelen; /* request */
129 char * li_name; /* request */
130 struct nfsd4_change_info li_cinfo; /* response */
131};
132
133struct nfsd4_lock_denied {
134 clientid_t ld_clientid;
135 struct nfs4_stateowner *ld_sop;
136 u64 ld_start;
137 u64 ld_length;
138 u32 ld_type;
139};
140
141struct nfsd4_lock {
142 /* request */
143 u32 lk_type;
144 u32 lk_reclaim; /* boolean */
145 u64 lk_offset;
146 u64 lk_length;
147 u32 lk_is_new;
148 union {
149 struct {
150 u32 open_seqid;
151 stateid_t open_stateid;
152 u32 lock_seqid;
153 clientid_t clientid;
154 struct xdr_netobj owner;
155 } new;
156 struct {
157 stateid_t lock_stateid;
158 u32 lock_seqid;
159 } old;
160 } v;
161
162 /* response */
163 union {
164 struct {
165 stateid_t stateid;
166 } ok;
167 struct nfsd4_lock_denied denied;
168 } u;
169 /* The lk_replay_owner is the open owner in the open_to_lock_owner
170 * case and the lock owner otherwise: */
171 struct nfs4_stateowner *lk_replay_owner;
172};
173#define lk_new_open_seqid v.new.open_seqid
174#define lk_new_open_stateid v.new.open_stateid
175#define lk_new_lock_seqid v.new.lock_seqid
176#define lk_new_clientid v.new.clientid
177#define lk_new_owner v.new.owner
178#define lk_old_lock_stateid v.old.lock_stateid
179#define lk_old_lock_seqid v.old.lock_seqid
180
181#define lk_rflags u.ok.rflags
182#define lk_resp_stateid u.ok.stateid
183#define lk_denied u.denied
184
185
186struct nfsd4_lockt {
187 u32 lt_type;
188 clientid_t lt_clientid;
189 struct xdr_netobj lt_owner;
190 u64 lt_offset;
191 u64 lt_length;
192 struct nfs4_stateowner * lt_stateowner;
193 struct nfsd4_lock_denied lt_denied;
194};
195
196
197struct nfsd4_locku {
198 u32 lu_type;
199 u32 lu_seqid;
200 stateid_t lu_stateid;
201 u64 lu_offset;
202 u64 lu_length;
203 struct nfs4_stateowner *lu_stateowner;
204};
205
206
207struct nfsd4_lookup {
208 u32 lo_len; /* request */
209 char * lo_name; /* request */
210};
211
212struct nfsd4_putfh {
213 u32 pf_fhlen; /* request */
214 char *pf_fhval; /* request */
215};
216
217struct nfsd4_open {
218 u32 op_claim_type; /* request */
219 struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
220 u32 op_delegate_type; /* request - CLAIM_PREV only */
221 stateid_t op_delegate_stateid; /* request - response */
222 u32 op_create; /* request */
223 u32 op_createmode; /* request */
224 u32 op_bmval[3]; /* request */
225 struct iattr iattr; /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
226 nfs4_verifier verf; /* EXCLUSIVE4 */
227 clientid_t op_clientid; /* request */
228 struct xdr_netobj op_owner; /* request */
229 u32 op_seqid; /* request */
230 u32 op_share_access; /* request */
231 u32 op_share_deny; /* request */
232 stateid_t op_stateid; /* response */
233 u32 op_recall; /* recall */
234 struct nfsd4_change_info op_cinfo; /* response */
235 u32 op_rflags; /* response */
236 int op_truncate; /* used during processing */
237 struct nfs4_stateowner *op_stateowner; /* used during processing */
238 struct nfs4_acl *op_acl;
239};
240#define op_iattr iattr
241#define op_verf verf
242
243struct nfsd4_open_confirm {
244 stateid_t oc_req_stateid /* request */;
245 u32 oc_seqid /* request */;
246 stateid_t oc_resp_stateid /* response */;
247 struct nfs4_stateowner * oc_stateowner; /* response */
248};
249
250struct nfsd4_open_downgrade {
251 stateid_t od_stateid;
252 u32 od_seqid;
253 u32 od_share_access;
254 u32 od_share_deny;
255 struct nfs4_stateowner *od_stateowner;
256};
257
258
259struct nfsd4_read {
260 stateid_t rd_stateid; /* request */
261 u64 rd_offset; /* request */
262 u32 rd_length; /* request */
263 int rd_vlen;
264 struct file *rd_filp;
265
266 struct svc_rqst *rd_rqstp; /* response */
267 struct svc_fh * rd_fhp; /* response */
268};
269
270struct nfsd4_readdir {
271 u64 rd_cookie; /* request */
272 nfs4_verifier rd_verf; /* request */
273 u32 rd_dircount; /* request */
274 u32 rd_maxcount; /* request */
275 u32 rd_bmval[3]; /* request */
276 struct svc_rqst *rd_rqstp; /* response */
277 struct svc_fh * rd_fhp; /* response */
278
279 struct readdir_cd common;
280 __be32 * buffer;
281 int buflen;
282 __be32 * offset;
283};
284
285struct nfsd4_release_lockowner {
286 clientid_t rl_clientid;
287 struct xdr_netobj rl_owner;
288};
289struct nfsd4_readlink {
290 struct svc_rqst *rl_rqstp; /* request */
291 struct svc_fh * rl_fhp; /* request */
292};
293
294struct nfsd4_remove {
295 u32 rm_namelen; /* request */
296 char * rm_name; /* request */
297 struct nfsd4_change_info rm_cinfo; /* response */
298};
299
300struct nfsd4_rename {
301 u32 rn_snamelen; /* request */
302 char * rn_sname; /* request */
303 u32 rn_tnamelen; /* request */
304 char * rn_tname; /* request */
305 struct nfsd4_change_info rn_sinfo; /* response */
306 struct nfsd4_change_info rn_tinfo; /* response */
307};
308
309struct nfsd4_secinfo {
310 u32 si_namelen; /* request */
311 char *si_name; /* request */
312 struct svc_export *si_exp; /* response */
313};
314
315struct nfsd4_setattr {
316 stateid_t sa_stateid; /* request */
317 u32 sa_bmval[3]; /* request */
318 struct iattr sa_iattr; /* request */
319 struct nfs4_acl *sa_acl;
320};
321
322struct nfsd4_setclientid {
323 nfs4_verifier se_verf; /* request */
324 u32 se_namelen; /* request */
325 char * se_name; /* request */
326 u32 se_callback_prog; /* request */
327 u32 se_callback_netid_len; /* request */
328 char * se_callback_netid_val; /* request */
329 u32 se_callback_addr_len; /* request */
330 char * se_callback_addr_val; /* request */
331 u32 se_callback_ident; /* request */
332 clientid_t se_clientid; /* response */
333 nfs4_verifier se_confirm; /* response */
334};
335
336struct nfsd4_setclientid_confirm {
337 clientid_t sc_clientid;
338 nfs4_verifier sc_confirm;
339};
340
341/* also used for NVERIFY */
342struct nfsd4_verify {
343 u32 ve_bmval[3]; /* request */
344 u32 ve_attrlen; /* request */
345 char * ve_attrval; /* request */
346};
347
348struct nfsd4_write {
349 stateid_t wr_stateid; /* request */
350 u64 wr_offset; /* request */
351 u32 wr_stable_how; /* request */
352 u32 wr_buflen; /* request */
353 int wr_vlen;
354
355 u32 wr_bytes_written; /* response */
356 u32 wr_how_written; /* response */
357 nfs4_verifier wr_verifier; /* response */
358};
359
360struct nfsd4_exchange_id {
361 nfs4_verifier verifier;
362 struct xdr_netobj clname;
363 u32 flags;
364 clientid_t clientid;
365 u32 seqid;
366 int spa_how;
367};
368
369struct nfsd4_sequence {
370 struct nfs4_sessionid sessionid; /* request/response */
371 u32 seqid; /* request/response */
372 u32 slotid; /* request/response */
373 u32 maxslots; /* request/response */
374 u32 cachethis; /* request */
375#if 0
376 u32 target_maxslots; /* response */
377 u32 status_flags; /* response */
378#endif /* not yet */
379};
380
381struct nfsd4_destroy_session {
382 struct nfs4_sessionid sessionid;
383};
384
385struct nfsd4_op {
386 int opnum;
387 __be32 status;
388 union {
389 struct nfsd4_access access;
390 struct nfsd4_close close;
391 struct nfsd4_commit commit;
392 struct nfsd4_create create;
393 struct nfsd4_delegreturn delegreturn;
394 struct nfsd4_getattr getattr;
395 struct svc_fh * getfh;
396 struct nfsd4_link link;
397 struct nfsd4_lock lock;
398 struct nfsd4_lockt lockt;
399 struct nfsd4_locku locku;
400 struct nfsd4_lookup lookup;
401 struct nfsd4_verify nverify;
402 struct nfsd4_open open;
403 struct nfsd4_open_confirm open_confirm;
404 struct nfsd4_open_downgrade open_downgrade;
405 struct nfsd4_putfh putfh;
406 struct nfsd4_read read;
407 struct nfsd4_readdir readdir;
408 struct nfsd4_readlink readlink;
409 struct nfsd4_remove remove;
410 struct nfsd4_rename rename;
411 clientid_t renew;
412 struct nfsd4_secinfo secinfo;
413 struct nfsd4_setattr setattr;
414 struct nfsd4_setclientid setclientid;
415 struct nfsd4_setclientid_confirm setclientid_confirm;
416 struct nfsd4_verify verify;
417 struct nfsd4_write write;
418 struct nfsd4_release_lockowner release_lockowner;
419
420 /* NFSv4.1 */
421 struct nfsd4_exchange_id exchange_id;
422 struct nfsd4_create_session create_session;
423 struct nfsd4_destroy_session destroy_session;
424 struct nfsd4_sequence sequence;
425 } u;
426 struct nfs4_replay * replay;
427};
428
429struct nfsd4_compoundargs {
430 /* scratch variables for XDR decode */
431 __be32 * p;
432 __be32 * end;
433 struct page ** pagelist;
434 int pagelen;
435 __be32 tmp[8];
436 __be32 * tmpp;
437 struct tmpbuf {
438 struct tmpbuf *next;
439 void (*release)(const void *);
440 void *buf;
441 } *to_free;
442
443 struct svc_rqst *rqstp;
444
445 u32 taglen;
446 char * tag;
447 u32 minorversion;
448 u32 opcnt;
449 struct nfsd4_op *ops;
450 struct nfsd4_op iops[8];
451};
452
453struct nfsd4_compoundres {
454 /* scratch variables for XDR encode */
455 __be32 * p;
456 __be32 * end;
457 struct xdr_buf * xbuf;
458 struct svc_rqst * rqstp;
459
460 u32 taglen;
461 char * tag;
462 u32 opcnt;
463 __be32 * tagp; /* tag, opcount encode location */
464 struct nfsd4_compound_state cstate;
465};
466
467static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
468{
469 struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
470 return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
471}
472
473static inline bool nfsd4_not_cached(struct nfsd4_compoundres *resp)
474{
475 return !resp->cstate.slot->sl_cachethis || nfsd4_is_solo_sequence(resp);
476}
477
478#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
479
480static inline void
481set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
482{
483 BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
484 cinfo->atomic = 1;
485 cinfo->change_supported = IS_I_VERSION(fhp->fh_dentry->d_inode);
486 if (cinfo->change_supported) {
487 cinfo->before_change = fhp->fh_pre_change;
488 cinfo->after_change = fhp->fh_post_change;
489 } else {
490 cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
491 cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
492 cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
493 cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
494 }
495}
496
497int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
498int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *,
499 struct nfsd4_compoundargs *);
500int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *,
501 struct nfsd4_compoundres *);
502void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
503void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
504__be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
505 struct dentry *dentry, __be32 *buffer, int *countp,
506 u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
507extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
508 struct nfsd4_compound_state *,
509 struct nfsd4_setclientid *setclid);
510extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
511 struct nfsd4_compound_state *,
512 struct nfsd4_setclientid_confirm *setclientid_confirm);
513extern void nfsd4_store_cache_entry(struct nfsd4_compoundres *resp);
514extern __be32 nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
515 struct nfsd4_sequence *seq);
516extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
517 struct nfsd4_compound_state *,
518struct nfsd4_exchange_id *);
519 extern __be32 nfsd4_create_session(struct svc_rqst *,
520 struct nfsd4_compound_state *,
521 struct nfsd4_create_session *);
522extern __be32 nfsd4_sequence(struct svc_rqst *,
523 struct nfsd4_compound_state *,
524 struct nfsd4_sequence *);
525extern __be32 nfsd4_destroy_session(struct svc_rqst *,
526 struct nfsd4_compound_state *,
527 struct nfsd4_destroy_session *);
528extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
529 struct nfsd4_open *open);
530extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
531 struct svc_fh *current_fh, struct nfsd4_open *open);
532extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
533 struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc);
534extern __be32 nfsd4_close(struct svc_rqst *rqstp,
535 struct nfsd4_compound_state *,
536 struct nfsd4_close *close);
537extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
538 struct nfsd4_compound_state *,
539 struct nfsd4_open_downgrade *od);
540extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
541 struct nfsd4_lock *lock);
542extern __be32 nfsd4_lockt(struct svc_rqst *rqstp,
543 struct nfsd4_compound_state *,
544 struct nfsd4_lockt *lockt);
545extern __be32 nfsd4_locku(struct svc_rqst *rqstp,
546 struct nfsd4_compound_state *,
547 struct nfsd4_locku *locku);
548extern __be32
549nfsd4_release_lockowner(struct svc_rqst *rqstp,
550 struct nfsd4_compound_state *,
551 struct nfsd4_release_lockowner *rlockowner);
552extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
553extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
554 struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr);
555extern __be32 nfsd4_renew(struct svc_rqst *rqstp,
556 struct nfsd4_compound_state *, clientid_t *clid);
557#endif
558
559/*
560 * Local variables:
561 * c-basic-offset: 8
562 * End:
563 */