lkml.org 
[lkml]   [2003]   [Dec]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH linux-2.6.0-test10-mm1] filemap_fdatawait.patch
On Wed, Dec 31, 2003 at 01:35:21AM -0800, Andrew Morton wrote:
> Suparna Bhattacharya <suparna@in.ibm.com> wrote:
> >
> > It seems like the case Daniel is thinking about is when
> > a process has issued writes to the page cache, and then filemap_fdatawrite
> > is called, while these pages are being written back to disk parallely by
> > another thread (not holding i_sem). The filemap_fdatawrite wouldn't see
> > pages that are in the process of being written out by the background
> > thread so it doesn't mark them for writeback.
>
> If those pages are under writeout then they are clean and
> filemap_fdatawrite() has nothing to do.

Sure, it doesn't, because the other thread is about to issue
a writeout on them. But it does mean that there is no guarantee
that those pages are already marked as writeback when
filemap_fdatawrite returns and filemap_fdatawait is called.

>
> If, however, those pages were redirtied while under I/O then they are
> dirty, on dirty_pages and are under writeout. In that case
> filemap_fdatawrite() must wait for the current write to complete and must
> start a new write.
>
> > The following filemap_fdatawait
> > would find these pages on the locked_pages list all right, but if its
> > unlucky enough to be in the window that Daniel mentions where PG_dirty
> > is cleared but PG_writeback hasn't yet been set, then the page would
> > have move to the clean list without waiting for the actual writeout
> > to complete !
>
> If you are referring to this code in mpage_writepage():
>
> lock_page(page);
>
> if (wbc->sync_mode != WB_SYNC_NONE)
> wait_on_page_writeback(page);
>
> if (page->mapping == mapping && !PageWriteback(page) &&
> test_clear_page_dirty(page)) {
>
>
> then I don't see the race - the page lock synchronises the two threads?
>

But filemap_fdatawait does not look at the page lock. So there's a
tiny window when the page is on locked_pages with PG_dirty cleared
and PG_writeback not set. Does that make sense, or is there something
I overlook ?

Daniel's patch precisely tried to fill that gap - he added a check for page
lock in filemap_datawait.

Regards
Suparna

>
> --
> To unsubscribe, send a message with 'unsubscribe linux-aio' in
> the body to majordomo@kvack.org. For more info on Linux AIO,
> see: http://www.kvack.org/aio/
> Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>

--
Suparna Bhattacharya (suparna@in.ibm.com)
Linux Technology Center
IBM Software Lab, India

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:59    [W:0.132 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site