aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/nfs_page.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/nfs_page.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/nfs_page.h')
-rw-r--r--include/linux/nfs_page.h151
1 files changed, 151 insertions, 0 deletions
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
new file mode 100644
index 000000000000..39e4895bcdb4
--- /dev/null
+++ b/include/linux/nfs_page.h
@@ -0,0 +1,151 @@
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/pagemap.h>
15#include <linux/wait.h>
16#include <linux/nfs_fs_sb.h>
17#include <linux/sunrpc/auth.h>
18#include <linux/nfs_xdr.h>
19
20#include <asm/atomic.h>
21
22/*
23 * Valid flags for a dirty buffer
24 */
25#define PG_BUSY 0
26#define PG_NEED_COMMIT 1
27#define PG_NEED_RESCHED 2
28
29struct nfs_page {
30 struct list_head wb_list, /* Defines state of page: */
31 *wb_list_head; /* read/write/commit */
32 struct page *wb_page; /* page to read in/write out */
33 struct nfs_open_context *wb_context; /* File state context info */
34 atomic_t wb_complete; /* i/os we're waiting for */
35 unsigned long wb_index; /* Offset >> PAGE_CACHE_SHIFT */
36 unsigned int wb_offset, /* Offset & ~PAGE_CACHE_MASK */
37 wb_pgbase, /* Start of page data */
38 wb_bytes; /* Length of request */
39 atomic_t wb_count; /* reference count */
40 unsigned long wb_flags;
41 struct nfs_writeverf wb_verf; /* Commit cookie */
42};
43
44#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags))
45#define NFS_NEED_COMMIT(req) (test_bit(PG_NEED_COMMIT,&(req)->wb_flags))
46#define NFS_NEED_RESCHED(req) (test_bit(PG_NEED_RESCHED,&(req)->wb_flags))
47
48extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx,
49 struct inode *inode,
50 struct page *page,
51 unsigned int offset,
52 unsigned int count);
53extern void nfs_clear_request(struct nfs_page *req);
54extern void nfs_release_request(struct nfs_page *req);
55
56
57extern void nfs_list_add_request(struct nfs_page *, struct list_head *);
58
59extern int nfs_scan_list(struct list_head *, struct list_head *,
60 unsigned long, unsigned int);
61extern int nfs_coalesce_requests(struct list_head *, struct list_head *,
62 unsigned int);
63extern int nfs_wait_on_request(struct nfs_page *);
64extern void nfs_unlock_request(struct nfs_page *req);
65
66/*
67 * Lock the page of an asynchronous request without incrementing the wb_count
68 */
69static inline int
70nfs_lock_request_dontget(struct nfs_page *req)
71{
72 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
73 return 0;
74 return 1;
75}
76
77/*
78 * Lock the page of an asynchronous request
79 */
80static inline int
81nfs_lock_request(struct nfs_page *req)
82{
83 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
84 return 0;
85 atomic_inc(&req->wb_count);
86 return 1;
87}
88
89
90/**
91 * nfs_list_remove_request - Remove a request from its wb_list
92 * @req: request
93 */
94static inline void
95nfs_list_remove_request(struct nfs_page *req)
96{
97 if (list_empty(&req->wb_list))
98 return;
99 if (!NFS_WBACK_BUSY(req)) {
100 printk(KERN_ERR "NFS: unlocked request attempted removed from list!\n");
101 BUG();
102 }
103 list_del_init(&req->wb_list);
104 req->wb_list_head = NULL;
105}
106
107static inline int
108nfs_defer_commit(struct nfs_page *req)
109{
110 if (test_and_set_bit(PG_NEED_COMMIT, &req->wb_flags))
111 return 0;
112 return 1;
113}
114
115static inline void
116nfs_clear_commit(struct nfs_page *req)
117{
118 smp_mb__before_clear_bit();
119 clear_bit(PG_NEED_COMMIT, &req->wb_flags);
120 smp_mb__after_clear_bit();
121}
122
123static inline int
124nfs_defer_reschedule(struct nfs_page *req)
125{
126 if (test_and_set_bit(PG_NEED_RESCHED, &req->wb_flags))
127 return 0;
128 return 1;
129}
130
131static inline void
132nfs_clear_reschedule(struct nfs_page *req)
133{
134 smp_mb__before_clear_bit();
135 clear_bit(PG_NEED_RESCHED, &req->wb_flags);
136 smp_mb__after_clear_bit();
137}
138
139static inline struct nfs_page *
140nfs_list_entry(struct list_head *head)
141{
142 return list_entry(head, struct nfs_page, wb_list);
143}
144
145static inline
146loff_t req_offset(struct nfs_page *req)
147{
148 return (((loff_t)req->wb_index) << PAGE_CACHE_SHIFT) + req->wb_offset;
149}
150
151#endif /* _LINUX_NFS_PAGE_H */