From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Jambor Subject: Relocking page in writepage Date: Wed, 15 Feb 2006 16:42:25 +0100 Message-ID: <9615ac9b0602150742v5b0911e2t1ee601716f4ed5dd@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Return-path: Received: from xproxy.gmail.com ([66.249.82.205]:17492 "EHLO xproxy.gmail.com") by vger.kernel.org with ESMTP id S1945987AbWBOPma convert rfc822-to-8bit (ORCPT ); Wed, 15 Feb 2006 10:42:30 -0500 Received: by xproxy.gmail.com with SMTP id t14so1093530wxc for ; Wed, 15 Feb 2006 07:42:29 -0800 (PST) To: Linux FS Development List Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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