From: "Martin Jambor" <jambormartin@gmail.com>
To: "Linux FS Development List" <linux-fsdevel@vger.kernel.org>
Subject: Re: Relocking page in writepage
Date: Sun, 26 Feb 2006 16:32:40 +0100 [thread overview]
Message-ID: <9615ac9b0602260732g5cf7f7dbs36f0c0f75e536c90@mail.gmail.com> (raw)
In-Reply-To: <20060225025053.2b25a91d.akpm@osdl.org>
On 2/25/06, Andrew Morton <akpm@osdl.org> wrote:
> I can't immediately think of a problem with that.
>
> I guess it would be nicer to do:
>
> lock_page();
> if (page->mapping != mapping) {
> unlock_page();
> page_cache_release();
>
> so the page get freed immediately if the race happened, rather than having
> it drift down the LRU.
>
> umm, actually you do need to handle the case where someone came in and
> redirtied the page and potentially stated writeback against it.
>
> lock_page();
> wait_on_page_writeback();
> if (page->mapping != mapping) {
> unlock_page();
> page_cache_release();
> return;
> }
>
> Now, we don't know whether to write the page. Someone else might have
> redirtied it and written it while w dropped the lock.
>
> So you have to go off and write it, occasionally unnecessarily.
>
> umm, no. If you leave PageWriteback() set throughout, nobody will try to
> restart a write.
Well, I set writeback much later, only after I know there wouldn't be
any errors.
However, I was thinking if the following alternative solution would be ok:
set_page_writeback(page);
unlock_page(page)
/* do something that might deadlock */
lock_page(page);
if (error) { /* -EIO, WRITEPAGE_ACTIVATE etc... */
test_clear_page_writeback(page);
wake_up_page(page, PG_writeback);
return error;
}
/* continue as usual */
The problem with it is that test_clear_page_writeback() and
wake_up_page() are not exported for modules (which is a slight problem
at this stage of our project). On the other hand a page under
writeback shouldn't be stripped off its mapping or rewritten etc.
which simplifies things a lot.
Thanks for the input and any further comments, meanwhile I'll play
around with it and see what I can get away with.
Martin
prev parent reply other threads:[~2006-02-26 15:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9615ac9b0602260732g5cf7f7dbs36f0c0f75e536c90@mail.gmail.com \
--to=jambormartin@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).