f302f61042077a499c269cc37910d0a2db30a713
[linux-flexiantxendom0-3.2.10.git] / include / linux / nfs_fs.h
1 /*
2  *  linux/include/linux/nfs_fs.h
3  *
4  *  Copyright (C) 1992  Rick Sladkey
5  *
6  *  OS-specific nfs filesystem definitions and declarations
7  */
8
9 #ifndef _LINUX_NFS_FS_H
10 #define _LINUX_NFS_FS_H
11
12 #include <linux/config.h>
13 #include <linux/in.h>
14 #include <linux/mm.h>
15 #include <linux/pagemap.h>
16 #include <linux/rwsem.h>
17 #include <linux/wait.h>
18 #include <linux/uio.h>
19
20 #include <linux/nfs_fs_sb.h>
21
22 #include <linux/sunrpc/debug.h>
23 #include <linux/sunrpc/auth.h>
24 #include <linux/sunrpc/clnt.h>
25
26 #include <linux/nfs.h>
27 #include <linux/nfs2.h>
28 #include <linux/nfs3.h>
29 #include <linux/nfs4.h>
30 #include <linux/nfs_xdr.h>
31 #include <linux/workqueue.h>
32
33 /*
34  * Enable debugging support for nfs client.
35  * Requires RPC_DEBUG.
36  */
37 #ifdef RPC_DEBUG
38 # define NFS_DEBUG
39 #endif
40
41 #define NFS_MAX_FILE_IO_BUFFER_SIZE     32768
42 #define NFS_DEF_FILE_IO_BUFFER_SIZE     4096
43
44 /*
45  * The upper limit on timeouts for the exponential backoff algorithm.
46  */
47 #define NFS_WRITEBACK_DELAY             (5*HZ)
48 #define NFS_WRITEBACK_LOCKDELAY         (60*HZ)
49 #define NFS_COMMIT_DELAY                (5*HZ)
50
51 /*
52  * superblock magic number for NFS
53  */
54 #define NFS_SUPER_MAGIC                 0x6969
55
56 /*
57  * These are the default flags for swap requests
58  */
59 #define NFS_RPC_SWAPFLAGS               (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
60
61 #define NFS_RW_SYNC             0x0001  /* O_SYNC handling */
62 #define NFS_RW_SWAP             0x0002  /* This is a swap request */
63
64 /*
65  * When flushing a cluster of dirty pages, there can be different
66  * strategies:
67  */
68 #define FLUSH_AGING             0       /* only flush old buffers */
69 #define FLUSH_SYNC              1       /* file being synced, or contention */
70 #define FLUSH_WAIT              2       /* wait for completion */
71 #define FLUSH_STABLE            4       /* commit to stable storage */
72 #define FLUSH_LOWPRI            8       /* low priority background flush */
73 #define FLUSH_HIGHPRI           16      /* high priority memory reclaim flush */
74
75 #ifdef __KERNEL__
76
77 /*
78  * NFSv3 Access mode cache
79  */
80 struct nfs_access_cache {
81         unsigned long           jiffies;
82         struct rpc_cred *       cred;
83         int                     mask;
84         int                     err;
85 };
86
87 /*
88  * nfs fs inode data in memory
89  */
90 struct nfs_inode {
91         /*
92          * The 64bit 'inode number'
93          */
94         __u64 fileid;
95
96         /*
97          * NFS file handle
98          */
99         struct nfs_fh           fh;
100
101         /*
102          * Various flags
103          */
104         unsigned int            flags;
105
106         /*
107          * read_cache_jiffies is when we started read-caching this inode,
108          * and read_cache_mtime is the mtime of the inode at that time.
109          * attrtimeo is for how long the cached information is assumed
110          * to be valid. A successful attribute revalidation doubles
111          * attrtimeo (up to acregmax/acdirmax), a failure resets it to
112          * acregmin/acdirmin.
113          *
114          * We need to revalidate the cached attrs for this inode if
115          *
116          *      jiffies - read_cache_jiffies > attrtimeo
117          *
118          * and invalidate any cached data/flush out any dirty pages if
119          * we find that
120          *
121          *      mtime != read_cache_mtime
122          */
123         unsigned long           readdir_timestamp;
124         unsigned long           read_cache_jiffies;
125         unsigned long           attrtimeo;
126         unsigned long           attrtimeo_timestamp;
127         __u64                   change_attr;            /* v4 only */
128
129         /* "Generation counter" for the attribute cache. This is
130          * bumped whenever we update the metadata on the
131          * server.
132          */
133         unsigned long           cache_change_attribute;
134         /*
135          * Counter indicating the number of outstanding requests that
136          * will cause a file data update.
137          */
138         atomic_t                data_updates;
139
140         struct nfs_access_cache cache_access;
141
142         /*
143          * This is the cookie verifier used for NFSv3 readdir
144          * operations
145          */
146         __u32                   cookieverf[2];
147
148         /*
149          * This is the list of dirty unwritten pages.
150          */
151         struct list_head        dirty;
152         struct list_head        commit;
153         struct radix_tree_root  nfs_page_tree;
154
155         unsigned int            ndirty,
156                                 ncommit,
157                                 npages;
158
159         /* Credentials for shared mmap */
160         struct rpc_cred         *mm_cred;
161
162         wait_queue_head_t       nfs_i_wait;
163
164 #ifdef CONFIG_NFS_V4
165         /* NFSv4 state */
166         struct list_head        open_states;
167 #endif /* CONFIG_NFS_V4*/
168
169         struct inode            vfs_inode;
170 };
171
172 /*
173  * Legal inode flag values
174  */
175 #define NFS_INO_STALE           0x0001          /* possible stale inode */
176 #define NFS_INO_ADVISE_RDPLUS   0x0002          /* advise readdirplus */
177 #define NFS_INO_REVALIDATING    0x0004          /* revalidating attrs */
178 #define NFS_INO_INVALID_ATTR    0x0008          /* cached attrs are invalid */
179 #define NFS_INO_INVALID_DATA    0x0010          /* cached data is invalid */
180 #define NFS_INO_INVALID_ATIME   0x0020          /* cached atime is invalid */
181
182 static inline struct nfs_inode *NFS_I(struct inode *inode)
183 {
184         return container_of(inode, struct nfs_inode, vfs_inode);
185 }
186 #define NFS_SB(s)               ((struct nfs_server *)(s->s_fs_info))
187
188 #define NFS_FH(inode)                   (&NFS_I(inode)->fh)
189 #define NFS_SERVER(inode)               (NFS_SB(inode->i_sb))
190 #define NFS_CLIENT(inode)               (NFS_SERVER(inode)->client)
191 #define NFS_PROTO(inode)                (NFS_SERVER(inode)->rpc_ops)
192 #define NFS_ADDR(inode)                 (RPC_PEERADDR(NFS_CLIENT(inode)))
193 #define NFS_COOKIEVERF(inode)           (NFS_I(inode)->cookieverf)
194 #define NFS_READTIME(inode)             (NFS_I(inode)->read_cache_jiffies)
195 #define NFS_CHANGE_ATTR(inode)          (NFS_I(inode)->change_attr)
196 #define NFS_ATTRTIMEO(inode)            (NFS_I(inode)->attrtimeo)
197 #define NFS_MINATTRTIMEO(inode) \
198         (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmin \
199                                : NFS_SERVER(inode)->acregmin)
200 #define NFS_MAXATTRTIMEO(inode) \
201         (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmax \
202                                : NFS_SERVER(inode)->acregmax)
203 #define NFS_ATTRTIMEO_UPDATE(inode)     (NFS_I(inode)->attrtimeo_timestamp)
204
205 #define NFS_FLAGS(inode)                (NFS_I(inode)->flags)
206 #define NFS_REVALIDATING(inode)         (NFS_FLAGS(inode) & NFS_INO_REVALIDATING)
207 #define NFS_STALE(inode)                (NFS_FLAGS(inode) & NFS_INO_STALE)
208
209 #define NFS_FILEID(inode)               (NFS_I(inode)->fileid)
210
211 static inline int nfs_caches_unstable(struct inode *inode)
212 {
213         return atomic_read(&NFS_I(inode)->data_updates) != 0;
214 }
215
216 static inline void NFS_CACHEINV(struct inode *inode)
217 {
218         if (!nfs_caches_unstable(inode))
219                 NFS_FLAGS(inode) |= NFS_INO_INVALID_ATTR;
220 }
221
222 static inline int nfs_server_capable(struct inode *inode, int cap)
223 {
224         return NFS_SERVER(inode)->caps & cap;
225 }
226
227 static inline int NFS_USE_READDIRPLUS(struct inode *inode)
228 {
229         return NFS_FLAGS(inode) & NFS_INO_ADVISE_RDPLUS;
230 }
231
232 static inline
233 loff_t page_offset(struct page *page)
234 {
235         return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
236 }
237
238 /**
239  * nfs_save_change_attribute - Returns the inode attribute change cookie
240  * @inode - pointer to inode
241  * The "change attribute" is updated every time we finish an operation
242  * that will result in a metadata change on the server.
243  */
244 static inline long nfs_save_change_attribute(struct inode *inode)
245 {
246         return NFS_I(inode)->cache_change_attribute;
247 }
248
249 /**
250  * nfs_verify_change_attribute - Detects NFS inode cache updates
251  * @inode - pointer to inode
252  * @chattr - previously saved change attribute
253  * Return "false" if metadata has been updated (or is in the process of
254  * being updated) since the change attribute was saved.
255  */
256 static inline int nfs_verify_change_attribute(struct inode *inode, unsigned long chattr)
257 {
258         return !nfs_caches_unstable(inode)
259                 && chattr == NFS_I(inode)->cache_change_attribute;
260 }
261
262 /*
263  * linux/fs/nfs/inode.c
264  */
265 extern void nfs_zap_caches(struct inode *);
266 extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
267                                 struct nfs_fattr *);
268 extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
269 extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
270 extern int nfs_permission(struct inode *, int, struct nameidata *);
271 extern void nfs_set_mmcred(struct inode *, struct rpc_cred *);
272 extern int nfs_open(struct inode *, struct file *);
273 extern int nfs_release(struct inode *, struct file *);
274 extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
275 extern int nfs_setattr(struct dentry *, struct iattr *);
276 extern void nfs_begin_attr_update(struct inode *);
277 extern void nfs_end_attr_update(struct inode *);
278 extern void nfs_begin_data_update(struct inode *);
279 extern void nfs_end_data_update(struct inode *);
280 extern void nfs_end_data_update_defer(struct inode *);
281
282 /* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
283 extern u32 root_nfs_parse_addr(char *name); /*__init*/
284
285 /*
286  * linux/fs/nfs/file.c
287  */
288 extern struct inode_operations nfs_file_inode_operations;
289 extern struct file_operations nfs_file_operations;
290 extern struct address_space_operations nfs_file_aops;
291
292 /*
293  * linux/fs/nfs/xattr.c
294  */
295 #ifdef CONFIG_NFS_ACL
296 extern ssize_t nfs_listxattr(struct dentry *, char *, size_t);
297 extern ssize_t nfs_getxattr(struct dentry *, const char *, void *, size_t);
298 extern int nfs_setxattr(struct dentry *, const char *,
299                         const void *, size_t, int);
300 extern int nfs_removexattr (struct dentry *, const char *name);
301 #else
302 # define nfs_listxattr NULL
303 # define nfs_getxattr NULL
304 # define nfs_setxattr NULL
305 # define nfs_removexattr NULL
306 #endif
307
308 static __inline__ struct rpc_cred *
309 nfs_file_cred(struct file *file)
310 {
311         struct rpc_cred *cred = NULL;
312         if (file)
313                 cred = (struct rpc_cred *)file->private_data;
314 #ifdef RPC_DEBUG
315         BUG_ON(cred && cred->cr_magic != RPCAUTH_CRED_MAGIC);
316 #endif
317         return cred;
318 }
319
320 /*
321  * linux/fs/nfs/direct.c
322  */
323 extern ssize_t nfs_direct_IO(int, struct kiocb *, const struct iovec *, loff_t,
324                         unsigned long);
325 extern ssize_t nfs_file_direct_read(struct kiocb *iocb, char __user *buf,
326                         size_t count, loff_t pos);
327 extern ssize_t nfs_file_direct_write(struct kiocb *iocb, const char __user *buf,
328                         size_t count, loff_t pos);
329
330 /*
331  * linux/fs/nfs/dir.c
332  */
333 extern struct inode_operations nfs_dir_inode_operations;
334 extern struct file_operations nfs_dir_operations;
335 extern struct dentry_operations nfs_dentry_operations;
336
337 /*
338  * linux/fs/nfs/symlink.c
339  */
340 extern struct inode_operations nfs_symlink_inode_operations;
341
342 /*
343  * linux/fs/nfs/locks.c
344  */
345 extern int nfs_lock(struct file *, int, struct file_lock *);
346
347 /*
348  * linux/fs/nfs/unlink.c
349  */
350 extern int  nfs_async_unlink(struct dentry *);
351 extern void nfs_complete_unlink(struct dentry *);
352
353 /*
354  * linux/fs/nfs/write.c
355  */
356 extern int  nfs_writepage(struct page *page, struct writeback_control *wbc);
357 extern int  nfs_writepages(struct address_space *, struct writeback_control *);
358 extern int  nfs_flush_incompatible(struct file *file, struct page *page);
359 extern int  nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
360 extern void nfs_writeback_done(struct rpc_task *task);
361
362 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
363 extern void nfs_commit_done(struct rpc_task *);
364 #endif
365
366 /*
367  * Try to write back everything synchronously (but check the
368  * return value!)
369  */
370 extern int  nfs_sync_inode(struct inode *, unsigned long, unsigned int, int);
371 extern int  nfs_flush_inode(struct inode *, unsigned long, unsigned int, int);
372 extern int  nfs_flush_list(struct list_head *, int, int);
373 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
374 extern int  nfs_commit_inode(struct inode *, unsigned long, unsigned int, int);
375 extern int  nfs_commit_list(struct list_head *, int);
376 #else
377 static inline int
378 nfs_commit_inode(struct inode *inode, unsigned long idx_start, unsigned int npages, int how)
379 {
380         return 0;
381 }
382 #endif
383
384 static inline int
385 nfs_have_writebacks(struct inode *inode)
386 {
387         return NFS_I(inode)->npages != 0;
388 }
389
390 static inline int
391 nfs_wb_all(struct inode *inode)
392 {
393         int error = nfs_sync_inode(inode, 0, 0, FLUSH_WAIT);
394         return (error < 0) ? error : 0;
395 }
396
397 /*
398  * Write back all requests on one page - we do this before reading it.
399  */
400 static inline int nfs_wb_page_priority(struct inode *inode, struct page* page, int how)
401 {
402         int error = nfs_sync_inode(inode, page->index, 1,
403                         how | FLUSH_WAIT | FLUSH_STABLE);
404         return (error < 0) ? error : 0;
405 }
406
407 static inline int nfs_wb_page(struct inode *inode, struct page* page)
408 {
409         return nfs_wb_page_priority(inode, page, 0);
410 }
411
412 /* Hack for future NFS swap support */
413 #ifndef IS_SWAPFILE
414 # define IS_SWAPFILE(inode)     (0)
415 #endif
416
417 /*
418  * linux/fs/nfs/read.c
419  */
420 extern int  nfs_readpage(struct file *, struct page *);
421 extern int  nfs_readpages(struct file *, struct address_space *,
422                 struct list_head *, unsigned);
423 extern int  nfs_pagein_list(struct list_head *, int);
424 extern void nfs_readpage_result(struct rpc_task *);
425
426 /*
427  * linux/fs/mount_clnt.c
428  * (Used only by nfsroot module)
429  */
430 extern int  nfsroot_mount(struct sockaddr_in *, char *, struct nfs_fh *,
431                 int, int);
432
433 /*
434  * inline functions
435  */
436
437 static inline int nfs_attribute_timeout(struct inode *inode)
438 {
439         struct nfs_inode *nfsi = NFS_I(inode);
440
441         return time_after(jiffies, nfsi->read_cache_jiffies+nfsi->attrtimeo);
442 }
443
444 /**
445  * nfs_revalidate_inode - Revalidate the inode attributes
446  * @server - pointer to nfs_server struct
447  * @inode - pointer to inode struct
448  *
449  * Updates inode attribute information by retrieving the data from the server.
450  */
451 static inline int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
452 {
453         if (!(NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA))
454                         && !nfs_attribute_timeout(inode))
455                 return NFS_STALE(inode) ? -ESTALE : 0;
456         return __nfs_revalidate_inode(server, inode);
457 }
458
459 static inline loff_t
460 nfs_size_to_loff_t(__u64 size)
461 {
462         loff_t maxsz = (((loff_t) ULONG_MAX) << PAGE_CACHE_SHIFT) + PAGE_CACHE_SIZE - 1;
463         if (size > maxsz)
464                 return maxsz;
465         return (loff_t) size;
466 }
467
468 static inline ino_t
469 nfs_fileid_to_ino_t(u64 fileid)
470 {
471         ino_t ino = (ino_t) fileid;
472         if (sizeof(ino_t) < sizeof(u64))
473                 ino ^= fileid >> (sizeof(u64)-sizeof(ino_t)) * 8;
474         return ino;
475 }
476
477 /* NFS root */
478
479 extern void * nfs_root_data(void);
480
481 #define nfs_wait_event(clnt, wq, condition)                             \
482 ({                                                                      \
483         int __retval = 0;                                               \
484         if (clnt->cl_intr) {                                            \
485                 sigset_t oldmask;                                       \
486                 rpc_clnt_sigmask(clnt, &oldmask);                       \
487                 __retval = wait_event_interruptible(wq, condition);     \
488                 rpc_clnt_sigunmask(clnt, &oldmask);                     \
489         } else                                                          \
490                 wait_event(wq, condition);                              \
491         __retval;                                                       \
492 })
493
494 #define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
495
496 #ifdef CONFIG_NFS_V4
497
498 struct idmap;
499
500 /*
501  * In a seqid-mutating op, this macro controls which error return
502  * values trigger incrementation of the seqid.
503  *
504  * from rfc 3010:
505  * The client MUST monotonically increment the sequence number for the
506  * CLOSE, LOCK, LOCKU, OPEN, OPEN_CONFIRM, and OPEN_DOWNGRADE
507  * operations.  This is true even in the event that the previous
508  * operation that used the sequence number received an error.  The only
509  * exception to this rule is if the previous operation received one of
510  * the following errors: NFSERR_STALE_CLIENTID, NFSERR_STALE_STATEID,
511  * NFSERR_BAD_STATEID, NFSERR_BAD_SEQID, NFSERR_BADXDR,
512  * NFSERR_RESOURCE, NFSERR_NOFILEHANDLE.
513  *
514  */
515 #define seqid_mutating_err(err)       \
516 (((err) != NFSERR_STALE_CLIENTID) &&  \
517  ((err) != NFSERR_STALE_STATEID)  &&  \
518  ((err) != NFSERR_BAD_STATEID)    &&  \
519  ((err) != NFSERR_BAD_SEQID)      &&  \
520  ((err) != NFSERR_BAD_XDR)        &&  \
521  ((err) != NFSERR_RESOURCE)       &&  \
522  ((err) != NFSERR_NOFILEHANDLE))
523
524 enum nfs4_client_state {
525         NFS4CLNT_OK  = 0,
526         NFS4CLNT_NEW,
527         NFS4CLNT_SETUP_STATE,
528 };
529
530 /*
531  * The nfs4_client identifies our client state to the server.
532  */
533 struct nfs4_client {
534         struct list_head        cl_servers;     /* Global list of servers */
535         struct in_addr          cl_addr;        /* Server identifier */
536         u64                     cl_clientid;    /* constant */
537         nfs4_verifier           cl_confirm;
538         unsigned long           cl_state;
539         long                    cl_generation;
540
541         u32                     cl_lockowner_id;
542
543         /*
544          * The following rwsem ensures exclusive access to the server
545          * while we recover the state following a lease expiration.
546          */
547         struct rw_semaphore     cl_sem;
548
549         struct list_head        cl_state_owners;
550         struct list_head        cl_unused;
551         int                     cl_nunused;
552         spinlock_t              cl_lock;
553         atomic_t                cl_count;
554
555         struct rpc_clnt *       cl_rpcclient;
556         struct rpc_cred *       cl_cred;
557
558         struct list_head        cl_superblocks; /* List of nfs_server structs */
559
560         unsigned long           cl_lease_time;
561         unsigned long           cl_last_renewal;
562         struct work_struct      cl_renewd;
563         struct work_struct      cl_recoverd;
564
565         wait_queue_head_t       cl_waitq;
566         struct rpc_wait_queue   cl_rpcwaitq;
567
568         /* idmapper */
569         struct idmap *          cl_idmap;
570
571         /* Our own IP address, as a null-terminated string.
572          * This is used to generate the clientid, and the callback address.
573          */
574         char                    cl_ipaddr[16];
575 };
576
577 /*
578  * NFS4 state_owners and lock_owners are simply labels for ordered
579  * sequences of RPC calls. Their sole purpose is to provide once-only
580  * semantics by allowing the server to identify replayed requests.
581  *
582  * The ->so_sema is held during all state_owner seqid-mutating operations:
583  * OPEN, OPEN_DOWNGRADE, and CLOSE. Its purpose is to properly serialize
584  * so_seqid.
585  */
586 struct nfs4_state_owner {
587         struct list_head     so_list;    /* per-clientid list of state_owners */
588         struct nfs4_client   *so_client;
589         u32                  so_id;      /* 32-bit identifier, unique */
590         struct semaphore     so_sema;
591         u32                  so_seqid;   /* protected by so_sema */
592         unsigned int         so_flags;   /* protected by so_sema */
593         atomic_t             so_count;
594         long                 so_generation;
595
596         struct rpc_cred      *so_cred;   /* Associated cred */
597         struct list_head     so_states;
598 };
599
600 /*
601  * struct nfs4_state maintains the client-side state for a given
602  * (state_owner,inode) tuple (OPEN) or state_owner (LOCK).
603  *
604  * OPEN:
605  * In order to know when to OPEN_DOWNGRADE or CLOSE the state on the server,
606  * we need to know how many files are open for reading or writing on a
607  * given inode. This information too is stored here.
608  *
609  * LOCK: one nfs4_state (LOCK) to hold the lock stateid nfs4_state(OPEN)
610  */
611
612 struct nfs4_lock_state {
613         struct list_head        ls_locks;       /* Other lock stateids */
614         fl_owner_t              ls_owner;       /* POSIX lock owner */
615         struct nfs4_state *     ls_parent;      /* Parent nfs4_state */
616         u32                     ls_seqid;
617         u32                     ls_id;
618         nfs4_stateid            ls_stateid;
619         atomic_t                ls_count;
620 };
621
622 /* bits for nfs4_state->flags */
623 enum {
624         LK_STATE_IN_USE,
625 };
626
627 struct nfs4_state {
628         struct list_head open_states;   /* List of states for the same state_owner */
629         struct list_head inode_states;  /* List of states for the same inode */
630         struct list_head lock_states;   /* List of subservient lock stateids */
631
632         struct nfs4_state_owner *owner; /* Pointer to the open owner */
633         struct inode *inode;            /* Pointer to the inode */
634
635         unsigned long flags;            /* Do we hold any locks? */
636         struct semaphore lock_sema;     /* Serializes file locking operations */
637         rwlock_t state_lock;            /* Protects the lock_states list */
638
639         nfs4_stateid stateid;
640
641         unsigned int nreaders;
642         unsigned int nwriters;
643         int state;                      /* State on the server (R,W, or RW) */
644         atomic_t count;
645 };
646
647
648 extern struct dentry_operations nfs4_dentry_operations;
649 extern struct inode_operations nfs4_dir_inode_operations;
650
651 /* nfs4proc.c */
652 extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short);
653 extern int nfs4_proc_setclientid_confirm(struct nfs4_client *);
654 extern int nfs4_open_reclaim(struct nfs4_state_owner *, struct nfs4_state *);
655 extern int nfs4_proc_async_renew(struct nfs4_client *);
656 extern int nfs4_proc_renew(struct nfs4_client *);
657 extern int nfs4_do_close(struct inode *, struct nfs4_state *);
658 int nfs4_do_downgrade(struct inode *inode, struct nfs4_state *state, mode_t mode);
659 extern int nfs4_wait_clnt_recover(struct rpc_clnt *, struct nfs4_client *);
660 extern struct inode *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *);
661 extern int nfs4_open_revalidate(struct inode *, struct dentry *, int);
662
663 /* nfs4renewd.c */
664 extern void nfs4_schedule_state_renewal(struct nfs4_client *);
665 extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
666 extern void nfs4_kill_renewd(struct nfs4_client *);
667
668 /* nfs4state.c */
669 extern void init_nfsv4_state(struct nfs_server *);
670 extern void destroy_nfsv4_state(struct nfs_server *);
671 extern struct nfs4_client *nfs4_get_client(struct in_addr *);
672 extern void nfs4_put_client(struct nfs4_client *clp);
673 extern u32 nfs4_alloc_lockowner_id(struct nfs4_client *);
674
675 extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *);
676 extern void nfs4_put_state_owner(struct nfs4_state_owner *);
677 extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
678 extern void nfs4_put_open_state(struct nfs4_state *);
679 extern void nfs4_close_state(struct nfs4_state *, mode_t);
680 extern struct nfs4_state *nfs4_find_state(struct inode *, struct rpc_cred *, mode_t mode);
681 extern void nfs4_increment_seqid(int status, struct nfs4_state_owner *sp);
682 extern int nfs4_handle_error(struct nfs_server *, int);
683 extern void nfs4_schedule_state_recovery(struct nfs4_client *);
684 extern struct nfs4_lock_state *nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t);
685 extern struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t);
686 extern void nfs4_put_lock_state(struct nfs4_lock_state *state);
687 extern void nfs4_increment_lock_seqid(int status, struct nfs4_lock_state *ls);
688 extern void nfs4_notify_setlk(struct inode *, struct file_lock *, struct nfs4_lock_state *);
689 extern void nfs4_notify_unlck(struct inode *, struct file_lock *, struct nfs4_lock_state *);
690 extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t);
691
692
693
694 struct nfs4_mount_data;
695 #else
696 #define init_nfsv4_state(server)  do { } while (0)
697 #define destroy_nfsv4_state(server)       do { } while (0)
698 #define nfs4_put_state_owner(inode, owner) do { } while (0)
699 #define nfs4_put_open_state(state) do { } while (0)
700 #define nfs4_renewd_prepare_shutdown(server) do { } while (0)
701 #endif
702
703 #endif /* __KERNEL__ */
704
705 /*
706  * NFS debug flags
707  */
708 #define NFSDBG_VFS              0x0001
709 #define NFSDBG_DIRCACHE         0x0002
710 #define NFSDBG_LOOKUPCACHE      0x0004
711 #define NFSDBG_PAGECACHE        0x0008
712 #define NFSDBG_PROC             0x0010
713 #define NFSDBG_XDR              0x0020
714 #define NFSDBG_FILE             0x0040
715 #define NFSDBG_ROOT             0x0080
716 #define NFSDBG_ALL              0xFFFF
717
718 #ifdef __KERNEL__
719 # undef ifdebug
720 # ifdef NFS_DEBUG
721 #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
722 # else
723 #  define ifdebug(fac)          if (0)
724 # endif
725 #endif /* __KERNEL */
726
727 #endif