aboutsummaryrefslogtreecommitdiffstats
path: root/fs/afs/file.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-05-10 07:08:37 -0400
committerPaul Mackerras <paulus@samba.org>2007-05-10 07:08:37 -0400
commit2ecf042ef530dd0943e41d84b6344f507941af3e (patch)
tree73100361dd74e3f80f14c7c81ba4675948983f44 /fs/afs/file.c
parent32a56ebb24f23da1bbaf24292acf85b6c04526ab (diff)
parentde5603748af8bf7deac403e6ba92887f8d18e812 (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'fs/afs/file.c')
-rw-r--r--fs/afs/file.c107
1 files changed, 52 insertions, 55 deletions
diff --git a/fs/afs/file.c b/fs/afs/file.c
index ae256498f4f7..3e25795e5a42 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -15,32 +15,43 @@
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/pagemap.h> 17#include <linux/pagemap.h>
18#include <linux/writeback.h>
18#include "internal.h" 19#include "internal.h"
19 20
20static int afs_file_readpage(struct file *file, struct page *page); 21static int afs_readpage(struct file *file, struct page *page);
21static void afs_file_invalidatepage(struct page *page, unsigned long offset); 22static void afs_invalidatepage(struct page *page, unsigned long offset);
22static int afs_file_releasepage(struct page *page, gfp_t gfp_flags); 23static int afs_releasepage(struct page *page, gfp_t gfp_flags);
24static int afs_launder_page(struct page *page);
23 25
24const struct file_operations afs_file_operations = { 26const struct file_operations afs_file_operations = {
25 .open = afs_open, 27 .open = afs_open,
26 .release = afs_release, 28 .release = afs_release,
27 .llseek = generic_file_llseek, 29 .llseek = generic_file_llseek,
28 .read = do_sync_read, 30 .read = do_sync_read,
31 .write = do_sync_write,
29 .aio_read = generic_file_aio_read, 32 .aio_read = generic_file_aio_read,
33 .aio_write = afs_file_write,
30 .mmap = generic_file_readonly_mmap, 34 .mmap = generic_file_readonly_mmap,
31 .sendfile = generic_file_sendfile, 35 .sendfile = generic_file_sendfile,
36 .fsync = afs_fsync,
32}; 37};
33 38
34const struct inode_operations afs_file_inode_operations = { 39const struct inode_operations afs_file_inode_operations = {
35 .getattr = afs_inode_getattr, 40 .getattr = afs_getattr,
41 .setattr = afs_setattr,
36 .permission = afs_permission, 42 .permission = afs_permission,
37}; 43};
38 44
39const struct address_space_operations afs_fs_aops = { 45const struct address_space_operations afs_fs_aops = {
40 .readpage = afs_file_readpage, 46 .readpage = afs_readpage,
41 .set_page_dirty = __set_page_dirty_nobuffers, 47 .set_page_dirty = afs_set_page_dirty,
42 .releasepage = afs_file_releasepage, 48 .launder_page = afs_launder_page,
43 .invalidatepage = afs_file_invalidatepage, 49 .releasepage = afs_releasepage,
50 .invalidatepage = afs_invalidatepage,
51 .prepare_write = afs_prepare_write,
52 .commit_write = afs_commit_write,
53 .writepage = afs_writepage,
54 .writepages = afs_writepages,
44}; 55};
45 56
46/* 57/*
@@ -52,7 +63,7 @@ int afs_open(struct inode *inode, struct file *file)
52 struct key *key; 63 struct key *key;
53 int ret; 64 int ret;
54 65
55 _enter("{%x:%x},", vnode->fid.vid, vnode->fid.vnode); 66 _enter("{%x:%u},", vnode->fid.vid, vnode->fid.vnode);
56 67
57 key = afs_request_key(vnode->volume->cell); 68 key = afs_request_key(vnode->volume->cell);
58 if (IS_ERR(key)) { 69 if (IS_ERR(key)) {
@@ -78,7 +89,7 @@ int afs_release(struct inode *inode, struct file *file)
78{ 89{
79 struct afs_vnode *vnode = AFS_FS_I(inode); 90 struct afs_vnode *vnode = AFS_FS_I(inode);
80 91
81 _enter("{%x:%x},", vnode->fid.vid, vnode->fid.vnode); 92 _enter("{%x:%u},", vnode->fid.vid, vnode->fid.vnode);
82 93
83 key_put(file->private_data); 94 key_put(file->private_data);
84 _leave(" = 0"); 95 _leave(" = 0");
@@ -89,10 +100,10 @@ int afs_release(struct inode *inode, struct file *file)
89 * deal with notification that a page was read from the cache 100 * deal with notification that a page was read from the cache
90 */ 101 */
91#ifdef AFS_CACHING_SUPPORT 102#ifdef AFS_CACHING_SUPPORT
92static void afs_file_readpage_read_complete(void *cookie_data, 103static void afs_readpage_read_complete(void *cookie_data,
93 struct page *page, 104 struct page *page,
94 void *data, 105 void *data,
95 int error) 106 int error)
96{ 107{
97 _enter("%p,%p,%p,%d", cookie_data, page, data, error); 108 _enter("%p,%p,%p,%d", cookie_data, page, data, error);
98 109
@@ -109,10 +120,10 @@ static void afs_file_readpage_read_complete(void *cookie_data,
109 * deal with notification that a page was written to the cache 120 * deal with notification that a page was written to the cache
110 */ 121 */
111#ifdef AFS_CACHING_SUPPORT 122#ifdef AFS_CACHING_SUPPORT
112static void afs_file_readpage_write_complete(void *cookie_data, 123static void afs_readpage_write_complete(void *cookie_data,
113 struct page *page, 124 struct page *page,
114 void *data, 125 void *data,
115 int error) 126 int error)
116{ 127{
117 _enter("%p,%p,%p,%d", cookie_data, page, data, error); 128 _enter("%p,%p,%p,%d", cookie_data, page, data, error);
118 129
@@ -121,9 +132,9 @@ static void afs_file_readpage_write_complete(void *cookie_data,
121#endif 132#endif
122 133
123/* 134/*
124 * AFS read page from file (or symlink) 135 * AFS read page from file, directory or symlink
125 */ 136 */
126static int afs_file_readpage(struct file *file, struct page *page) 137static int afs_readpage(struct file *file, struct page *page)
127{ 138{
128 struct afs_vnode *vnode; 139 struct afs_vnode *vnode;
129 struct inode *inode; 140 struct inode *inode;
@@ -219,39 +230,17 @@ error:
219} 230}
220 231
221/* 232/*
222 * get a page cookie for the specified page
223 */
224#ifdef AFS_CACHING_SUPPORT
225int afs_cache_get_page_cookie(struct page *page,
226 struct cachefs_page **_page_cookie)
227{
228 int ret;
229
230 _enter("");
231 ret = cachefs_page_get_private(page,_page_cookie, GFP_NOIO);
232
233 _leave(" = %d", ret);
234 return ret;
235}
236#endif
237
238/*
239 * invalidate part or all of a page 233 * invalidate part or all of a page
240 */ 234 */
241static void afs_file_invalidatepage(struct page *page, unsigned long offset) 235static void afs_invalidatepage(struct page *page, unsigned long offset)
242{ 236{
243 int ret = 1; 237 int ret = 1;
244 238
245 _enter("{%lu},%lu", page->index, offset); 239 kenter("{%lu},%lu", page->index, offset);
246 240
247 BUG_ON(!PageLocked(page)); 241 BUG_ON(!PageLocked(page));
248 242
249 if (PagePrivate(page)) { 243 if (PagePrivate(page)) {
250#ifdef AFS_CACHING_SUPPORT
251 struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
252 cachefs_uncache_page(vnode->cache,page);
253#endif
254
255 /* We release buffers only if the entire page is being 244 /* We release buffers only if the entire page is being
256 * invalidated. 245 * invalidated.
257 * The get_block cached value has been unconditionally 246 * The get_block cached value has been unconditionally
@@ -272,25 +261,33 @@ static void afs_file_invalidatepage(struct page *page, unsigned long offset)
272} 261}
273 262
274/* 263/*
264 * write back a dirty page
265 */
266static int afs_launder_page(struct page *page)
267{
268 _enter("{%lu}", page->index);
269
270 return 0;
271}
272
273/*
275 * release a page and cleanup its private data 274 * release a page and cleanup its private data
276 */ 275 */
277static int afs_file_releasepage(struct page *page, gfp_t gfp_flags) 276static int afs_releasepage(struct page *page, gfp_t gfp_flags)
278{ 277{
279 struct cachefs_page *pageio; 278 struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
279 struct afs_writeback *wb;
280 280
281 _enter("{%lu},%x", page->index, gfp_flags); 281 _enter("{{%x:%u}[%lu],%lx},%x",
282 vnode->fid.vid, vnode->fid.vnode, page->index, page->flags,
283 gfp_flags);
282 284
283 if (PagePrivate(page)) { 285 if (PagePrivate(page)) {
284#ifdef AFS_CACHING_SUPPORT 286 wb = (struct afs_writeback *) page_private(page);
285 struct afs_vnode *vnode = AFS_FS_I(page->mapping->host); 287 ASSERT(wb != NULL);
286 cachefs_uncache_page(vnode->cache, page);
287#endif
288
289 pageio = (struct cachefs_page *) page_private(page);
290 set_page_private(page, 0); 288 set_page_private(page, 0);
291 ClearPagePrivate(page); 289 ClearPagePrivate(page);
292 290 afs_put_writeback(wb);
293 kfree(pageio);
294 } 291 }
295 292
296 _leave(" = 0"); 293 _leave(" = 0");