12 #include <linux/kernel.h>
13 #include <linux/module.h>
22 static void afs_invalidatepage(
struct page *
page,
unsigned long offset);
23 static int afs_releasepage(
struct page *
page,
gfp_t gfp_flags);
24 static int afs_launder_page(
struct page *
page);
51 .readpage = afs_readpage,
52 .readpages = afs_readpages,
54 .launder_page = afs_launder_page,
55 .releasepage = afs_releasepage,
56 .invalidatepage = afs_invalidatepage,
68 struct afs_vnode *vnode = AFS_FS_I(inode);
76 _leave(
" = %ld [key]", PTR_ERR(key));
82 _leave(
" = %d [val]", ret);
96 struct afs_vnode *vnode = AFS_FS_I(inode);
105 #ifdef CONFIG_AFS_FSCACHE
109 static void afs_file_readpage_read_complete(
struct page *
page,
113 _enter(
"%p,%p,%d", page, data, error);
118 SetPageUptodate(page);
129 struct afs_vnode *vnode = AFS_FS_I(inode);
137 BUG_ON(!PageLocked(page));
144 #ifdef CONFIG_AFS_FSCACHE
145 ret = fscache_read_or_alloc_page(vnode->cache,
147 afs_file_readpage_read_complete,
160 _debug(
"cache said ENODATA");
165 _debug(
"cache said ENOBUFS");
176 _debug(
"got NOENT from server"
177 " - marking file deleted and stale");
182 #ifdef CONFIG_AFS_FSCACHE
183 fscache_uncache_page(vnode->cache, page);
189 SetPageUptodate(page);
192 #ifdef CONFIG_AFS_FSCACHE
194 fscache_write_page(vnode->cache, page,
GFP_KERNEL) != 0) {
195 fscache_uncache_page(vnode->cache, page);
216 static int afs_readpage(
struct file *
file,
struct page *page)
249 key_serial(key), mapping->
host->i_ino, nr_pages);
253 vnode = AFS_FS_I(mapping->
host);
260 #ifdef CONFIG_AFS_FSCACHE
261 ret = fscache_read_or_alloc_pages(vnode->cache,
265 afs_file_readpage_read_complete,
267 mapping_gfp_mask(mapping));
275 BUG_ON(!list_empty(pages));
277 _leave(
" = 0 [reading all]");
294 _leave(
" = %d [netting]", ret);
301 static int afs_launder_page(
struct page *page)
313 static void afs_invalidatepage(
struct page *page,
unsigned long offset)
319 BUG_ON(!PageLocked(page));
323 #ifdef CONFIG_AFS_FSCACHE
326 fscache_wait_on_page_write(vnode->cache, page);
327 fscache_uncache_page(vnode->cache, page);
331 if (PagePrivate(page)) {
332 if (wb && !PageWriteback(page)) {
333 set_page_private(page, 0);
337 if (!page_private(page))
338 ClearPagePrivate(page);
349 static int afs_releasepage(
struct page *page,
gfp_t gfp_flags)
354 _enter(
"{{%x:%u}[%lu],%lx},%x",
360 #ifdef CONFIG_AFS_FSCACHE
361 if (!fscache_maybe_release_page(vnode->cache, page, gfp_flags)) {
362 _leave(
" = F [cache busy]");
367 if (PagePrivate(page)) {
369 set_page_private(page, 0);
372 ClearPagePrivate(page);