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