From: Steven Rostedt <rostedt@goodmis.org>
To: Jay <jinshan.xiong@whamcloud.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: is this a bug?
Date: Fri, 25 Mar 2011 11:18:11 -0400 [thread overview]
Message-ID: <20110325151810.GC9313@home.goodmis.org> (raw)
In-Reply-To: <AANLkTikipA3__OX3sZd-VBS2Hvg5BSE=B9s+0RTyiVVQ@mail.gmail.com>
Strange mail client you have.
On Wed, Mar 23, 2011 at 05:46:56PM -0700, Jay wrote:
> Hi,
>
> Assuming vmscan is doing its job to steal the last page from an
> inode's namespace, so:
>
> shrink_page_list -> remove_mapping -> __remove_from_page_cache:
>
> void __remove_from_page_cache(struct page *page)
>
> {
>
> ...
>
> radix_tree_delete(&mapping->page_tree, page->index);
>
> page->mapping = NULL;
>
> >>> after removing the page from radix tree, it stuck at here.
>
> mapping->nrpages--;
>
> ...
>
> }
>
> then another process just calls iput_final to release the inode, so
> iput_final -> evict:
>
> static void evict(struct inode *inode)
>
> {
>
> ...
>
> } else {
>
> if (inode->i_data.nrpages)
>
> >>> here it finds that nrpage is 1, so go into truncate_inode_pages() but it won't find any page in the page tree.
>
> truncate_inode_pages(&inode->i_data, 0);
>
> >>> here nrpages remains 1.
>
> end_writeback(inode);
>
> >>> hit BUG_ON(inode->i_data.nrpages) in end_writeback().
Did you actually hit this bug?
>
> }
>
> ...
>
> }
>
> The root cause of this problem is that nrpages is accessed w/o holding
> mapping->page_tree. The fix is also easy, just grab ->tree_lock inside
> truncate_inode_pages_range:
>
> + spin_lock_irq(&mapping->tree_lock);
>
> - if (mapping->nrpages == 0)
>
> + if (mapping->nrpages == 0) {
>
> + spin_unlock_irq(&mapping->tree_lock);
>
> return;
>
> + }
>
> + spin_unlock_irq(&mapping->tree_lock);
>
> Am I missed anything?
Perhaps the comment before the __remove_from_page_cache()
/*
* Remove a page from the page cache and free it. Caller has to make
* sure the page is locked and that nobody else uses it - or that usage
* is safe. The caller must hold the mapping's tree_lock.
*/
-- Steve
next prev parent reply other threads:[~2011-03-25 15:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 0:46 is this a bug? Jay
2011-03-25 15:18 ` Steven Rostedt [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-06-21 3:08 Is " Peter Teoh
2001-08-07 11:51 is " Thodoris Pitikaris
2001-08-07 13:51 ` Andrzej Krzysztofowicz
2001-08-08 2:19 ` Dr. Kelsey Hudson
2001-08-08 3:15 ` J Sloan
2001-08-08 3:45 ` Dr. Kelsey Hudson
2001-08-08 10:53 ` David Weinehall
2001-08-08 11:05 ` Alan Cox
2001-08-08 12:59 ` Ron Flory
2001-08-08 16:51 ` jury gerold
2001-08-10 9:12 ` Eric W. Biederman
2001-08-10 12:22 ` jury gerold
2001-08-10 16:22 ` Eric W. Biederman
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=20110325151810.GC9313@home.goodmis.org \
--to=rostedt@goodmis.org \
--cc=jinshan.xiong@whamcloud.com \
--cc=linux-kernel@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