From: David Howells The attached patch makes the kAFS filesystem in fs/afs/ use FS-Cache, and through it any attached caches. The kAFS filesystem will use caching automatically if it's available. Signed-off-by: David Howells Signed-off-by: Andrew Morton --- fs/afs/file.c | 60 +++++++++++++++++++++-------------------------- fs/afs/vnode.c | 2 + 2 files changed, 30 insertions(+), 32 deletions(-) diff -puN fs/afs/file.c~fs-cache-make-kafs-use-fs-cache-12 fs/afs/file.c --- a/fs/afs/file.c~fs-cache-make-kafs-use-fs-cache-12 +++ a/fs/afs/file.c @@ -83,7 +83,7 @@ static int afs_file_mmap(struct file *fi file_accessed(file); vma->vm_ops = &afs_fs_vm_operations; return 0; -} /* end afs_file_mmap() */ +} /*****************************************************************************/ /* @@ -101,8 +101,7 @@ static void afs_file_readpage_read_compl if (!error) SetPageUptodate(page); unlock_page(page); - -} /* end afs_file_readpage_read_complete() */ +} #endif /*****************************************************************************/ @@ -119,8 +118,7 @@ static void afs_file_readpage_write_comp /* note that the page has been written to the cache and can now be * modified */ end_page_fs_misc(page); - -} /* end afs_file_readpage_write_complete() */ +} #endif /*****************************************************************************/ @@ -230,8 +228,7 @@ static int afs_file_readpage(struct file _leave(" = %d", ret); return ret; - -} /* end afs_file_readpage() */ +} /*****************************************************************************/ /* @@ -242,10 +239,6 @@ static int afs_file_readpages(struct fil struct list_head *pages, unsigned nr_pages) { struct afs_vnode *vnode; -#if 0 - struct pagevec lru_pvec; - unsigned page_idx; -#endif int ret = 0; _enter(",{%lu},,%d", mapping->host->i_ino, nr_pages); @@ -290,13 +283,14 @@ static int afs_file_readpages(struct fil _leave(" = %d [netting]", ret); return ret; - -} /* end afs_file_readpages() */ +} #endif /*****************************************************************************/ /* * invalidate part or all of a page + * - release a page and clean up its private data if offset is 0 (indicating + * the entire page) */ static void afs_file_invalidatepage(struct page *page, unsigned long offset) { @@ -305,38 +299,41 @@ static void afs_file_invalidatepage(stru BUG_ON(!PageLocked(page)); if (PagePrivate(page)) { - /* We release buffers only if the entire page is being - * invalidated. - * The get_block cached value has been unconditionally - * invalidated, so real IO is not possible anymore. - */ - if (offset == 0 && !PageWriteback(page)) - page->mapping->a_ops->releasepage(page, 0); + /* we clean up only if the entire page is being invalidated */ + if (offset == 0 && !PageWriteback(page)) { +#ifdef CONFIG_AFS_FSCACHE + wait_on_page_fs_misc(page); + fscache_uncache_page( + AFS_FS_I(page->mapping->host)->cache, page); + ClearPagePrivate(page); +#endif + } } _leave(""); - -} /* end afs_file_invalidatepage() */ +} /*****************************************************************************/ /* - * release a page and cleanup its private data + * release a page and clean up its private state if it's not busy + * - return true if the page can now be released, false if not */ static int afs_file_releasepage(struct page *page, gfp_t gfp_flags) { _enter("{%lu},%x", page->index, gfp_flags); -#ifdef CONFIG_AFS_FSCACHE - wait_on_page_fs_misc(page); + /* deny */ + if (PageFsMisc(page)) { + _leave(" = F"); + return 0; + } + fscache_uncache_page(AFS_FS_I(page->mapping->host)->cache, page); - ClearPagePrivate(page); -#endif /* indicate that the page can be released */ - _leave(" = 1"); + _leave(" = T"); return 1; - -} /* end afs_file_releasepage() */ +} /*****************************************************************************/ /* @@ -348,6 +345,5 @@ static int afs_file_page_mkwrite(struct { wait_on_page_fs_misc(page); return 0; - -} /* end afs_file_page_mkwrite() */ +} #endif diff -puN fs/afs/vnode.c~fs-cache-make-kafs-use-fs-cache-12 fs/afs/vnode.c --- a/fs/afs/vnode.c~fs-cache-make-kafs-use-fs-cache-12 +++ a/fs/afs/vnode.c @@ -508,6 +508,7 @@ static void afs_vnode_cache_mark_pages_c } } /* end afs_vnode_cache_mark_pages_cached() */ +#endif /*****************************************************************************/ /* @@ -517,6 +518,7 @@ static void afs_vnode_cache_mark_pages_c * - the netfs should use this to clean up any markers indicating cached pages * - this is mandatory for any object that may have data */ +#ifdef CONFIG_AFS_FSCACHE static void afs_vnode_cache_now_uncached(void *cookie_netfs_data) { struct afs_vnode *vnode = cookie_netfs_data; _