From: Jie Liu <jeff.liu@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH v7 2/4] xfs: Introduce a helper routine to probe data or hole offset from page cache
Date: Tue, 21 Aug 2012 13:04:50 +0800 [thread overview]
Message-ID: <503316F2.9050704@oracle.com> (raw)
In-Reply-To: <20120820231309.GJ19235@dastard>
On 08/21/12 07:13, Dave Chinner wrote:
> On Mon, Aug 13, 2012 at 09:07:58PM +0800, Jeff Liu wrote:
>> helper routine to lookup data or hole offset from page cache for unwritten extents.
>>
>> Signed-off-by: Jie Liu <jeff.liu@oracle.com>
> ....
>> + unsigned int i;
>> +
>> + want = min_t(pgoff_t, end - index, (pgoff_t)PAGEVEC_SIZE);
> No need for the cast to (pgoff_t) here. That's what the min_t()
> macro does for you.
Thanks for pointing this out.
>
>> + for (i = 0; i < nr_pages; i++) {
>> + struct page *page = pvec.pages[i];
>> + loff_t b_offset;
>> +
>> + /*
>> + * Page index is out of range, searching done.
>> + * If the current offset is not reaches the end
>> + * of the specified search range, there should
>> + * be a hole between them.
>> + */
>> + if (page->index > end) {
>> + if (type == HOLE_OFF && lastoff < endoff) {
>> + *offset = lastoff;
>> + found = true;
>> + }
>> + goto out;
>> + }
>> +
>> + lock_page(page);
>> + /*
>> + * Page truncated or invalidated(page->mapping == NULL).
>> + * We can freely skip it and proceed to check the next
>> + * page.
>> + */
>> + if (unlikely(page->mapping != inode->i_mapping)) {
>> + unlock_page(page);
>> + continue;
>> + }
> Still need to check page->index again after locking the page. As
> this isn't performance critical, I don't think you need the check
> before the page is locked, anyway....
I understand that we have to check page->mapping with page locked
because race against inode truncation.
But could you teaching me why page->index will be changed in either
memory reclaim or truncates even if
the page returned with refcount > 0?
Thanks,
-Jeff
>
> Cheers,
>
> Dave.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2012-08-21 5:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-13 13:07 [PATCH v7 2/4] xfs: Introduce a helper routine to probe data or hole offset from page cache Jeff Liu
2012-08-20 15:31 ` Mark Tinguely
2012-08-20 23:08 ` Dave Chinner
2012-08-21 4:54 ` Jie Liu
2012-08-21 5:25 ` Dave Chinner
2012-08-21 6:41 ` Jie Liu
2012-08-20 23:13 ` Dave Chinner
2012-08-21 5:04 ` Jie Liu [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=503316F2.9050704@oracle.com \
--to=jeff.liu@oracle.com \
--cc=david@fromorbit.com \
--cc=xfs@oss.sgi.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