All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 2/5] NFSv4.1: Fix an off-by-one error in pnfs_generic_pg_test
Date: Thu,  9 Jun 2011 21:30:59 -0400	[thread overview]
Message-ID: <1307669462-15764-2-git-send-email-Trond.Myklebust@netapp.com> (raw)
In-Reply-To: <1307669462-15764-1-git-send-email-Trond.Myklebust@netapp.com>

And document what is going on there...

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
 fs/nfs/pnfs.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 12b53ef..9a4ce7c 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1073,11 +1073,22 @@ pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
 			return true;
 	}
 
-	if (req_offset(req) > end_offset(pgio->pg_lseg->pls_range.offset,
-					 pgio->pg_lseg->pls_range.length))
-		return false;
-
-	return true;
+	/*
+	 * Test if a nfs_page is fully contained in the pnfs_layout_range.
+	 * Note that this test makes several assumptions:
+	 * - that the previous nfs_page in the struct nfs_pageio_descriptor
+	 *   is known to lie within the range.
+	 *   - that the nfs_page being tested is known to be contiguous with the
+	 *   previous nfs_page.
+	 *   - Layout ranges are page aligned, so we only have to test the
+	 *   start offset of the request.
+	 *
+	 * Please also note that 'end_offset' is actually the offset of the
+	 * first byte that lies outside the pnfs_layout_range. FIXME?
+	 *
+	 */
+	return req_offset(req) < end_offset(pgio->pg_lseg->pls_range.offset,
+					 pgio->pg_lseg->pls_range.length);
 }
 EXPORT_SYMBOL_GPL(pnfs_generic_pg_test);
 
-- 
1.7.5.2


  reply	other threads:[~2011-06-10  1:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-10  1:30 [PATCH 1/5] NFSv4.1: Fix some issues with pnfs_generic_pg_test Trond Myklebust
2011-06-10  1:30 ` Trond Myklebust [this message]
2011-06-10  1:31   ` [PATCH 3/5] NFS: Cleanup of the nfs_pageio code in preparation for a pnfs bugfix Trond Myklebust
2011-06-10  1:31     ` [PATCH 4/5] NFSv4.1: Add an initialisation callback for pNFS Trond Myklebust
2011-06-10  1:31       ` [PATCH 5/5] NFSv4.1: Fall back to ordinary i/o through the mds if we have no layout segment Trond Myklebust
2011-06-10  2:53       ` [PATCH 4/5] NFSv4.1: Add an initialisation callback for pNFS Boaz Harrosh
2011-06-10  4:06         ` Benny Halevy
2011-06-10  4:28           ` Boaz Harrosh
2011-06-10  4:43             ` Benny Halevy
2011-06-10 16:14               ` Boaz Harrosh
2011-06-10 16:28                 ` Trond Myklebust
2011-06-10 16:57                   ` Boaz Harrosh
2011-06-10 17:32                     ` Trond Myklebust
2011-06-10 19:29                       ` Benny Halevy

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=1307669462-15764-2-git-send-email-Trond.Myklebust@netapp.com \
    --to=trond.myklebust@netapp.com \
    --cc=linux-nfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.