Re: [PATCH 5/9] writeback: introduce the pageout work

From: Andrew Morton
Date: Thu Mar 01 2012 - 14:46:33 EST


On Thu, 1 Mar 2012 19:41:51 +0800
Fengguang Wu <fengguang.wu@xxxxxxxxx> wrote:

> > I think using get_page() might be a good way to go. Naive implementation:
> > If we need to write a page from kswapd, we do get_page(), attach page to
> > wb_writeback_work and push it to flusher thread to deal with it.
> > Flusher thread sees the work, takes a page lock, verifies the page is still
> > attached to some inode & dirty (it could have been truncated / cleaned by
> > someone else) and if yes, it submits page for IO (possibly with some
> > writearound). This scheme won't have problems with iput() and won't have
> > problems with umount. Also we guarantee some progress - either flusher
> > thread does it, or some else must have done the work before flusher thread
> > got to it.
>
> I like this idea.
>
> get_page() looks the perfect solution to verify if the struct inode
> pointer (w/o igrab) is still live and valid.
>
> [...upon rethinking...] Oh but still we need to lock some page to pin
> the inode during the writeout. Then there is the dilemma: if the page
> is locked, we effectively keep it from being written out...

No, all you need to do is to structure the code so that after the page
gets unlocked, the kernel thread does not touch the address_space. So
the processing within the kthread is along the lines of

writearound(locked_page)
{
write some pages preceding locked_page; /* touches address_space */
write locked_page;
write pages following locked_page; /* touches address_space */
unlock_page(locked_page);
}

--
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/