public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Mark Tinguely <tinguely@sgi.com>
Cc: jeff.liu@oracle.com, xfs@oss.sgi.com
Subject: Re: [PATCH v6 2/4] xfs: Introduce a new function to find the desired type of offset from page cache
Date: Fri, 10 Aug 2012 09:28:41 +1000	[thread overview]
Message-ID: <20120809232840.GB2877@dastard> (raw)
In-Reply-To: <5023CC01.3060201@sgi.com>

On Thu, Aug 09, 2012 at 09:41:05AM -0500, Mark Tinguely wrote:
.....
> >+
> >+		/*
> >+		 * At lease we found one page.  If this is the first time we
> >+		 * step into the loop, and if the first page index offset is
> >+		 * greater than the given search offset, a hole was found.
> >+		 */
> >+		if (type == HOLE_OFF&&  lastoff == startoff&&
> >+		    lastoff<  page_offset(pvec.pages[0])) {
> >+			found = true;
> >+			break;
> >+		}
> 
> I played with the code and appreciate the trickiness of the startoff.
> I this can be refined a bit more. see below.
> 
> >+
> >+		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;
> >+			}
> 
> Before we take the lock, we can check to see if the page starts
> later than expected (a hole). The pre-loop start check can be
> removed and something like the follow added:

Really, we don't need to be that tricky or smart. This is not a
performance critical operation, so we don't need to optimise away
page locks, especially when the risk of getting it wrong is
compromising data integrity...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2012-08-09 23:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-03  6:10 [PATCH v6 2/4] xfs: Introduce a new function to find the desired type of offset from page cache Jeff Liu
2012-08-09 14:41 ` Mark Tinguely
2012-08-09 23:28   ` Dave Chinner [this message]
2012-08-10  8:02   ` Jie Liu
2012-08-10  8:27     ` Jie Liu
2012-08-09 23:24 ` Dave Chinner
2012-08-10  8:13   ` Jie Liu

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=20120809232840.GB2877@dastard \
    --to=david@fromorbit.com \
    --cc=jeff.liu@oracle.com \
    --cc=tinguely@sgi.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