[PATCH 4/4] pnfs-submit: move get_lseg into pnfs_has_layout, and rename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



rename pnfs_has_layout to pnfs_find_lseg, and move get_lseg into
the function, only returning valid lsegs.  Additionally, make the
function static, as it now has only a single caller.

Signed-off-by: Fred Isaman <iisaman@xxxxxxxxxx>
---
 fs/nfs/pnfs.c |   26 +++++++-------------------
 fs/nfs/pnfs.h |    2 --
 2 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index d06bf16..a21debe 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -860,8 +860,8 @@ is_matching_lseg(struct pnfs_layout_segment *lseg,
 /*
  * lookup range in layout
  */
-struct pnfs_layout_segment *
-pnfs_has_layout(struct pnfs_layout_hdr *lo,
+static struct pnfs_layout_segment *
+pnfs_find_lseg(struct pnfs_layout_hdr *lo,
 		struct pnfs_layout_range *range)
 {
 	struct pnfs_layout_segment *lseg, *ret = NULL;
@@ -870,7 +870,8 @@ pnfs_has_layout(struct pnfs_layout_hdr *lo,
 
 	assert_spin_locked(&lo->inode->i_lock);
 	list_for_each_entry(lseg, &lo->segs, fi_list) {
-		if (is_matching_lseg(lseg, range)) {
+		if (lseg->valid && is_matching_lseg(lseg, range)) {
+			get_lseg(lseg);
 			ret = lseg;
 			break;
 		}
@@ -913,22 +914,9 @@ pnfs_update_layout(struct inode *ino,
 	}
 
 	/* Check to see if the layout for the given range already exists */
-	lseg = pnfs_has_layout(lo, &arg);
-	if (lseg) {
-		if (lseg->valid) {
-			dprintk("%s: Using cached lseg %p for %llu@%llu "
-				"iomode %d)\n",
-				__func__,
-				lseg,
-				arg.length,
-				arg.offset,
-				arg.iomode);
-			get_lseg(lseg);
-			goto out_unlock;
-		}
-		/* someone is cleaning the layout */
-		lseg = NULL;
-	}
+	lseg = pnfs_find_lseg(lo, &arg);
+	if (lseg)
+		goto out_unlock;
 
 	/* if LAYOUTGET already failed once we don't try again */
 	if (test_bit(lo_fail_bit(iomode), &nfsi->layout->plh_flags))
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 3314f64..12fe7ab 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -199,8 +199,6 @@ void put_lseg(struct pnfs_layout_segment *lseg);
 bool should_free_lseg(struct pnfs_layout_range *lseg_range,
 		      struct pnfs_layout_range *recall_range);
 struct pnfs_layout_segment *
-pnfs_has_layout(struct pnfs_layout_hdr *lo, struct pnfs_layout_range *range);
-struct pnfs_layout_segment *
 pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,
 		   enum pnfs_iomode access_type);
 bool pnfs_return_layout_barrier(struct nfs_inode *, struct pnfs_layout_range *);
-- 
1.7.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux