linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fred Isaman <iisaman@netapp.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 1/4] pnfs-submit: Rely on full-file layout assumption to clean out some code
Date: Thu,  8 Jul 2010 15:25:19 -0400	[thread overview]
Message-ID: <1278617122-24164-2-git-send-email-iisaman@netapp.com> (raw)
In-Reply-To: <1278617122-24164-1-git-send-email-iisaman@netapp.com>

Note that even assuming full file layout, there can still be two lsegs,
one for each iomode.

Signed-off-by: Fred Isaman <iisaman@netapp.com>
---
 fs/nfs/pnfs.c |   85 +-------------------------------------------------------
 1 files changed, 2 insertions(+), 83 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index baa3de7..5b0c4ec 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -444,65 +444,6 @@ put_lseg(struct pnfs_layout_segment *lseg)
 }
 EXPORT_SYMBOL(put_lseg);
 
-static inline u64
-end_offset(u64 start, u64 len)
-{
-	u64 end;
-
-	end = start + len;
-	return end >= start ? end: NFS4_MAX_UINT64;
-}
-
-/* last octet in a range */
-static inline u64
-last_byte_offset(u64 start, u64 len)
-{
-	u64 end;
-
-	BUG_ON(!len);
-	end = start + len;
-	return end > start ? end - 1: NFS4_MAX_UINT64;
-}
-
-/*
- * is l2 fully contained in l1?
- *   start1                             end1
- *   [----------------------------------)
- *           start2           end2
- *           [----------------)
- */
-static inline int
-lo_seg_contained(struct nfs4_pnfs_layout_segment *l1,
-		 struct nfs4_pnfs_layout_segment *l2)
-{
-	u64 start1 = l1->offset;
-	u64 end1 = end_offset(start1, l1->length);
-	u64 start2 = l2->offset;
-	u64 end2 = end_offset(start2, l2->length);
-
-	return (start1 <= start2) && (end1 >= end2);
-}
-
-/*
- * is l1 and l2 intersecting?
- *   start1                             end1
- *   [----------------------------------)
- *                              start2           end2
- *                              [----------------)
- */
-static inline int
-lo_seg_intersecting(struct nfs4_pnfs_layout_segment *l1,
-		    struct nfs4_pnfs_layout_segment *l2)
-{
-	u64 start1 = l1->offset;
-	u64 end1 = end_offset(start1, l1->length);
-	u64 start2 = l2->offset;
-	u64 end2 = end_offset(start2, l2->length);
-
-	return (end1 == NFS4_MAX_UINT64 || end1 > start2) &&
-	       (end2 == NFS4_MAX_UINT64 || end2 > start1);
-}
-
 void
 pnfs_set_layout_stateid(struct pnfs_layout_type *lo,
 			const nfs4_stateid *stateid)
@@ -616,8 +557,7 @@ should_free_lseg(struct pnfs_layout_segment *lseg,
 		   struct nfs4_pnfs_layout_segment *range)
 {
 	return (range->iomode == IOMODE_ANY ||
-		lseg->range.iomode == range->iomode) &&
-	       lo_seg_intersecting(&lseg->range, range);
+		lseg->range.iomode == range->iomode);
 }
 
 static struct pnfs_layout_segment *
@@ -832,18 +772,6 @@ static inline s64
 cmp_layout(struct nfs4_pnfs_layout_segment *l1,
 	   struct nfs4_pnfs_layout_segment *l2)
 {
-	s64 d;
-
-	/* higher offset > lower offset */
-	d = l1->offset - l2->offset;
-	if (d)
-		return d;
-
-	/* longer length > shorter length */
-	d = l1->length - l2->length;
-	if (d)
-		return d;
-
 	/* read > read/write */
 	return (int)(l1->iomode == IOMODE_READ) -
 	       (int)(l2->iomode == IOMODE_READ);
@@ -1004,16 +932,7 @@ static inline int
 has_matching_lseg(struct pnfs_layout_segment *lseg,
 		  struct nfs4_pnfs_layout_segment *range)
 {
-	struct nfs4_pnfs_layout_segment range1;
-
-	if ((range->iomode == IOMODE_RW && lseg->range.iomode != IOMODE_RW) ||
-	    !lo_seg_intersecting(&lseg->range, range))
-		return 0;
-
-	/* range1 covers only the first byte in the range */
-	range1 = *range;
-	range1.length = 1;
-	return lo_seg_contained(&lseg->range, &range1);
+	return (range->iomode != IOMODE_RW || lseg->range.iomode == IOMODE_RW);
 }
 
 /*
-- 
1.6.6.1


  reply	other threads:[~2010-07-08 19:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-08 19:25 [PATCH 0/4] pnfs-submit code removal patches Fred Isaman
2010-07-08 19:25 ` Fred Isaman [this message]
2010-07-08 19:25   ` [PATCH 2/4] pnfs-submit: Remove readahead_range Fred Isaman
2010-07-08 19:25     ` [PATCH 3/4] pnfs-submit: Remove offset and count arguments from pnfs_update_layout Fred Isaman
2010-07-08 19:25       ` [PATCH 4/4] pnfs-submit: Remove unused encode_getattr_three code Fred Isaman
2010-07-12 15:46 ` [PATCH 0/4] pnfs-submit code removal patches 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=1278617122-24164-2-git-send-email-iisaman@netapp.com \
    --to=iisaman@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).