linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Relocking page in writepage
@ 2006-02-15 15:42 Martin Jambor
  2006-02-25 10:50 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Jambor @ 2006-02-15 15:42 UTC (permalink / raw)
  To: Linux FS Development List

Hi,

is it ok to do something like the following in aops->writepage (or in
writepages after calling clear_page_dirty_for_io(page) for that
matter):

        struct address_space mapping = page->mapping;
	page_cache_get(page);
	unlock_page(page);

        /* do something that might deadlock if page was locked */

	lock_page(page);
	page_cache_release(page);

	if (page->mapping != mapping) { /* truncated while doing the above */
		unlock_page(page);
		return 0;
	}

        /* continue as usual  (i.e. initiate writing, set writeback
and unlock) */

A few practical tests showed no problem but I thought it would be
better to ask anyway...
I know it isn't a nice thing to do but otherwise I would probably need
to implement some mechanism to remember the page I have locked and
never try to lock (or page_cache_grab) it again. Both are cumbersome
but this is easier, what do you think about it?

Thank you very much for any insight,

Martin Jambor

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

end of thread, other threads:[~2006-02-26 15:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-15 15:42 Relocking page in writepage Martin Jambor
2006-02-25 10:50 ` Andrew Morton
2006-02-26 15:32   ` Martin Jambor

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