From: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
To: James Washer <washer@us.ibm.com>
Cc: linux-kernel@vger.kernel.org, washer@beaverton.ibm.com
Subject: Re: CONFIRMED bug in do_generic_file_read
Date: Fri, 13 May 2005 19:20:56 +0100 [thread overview]
Message-ID: <20050513182056.GK1150@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <OF77CCCDF4.63E93C67-ON88257000.0060D4EE-88257000.006248F5@us.ibm.com>
On Fri, May 13, 2005 at 10:55:24AM -0700, James Washer wrote:
> In do_generic_file_read(), when the page is not found, it is created, and
.. with refcount 1
> __add_to_page_cache() is called, which will in turn call page_cache_get()
> which gives us a page->count of 1, no?
That would be 2.
> Now, we "goto reapage", which calls a_op->readpage. If this readpage
> simply returns an error, without any other actions, we drop down to the
> page_cache_release(). Finding the page->count==0, we'll proceed to call
> __free_page(), which calls __free_pages() which decrements and tests
> page->count via put_page_testzero(), returning true as page->count is now
> zero... and were off to __free_pages_ok() and our panic...
>
> What did I miss? Forgive me being dense, if I'm missing something here.
> And thanks again for you help understanding this.
Think for a minute - we allocate a refcounted object. That means
getting (the only) reference to it. That means refcount equal to 1. It's
a fairly common idiom - not just pages are handled that way.
What happens is:
* We created a page. We have a reference to it.
* We put it into cache. Now there are two ways to reach it - our reference
and global search structure.
* We do ->readpage() - we know that we have a reference, so it's not going
away
* We drop our reference. That does not affect the presence in cache - it's
not our responsibility anymore. We are done with this page; if somebody
decides to kick it out of cache, it will be their resposibility to drop the
reference created when putting into cache.
prev parent reply other threads:[~2005-05-13 18:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-13 0:57 Jim Washer
2005-05-13 7:57 ` Al Viro
[not found] ` <OFF1B70B69.DFDD4B59-ON88257000.004A3F64-88257000.004B2949@us.ibm.com>
2005-05-13 15:17 ` Al Viro
[not found] ` <OF77CCCDF4.63E93C67-ON88257000.0060D4EE-88257000.006248F5@us.ibm.com>
2005-05-13 18:20 ` Al Viro [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=20050513182056.GK1150@parcelfarce.linux.theplanet.co.uk \
--to=viro@parcelfarce.linux.theplanet.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=washer@beaverton.ibm.com \
--cc=washer@us.ibm.com \
/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
all inboxes | Powered by JetHome®