linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pagevec_lookup_tag() and pagevec_release() substitutes and an OOM
@ 2006-02-08  0:29 Martin Jambor
  2006-02-08  5:01 ` Martin Jambor
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Jambor @ 2006-02-08  0:29 UTC (permalink / raw)
  To: Linux FS Development List

Hi all,

I am implementing aops->writepages of a filesystem and for various
reasons I cannot use mpage_writepages. On the other hand, I would like
to do be able to get a vector of pages and process it page by page (in
my way) just like mpage_writepages gets pages.

However, pagevec functions are not exported (I don't understand why)
and so I cannot use them directly by my module but rather I had to do
a bit of cutting and pasting from 2.6.14 kernel source :-(

So my approach was to use a plain array of pointers to pages and
instead of calling

unsigned pagevec_lookup_tag(struct pagevec *pvec, struct address_space *mapping,
		pgoff_t *index, int tag, unsigned nr_pages)

I use my own function which is basically copied find_get_pages_tag()
(which also isn't exported):

static unsigned my_find_get_pages_tag(struct address_space *mapping,
				   pgoff_t *index, int tag, unsigned int nr_pages,
                                   struct page **pages)
{
	unsigned int i;
	unsigned int ret;

	read_lock_irq(&mapping->tree_lock);
	ret = radix_tree_gang_lookup_tag(&mapping->page_tree,
				(void **)pages, *index, nr_pages, tag);
	for (i = 0; i < ret; i++)
		page_cache_get(pages[i]);
	if (ret)
		*index = pages[ret - 1]->index + 1;
	read_unlock_irq(&mapping->tree_lock);
	return ret;
}

instead of pagevec_release() I use a much simpler function:

static void release_pagearray(struct page **pages, unsigned int nr_pages)
{
	unsigned i;
	
	for (i = 0; i < nr_pages; i++)
		page_cache_release(pages[i]);
}

Everything seems to be working well except that I get an OOM. The free
and vmstat utilities show that "cache" is the only thing that is
getting unreasonably bigger. There are many reasons why I believe the
page cache pages are still somehow pinned down by my code and cannot
be freed when I am done with them. I must admit that I find it quite
difficult to uderstand the pagevec source and if someone knew what I
am doing wrong, I would be very grateful.

(Yes, I have carefully checked several times very carefully that I
set&clear writeback as indicated in Documentation/filesystmes/Locking
and how it is done by mpage_writepages.)

Thank you very much in advance for any comment.

Martin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-02-08 14:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-08  0:29 pagevec_lookup_tag() and pagevec_release() substitutes and an OOM Martin Jambor
2006-02-08  5:01 ` Martin Jambor
2006-02-08  7:48   ` Andrew Morton
2006-02-08 14:55     ` Dave Kleikamp

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).