Skip to contentSkip to conversation

pnfs-submit: remove unused stateid argument from pnfs_return_layout

PATCH In review Fred Isaman 2 participants 5 messages Nov 15, 2010 – Nov 17, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 pnfs-submit: remove unused stateid argument from pnfs_return_layout

This is a relic from the old CB_LAYOUTRECALL code.

---
 fs/nfs/inode.c          |    2 +-
 fs/nfs/nfs4proc.c       |    5 -----
 fs/nfs/pnfs.c           |   14 ++------------
 fs/nfs/pnfs.h           |    5 +----
 include/linux/nfs_xdr.h |    1 -
 5 files changed, 4 insertions(+), 23 deletions(-)
fs/nfs/inode.c +1 -1
index 8727ade..3bf7a42 100644
@@ -1419,7 +1419,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
  */
 void nfs4_evict_inode(struct inode *inode)
 {
-	pnfs_return_layout(inode, NULL, NULL, RETURN_FILE, true);
+	pnfs_return_layout(inode, NULL, RETURN_FILE, true);
 	truncate_inode_pages(&inode->i_data, 0);
 	end_writeback(inode);
 	pnfs_destroy_layout(NFS_I(inode));
fs/nfs/nfs4proc.c +0 -5
index 55505e4..bd234c4 100644
@@ -5622,11 +5622,6 @@ nfs4_layoutreturn_prepare(struct rpc_task *task, void *calldata)
 			return;
 		}
 	}
-	if (lrp->stateid) {
-		/* Forget the layout, without sending the return */
-		rpc_exit(task, 0);
-		return;
-	}
 	if (nfs41_setup_sequence(lrp->clp->cl_session, &lrp->args.seq_args,
 				&lrp->res.seq_res, 0, task))
 		return;
fs/nfs/pnfs.c +2 -12
index 0b7fc1d..a62f518 100644
@@ -693,7 +693,7 @@ out_nolayout:
 static int
 return_layout(struct inode *ino, struct pnfs_layout_range *range,
 	      enum pnfs_layoutreturn_type type, struct pnfs_layout_hdr *lo,
-	      bool wait, const nfs4_stateid *stateid)
+	      bool wait)
 {
 	struct nfs4_layoutreturn *lrp;
 	struct nfs_server *server = NFS_SERVER(ino);
@@ -714,7 +714,6 @@ return_layout(struct inode *ino, struct pnfs_layout_range *range,
 	lrp->args.return_type = type;
 	lrp->args.range = *range;
 	lrp->args.inode = ino;
-	lrp->stateid = stateid;
 	lrp->clp = server->nfs_client;
 
 	status = nfs4_proc_layoutreturn(lrp, wait);
@@ -725,7 +724,6 @@ out:
 
 int
 _pnfs_return_layout(struct inode *ino, struct pnfs_layout_range *range,
-		    const nfs4_stateid *stateid, /* optional */
 		    enum pnfs_layoutreturn_type type,
 		    bool wait)
 {
@@ -766,11 +764,6 @@ _pnfs_return_layout(struct inode *ino, struct pnfs_layout_range *range,
 		pnfs_free_lseg_list(&tmp_list);
 
 		if (layoutcommit_needed(nfsi)) {
-			if (stateid && !wait) { /* callback */
-				dprintk("%s: layoutcommit pending\n", __func__);
-				status = -EAGAIN;
-				goto out_put;
-			}
 			status = pnfs_layoutcommit_inode(ino, wait);
 			if (status) {
 				/* Return layout even if layoutcommit fails */
@@ -779,14 +772,11 @@ _pnfs_return_layout(struct inode *ino, struct pnfs_layout_range *range,
 					__func__, status);
 			}
 		}
-		status = return_layout(ino, &arg, type, lo, wait, stateid);
+		status = return_layout(ino, &arg, type, lo, wait);
 	}
 out:
 	dprintk("<-- %s status: %d\n", __func__, status);
 	return status;
-out_put:
-	put_layout_hdr(ino);
-	goto out;
 }
 
 /*
fs/nfs/pnfs.h +1 -4
index c5b4282..46dab34 100644
@@ -205,7 +205,6 @@ 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 *);
 int _pnfs_return_layout(struct inode *, struct pnfs_layout_range *,
-			const nfs4_stateid *stateid, /* optional */
 			enum pnfs_layoutreturn_type, bool wait);
 void set_pnfs_layoutdriver(struct nfs_server *, u32 id);
 void unset_pnfs_layoutdriver(struct nfs_server *);
@@ -279,7 +278,6 @@ pnfs_layout_roc_iomode(struct nfs_inode *nfsi)
 
 static inline int pnfs_return_layout(struct inode *ino,
 				     struct pnfs_layout_range *range,
-				     const nfs4_stateid *stateid, /* optional */
 				     enum pnfs_layoutreturn_type type,
 				     bool wait)
 {
@@ -288,7 +286,7 @@ static inline int pnfs_return_layout(struct inode *ino,
 
 	if (pnfs_enabled_sb(nfss) &&
 	    (type != RETURN_FILE || has_layout(nfsi)))
-		return _pnfs_return_layout(ino, range, stateid, type, wait);
+		return _pnfs_return_layout(ino, range, type, wait);
 
 	return 0;
 }
@@ -383,7 +381,6 @@ pnfs_layout_roc_iomode(struct nfs_inode *nfsi)
 
 static inline int pnfs_return_layout(struct inode *ino,
 				     struct pnfs_layout_range *range,
-				     const nfs4_stateid *stateid, /* optional */
 				     enum pnfs_layoutreturn_type type,
 				     bool wait)
 {
include/linux/nfs_xdr.h +0 -1
index d4c4804..7a19acb 100644
@@ -276,7 +276,6 @@ struct nfs4_layoutreturn {
 	struct nfs4_layoutreturn_args args;
 	struct nfs4_layoutreturn_res res;
 	struct rpc_cred *cred;
-	const nfs4_stateid *stateid;
 	struct nfs_client *clp;
 	int rpc_status;
 };
Signature · 1 line
1.7.2.1
#1 lore raw

PATCH 2/4 pnfs-submit: remove type argument from pnfs_return_layout

pnfs_return_layout is only called with type=RETURN_FILE, so remove as argument

---
 fs/nfs/inode.c |    2 +-
 fs/nfs/pnfs.c  |   76 ++++++++++++++++++++++++-------------------------------
 fs/nfs/pnfs.h  |   10 ++-----
 3 files changed, 37 insertions(+), 51 deletions(-)
fs/nfs/inode.c +1 -1
index 3bf7a42..bbeb337 100644
@@ -1419,7 +1419,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
  */
 void nfs4_evict_inode(struct inode *inode)
 {
-	pnfs_return_layout(inode, NULL, RETURN_FILE, true);
+	pnfs_return_layout(inode, NULL, true);
 	truncate_inode_pages(&inode->i_data, 0);
 	end_writeback(inode);
 	pnfs_destroy_layout(NFS_I(inode));
fs/nfs/pnfs.c +32 -42

116 lines not on this page · raw message

fs/nfs/pnfs.h +3 -7
index 46dab34..a124ad2 100644
@@ -204,8 +204,7 @@ 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 *);
-int _pnfs_return_layout(struct inode *, struct pnfs_layout_range *,
-			enum pnfs_layoutreturn_type, bool wait);
+int _pnfs_return_layout(struct inode *, struct pnfs_layout_range *, bool wait);
 void set_pnfs_layoutdriver(struct nfs_server *, u32 id);
 void unset_pnfs_layoutdriver(struct nfs_server *);
 enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *,
@@ -278,15 +277,13 @@ pnfs_layout_roc_iomode(struct nfs_inode *nfsi)
 
 static inline int pnfs_return_layout(struct inode *ino,
 				     struct pnfs_layout_range *range,
-				     enum pnfs_layoutreturn_type type,
 				     bool wait)
 {
 	struct nfs_inode *nfsi = NFS_I(ino);
 	struct nfs_server *nfss = NFS_SERVER(ino);
 
-	if (pnfs_enabled_sb(nfss) &&
-	    (type != RETURN_FILE || has_layout(nfsi)))
-		return _pnfs_return_layout(ino, range, type, wait);
+	if (pnfs_enabled_sb(nfss) && has_layout(nfsi))
+		return _pnfs_return_layout(ino, range, wait);
 
 	return 0;
 }
@@ -381,7 +378,6 @@ pnfs_layout_roc_iomode(struct nfs_inode *nfsi)
 
 static inline int pnfs_return_layout(struct inode *ino,
 				     struct pnfs_layout_range *range,
-				     enum pnfs_layoutreturn_type type,
 				     bool wait)
 {
 	return 0;
Signature · 1 line
1.7.2.1
#2 lore raw

PATCH 3/4 pnfs-submit: remove has_layout_to_return()

In reply to Fred Isaman

Refactoring _pnfs_return_layout(), the only caller of has_layout_to_return(), allows us to remove it entirely in favor of pnfs_clear_lseg_list().

---
 fs/nfs/pnfs.c |   34 ++++++----------------------------
 fs/nfs/pnfs.h |    2 +-
 2 files changed, 7 insertions(+), 29 deletions(-)
fs/nfs/pnfs.c +6 -28
index eefa440..d06bf16 100644
@@ -375,11 +375,13 @@ static void mark_lseg_invalid(struct pnfs_layout_segment *lseg,
 	}
 }
 
-void
+/* Returns false if there was nothing to do, true otherwise */
+bool
 pnfs_clear_lseg_list(struct pnfs_layout_hdr *lo, struct list_head *tmp_list,
 		     struct pnfs_layout_range *range)
 {
 	struct pnfs_layout_segment *lseg, *next;
+	bool rv = false;
 
 	dprintk("%s:Begin lo %p offset %llu length %llu iomode %d\n",
 		__func__, lo, range->offset, range->length, range->iomode);
@@ -392,8 +394,10 @@ pnfs_clear_lseg_list(struct pnfs_layout_hdr *lo, struct list_head *tmp_list,
 				lseg, lseg->range.iomode, lseg->range.offset,
 				lseg->range.length);
 			mark_lseg_invalid(lseg, tmp_list);
+			rv = true;
 		}
 	dprintk("%s:Return\n", __func__);
+	return rv;
 }
 
 void
@@ -566,25 +570,6 @@ send_layoutget(struct pnfs_layout_hdr *lo,
 	return lseg;
 }
 
-static struct pnfs_layout_segment *
-has_layout_to_return(struct pnfs_layout_hdr *lo,
-		     struct pnfs_layout_range *range)
-{
-	struct pnfs_layout_segment *out = NULL, *lseg;
-	dprintk("%s:Begin lo %p offset %llu length %llu iomode %d\n",
-		__func__, lo, range->offset, range->length, range->iomode);
-
-	assert_spin_locked(&lo->inode->i_lock);
-	list_for_each_entry(lseg, &lo->segs, fi_list)
-		if (should_free_lseg(&lseg->range, range)) {
-			out = lseg;
-			break;
-		}
-
-	dprintk("%s:Return lseg=%p\n", __func__, out);
-	return out;
-}
-
 void nfs4_asynch_forget_layouts(struct pnfs_layout_hdr *lo,
 				struct pnfs_layout_range *range,
 				int notify_bit, atomic_t *notify_count,
@@ -726,7 +711,6 @@ _pnfs_return_layout(struct inode *ino, struct pnfs_layout_range *range,
 	struct nfs_inode *nfsi = NFS_I(ino);
 	struct pnfs_layout_range arg;
 	LIST_HEAD(tmp_list);
-	struct pnfs_layout_segment *lseg, *tmp;
 	int status = 0;
 
 	dprintk("--> %s\n", __func__);
@@ -737,18 +721,12 @@ _pnfs_return_layout(struct inode *ino, struct pnfs_layout_range *range,
 
 	spin_lock(&ino->i_lock);
 	lo = nfsi->layout;
-	if (lo && !has_layout_to_return(lo, &arg))
-		lo = NULL;
-	if (!lo) {
+	if (!lo || !pnfs_clear_lseg_list(lo, &tmp_list, &arg)) {
 		spin_unlock(&ino->i_lock);
 		dprintk("%s: no layout segments to return\n", __func__);
 		goto out;
 	}
-
 	lo->plh_block_lgets++;
-	list_for_each_entry_safe(lseg, tmp, &lo->segs, fi_list)
-		if (should_free_lseg(&lseg->range, &arg))
-			mark_lseg_invalid(lseg, &tmp_list);
 	/* Reference matched in nfs4_layoutreturn_release */
 	get_layout_hdr(lo);
 	spin_unlock(&ino->i_lock);
fs/nfs/pnfs.h +1 -1
index a124ad2..3314f64 100644
@@ -222,7 +222,7 @@ void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *,
 void pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *);
 bool pnfs_layoutgets_blocked(struct pnfs_layout_hdr *lo, nfs4_stateid *stateid);
 int pnfs_layout_process(struct nfs4_layoutget *lgp);
-void pnfs_clear_lseg_list(struct pnfs_layout_hdr *, struct list_head *tmp_list,
+bool pnfs_clear_lseg_list(struct pnfs_layout_hdr *, struct list_head *tmp_list,
 			  struct pnfs_layout_range *);
 void pnfs_free_lseg_list(struct list_head *tmp_list);
 void pnfs_destroy_layout(struct nfs_inode *);
Signature · 1 line
1.7.2.1
#3 lore raw

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

In reply to Fred Isaman

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.

---
 fs/nfs/pnfs.c |   26 +++++++-------------------
 fs/nfs/pnfs.h |    2 --
 2 files changed, 7 insertions(+), 21 deletions(-)
fs/nfs/pnfs.c +7 -19
index d06bf16..a21debe 100644
@@ -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))
fs/nfs/pnfs.h +0 -2
index 3314f64..12fe7ab 100644
@@ -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 *);
Signature · 1 line
1.7.2.1
#4 lore raw
In reply to Fred Isaman

Thanks! All 4 patches merged in pnfs-all-2.6.37-rc2-2010-11-17

Benny

Quoted 146 lines · Fred Isaman

This is a relic from the old CB_LAYOUTRECALL code.

---
 fs/nfs/inode.c          |    2 +-
 fs/nfs/nfs4proc.c       |    5 -----
 fs/nfs/pnfs.c           |   14 ++------------
 fs/nfs/pnfs.h           |    5 +----
 include/linux/nfs_xdr.h |    1 -
 5 files changed, 4 insertions(+), 23 deletions(-)
fs/nfs/inode.c +1 -1
index 8727ade..3bf7a42 100644
@@ -1419,7 +1419,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
  */
 void nfs4_evict_inode(struct inode *inode)
 {
-	pnfs_return_layout(inode, NULL, NULL, RETURN_FILE, true);
+	pnfs_return_layout(inode, NULL, RETURN_FILE, true);
 	truncate_inode_pages(&inode->i_data, 0);
 	end_writeback(inode);
 	pnfs_destroy_layout(NFS_I(inode));
fs/nfs/nfs4proc.c +0 -5
index 55505e4..bd234c4 100644
@@ -5622,11 +5622,6 @@ nfs4_layoutreturn_prepare(struct rpc_task *task, void *calldata)
 			return;
 		}
 	}
-	if (lrp->stateid) {
-		/* Forget the layout, without sending the return */
-		rpc_exit(task, 0);
-		return;
-	}
 	if (nfs41_setup_sequence(lrp->clp->cl_session, &lrp->args.seq_args,
 				&lrp->res.seq_res, 0, task))
 		return;
fs/nfs/pnfs.c +2 -12
index 0b7fc1d..a62f518 100644
@@ -693,7 +693,7 @@ out_nolayout:
 static int
 return_layout(struct inode *ino, struct pnfs_layout_range *range,
 	      enum pnfs_layoutreturn_type type, struct pnfs_layout_hdr *lo,
-	      bool wait, const nfs4_stateid *stateid)
+	      bool wait)
 {
 	struct nfs4_layoutreturn *lrp;
 	struct nfs_server *server = NFS_SERVER(ino);
@@ -714,7 +714,6 @@ return_layout(struct inode *ino, struct pnfs_layout_range *range,
 	lrp->args.return_type = type;
 	lrp->args.range = *range;
 	lrp->args.inode = ino;
-	lrp->stateid = stateid;
 	lrp->clp = server->nfs_client;
 
 	status = nfs4_proc_layoutreturn(lrp, wait);
@@ -725,7 +724,6 @@ out:
 
 int
 _pnfs_return_layout(struct inode *ino, struct pnfs_layout_range *range,
-		    const nfs4_stateid *stateid, /* optional */
 		    enum pnfs_layoutreturn_type type,
 		    bool wait)
 {
@@ -766,11 +764,6 @@ _pnfs_return_layout(struct inode *ino, struct pnfs_layout_range *range,
 		pnfs_free_lseg_list(&tmp_list);
 
 		if (layoutcommit_needed(nfsi)) {
-			if (stateid && !wait) { /* callback */
-				dprintk("%s: layoutcommit pending\n", __func__);
-				status = -EAGAIN;
-				goto out_put;
-			}
 			status = pnfs_layoutcommit_inode(ino, wait);
 			if (status) {
 				/* Return layout even if layoutcommit fails */
@@ -779,14 +772,11 @@ _pnfs_return_layout(struct inode *ino, struct pnfs_layout_range *range,
 					__func__, status);
 			}
 		}
-		status = return_layout(ino, &arg, type, lo, wait, stateid);
+		status = return_layout(ino, &arg, type, lo, wait);
 	}
 out:
 	dprintk("<-- %s status: %d\n", __func__, status);
 	return status;
-out_put:
-	put_layout_hdr(ino);
-	goto out;
 }
 
 /*
fs/nfs/pnfs.h +1 -4
index c5b4282..46dab34 100644
@@ -205,7 +205,6 @@ 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 *);
 int _pnfs_return_layout(struct inode *, struct pnfs_layout_range *,
-			const nfs4_stateid *stateid, /* optional */
 			enum pnfs_layoutreturn_type, bool wait);
 void set_pnfs_layoutdriver(struct nfs_server *, u32 id);
 void unset_pnfs_layoutdriver(struct nfs_server *);
@@ -279,7 +278,6 @@ pnfs_layout_roc_iomode(struct nfs_inode *nfsi)
 
 static inline int pnfs_return_layout(struct inode *ino,
 				     struct pnfs_layout_range *range,
-				     const nfs4_stateid *stateid, /* optional */
 				     enum pnfs_layoutreturn_type type,
 				     bool wait)
 {
@@ -288,7 +286,7 @@ static inline int pnfs_return_layout(struct inode *ino,
 
 	if (pnfs_enabled_sb(nfss) &&
 	    (type != RETURN_FILE || has_layout(nfsi)))
-		return _pnfs_return_layout(ino, range, stateid, type, wait);
+		return _pnfs_return_layout(ino, range, type, wait);
 
 	return 0;
 }
@@ -383,7 +381,6 @@ pnfs_layout_roc_iomode(struct nfs_inode *nfsi)
 
 static inline int pnfs_return_layout(struct inode *ino,
 				     struct pnfs_layout_range *range,
-				     const nfs4_stateid *stateid, /* optional */
 				     enum pnfs_layoutreturn_type type,
 				     bool wait)
 {
include/linux/nfs_xdr.h +0 -1
index d4c4804..7a19acb 100644
@@ -276,7 +276,6 @@ struct nfs4_layoutreturn {
 	struct nfs4_layoutreturn_args args;
 	struct nfs4_layoutreturn_res res;
 	struct rpc_cred *cred;
-	const nfs4_stateid *stateid;
 	struct nfs_client *clp;
 	int rpc_status;
 };