- Kai Germaschewski: ymfpci cleanups and resource leak fixes
[davej-history.git] / include / linux / nfs_page.h
blob2f37a4b1949138c8328746a1f0f904551e7dc3d8
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_list, /* Defines state of page: */
27 *wb_list_head; /* read/write/commit */
28 struct file *wb_file;
29 struct inode *wb_inode;
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) (test_bit(PG_BUSY,&(req)->wb_flags))
43 extern struct nfs_page *nfs_create_request(struct file *file,
44 struct inode *inode,
45 struct page *page,
46 unsigned int offset,
47 unsigned int count);
48 extern void nfs_release_request(struct nfs_page *req);
51 extern void nfs_list_add_request(struct nfs_page *req,
52 struct list_head *head);
53 extern void nfs_list_remove_request(struct nfs_page *req);
55 extern int nfs_scan_list_timeout(struct list_head *head,
56 struct list_head *dst,
57 struct inode *inode);
58 extern int nfs_scan_list(struct list_head *src, struct list_head *dst,
59 struct file *file, unsigned long idx_start,
60 unsigned int npages);
61 extern int nfs_coalesce_requests(struct list_head *src, struct list_head *dst,
62 unsigned int maxpages);
64 extern spinlock_t nfs_wreq_lock;
67 * Lock the page of an asynchronous request
69 static __inline__ int
70 nfs_lock_request(struct nfs_page *req)
72 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
73 return 0;
74 req->wb_count++;
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 BUG();
85 smp_mb__before_clear_bit();
86 clear_bit(PG_BUSY, &req->wb_flags);
87 smp_mb__after_clear_bit();
88 if (waitqueue_active(&req->wb_wait))
89 wake_up(&req->wb_wait);
90 nfs_release_request(req);
93 static __inline__ struct nfs_page *
94 nfs_list_entry(struct list_head *head)
96 return list_entry(head, struct nfs_page, wb_list);
99 static __inline__ struct nfs_page *
100 nfs_inode_wb_entry(struct list_head *head)
102 return list_entry(head, struct nfs_page, wb_hash);
105 #endif /* _LINUX_NFS_PAGE_H */