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