From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Howells Subject: Re: fscache review comments, part 1 Date: Mon, 09 Oct 2006 14:46:40 +0100 Message-ID: <12599.1160401600@redhat.com> References: <20060928164529.GA3497@infradead.org> Cc: akpm@osdl.org, linux-fsdevel@vger.kernel.org, torvalds@osdl.org Return-path: Received: from mx1.redhat.com ([66.187.233.31]:20400 "EHLO mx1.redhat.com") by vger.kernel.org with ESMTP id S932819AbWJINqw (ORCPT ); Mon, 9 Oct 2006 09:46:52 -0400 In-Reply-To: <20060928164529.GA3497@infradead.org> To: Christoph Hellwig Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Christoph Hellwig 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