Re: [RFC PATCH 54/61] afs: Wait on PG_fscache before modifying/releasing a page

From: David Howells
Date: Fri May 08 2020 - 10:40:01 EST


David Howells <dhowells@xxxxxxxxxx> wrote:

> ITER_MAPPING relies on the mapping to maintain the pointers to the pages so
> that it can find them rather than being like ITER_BVEC where there's a
> separate list.
>
> Truncate removes the pages from the mapping - at which point ITER_MAPPING can
> no longer find them.

It looks like ITER_MAPPING is fine with truncate, provided the invalidation
waits for the iterator to complete first:

int truncate_inode_page(struct address_space *mapping, struct page *page)
{
VM_BUG_ON_PAGE(PageTail(page), page);

if (page->mapping != mapping)
return -EIO;

truncate_cleanup_page(mapping, page);
delete_from_page_cache(page);
return 0;
}

In which case, ->invalidatepage() needs to wait for PG_fscache.

Similarly, it looks like ->releasepage() is fine, provided it waits for
PG_fscache also.

If I have to use ITER_BVEC, what's the advisability of using vmalloc() to
allocate the bio_vec array for a transient op? Such an array can reference up
to 1MiB on a 64-bit machine with 4KiB non-compound pages if it only allocates
up to a single page. I'm wondering what the teardown cost is, though, if all
the corresponding PTEs have to be erased from all CPUs.

David