Import 2.3.6
[davej-history.git] / include / linux / nfs_fs.h
blob613eb68722bb8bf9a0a8a5550ad3d0f723867ff2
1 /*
2 * linux/include/linux/nfs_fs.h
4 * Copyright (C) 1992 Rick Sladkey
6 * OS-specific nfs filesystem definitions and declarations
7 */
9 #ifndef _LINUX_NFS_FS_H
10 #define _LINUX_NFS_FS_H
12 #include <linux/signal.h>
13 #include <linux/sched.h>
14 #include <linux/in.h>
16 #include <linux/sunrpc/sched.h>
17 #include <linux/nfs.h>
18 #include <linux/nfs_mount.h>
21 * Enable debugging support for nfs client.
22 * Requires RPC_DEBUG.
24 #ifdef RPC_DEBUG
25 # define NFS_DEBUG
26 #endif
29 * NFS_MAX_DIRCACHE controls the number of simultaneously cached
30 * directory chunks. Each chunk holds the list of nfs_entry's returned
31 * in a single readdir call in a memory region of size PAGE_SIZE.
33 * Note that at most server->rsize bytes of the cache memory are used.
35 #define NFS_MAX_DIRCACHE 16
37 #define NFS_MAX_FILE_IO_BUFFER_SIZE 16384
38 #define NFS_DEF_FILE_IO_BUFFER_SIZE 4096
41 * The upper limit on timeouts for the exponential backoff algorithm.
43 #define NFS_MAX_RPC_TIMEOUT (6*HZ)
46 * Size of the lookup cache in units of number of entries cached.
47 * It is better not to make this too large although the optimum
48 * depends on a usage and environment.
50 #define NFS_LOOKUP_CACHE_SIZE 64
53 * superblock magic number for NFS
55 #define NFS_SUPER_MAGIC 0x6969
57 #define NFS_FH(dentry) ((struct nfs_fh *) ((dentry)->d_fsdata))
58 #define NFS_DSERVER(dentry) (&(dentry)->d_sb->u.nfs_sb.s_server)
59 #define NFS_SERVER(inode) (&(inode)->i_sb->u.nfs_sb.s_server)
60 #define NFS_CLIENT(inode) (NFS_SERVER(inode)->client)
61 #define NFS_ADDR(inode) (RPC_PEERADDR(NFS_CLIENT(inode)))
62 #define NFS_CONGESTED(inode) (RPC_CONGESTED(NFS_CLIENT(inode)))
64 #define NFS_READTIME(inode) ((inode)->u.nfs_i.read_cache_jiffies)
65 #define NFS_OLDMTIME(inode) ((inode)->u.nfs_i.read_cache_mtime)
66 #define NFS_CACHEINV(inode) \
67 do { \
68 NFS_READTIME(inode) = jiffies - 1000000; \
69 NFS_OLDMTIME(inode) = 0; \
70 } while (0)
71 #define NFS_ATTRTIMEO(inode) ((inode)->u.nfs_i.attrtimeo)
72 #define NFS_MINATTRTIMEO(inode) \
73 (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmin \
74 : NFS_SERVER(inode)->acregmin)
75 #define NFS_MAXATTRTIMEO(inode) \
76 (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmax \
77 : NFS_SERVER(inode)->acregmax)
79 #define NFS_FLAGS(inode) ((inode)->u.nfs_i.flags)
80 #define NFS_REVALIDATING(inode) (NFS_FLAGS(inode) & NFS_INO_REVALIDATE)
81 #define NFS_WRITEBACK(inode) ((inode)->u.nfs_i.writeback)
82 #define NFS_COOKIES(inode) ((inode)->u.nfs_i.cookies)
83 #define NFS_DIREOF(inode) ((inode)->u.nfs_i.direof)
86 * These are the default flags for swap requests
88 #define NFS_RPC_SWAPFLAGS (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
90 /* Flags in the RPC client structure */
91 #define NFS_CLNTF_BUFSIZE 0x0001 /* readdir buffer in longwords */
93 #ifdef __KERNEL__
96 * This struct describes a file region to be written.
97 * It's kind of a pity we have to keep all these lists ourselves, rather
98 * than sticking an extra pointer into struct page.
100 struct nfs_wreq {
101 struct rpc_listitem wb_list; /* linked list of req's */
102 struct rpc_task wb_task; /* RPC task */
103 struct file * wb_file; /* dentry referenced */
104 struct page * wb_page; /* page to be written */
105 wait_queue_head_t wb_wait; /* wait for completion */
106 unsigned int wb_offset; /* offset within page */
107 unsigned int wb_bytes; /* dirty range */
108 unsigned int wb_count; /* user count */
109 int wb_status;
110 pid_t wb_pid; /* owner process */
111 unsigned short wb_flags; /* status flags */
113 struct nfs_writeargs wb_args; /* NFS RPC stuff */
114 struct nfs_fattr wb_fattr; /* file attributes */
117 #define WB_NEXT(req) ((struct nfs_wreq *) ((req)->wb_list.next))
120 * Various flags for wb_flags
122 #define NFS_WRITE_CANCELLED 0x0004 /* has been cancelled */
123 #define NFS_WRITE_UNCOMMITTED 0x0008 /* written but uncommitted (NFSv3) */
124 #define NFS_WRITE_INVALIDATE 0x0010 /* invalidate after write */
125 #define NFS_WRITE_INPROGRESS 0x0100 /* RPC call in progress */
126 #define NFS_WRITE_COMPLETE 0x0200 /* RPC call completed */
128 #define WB_CANCELLED(req) ((req)->wb_flags & NFS_WRITE_CANCELLED)
129 #define WB_UNCOMMITTED(req) ((req)->wb_flags & NFS_WRITE_UNCOMMITTED)
130 #define WB_INVALIDATE(req) ((req)->wb_flags & NFS_WRITE_INVALIDATE)
131 #define WB_INPROGRESS(req) ((req)->wb_flags & NFS_WRITE_INPROGRESS)
132 #define WB_COMPLETE(req) ((req)->wb_flags & NFS_WRITE_COMPLETE)
135 * linux/fs/nfs/proc.c
137 extern int nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
138 struct nfs_fattr *fattr);
139 extern int nfs_proc_setattr(struct nfs_server *server, struct nfs_fh *fhandle,
140 struct nfs_sattr *sattr, struct nfs_fattr *fattr);
141 extern int nfs_proc_lookup(struct nfs_server *server, struct nfs_fh *dir,
142 const char *name, struct nfs_fh *fhandle,
143 struct nfs_fattr *fattr);
144 extern int nfs_proc_read(struct nfs_server *server, struct nfs_fh *fhandle,
145 int swap, unsigned long offset, unsigned int count,
146 void *buffer, struct nfs_fattr *fattr);
147 extern int nfs_proc_write(struct nfs_server *server, struct nfs_fh *fhandle,
148 int swap, unsigned long offset, unsigned int count,
149 const void *buffer, struct nfs_fattr *fattr);
150 extern int nfs_proc_create(struct nfs_server *server, struct nfs_fh *dir,
151 const char *name, struct nfs_sattr *sattr,
152 struct nfs_fh *fhandle, struct nfs_fattr *fattr);
153 extern int nfs_proc_remove(struct nfs_server *server, struct nfs_fh *dir,
154 const char *name);
155 extern int nfs_proc_rename(struct nfs_server *server,
156 struct nfs_fh *old_dir, const char *old_name,
157 struct nfs_fh *new_dir, const char *new_name);
158 extern int nfs_proc_link(struct nfs_server *server, struct nfs_fh *fhandle,
159 struct nfs_fh *dir, const char *name);
160 extern int nfs_proc_symlink(struct nfs_server *server, struct nfs_fh *dir,
161 const char *name, const char *path,
162 struct nfs_sattr *sattr);
163 extern int nfs_proc_mkdir(struct nfs_server *server, struct nfs_fh *dir,
164 const char *name, struct nfs_sattr *sattr,
165 struct nfs_fh *fhandle, struct nfs_fattr *fattr);
166 extern int nfs_proc_rmdir(struct nfs_server *server, struct nfs_fh *dir,
167 const char *name);
168 extern int nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
169 struct nfs_fsinfo *res);
173 * linux/fs/nfs/inode.c
175 extern struct super_block *nfs_read_super(struct super_block *, void *, int);
176 extern int init_nfs_fs(void);
177 extern struct inode *nfs_fhget(struct dentry *, struct nfs_fh *,
178 struct nfs_fattr *);
179 extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
180 extern int nfs_revalidate(struct dentry *);
181 extern int nfs_open(struct inode *, struct file *);
182 extern int nfs_release(struct inode *, struct file *);
183 extern int _nfs_revalidate_inode(struct nfs_server *, struct dentry *);
186 * linux/fs/nfs/file.c
188 extern struct inode_operations nfs_file_inode_operations;
191 * linux/fs/nfs/dir.c
193 extern struct inode_operations nfs_dir_inode_operations;
194 extern struct dentry_operations nfs_dentry_operations;
195 extern void nfs_invalidate_dircache(struct inode *);
198 * linux/fs/nfs/symlink.c
200 extern struct inode_operations nfs_symlink_inode_operations;
203 * linux/fs/nfs/locks.c
205 extern int nfs_lock(struct file *, int, struct file_lock *);
208 * linux/fs/nfs/write.c
210 extern int nfs_writepage(struct file *, struct page *);
211 extern int nfs_check_failed_request(struct inode *);
214 * Try to write back everything synchronously (but check the
215 * return value!)
217 extern int nfs_wb_all(struct inode *);
218 extern int nfs_wb_page(struct inode *, struct page *);
219 extern int nfs_wb_file(struct inode *, struct file *);
222 * Invalidate write-backs, possibly trying to write them
223 * back first..
225 extern void nfs_inval(struct inode *);
226 extern int nfs_updatepage(struct file *, struct page *, unsigned long, unsigned int);
229 * linux/fs/nfs/read.c
231 extern int nfs_readpage(struct file *, struct page *);
234 * linux/fs/mount_clnt.c
235 * (Used only by nfsroot module)
237 extern int nfs_mount(struct sockaddr_in *, char *, struct nfs_fh *);
240 * inline functions
242 static inline int
243 nfs_revalidate_inode(struct nfs_server *server, struct dentry *dentry)
245 struct inode *inode = dentry->d_inode;
246 if (jiffies - NFS_READTIME(inode) < NFS_ATTRTIMEO(inode))
247 return 0;
248 return _nfs_revalidate_inode(server, dentry);
251 /* NFS root */
253 extern int nfs_root_mount(struct super_block *sb);
255 #endif /* __KERNEL__ */
258 * NFS debug flags
260 #define NFSDBG_VFS 0x0001
261 #define NFSDBG_DIRCACHE 0x0002
262 #define NFSDBG_LOOKUPCACHE 0x0004
263 #define NFSDBG_PAGECACHE 0x0008
264 #define NFSDBG_PROC 0x0010
265 #define NFSDBG_XDR 0x0020
266 #define NFSDBG_FILE 0x0040
267 #define NFSDBG_ROOT 0x0080
268 #define NFSDBG_ALL 0xFFFF
270 #ifdef __KERNEL__
271 # undef ifdebug
272 # ifdef NFS_DEBUG
273 # define ifdebug(fac) if (nfs_debug & NFSDBG_##fac)
274 # else
275 # define ifdebug(fac) if (0)
276 # endif
277 #endif /* __KERNEL */
279 #endif