linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: akpm@osdl.org, linux-fsdevel@vger.kernel.org, torvalds@osdl.org
Subject: Re: fscache review comments, part 1
Date: Mon, 09 Oct 2006 14:46:40 +0100	[thread overview]
Message-ID: <12599.1160401600@redhat.com> (raw)
In-Reply-To: <20060928164529.GA3497@infradead.org>

Christoph Hellwig <hch@infradead.org> wrote:

> 05-release-page.diff:
> 	ACK, though I'd wish someone could come up with nicer names for
> 	read_cache_pages_invalidate_page(s).

They could always be nested:-).  That way they don't pollute the namespace.
This is one of the gcc extensions.  If you do nm on the output, you see the
nested function appear like this if not inlined:

	000000000000058f t invalidate_page.17245

That above derives from this:


int read_cache_pages(struct address_space *mapping, struct list_head *pages,
			int (*filler)(void *, struct page *), void *data)
{
	struct page *page;
	struct pagevec lru_pvec;
	int ret = 0;

	/* see if a page needs releasing upon read_cache_pages() failure */
	void invalidate_page(struct address_space *mapping, struct page *page)
	{
		if (PagePrivate(page)) {
			if (TestSetPageLocked(page))
				BUG();
			page->mapping = mapping;
			do_invalidatepage(page, 0);
			page->mapping = NULL;
			unlock_page(page);
		}
		page_cache_release(page);
	}

	/* release a list of pages, invalidating them first if need be */
	void invalidate_pages(struct address_space *mapping,
			      struct list_head *pages)
	{
		struct page *victim;

		while (!list_empty(pages)) {
			victim = list_to_page(pages);
			list_del(&victim->lru);
			invalidate_page(mapping, victim);
		}
	}

	pagevec_init(&lru_pvec, 0);

	while (!list_empty(pages)) {
		page = list_to_page(pages);
		list_del(&page->lru);
		if (add_to_page_cache(page, mapping, page->index, GFP_KERNEL)) {
			invalidate_page(mapping, page);
			continue;
		}
		ret = filler(data, page);
		if (!pagevec_add(&lru_pvec, page))
			__pagevec_lru_add(&lru_pvec);
		if (ret) {
			invalidate_pages(mapping, pages);
			break;
		}
	}
	pagevec_lru_add(&lru_pvec);
	return ret;
}

David

  parent reply	other threads:[~2006-10-09 13:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-28 16:45 fscache review comments, part 1 Christoph Hellwig
2006-09-28 17:30 ` Andreas Dilger
2006-09-29  0:02   ` Christoph Hellwig
2006-09-29  1:51     ` Timothy Shimmin
2006-09-29  8:38 ` David Howells
2006-10-02 13:40 ` David Howells
2006-10-02 17:39   ` Andrew Morton
2006-10-02 21:41     ` Christoph Hellwig
2006-10-04 13:44 ` Al Viro
2006-10-04 14:18 ` 64-bit inode number issues David Howells
2006-10-07 21:01   ` Christoph Hellwig
2006-10-09  9:01     ` David Chinner
2006-10-09 11:32     ` David Howells
2006-10-09 14:12       ` Arjan van de Ven
2006-10-09 23:53       ` David Chinner
2006-10-12 18:32     ` Benjamin LaHaise
2006-10-17  6:02       ` Chris Wedgwood
2006-10-09  7:58   ` David Howells
2006-10-04 14:23 ` David Howells
2006-10-08  2:00   ` Theodore Tso
2006-10-08 16:02     ` Alexander Viro
2006-10-09 13:46 ` David Howells [this message]
2006-10-10 13:31   ` fscache review comments, part 1 Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12599.1160401600@redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).