Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 254706
b: refs/heads/master
c: c902ce1
h: refs/heads/master
v: v3
  • Loading branch information
David Howells authored and Linus Torvalds committed Jul 7, 2011
1 parent 56720d3 commit bb95aa8
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 075d9db13183c102770dc6cefabfee1b832f9614
refs/heads/master: c902ce1bfb40d8b049bd2319b388b4b68b04bc27
16 changes: 16 additions & 0 deletions trunk/Documentation/filesystems/caching/netfs-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,22 @@ storage request to complete, or it may attempt to cancel the storage request -
in which case the page will not be stored in the cache this time.


BULK INODE PAGE UNCACHE
-----------------------

A convenience routine is provided to perform an uncache on all the pages
attached to an inode. This assumes that the pages on the inode correspond on a
1:1 basis with the pages in the cache.

void fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
struct inode *inode);

This takes the netfs cookie that the pages were cached with and the inode that
the pages are attached to. This function will wait for pages to finish being
written to the cache and for the cache to finish with the page generally. No
error is returned.


==========================
INDEX AND DATA FILE UPDATE
==========================
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/cifs/fscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static void cifs_fscache_disable_inode_cookie(struct inode *inode)

if (cifsi->fscache) {
cFYI(1, "%s: (0x%p)", __func__, cifsi->fscache);
fscache_uncache_all_inode_pages(cifsi->fscache, inode);
fscache_relinquish_cookie(cifsi->fscache, 1);
cifsi->fscache = NULL;
}
Expand Down
44 changes: 44 additions & 0 deletions trunk/fs/fscache/page.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,3 +954,47 @@ void fscache_mark_pages_cached(struct fscache_retrieval *op,
pagevec_reinit(pagevec);
}
EXPORT_SYMBOL(fscache_mark_pages_cached);

/*
* Uncache all the pages in an inode that are marked PG_fscache, assuming them
* to be associated with the given cookie.
*/
void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
struct inode *inode)
{
struct address_space *mapping = inode->i_mapping;
struct pagevec pvec;
pgoff_t next;
int i;

_enter("%p,%p", cookie, inode);

if (!mapping || mapping->nrpages == 0) {
_leave(" [no pages]");
return;
}

pagevec_init(&pvec, 0);
next = 0;
while (next <= (loff_t)-1 &&
pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)
) {
for (i = 0; i < pagevec_count(&pvec); i++) {
struct page *page = pvec.pages[i];
pgoff_t page_index = page->index;

ASSERTCMP(page_index, >=, next);
next = page_index + 1;

if (PageFsCache(page)) {
__fscache_wait_on_page_write(cookie, page);
__fscache_uncache_page(cookie, page);
}
}
pagevec_release(&pvec);
cond_resched();
}

_leave("");
}
EXPORT_SYMBOL(__fscache_uncache_all_inode_pages);
8 changes: 3 additions & 5 deletions trunk/fs/nfs/fscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,10 @@ static void nfs_fscache_disable_inode_cookie(struct inode *inode)
dfprintk(FSCACHE,
"NFS: nfsi 0x%p turning cache off\n", NFS_I(inode));

/* Need to invalidate any mapped pages that were read in before
* turning off the cache.
/* Need to uncache any pages attached to this inode that
* fscache knows about before turning off the cache.
*/
if (inode->i_mapping && inode->i_mapping->nrpages)
invalidate_inode_pages2(inode->i_mapping);

fscache_uncache_all_inode_pages(NFS_I(inode)->fscache, inode);
nfs_fscache_zap_inode_cookie(inode);
}
}
Expand Down
21 changes: 21 additions & 0 deletions trunk/include/linux/fscache.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *);
extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *);
extern bool __fscache_maybe_release_page(struct fscache_cookie *, struct page *,
gfp_t);
extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *,
struct inode *);

/**
* fscache_register_netfs - Register a filesystem as desiring caching services
Expand Down Expand Up @@ -643,4 +645,23 @@ bool fscache_maybe_release_page(struct fscache_cookie *cookie,
return false;
}

/**
* fscache_uncache_all_inode_pages - Uncache all an inode's pages
* @cookie: The cookie representing the inode's cache object.
* @inode: The inode to uncache pages from.
*
* Uncache all the pages in an inode that are marked PG_fscache, assuming them
* to be associated with the given cookie.
*
* This function may sleep. It will wait for pages that are being written out
* and will wait whilst the PG_fscache mark is removed by the cache.
*/
static inline
void fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
struct inode *inode)
{
if (fscache_cookie_valid(cookie))
__fscache_uncache_all_inode_pages(cookie, inode);
}

#endif /* _LINUX_FSCACHE_H */

0 comments on commit bb95aa8

Please sign in to comment.