"Stephen C. Tweedie" wrote: > > Hi, > > On Thu, 2002-12-12 at 09:29, Ingo Oeser wrote: > > set_page_dirty() can be used in all cases, IMHO, since it: > > - will not sleep > ... > > Unfortunately, it can take both the inode_lock and pagecache_lock > spinlocks, so if you use it in the wrong place, with other locks already > held, you can cause a deadlock. So you _do_ need to be a bit careful, > and you can't just use it with abandon. > And in 2.5 the pagecache_lock is per-inode. This ends up meaning that it is not legal to run set_page_dirty(page) unless the caller has done something to prevent the thing at page->mapping from being freed. If that has not been done, it is conceivable (but hugely unlikely) that the page could be truncated from its mapping and that mapping could be thrown away while set_page_dirty() is trying to claim its ->page_lock. So in 2.5, set_page_dirty() is only legal if the caller has a ref against page->mapping->host, or if the page is locked. It's currently wrong in a couple of places. I have local fixes for the VM, and direct-IO still needs to be done. It will just be: lock_page(page); /* pins page->mapping */ set_page_dirty(page); unlock_page(page); -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/