linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@primarydata.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH v3 08/14] NFS: pnfs_mark_matching_lsegs_return() should match the layout sequence id
Date: Sun, 24 Jul 2016 17:30:53 -0400	[thread overview]
Message-ID: <1469395859-83194-9-git-send-email-trond.myklebust@primarydata.com> (raw)
In-Reply-To: <1469395859-83194-8-git-send-email-trond.myklebust@primarydata.com>

When determining which layout segments to return, we do want
pnfs_mark_matching_lsegs_return to check that they match the layout
sequence id. This ensures that we don't waste time if the server
is replaying a layout recall that has already been satisfied.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/pnfs.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index c57cbddca760..52b2a4dfdcb0 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -486,15 +486,6 @@ pnfs_lseg_range_intersecting(const struct pnfs_layout_range *l1,
 	       (end2 == NFS4_MAX_UINT64 || end2 > start1);
 }
 
-static bool
-should_free_lseg(const struct pnfs_layout_range *lseg_range,
-		 const struct pnfs_layout_range *recall_range)
-{
-	return (recall_range->iomode == IOMODE_ANY ||
-		lseg_range->iomode == recall_range->iomode) &&
-	       pnfs_lseg_range_intersecting(lseg_range, recall_range);
-}
-
 static bool pnfs_lseg_dec_and_remove_zero(struct pnfs_layout_segment *lseg,
 		struct list_head *tmp_list)
 {
@@ -533,6 +524,27 @@ static bool pnfs_seqid_is_newer(u32 s1, u32 s2)
 	return (s32)(s1 - s2) > 0;
 }
 
+static bool
+pnfs_should_free_range(const struct pnfs_layout_range *lseg_range,
+		 const struct pnfs_layout_range *recall_range)
+{
+	return (recall_range->iomode == IOMODE_ANY ||
+		lseg_range->iomode == recall_range->iomode) &&
+	       pnfs_lseg_range_intersecting(lseg_range, recall_range);
+}
+
+static bool
+pnfs_match_lseg_recall(const struct pnfs_layout_segment *lseg,
+		const struct pnfs_layout_range *recall_range,
+		u32 seq)
+{
+	if (seq != 0 && pnfs_seqid_is_newer(lseg->pls_seq, seq))
+		return false;
+	if (recall_range == NULL)
+		return true;
+	return pnfs_should_free_range(&lseg->pls_range, recall_range);
+}
+
 /**
  * pnfs_mark_matching_lsegs_invalid - tear down lsegs or mark them for later
  * @lo: layout header containing the lsegs
@@ -562,10 +574,7 @@ pnfs_mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo,
 	if (list_empty(&lo->plh_segs))
 		return 0;
 	list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list)
-		if (!recall_range ||
-		    should_free_lseg(&lseg->pls_range, recall_range)) {
-			if (seq && pnfs_seqid_is_newer(lseg->pls_seq, seq))
-				continue;
+		if (pnfs_match_lseg_recall(lseg, recall_range, seq)) {
 			dprintk("%s: freeing lseg %p iomode %d seq %u"
 				"offset %llu length %llu\n", __func__,
 				lseg, lseg->pls_range.iomode, lseg->pls_seq,
@@ -1845,7 +1854,7 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
 	assert_spin_locked(&lo->plh_inode->i_lock);
 
 	list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list)
-		if (should_free_lseg(&lseg->pls_range, return_range)) {
+		if (pnfs_match_lseg_recall(lseg, return_range, seq)) {
 			dprintk("%s: marking lseg %p iomode %d "
 				"offset %llu length %llu\n", __func__,
 				lseg, lseg->pls_range.iomode,
-- 
2.7.4


  reply	other threads:[~2016-07-24 21:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-24 21:30 [PATCH v3 00/14] More layoutreturn nits Trond Myklebust
2016-07-24 21:30 ` [PATCH v3 01/14] pNFS: LAYOUTRETURN should only update the stateid if the layout is valid Trond Myklebust
2016-07-24 21:30   ` [PATCH v3 02/14] pNFS: Clear the layout return tracking on layout reinitialisation Trond Myklebust
2016-07-24 21:30     ` [PATCH v3 03/14] pNFS: Always update the layout stateid if NFS_LAYOUT_INVALID_STID is set Trond Myklebust
2016-07-24 21:30       ` [PATCH v3 04/14] pNFS: Always update the layout barrier seqid on LAYOUTGET Trond Myklebust
2016-07-24 21:30         ` [PATCH v3 05/14] pNFS: Fix CB_LAYOUTRECALL stateid verification Trond Myklebust
2016-07-24 21:30           ` [PATCH v3 06/14] pNFS: Ensure layoutreturn acts as a completion for layout callbacks Trond Myklebust
2016-07-24 21:30             ` [PATCH v3 07/14] pNFS: Do not set plh_return_seq for non-callback related layoutreturns Trond Myklebust
2016-07-24 21:30               ` Trond Myklebust [this message]
2016-07-24 21:30                 ` [PATCH v3 09/14] pNFS: Cleanup - don't open code pnfs_mark_layout_stateid_invalid() Trond Myklebust
2016-07-24 21:30                   ` [PATCH v3 10/14] pNFS: Clear the layout metadata if the server changed the layout stateid Trond Myklebust
2016-07-24 21:30                     ` [PATCH v3 11/14] pNFS: Remove redundant pnfs_mark_layout_returned_if_empty() Trond Myklebust
2016-07-24 21:30                       ` [PATCH v3 12/14] pNFS: Remove redundant stateid invalidation Trond Myklebust
2016-07-24 21:30                         ` [PATCH v3 13/14] pNFS: Cleanup - do layout segment initialisation in one place Trond Myklebust
2016-07-24 21:30                           ` [PATCH v3 14/14] pNFS: Remove redundant smp_mb() from pnfs_init_lseg() Trond Myklebust

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=1469395859-83194-9-git-send-email-trond.myklebust@primarydata.com \
    --to=trond.myklebust@primarydata.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).