Re: FS-Cache: Add a helper to bulk uncache pages on an inode

From: Geert Uytterhoeven
Date: Tue Jul 12 2011 - 15:26:50 EST


On Thu, Jul 7, 2011 at 22:59, Linux Kernel Mailing List
<linux-kernel@xxxxxxxxxxxxxxx> wrote:
> Â ÂFS-Cache: Add a helper to bulk uncache pages on an inode
>
> Â ÂAdd an FS-Cache helper to bulk uncache pages on an inode. ÂThis will
> Â Âonly work for the circumstance where the pages in the cache correspond
> Â Â1:1 with the pages attached to an inode's page cache.
>
> Â ÂThis is required for CIFS and NFS: When disabling inode cookie, we were
> Â Âreturning the cookie and setting cifsi->fscache to NULL but failed to
> Â Âinvalidate any previously mapped pages. ÂThis resulted in "Bad page
> Â Âstate" errors and manifested in other kind of errors when running
> Â Âfsstress. ÂFix it by uncaching mapped pages when we disable the inode
> Â Âcookie.
>
> Â ÂThis patch should fix the following oops and "Bad page state" errors
> Â Âseen during fsstress testing.

> --- a/fs/fscache/page.c
> +++ b/fs/fscache/page.c
> @@ -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 &&

On m68k, I get:

fs/fscache/page.c: In function â__fscache_uncache_all_inode_pagesâ:
fs/fscache/page.c:979: warning: comparison is always false due to
limited range of data type

next is pgoff_t, which is defined to unsigned long by default, unless
overridden by the arch
(hmm, no single arch seems to do that?).
loff_t is (signed) long long.

> + Â Â Â Â Â Â Â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("");
> +}

Gr{oetje,eeting}s,

            Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
             Â Â -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/