Import 2.3.99pre9-1
[davej-history.git] / include / linux / nfs_page.h
blob475fced7c0d977bddba84115a5026be645b8d7cf
1 /*
2 * linux/include/linux/nfs_page.h
4 * Copyright (C) 2000 Trond Myklebust
6 * NFS page cache wrapper.
7 */
9 #ifndef _LINUX_NFS_PAGE_H
10 #define _LINUX_NFS_PAGE_H
13 #include <linux/list.h>
14 #include <linux/mm.h>
15 #include <linux/wait.h>
16 #include <linux/sunrpc/auth.h>
17 #include <linux/nfs_xdr.h>
20 * Valid flags for a dirty buffer
22 #define PG_BUSY 0x0001
24 struct nfs_page {
25 struct list_head wb_hash, /* Inode */
26 wb_list, /* Defines state of page: */
27 *wb_list_head; /* read/write/commit */
28 struct file *wb_file;
29 struct dentry *wb_dentry;
30 struct rpc_cred *wb_cred;
31 struct page *wb_page; /* page to read in/write out */
32 wait_queue_head_t wb_wait; /* wait queue */
33 unsigned long wb_timeout; /* when to read/write/commit */
34 unsigned int wb_offset, /* Offset of read/write */
35 wb_bytes, /* Length of request */
36 wb_count, /* reference count */
37 wb_flags;
38 struct nfs_writeverf wb_verf; /* Commit cookie */
41 #define NFS_WBACK_BUSY(req) ((req)->wb_flags & PG_BUSY)
43 extern struct nfs_page *nfs_create_request(struct dentry *dentry,
44 struct page *page,
45 unsigned int offset,
46 unsigned int count);
47 extern void nfs_release_request(struct nfs_page *req);
50 extern void nfs_list_add_request(struct nfs_page *req,
51 struct list_head *head);
52 extern void nfs_list_remove_request(struct nfs_page *req);
54 extern int nfs_scan_list_timeout(struct list_head *head,
55 struct list_head *dst,
56 struct inode *inode);
57 extern int nfs_scan_list(struct list_head *src, struct list_head *dst,
58 struct file *file, unsigned long idx_start,
59 unsigned int npages);
60 extern int nfs_coalesce_requests(struct list_head *src, struct list_head *dst,
61 unsigned int maxpages);
63 extern spinlock_t nfs_wreq_lock;
66 * Lock the page of an asynchronous request
68 static __inline__ int
69 nfs_lock_request(struct nfs_page *req)
71 if (NFS_WBACK_BUSY(req))
72 return 0;
73 req->wb_count++;
74 req->wb_flags |= PG_BUSY;
75 return 1;
78 static __inline__ void
79 nfs_unlock_request(struct nfs_page *req)
81 if (!NFS_WBACK_BUSY(req)) {
82 printk(KERN_ERR "NFS: Invalid unlock attempted\n");
83 return;
85 req->wb_flags &= ~PG_BUSY;
86 wake_up(&req->wb_wait);
87 nfs_release_request(req);
90 static __inline__ struct nfs_page *
91 nfs_list_entry(struct list_head *head)
93 return list_entry(head, struct nfs_page, wb_list);
96 static __inline__ struct nfs_page *
97 nfs_inode_wb_entry(struct list_head *head)
99 return list_entry(head, struct nfs_page, wb_hash);
102 #endif /* _LINUX_NFS_PAGE_H */