1 /*
2 * linux/include/linux/nfs_page.h
3 *
4 * Copyright (C) 2000 Trond Myklebust
5 *
6 * NFS page cache wrapper.
7 */
8
9 #ifndef _LINUX_NFS_PAGE_H
10 #define _LINUX_NFS_PAGE_H
11
12
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>
18
19 /*
20 * Valid flags for a dirty buffer
21 */
22 #define PG_BUSY 0
23
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 unsigned long wb_flags;
38 struct nfs_writeverf wb_verf; /* Commit cookie */
39 };
40
41 #define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags))
42
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);
49
50
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);
54
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);
63
64 extern spinlock_t nfs_wreq_lock;
65
66 /*
67 * Lock the page of an asynchronous request
68 */
69 static __inline__ int
70 nfs_lock_request(struct nfs_page *req)
71 {
72 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
73 return 0;
74 req->wb_count++;
75 return 1;
76 }
77
78 static __inline__ void
79 nfs_unlock_request(struct nfs_page *req)
80 {
81 if (!NFS_WBACK_BUSY(req)) {
82 printk(KERN_ERR "NFS: Invalid unlock attempted\n");
83 BUG();
84 }
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);
91 }
92
93 static __inline__ struct nfs_page *
94 nfs_list_entry(struct list_head *head)
95 {
96 return list_entry(head, struct nfs_page, wb_list);
97 }
98
99 static __inline__ struct nfs_page *
100 nfs_inode_wb_entry(struct list_head *head)
101 {
102 return list_entry(head, struct nfs_page, wb_hash);
103 }
104
105 #endif /* _LINUX_NFS_PAGE_H */
106
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.