ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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/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 static __inline__ struct rpc_cred *
293 nfs_file_cred(struct file *file)
294 {
295         struct rpc_cred *cred = NULL;
296         if (file)
297                 cred = (struct rpc_cred *)file->private_data;
298 #ifdef RPC_DEBUG
299         BUG_ON(cred && cred->cr_magic != RPCAUTH_CRED_MAGIC);
300 #endif
301         return cred;
302 }
303
304 /*
305  * linux/fs/nfs/direct.c
306  */
307 extern ssize_t nfs_direct_IO(int, struct kiocb *, const struct iovec *, loff_t,
308                         unsigned long);
309
310 /*
311  * linux/fs/nfs/dir.c
312  */
313 extern struct inode_operations nfs_dir_inode_operations;
314 extern struct file_operations nfs_dir_operations;
315 extern struct dentry_operations nfs_dentry_operations;
316
317 /*
318  * linux/fs/nfs/symlink.c
319  */
320 extern struct inode_operations nfs_symlink_inode_operations;
321
322 /*
323  * linux/fs/nfs/locks.c
324  */
325 extern int nfs_lock(struct file *, int, struct file_lock *);
326
327 /*
328  * linux/fs/nfs/unlink.c
329  */
330 extern int  nfs_async_unlink(struct dentry *);
331 extern void nfs_complete_unlink(struct dentry *);
332
333 /*
334  * linux/fs/nfs/write.c
335  */
336 extern int  nfs_writepage(struct page *page, struct writeback_control *wbc);
337 extern int  nfs_writepages(struct address_space *, struct writeback_control *);
338 extern int  nfs_flush_incompatible(struct file *file, struct page *page);
339 extern int  nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
340 extern void nfs_writeback_done(struct rpc_task *task);
341
342 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
343 extern void nfs_commit_done(struct rpc_task *);
344 #endif
345
346 /*
347  * Try to write back everything synchronously (but check the
348  * return value!)
349  */
350 extern int  nfs_sync_inode(struct inode *, unsigned long, unsigned int, int);
351 extern int  nfs_flush_inode(struct inode *, unsigned long, unsigned int, int);
352 extern int  nfs_flush_list(struct list_head *, int, int);
353 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
354 extern int  nfs_commit_inode(struct inode *, unsigned long, unsigned int, int);
355 extern int  nfs_commit_list(struct list_head *, int);
356 #else
357 static inline int
358 nfs_commit_inode(struct inode *inode, unsigned long idx_start, unsigned int npages, int how)
359 {
360         return 0;
361 }
362 #endif
363
364 static inline int
365 nfs_have_writebacks(struct inode *inode)
366 {
367         return NFS_I(inode)->npages != 0;
368 }
369
370 static inline int
371 nfs_wb_all(struct inode *inode)
372 {
373         int error = nfs_sync_inode(inode, 0, 0, FLUSH_WAIT);
374         return (error < 0) ? error : 0;
375 }
376
377 /*
378  * Write back all requests on one page - we do this before reading it.
379  */
380 static inline int nfs_wb_page_priority(struct inode *inode, struct page* page, int how)
381 {
382         int error = nfs_sync_inode(inode, page->index, 1,
383                         how | FLUSH_WAIT | FLUSH_STABLE);
384         return (error < 0) ? error : 0;
385 }
386
387 static inline int nfs_wb_page(struct inode *inode, struct page* page)
388 {
389         return nfs_wb_page_priority(inode, page, 0);
390 }
391
392 /* Hack for future NFS swap support */
393 #ifndef IS_SWAPFILE
394 # define IS_SWAPFILE(inode)     (0)
395 #endif
396
397 /*
398  * linux/fs/nfs/read.c
399  */
400 extern int  nfs_readpage(struct file *, struct page *);
401 extern int  nfs_readpages(struct file *, struct address_space *,
402                 struct list_head *, unsigned);
403 extern int  nfs_pagein_list(struct list_head *, int);
404 extern void nfs_readpage_result(struct rpc_task *);
405
406 /*
407  * linux/fs/mount_clnt.c
408  * (Used only by nfsroot module)
409  */
410 extern int  nfsroot_mount(struct sockaddr_in *, char *, struct nfs_fh *,
411                 int, int);
412
413 /*
414  * inline functions
415  */
416
417 static inline int nfs_attribute_timeout(struct inode *inode)
418 {
419         struct nfs_inode *nfsi = NFS_I(inode);
420
421         return time_after(jiffies, nfsi->read_cache_jiffies+nfsi->attrtimeo);
422 }
423
424 /**
425  * nfs_revalidate_inode - Revalidate the inode attributes
426  * @server - pointer to nfs_server struct
427  * @inode - pointer to inode struct
428  *
429  * Updates inode attribute information by retrieving the data from the server.
430  */
431 static inline int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
432 {
433         if (!(NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA))
434                         && !nfs_attribute_timeout(inode))
435                 return NFS_STALE(inode) ? -ESTALE : 0;
436         return __nfs_revalidate_inode(server, inode);
437 }
438
439 static inline loff_t
440 nfs_size_to_loff_t(__u64 size)
441 {
442         loff_t maxsz = (((loff_t) ULONG_MAX) << PAGE_CACHE_SHIFT) + PAGE_CACHE_SIZE - 1;
443         if (size > maxsz)
444                 return maxsz;
445         return (loff_t) size;
446 }
447
448 static inline ino_t
449 nfs_fileid_to_ino_t(u64 fileid)
450 {
451         ino_t ino = (ino_t) fileid;
452         if (sizeof(ino_t) < sizeof(u64))
453                 ino ^= fileid >> (sizeof(u64)-sizeof(ino_t)) * 8;
454         return ino;
455 }
456
457 /* NFS root */
458
459 extern void * nfs_root_data(void);
460
461 #define nfs_wait_event(clnt, wq, condition)                             \
462 ({                                                                      \
463         int __retval = 0;                                               \
464         if (clnt->cl_intr) {                                            \
465                 sigset_t oldmask;                                       \
466                 rpc_clnt_sigmask(clnt, &oldmask);                       \
467                 __retval = wait_event_interruptible(wq, condition);     \
468                 rpc_clnt_sigunmask(clnt, &oldmask);                     \
469         } else                                                          \
470                 wait_event(wq, condition);                              \
471         __retval;                                                       \
472 })
473
474 #define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
475
476 #ifdef CONFIG_NFS_V4
477
478 struct idmap;
479
480 /*
481  * In a seqid-mutating op, this macro controls which error return
482  * values trigger incrementation of the seqid.
483  *
484  * from rfc 3010:
485  * The client MUST monotonically increment the sequence number for the
486  * CLOSE, LOCK, LOCKU, OPEN, OPEN_CONFIRM, and OPEN_DOWNGRADE
487  * operations.  This is true even in the event that the previous
488  * operation that used the sequence number received an error.  The only
489  * exception to this rule is if the previous operation received one of
490  * the following errors: NFSERR_STALE_CLIENTID, NFSERR_STALE_STATEID,
491  * NFSERR_BAD_STATEID, NFSERR_BAD_SEQID, NFSERR_BADXDR,
492  * NFSERR_RESOURCE, NFSERR_NOFILEHANDLE.
493  *
494  */
495 #define seqid_mutating_err(err)       \
496 (((err) != NFSERR_STALE_CLIENTID) &&  \
497  ((err) != NFSERR_STALE_STATEID)  &&  \
498  ((err) != NFSERR_BAD_STATEID)    &&  \
499  ((err) != NFSERR_BAD_SEQID)      &&  \
500  ((err) != NFSERR_BAD_XDR)        &&  \
501  ((err) != NFSERR_RESOURCE)       &&  \
502  ((err) != NFSERR_NOFILEHANDLE))
503
504 enum nfs4_client_state {
505         NFS4CLNT_OK  = 0,
506         NFS4CLNT_NEW,
507         NFS4CLNT_SETUP_STATE,
508 };
509
510 /*
511  * The nfs4_client identifies our client state to the server.
512  */
513 struct nfs4_client {
514         struct list_head        cl_servers;     /* Global list of servers */
515         struct in_addr          cl_addr;        /* Server identifier */
516         u64                     cl_clientid;    /* constant */
517         nfs4_verifier           cl_confirm;
518         unsigned long           cl_state;
519         long                    cl_generation;
520
521         u32                     cl_lockowner_id;
522
523         /*
524          * The following rwsem ensures exclusive access to the server
525          * while we recover the state following a lease expiration.
526          */
527         struct rw_semaphore     cl_sem;
528
529         struct list_head        cl_state_owners;
530         struct list_head        cl_unused;
531         int                     cl_nunused;
532         spinlock_t              cl_lock;
533         atomic_t                cl_count;
534
535         struct rpc_clnt *       cl_rpcclient;
536         struct rpc_cred *       cl_cred;
537
538         struct list_head        cl_superblocks; /* List of nfs_server structs */
539
540         unsigned long           cl_lease_time;
541         unsigned long           cl_last_renewal;
542         struct work_struct      cl_renewd;
543         struct work_struct      cl_recoverd;
544
545         wait_queue_head_t       cl_waitq;
546         struct rpc_wait_queue   cl_rpcwaitq;
547
548         /* idmapper */
549         struct idmap *          cl_idmap;
550
551         /* Our own IP address, as a null-terminated string.
552          * This is used to generate the clientid, and the callback address.
553          */
554         char                    cl_ipaddr[16];
555 };
556
557 /*
558  * NFS4 state_owners and lock_owners are simply labels for ordered
559  * sequences of RPC calls. Their sole purpose is to provide once-only
560  * semantics by allowing the server to identify replayed requests.
561  *
562  * The ->so_sema is held during all state_owner seqid-mutating operations:
563  * OPEN, OPEN_DOWNGRADE, and CLOSE. Its purpose is to properly serialize
564  * so_seqid.
565  */
566 struct nfs4_state_owner {
567         struct list_head     so_list;    /* per-clientid list of state_owners */
568         struct nfs4_client   *so_client;
569         u32                  so_id;      /* 32-bit identifier, unique */
570         struct semaphore     so_sema;
571         u32                  so_seqid;   /* protected by so_sema */
572         unsigned int         so_flags;   /* protected by so_sema */
573         atomic_t             so_count;
574         long                 so_generation;
575
576         struct rpc_cred      *so_cred;   /* Associated cred */
577         struct list_head     so_states;
578 };
579
580 /*
581  * struct nfs4_state maintains the client-side state for a given
582  * (state_owner,inode) tuple (OPEN) or state_owner (LOCK).
583  *
584  * OPEN:
585  * In order to know when to OPEN_DOWNGRADE or CLOSE the state on the server,
586  * we need to know how many files are open for reading or writing on a
587  * given inode. This information too is stored here.
588  *
589  * LOCK: one nfs4_state (LOCK) to hold the lock stateid nfs4_state(OPEN)
590  */
591
592 struct nfs4_lock_state {
593         struct list_head        ls_locks;       /* Other lock stateids */
594         fl_owner_t              ls_owner;       /* POSIX lock owner */
595         struct nfs4_state *     ls_parent;      /* Parent nfs4_state */
596         u32                     ls_seqid;
597         u32                     ls_id;
598         nfs4_stateid            ls_stateid;
599         atomic_t                ls_count;
600 };
601
602 /* bits for nfs4_state->flags */
603 enum {
604         LK_STATE_IN_USE,
605 };
606
607 struct nfs4_state {
608         struct list_head open_states;   /* List of states for the same state_owner */
609         struct list_head inode_states;  /* List of states for the same inode */
610         struct list_head lock_states;   /* List of subservient lock stateids */
611
612         struct nfs4_state_owner *owner; /* Pointer to the open owner */
613         struct inode *inode;            /* Pointer to the inode */
614
615         unsigned long flags;            /* Do we hold any locks? */
616         struct semaphore lock_sema;     /* Serializes file locking operations */
617         rwlock_t state_lock;            /* Protects the lock_states list */
618
619         nfs4_stateid stateid;
620
621         unsigned int nreaders;
622         unsigned int nwriters;
623         int state;                      /* State on the server (R,W, or RW) */
624         atomic_t count;
625 };
626
627
628 extern struct dentry_operations nfs4_dentry_operations;
629 extern struct inode_operations nfs4_dir_inode_operations;
630
631 /* nfs4proc.c */
632 extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short);
633 extern int nfs4_proc_setclientid_confirm(struct nfs4_client *);
634 extern int nfs4_open_reclaim(struct nfs4_state_owner *, struct nfs4_state *);
635 extern int nfs4_proc_async_renew(struct nfs4_client *);
636 extern int nfs4_proc_renew(struct nfs4_client *);
637 extern int nfs4_do_close(struct inode *, struct nfs4_state *);
638 int nfs4_do_downgrade(struct inode *inode, struct nfs4_state *state, mode_t mode);
639 extern int nfs4_wait_clnt_recover(struct rpc_clnt *, struct nfs4_client *);
640 extern struct inode *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *);
641 extern int nfs4_open_revalidate(struct inode *, struct dentry *, int);
642
643 /* nfs4renewd.c */
644 extern void nfs4_schedule_state_renewal(struct nfs4_client *);
645 extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
646 extern void nfs4_kill_renewd(struct nfs4_client *);
647
648 /* nfs4state.c */
649 extern void init_nfsv4_state(struct nfs_server *);
650 extern void destroy_nfsv4_state(struct nfs_server *);
651 extern struct nfs4_client *nfs4_get_client(struct in_addr *);
652 extern void nfs4_put_client(struct nfs4_client *clp);
653 extern u32 nfs4_alloc_lockowner_id(struct nfs4_client *);
654
655 extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *);
656 extern void nfs4_put_state_owner(struct nfs4_state_owner *);
657 extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
658 extern void nfs4_put_open_state(struct nfs4_state *);
659 extern void nfs4_close_state(struct nfs4_state *, mode_t);
660 extern struct nfs4_state *nfs4_find_state(struct inode *, struct rpc_cred *, mode_t mode);
661 extern void nfs4_increment_seqid(int status, struct nfs4_state_owner *sp);
662 extern int nfs4_handle_error(struct nfs_server *, int);
663 extern void nfs4_schedule_state_recovery(struct nfs4_client *);
664 extern struct nfs4_lock_state *nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t);
665 extern struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t);
666 extern void nfs4_put_lock_state(struct nfs4_lock_state *state);
667 extern void nfs4_increment_lock_seqid(int status, struct nfs4_lock_state *ls);
668 extern void nfs4_notify_setlk(struct inode *, struct file_lock *, struct nfs4_lock_state *);
669 extern void nfs4_notify_unlck(struct inode *, struct file_lock *, struct nfs4_lock_state *);
670 extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t);
671
672
673
674 struct nfs4_mount_data;
675 #else
676 #define init_nfsv4_state(server)  do { } while (0)
677 #define destroy_nfsv4_state(server)       do { } while (0)
678 #define nfs4_put_state_owner(inode, owner) do { } while (0)
679 #define nfs4_put_open_state(state) do { } while (0)
680 #define nfs4_renewd_prepare_shutdown(server) do { } while (0)
681 #endif
682
683 #endif /* __KERNEL__ */
684
685 /*
686  * NFS debug flags
687  */
688 #define NFSDBG_VFS              0x0001
689 #define NFSDBG_DIRCACHE         0x0002
690 #define NFSDBG_LOOKUPCACHE      0x0004
691 #define NFSDBG_PAGECACHE        0x0008
692 #define NFSDBG_PROC             0x0010
693 #define NFSDBG_XDR              0x0020
694 #define NFSDBG_FILE             0x0040
695 #define NFSDBG_ROOT             0x0080
696 #define NFSDBG_ALL              0xFFFF
697
698 #ifdef __KERNEL__
699 # undef ifdebug
700 # ifdef NFS_DEBUG
701 #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
702 # else
703 #  define ifdebug(fac)          if (0)
704 # endif
705 #endif /* __KERNEL */
706
707 #endif