pre-2.3.4..
[davej-history.git] / include / linux / nfs_fs.h
blob9a4a08df4a630e5676a9f9c3d49b12750f596f91
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)
84 * These are the default flags for swap requests
86 #define NFS_RPC_SWAPFLAGS (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
88 /* Flags in the RPC client structure */
89 #define NFS_CLNTF_BUFSIZE 0x0001 /* readdir buffer in longwords */
91 #ifdef __KERNEL__
94 * This struct describes a file region to be written.
95 * It's kind of a pity we have to keep all these lists ourselves, rather
96 * than sticking an extra pointer into struct page.
98 struct nfs_wreq {
99 struct rpc_listitem wb_list; /* linked list of req's */
100 struct rpc_task wb_task; /* RPC task */
101 struct file * wb_file; /* dentry referenced */
102 struct page * wb_page; /* page to be written */
103 wait_queue_head_t wb_wait; /* wait for completion */
104 unsigned int wb_offset; /* offset within page */
105 unsigned int wb_bytes; /* dirty range */
106 unsigned int wb_count; /* user count */
107 int wb_status;
108 pid_t wb_pid; /* owner process */
109 unsigned short wb_flags; /* status flags */
111 struct nfs_writeargs wb_args; /* NFS RPC stuff */
112 struct nfs_fattr wb_fattr; /* file attributes */
115 #define WB_NEXT(req) ((struct nfs_wreq *) ((req)->wb_list.next))
118 * Various flags for wb_flags
120 #define NFS_WRITE_CANCELLED 0x0004 /* has been cancelled */
121 #define NFS_WRITE_UNCOMMITTED 0x0008 /* written but uncommitted (NFSv3) */
122 #define NFS_WRITE_INVALIDATE 0x0010 /* invalidate after write */
123 #define NFS_WRITE_INPROGRESS 0x0100 /* RPC call in progress */
124 #define NFS_WRITE_COMPLETE 0x0200 /* RPC call completed */
126 #define WB_CANCELLED(req) ((req)->wb_flags & NFS_WRITE_CANCELLED)
127 #define WB_UNCOMMITTED(req) ((req)->wb_flags & NFS_WRITE_UNCOMMITTED)
128 #define WB_INVALIDATE(req) ((req)->wb_flags & NFS_WRITE_INVALIDATE)
129 #define WB_INPROGRESS(req) ((req)->wb_flags & NFS_WRITE_INPROGRESS)
130 #define WB_COMPLETE(req) ((req)->wb_flags & NFS_WRITE_COMPLETE)
133 * linux/fs/nfs/proc.c
135 extern int nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
136 struct nfs_fattr *fattr);
137 extern int nfs_proc_setattr(struct nfs_server *server, struct nfs_fh *fhandle,
138 struct nfs_sattr *sattr, struct nfs_fattr *fattr);
139 extern int nfs_proc_lookup(struct nfs_server *server, struct nfs_fh *dir,
140 const char *name, struct nfs_fh *fhandle,
141 struct nfs_fattr *fattr);
142 extern int nfs_proc_readlink(struct nfs_server *server, struct nfs_fh *fhandle,
143 void **p0, char **string, unsigned int *len,
144 unsigned int maxlen);
145 extern int nfs_proc_read(struct nfs_server *server, struct nfs_fh *fhandle,
146 int swap, unsigned long offset, unsigned int count,
147 void *buffer, struct nfs_fattr *fattr);
148 extern int nfs_proc_write(struct nfs_server *server, struct nfs_fh *fhandle,
149 int swap, unsigned long offset, unsigned int count,
150 const void *buffer, struct nfs_fattr *fattr);
151 extern int nfs_proc_create(struct nfs_server *server, struct nfs_fh *dir,
152 const char *name, struct nfs_sattr *sattr,
153 struct nfs_fh *fhandle, struct nfs_fattr *fattr);
154 extern int nfs_proc_remove(struct nfs_server *server, struct nfs_fh *dir,
155 const char *name);
156 extern int nfs_proc_rename(struct nfs_server *server,
157 struct nfs_fh *old_dir, const char *old_name,
158 struct nfs_fh *new_dir, const char *new_name);
159 extern int nfs_proc_link(struct nfs_server *server, struct nfs_fh *fhandle,
160 struct nfs_fh *dir, const char *name);
161 extern int nfs_proc_symlink(struct nfs_server *server, struct nfs_fh *dir,
162 const char *name, const char *path,
163 struct nfs_sattr *sattr);
164 extern int nfs_proc_mkdir(struct nfs_server *server, struct nfs_fh *dir,
165 const char *name, struct nfs_sattr *sattr,
166 struct nfs_fh *fhandle, struct nfs_fattr *fattr);
167 extern int nfs_proc_rmdir(struct nfs_server *server, struct nfs_fh *dir,
168 const char *name);
169 extern int nfs_proc_readdir(struct nfs_server *server, struct nfs_fh *fhandle,
170 u32 cookie, unsigned int size, __u32 *entry);
171 extern int nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
172 struct nfs_fsinfo *res);
176 * linux/fs/nfs/inode.c
178 extern struct super_block *nfs_read_super(struct super_block *, void *, int);
179 extern int init_nfs_fs(void);
180 extern struct inode *nfs_fhget(struct dentry *, struct nfs_fh *,
181 struct nfs_fattr *);
182 extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
183 extern int nfs_revalidate(struct dentry *);
184 extern int nfs_open(struct inode *, struct file *);
185 extern int nfs_release(struct inode *, struct file *);
186 extern int _nfs_revalidate_inode(struct nfs_server *, struct dentry *);
189 * linux/fs/nfs/file.c
191 extern struct inode_operations nfs_file_inode_operations;
194 * linux/fs/nfs/dir.c
196 extern struct inode_operations nfs_dir_inode_operations;
197 extern struct dentry_operations nfs_dentry_operations;
198 extern void nfs_free_dircache(void);
199 extern void nfs_invalidate_dircache(struct inode *);
200 extern void nfs_invalidate_dircache_sb(struct super_block *);
203 * linux/fs/nfs/symlink.c
205 extern struct inode_operations nfs_symlink_inode_operations;
208 * linux/fs/nfs/locks.c
210 extern int nfs_lock(struct file *, int, struct file_lock *);
213 * linux/fs/nfs/write.c
215 extern int nfs_writepage(struct file *, struct page *);
216 extern int nfs_check_failed_request(struct inode *);
219 * Try to write back everything synchronously (but check the
220 * return value!)
222 extern int nfs_wb_all(struct inode *);
223 extern int nfs_wb_page(struct inode *, struct page *);
224 extern int nfs_wb_file(struct inode *, struct file *);
227 * Invalidate write-backs, possibly trying to write them
228 * back first..
230 extern void nfs_inval(struct inode *);
231 extern int nfs_updatepage(struct file *, struct page *, unsigned long, unsigned int, int);
234 * linux/fs/nfs/read.c
236 extern int nfs_readpage(struct file *, struct page *);
239 * linux/fs/mount_clnt.c
240 * (Used only by nfsroot module)
242 extern int nfs_mount(struct sockaddr_in *, char *, struct nfs_fh *);
245 * inline functions
247 static inline int
248 nfs_revalidate_inode(struct nfs_server *server, struct dentry *dentry)
250 struct inode *inode = dentry->d_inode;
251 if (jiffies - NFS_READTIME(inode) < NFS_ATTRTIMEO(inode))
252 return 0;
253 return _nfs_revalidate_inode(server, dentry);
256 /* NFS root */
258 extern int nfs_root_mount(struct super_block *sb);
260 #endif /* __KERNEL__ */
263 * NFS debug flags
265 #define NFSDBG_VFS 0x0001
266 #define NFSDBG_DIRCACHE 0x0002
267 #define NFSDBG_LOOKUPCACHE 0x0004
268 #define NFSDBG_PAGECACHE 0x0008
269 #define NFSDBG_PROC 0x0010
270 #define NFSDBG_XDR 0x0020
271 #define NFSDBG_FILE 0x0040
272 #define NFSDBG_ROOT 0x0080
273 #define NFSDBG_ALL 0xFFFF
275 #ifdef __KERNEL__
276 # undef ifdebug
277 # ifdef NFS_DEBUG
278 # define ifdebug(fac) if (nfs_debug & NFSDBG_##fac)
279 # else
280 # define ifdebug(fac) if (0)
281 # endif
282 #endif /* __KERNEL */
284 #endif