aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/flexfilelayout
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2015-11-02 10:11:17 -0500
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-11-02 13:50:35 -0500
commit135444126a1175912b43366f6109cb297018f034 (patch)
treeb16d9fbad0053f1949873af5f3793443495c9364 /fs/nfs/flexfilelayout
parenta85240d2543e1947868d81aab44e36bea6bb876e (diff)
pNFS/flexfiles: When mirrored, retry failed reads by switching mirrors
If the pNFS/flexfiles file is mirrored, and a read to one mirror fails, then we should bump the mirror index, so that we retry to a different mirror. Once we've iterated through all mirrors and all failed, we can return the layout and issue a new LAYOUTGET. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/flexfilelayout')
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index fbc5a56de875..7fc14b90886e 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -741,17 +741,17 @@ ff_layout_alloc_commit_info(struct pnfs_layout_segment *lseg,
741} 741}
742 742
743static struct nfs4_pnfs_ds * 743static struct nfs4_pnfs_ds *
744ff_layout_choose_best_ds_for_read(struct nfs_pageio_descriptor *pgio, 744ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg,
745 int start_idx,
745 int *best_idx) 746 int *best_idx)
746{ 747{
747 struct nfs4_ff_layout_segment *fls; 748 struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg);
748 struct nfs4_pnfs_ds *ds; 749 struct nfs4_pnfs_ds *ds;
749 int idx; 750 int idx;
750 751
751 fls = FF_LAYOUT_LSEG(pgio->pg_lseg);
752 /* mirrors are sorted by efficiency */ 752 /* mirrors are sorted by efficiency */
753 for (idx = 0; idx < fls->mirror_array_cnt; idx++) { 753 for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) {
754 ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, idx, false); 754 ds = nfs4_ff_layout_prepare_ds(lseg, idx, false);
755 if (ds) { 755 if (ds) {
756 *best_idx = idx; 756 *best_idx = idx;
757 return ds; 757 return ds;
@@ -782,7 +782,7 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio,
782 if (pgio->pg_lseg == NULL) 782 if (pgio->pg_lseg == NULL)
783 goto out_mds; 783 goto out_mds;
784 784
785 ds = ff_layout_choose_best_ds_for_read(pgio, &ds_idx); 785 ds = ff_layout_choose_best_ds_for_read(pgio->pg_lseg, 0, &ds_idx);
786 if (!ds) 786 if (!ds)
787 goto out_mds; 787 goto out_mds;
788 mirror = FF_LAYOUT_COMP(pgio->pg_lseg, ds_idx); 788 mirror = FF_LAYOUT_COMP(pgio->pg_lseg, ds_idx);
@@ -1171,6 +1171,10 @@ static int ff_layout_read_done_cb(struct rpc_task *task,
1171 1171
1172 switch (err) { 1172 switch (err) {
1173 case -NFS4ERR_RESET_TO_PNFS: 1173 case -NFS4ERR_RESET_TO_PNFS:
1174 if (ff_layout_choose_best_ds_for_read(hdr->lseg,
1175 hdr->pgio_mirror_idx + 1,
1176 &hdr->pgio_mirror_idx))
1177 goto out_eagain;
1174 set_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE, 1178 set_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE,
1175 &hdr->lseg->pls_layout->plh_flags); 1179 &hdr->lseg->pls_layout->plh_flags);
1176 pnfs_read_resend_pnfs(hdr); 1180 pnfs_read_resend_pnfs(hdr);
@@ -1179,11 +1183,13 @@ static int ff_layout_read_done_cb(struct rpc_task *task,
1179 ff_layout_reset_read(hdr); 1183 ff_layout_reset_read(hdr);
1180 return task->tk_status; 1184 return task->tk_status;
1181 case -EAGAIN: 1185 case -EAGAIN:
1182 rpc_restart_call_prepare(task); 1186 goto out_eagain;
1183 return -EAGAIN;
1184 } 1187 }
1185 1188
1186 return 0; 1189 return 0;
1190out_eagain:
1191 rpc_restart_call_prepare(task);
1192 return -EAGAIN;
1187} 1193}
1188 1194
1189static bool 1195static bool