aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2019-02-28 10:34:13 -0500
committerTrond Myklebust <trond.myklebust@hammerspace.com>2019-03-01 22:37:38 -0500
commit749da527b3e7bff92cc76b907bc222ef2df6fcdc (patch)
tree0b01b02bbedf1fa5309f10e7ab2db3fec1f00bb2
parent76c6690522bb3e335ce1e201360df8776cab4d2c (diff)
NFS/flexfiles: Simplify nfs4_ff_layout_select_ds_fh()
Pass in a pointer to the mirror rather than having to retrieve it from the array and then verify the resulting pointer. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c4
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.h2
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayoutdev.c15
3 files changed, 5 insertions, 16 deletions
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 44ccfce3784e..f57cb38bd286 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1795,7 +1795,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
1795 hdr->pgio_done_cb = ff_layout_read_done_cb; 1795 hdr->pgio_done_cb = ff_layout_read_done_cb;
1796 refcount_inc(&ds->ds_clp->cl_count); 1796 refcount_inc(&ds->ds_clp->cl_count);
1797 hdr->ds_clp = ds->ds_clp; 1797 hdr->ds_clp = ds->ds_clp;
1798 fh = nfs4_ff_layout_select_ds_fh(lseg, idx); 1798 fh = nfs4_ff_layout_select_ds_fh(mirror);
1799 if (fh) 1799 if (fh)
1800 hdr->args.fh = fh; 1800 hdr->args.fh = fh;
1801 1801
@@ -1863,7 +1863,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
1863 refcount_inc(&ds->ds_clp->cl_count); 1863 refcount_inc(&ds->ds_clp->cl_count);
1864 hdr->ds_clp = ds->ds_clp; 1864 hdr->ds_clp = ds->ds_clp;
1865 hdr->ds_commit_idx = idx; 1865 hdr->ds_commit_idx = idx;
1866 fh = nfs4_ff_layout_select_ds_fh(lseg, idx); 1866 fh = nfs4_ff_layout_select_ds_fh(mirror);
1867 if (fh) 1867 if (fh)
1868 hdr->args.fh = fh; 1868 hdr->args.fh = fh;
1869 1869
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h
index 2e3c606625ef..935cba942834 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.h
+++ b/fs/nfs/flexfilelayout/flexfilelayout.h
@@ -203,7 +203,7 @@ unsigned int ff_layout_fetch_ds_ioerr(struct pnfs_layout_hdr *lo,
203 struct list_head *head, 203 struct list_head *head,
204 unsigned int maxnum); 204 unsigned int maxnum);
205struct nfs_fh * 205struct nfs_fh *
206nfs4_ff_layout_select_ds_fh(struct pnfs_layout_segment *lseg, u32 mirror_idx); 206nfs4_ff_layout_select_ds_fh(struct nfs4_ff_layout_mirror *mirror);
207int 207int
208nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg, 208nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg,
209 u32 mirror_idx, 209 u32 mirror_idx,
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index 7fd92226e4b9..3a2419313fe9 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -351,21 +351,10 @@ ff_layout_get_mirror_cred(struct nfs4_ff_layout_mirror *mirror, u32 iomode)
351} 351}
352 352
353struct nfs_fh * 353struct nfs_fh *
354nfs4_ff_layout_select_ds_fh(struct pnfs_layout_segment *lseg, u32 mirror_idx) 354nfs4_ff_layout_select_ds_fh(struct nfs4_ff_layout_mirror *mirror)
355{ 355{
356 struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, mirror_idx);
357 struct nfs_fh *fh = NULL;
358
359 if (!ff_layout_mirror_valid(lseg, mirror, false)) {
360 pr_err_ratelimited("NFS: %s: No data server for mirror offset index %d\n",
361 __func__, mirror_idx);
362 goto out;
363 }
364
365 /* FIXME: For now assume there is only 1 version available for the DS */ 356 /* FIXME: For now assume there is only 1 version available for the DS */
366 fh = &mirror->fh_versions[0]; 357 return &mirror->fh_versions[0];
367out:
368 return fh;
369} 358}
370 359
371int 360int