2 * linux/include/linux/nfs_page.h
4 * Copyright (C) 2000 Trond Myklebust
6 * NFS page cache wrapper.
9 #ifndef _LINUX_NFS_PAGE_H
10 #define _LINUX_NFS_PAGE_H
13 #include <linux/list.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
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 */
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 *,
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 struct file *, unsigned long, unsigned int);
57 extern int nfs_coalesce_requests(struct list_head *, struct list_head *,
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
67 nfs_lock_request_dontget(struct nfs_page *req)
69 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
75 * Lock the page of an asynchronous request
78 nfs_lock_request(struct nfs_page *req)
80 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
87 nfs_unlock_request(struct nfs_page *req)
89 if (!NFS_WBACK_BUSY(req)) {
90 printk(KERN_ERR "NFS: Invalid unlock attempted\n");
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
106 nfs_list_remove_request(struct nfs_page *req)
108 if (list_empty(&req->wb_list))
110 if (!NFS_WBACK_BUSY(req)) {
111 printk(KERN_ERR "NFS: unlocked request attempted removed from list!\n");
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);
131 __nfs_add_lru(struct list_head *head, struct nfs_page *req)
133 list_add_tail(&req->wb_lru, head);
137 __nfs_del_lru(struct nfs_page *req)
139 if (list_empty(&req->wb_lru))
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 */