Skip to contentSkip to conversation

pNFS writeback fixes

PATCH New Trond Myklebust 1 participant 4 messages Apr 29, 2017

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

cover pNFS writeback fixes

Fix up the pNFS flexfiles writeback code to respect the flag FF_FLAGS_NO_IO_THRU_MDS.

Fix up the client to clear out requests that are queued for commit if we are told the layout has been revoked or otherwise lost.

Trond Myklebust (3):
pNFS/flexfiles: Fix up the ff_layout_write_pagelist failure path
pNFS: Don't send COMMITs to the DSes if the server invalidated our
layout
pNFS: Ensure we commit the layout if it has been invalidated

 fs/nfs/flexfilelayout/flexfilelayout.c | 11 ++++++++---
 fs/nfs/nfs42proc.c                     |  1 +
 fs/nfs/nfs4proc.c                      |  1 +
 fs/nfs/pnfs.c                          | 17 ++++++++++++++++-
 fs/nfs/pnfs_nfs.c                      |  7 +++++++
 5 files changed, 33 insertions(+), 4 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/3 pNFS/flexfiles: Fix up the ff_layout_write_pagelist failure path

If the attempt to write through pNFS fails, we need to use the same failure semantics as for the read path: If the FF_FLAGS_NO_IO_THRU_MDS flag is set or we have sufficient valid DSes, then we must retry through pNFS

Fixes d67ae825a59d ("pnfs/flexfiles: Add the FlexFile Layout Driver")
---
 fs/nfs/flexfilelayout/flexfilelayout.c | 11 ++++++++---
 fs/nfs/pnfs.c                          | 14 +++++++++++++-
 2 files changed, 21 insertions(+), 4 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +8 -3
index f23b63eb356e..4e8bf02a62f9 100644
@@ -1802,16 +1802,16 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
 
 	ds = nfs4_ff_layout_prepare_ds(lseg, idx, true);
 	if (!ds)
-		return PNFS_NOT_ATTEMPTED;
+		goto out_failed;
 
 	ds_clnt = nfs4_ff_find_or_create_ds_client(lseg, idx, ds->ds_clp,
 						   hdr->inode);
 	if (IS_ERR(ds_clnt))
-		return PNFS_NOT_ATTEMPTED;
+		goto out_failed;
 
 	ds_cred = ff_layout_get_ds_cred(lseg, idx, hdr->cred);
 	if (!ds_cred)
-		return PNFS_NOT_ATTEMPTED;
+		goto out_failed;
 
 	vers = nfs4_ff_layout_ds_version(lseg, idx);
 
@@ -1841,6 +1841,11 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
 			  sync, RPC_TASK_SOFTCONN);
 	put_rpccred(ds_cred);
 	return PNFS_ATTEMPTED;
+
+out_failed:
+	if (ff_layout_avoid_mds_available_ds(lseg))
+		return PNFS_TRY_AGAIN;
+	return PNFS_NOT_ATTEMPTED;
 }
 
 static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i)
fs/nfs/pnfs.c +13 -1
index e45b3ffeda08..6c2e4c73684c 100644
@@ -2292,8 +2292,20 @@ pnfs_do_write(struct nfs_pageio_descriptor *desc,
 	enum pnfs_try_status trypnfs;
 
 	trypnfs = pnfs_try_to_write_data(hdr, call_ops, lseg, how);
-	if (trypnfs == PNFS_NOT_ATTEMPTED)
+	switch (trypnfs) {
+	case PNFS_NOT_ATTEMPTED:
 		pnfs_write_through_mds(desc, hdr);
+	case PNFS_ATTEMPTED:
+		break;
+	case PNFS_TRY_AGAIN:
+		/* cleanup hdr and prepare to redo pnfs */
+		if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) {
+			struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
+			list_splice_init(&hdr->pages, &mirror->pg_list);
+			mirror->pg_recoalesce = 1;
+		}
+		hdr->mds_ops->rpc_release(hdr);
+	}
 }
 
 static void pnfs_writehdr_free(struct nfs_pgio_header *hdr)
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/3 pNFS: Don't send COMMITs to the DSes if the server invalidated our layout

If the layout was invalidated, then assume we should requeue all the pending writes for the DS in question.

---
 fs/nfs/pnfs_nfs.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/nfs/pnfs_nfs.c +7 -0
index dc4111d08a27..7697ac0ff81a 100644
@@ -217,6 +217,13 @@ pnfs_generic_alloc_ds_commits(struct nfs_commit_info *cinfo,
 	for (i = 0; i < fl_cinfo->nbuckets; i++, bucket++) {
 		if (list_empty(&bucket->committing))
 			continue;
+		/*
+		 * If the layout segment is invalid, then let
+		 * pnfs_generic_retry_commit() clean up the bucket.
+		 */
+		if (!pnfs_is_valid_lseg(bucket->clseg) &&
+		    !test_bit(NFS_LSEG_LAYOUTRETURN, &bucket->clseg->pls_flags))
+			continue;
 		data = nfs_commitdata_alloc(false);
 		if (!data)
 			break;
Signature · 1 line
2.9.3
#3 lore raw

PATCH 3/3 pNFS: Ensure we commit the layout if it has been invalidated

If the layout is being invalidated on the server, then we must invoke nfs_commit_inode() to ensure any commits to the DS get cleared out.

---
 fs/nfs/nfs42proc.c | 1 +
 fs/nfs/nfs4proc.c  | 1 +
 fs/nfs/pnfs.c      | 3 +++
 3 files changed, 5 insertions(+)
fs/nfs/nfs42proc.c +1 -0
index c81c61971625..87f5b7b971ca 100644
@@ -379,6 +379,7 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata)
 			pnfs_mark_layout_stateid_invalid(lo, &head);
 			spin_unlock(&inode->i_lock);
 			pnfs_free_lseg_list(&head);
+			nfs_commit_inode(inode, 0);
 		} else
 			spin_unlock(&inode->i_lock);
 		break;
fs/nfs/nfs4proc.c +1 -0
index c2b82caa9068..158c3d52146f 100644
@@ -8330,6 +8330,7 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
 		 */
 		pnfs_mark_layout_stateid_invalid(lo, &head);
 		spin_unlock(&inode->i_lock);
+		nfs_commit_inode(inode, 0);
 		pnfs_free_lseg_list(&head);
 		status = -EAGAIN;
 		goto out;
fs/nfs/pnfs.c +3 -0
index 6c2e4c73684c..140ecd7d350f 100644
@@ -727,6 +727,7 @@ pnfs_destroy_layout(struct nfs_inode *nfsi)
 		pnfs_layout_clear_fail_bit(lo, NFS_LAYOUT_RW_FAILED);
 		spin_unlock(&nfsi->vfs_inode.i_lock);
 		pnfs_free_lseg_list(&tmp_list);
+		nfs_commit_inode(&nfsi->vfs_inode, 0);
 		pnfs_put_layout_hdr(lo);
 	} else
 		spin_unlock(&nfsi->vfs_inode.i_lock);
@@ -1989,6 +1990,8 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)
 	spin_unlock(&ino->i_lock);
 	lseg->pls_layout = lo;
 	NFS_SERVER(ino)->pnfs_curr_ld->free_lseg(lseg);
+	if (!pnfs_layout_is_valid(lo))
+		nfs_commit_inode(ino, 0);
 	return ERR_PTR(-EAGAIN);
 }
 
Signature · 1 line
2.9.3