Updated binary toolchain for kernel 2.4 target (gcc 4.2.4, binutils 2.20.1)
[tomato.git] / tools / brcm / K24 / hndtools-mipsel-uclibc-4.2.4 / include / linux / nfs_page.h
blobf4379a69da2a3a39722a2e249ab866d1e56721b8
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 0
24 struct nfs_page {
25 struct list_head wb_hash, /* Inode */
26 wb_lru, /* superblock lru list */
27 wb_list, /* Defines state of page: */
28 *wb_list_head; /* read/write/commit */
29 struct file *wb_file;
30 struct inode *wb_inode;
31 struct rpc_cred *wb_cred;
32 struct page *wb_page; /* page to read in/write out */
33 wait_queue_head_t wb_wait; /* wait queue */
34 unsigned long wb_timeout; /* when to read/write/commit */
35 unsigned int wb_offset, /* Offset of read/write */
36 wb_bytes, /* Length of request */
37 wb_count; /* reference count */
38 unsigned long wb_flags;
39 struct nfs_writeverf wb_verf; /* Commit cookie */
42 #define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags))
44 extern struct nfs_page *nfs_create_request(struct rpc_cred *, struct inode *,
45 struct page *,
46 unsigned int, unsigned int);
47 extern void nfs_clear_request(struct nfs_page *req);
48 extern void nfs_release_request(struct nfs_page *req);
51 extern void nfs_list_add_request(struct nfs_page *, struct list_head *);
53 extern int nfs_scan_lru(struct list_head *, struct list_head *, int);
54 extern int nfs_scan_lru_timeout(struct list_head *, struct list_head *, int);
55 extern int nfs_scan_list(struct list_head *, struct list_head *,
56 unsigned long, unsigned int);
57 extern int nfs_coalesce_requests(struct list_head *, struct list_head *,
58 unsigned int);
59 extern int nfs_wait_on_request(struct nfs_page *);
61 extern spinlock_t nfs_wreq_lock;
64 * Lock the page of an asynchronous request without incrementing the wb_count
66 static inline int
67 nfs_lock_request_dontget(struct nfs_page *req)
69 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
70 return 0;
71 return 1;
75 * Lock the page of an asynchronous request
77 static inline int
78 nfs_lock_request(struct nfs_page *req)
80 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
81 return 0;
82 req->wb_count++;
83 return 1;
86 static inline void
87 nfs_unlock_request(struct nfs_page *req)
89 if (!NFS_WBACK_BUSY(req)) {
90 printk(KERN_ERR "NFS: Invalid unlock attempted\n");
91 BUG();
93 smp_mb__before_clear_bit();
94 clear_bit(PG_BUSY, &req->wb_flags);
95 smp_mb__after_clear_bit();
96 if (waitqueue_active(&req->wb_wait))
97 wake_up_all(&req->wb_wait);
98 nfs_release_request(req);
102 * nfs_list_remove_request - Remove a request from its wb_list
103 * @req: request
105 static inline void
106 nfs_list_remove_request(struct nfs_page *req)
108 if (list_empty(&req->wb_list))
109 return;
110 if (!NFS_WBACK_BUSY(req)) {
111 printk(KERN_ERR "NFS: unlocked request attempted removed from list!\n");
112 BUG();
114 list_del_init(&req->wb_list);
115 req->wb_list_head = NULL;
118 static inline struct nfs_page *
119 nfs_list_entry(struct list_head *head)
121 return list_entry(head, struct nfs_page, wb_list);
124 static inline struct nfs_page *
125 nfs_inode_wb_entry(struct list_head *head)
127 return list_entry(head, struct nfs_page, wb_hash);
130 static inline void
131 __nfs_add_lru(struct list_head *head, struct nfs_page *req)
133 list_add_tail(&req->wb_lru, head);
136 static inline void
137 __nfs_del_lru(struct nfs_page *req)
139 if (list_empty(&req->wb_lru))
140 return;
141 list_del_init(&req->wb_lru);
144 static inline struct nfs_page *
145 nfs_lru_entry(struct list_head *head)
147 return list_entry(head, struct nfs_page, wb_lru);
150 #endif /* _LINUX_NFS_PAGE_H */