On Mon 25-04-11 17:37:38, Darrick J. Wong wrote: > On Fri, Apr 22, 2011 at 10:34:34PM +0200, Jan Kara wrote: > > On Fri 22-04-11 08:50:01, Chris Mason wrote: > > > Excerpts from Darrick J. Wong's message of 2011-04-21 20:02:26 -0400: > > > > Hi everyone, > > > > > > > > I've finally managed to get together a patch that seems to provide stable pages > > > > during writeback, or at least gets us to the point that after several days of > > > > running tests I don't see DIF checksum errors anymore. :) > > > > > > > > The last two pieces to go into this puzzle were (a) bio_integrity_prep needs to > > > > walk the process tree to find all userland ptes that map to a particular memory > > > > page and revoke write access, and > > > > > > Hmm, did you need the bio_integrity_prep change for all the filesystems? > > > This should be happening already as part of using page_mkwrite. > > Or more precisely page_mkclean() should do what you try to do in > > bio_integrity_prep()... It would certainly be interesting (bug) if you > > could write to the page after calling page_mkclean() without page_mkwrite() > > being called. > > Hm... in mpage_da_submit_io I see the following sequence of calls: > > 1. clear_page_dirty_for_io > 2. possibly one of: ext4_bio_write_page or block_write_full_page. > If ext4_bio_write_page, > 2a. kmem_cache_alloc > 2b. set_page_writeback > > Before and after #1, the page is locked but writeback is not set. > > Before #2, the page must be locked and writeback must not be set, because both > of those two functions want to set the writeback bit themselves. However, > ext4_bio_write_page tries to allocate memory with GFP_NOFS, which means it can > sleep (I think). Yes, it can sleep. But the page remains locked until we set page as writeback in both cases. > Unfortunately, ext4_page_mkwrite will check for page locked, wait for > page writeback, and then return the page. I think it is theoretically > possible for #1 to trigger a page_mkwrite which completes before #2b, > right? I'm not sure I understand but once the page is locked by ext4_writepages() before #1, ext4_page_mkwrite() will block until it can get the page lock - which can happen only after set_page_writeback() in #2 is done. So then ext4_page_mkwrite() will block waiting for PageWriteback which gets cleared after the IO is finished... Or did you mean something else? > In which case the thread that called mkwrite will think that the > page isn't being written out, and happily scribble on it during > writeback. I could be wrong, but it seems to me that one has to > write-protect the page after setting the writeback bit. Honza -- Jan Kara <jack@xxxxxxx> SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html