]> git.baikalelectronics.ru Git - kernel.git/commitdiff
NFS/flexfile: Simplify nfs4_ff_layout_select_ds_stateid()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 28 Feb 2019 15:49:11 +0000 (10:49 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 2 Mar 2019 03:37:38 +0000 (22:37 -0500)
Pass in a pointer to the mirror rather than forcing another
array access.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/flexfilelayout/flexfilelayout.c
fs/nfs/flexfilelayout/flexfilelayout.h
fs/nfs/flexfilelayout/flexfilelayoutdev.c

index 650df8d109a11f32ac9da9f023b93cad02311740..f9264e1922a28b836367b145c215d9ceb8883843 100644 (file)
@@ -1799,9 +1799,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
        if (fh)
                hdr->args.fh = fh;
 
-       if (vers == 4 &&
-               !nfs4_ff_layout_select_ds_stateid(lseg, idx, &hdr->args.stateid))
-               goto out_failed;
+       nfs4_ff_layout_select_ds_stateid(mirror, &hdr->args.stateid);
 
        /*
         * Note that if we ever decide to split across DSes,
@@ -1867,9 +1865,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
        if (fh)
                hdr->args.fh = fh;
 
-       if (vers == 4 &&
-               !nfs4_ff_layout_select_ds_stateid(lseg, idx, &hdr->args.stateid))
-               goto out_failed;
+       nfs4_ff_layout_select_ds_stateid(mirror, &hdr->args.stateid);
 
        /*
         * Note that if we ever decide to split across DSes,
index 99cfe2e8f32ab061c066332b9eb58e3a555146da..2f369966abf7179c625f5d046e52cbfa1fc80eb0 100644 (file)
@@ -204,10 +204,9 @@ unsigned int ff_layout_fetch_ds_ioerr(struct pnfs_layout_hdr *lo,
                unsigned int maxnum);
 struct nfs_fh *
 nfs4_ff_layout_select_ds_fh(struct nfs4_ff_layout_mirror *mirror);
-int
-nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg,
-                               u32 mirror_idx,
-                               nfs4_stateid *stateid);
+void
+nfs4_ff_layout_select_ds_stateid(const struct nfs4_ff_layout_mirror *mirror,
+               nfs4_stateid *stateid);
 
 struct nfs4_pnfs_ds *
 nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
index 1673935074ccb7e5fefe073755b63ad12f42f648..d8ef4042f25a5314afee9e69a996a4e853313cef 100644 (file)
@@ -357,23 +357,12 @@ nfs4_ff_layout_select_ds_fh(struct nfs4_ff_layout_mirror *mirror)
        return &mirror->fh_versions[0];
 }
 
-int
-nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg,
-                               u32 mirror_idx,
-                               nfs4_stateid *stateid)
+void
+nfs4_ff_layout_select_ds_stateid(const struct nfs4_ff_layout_mirror *mirror,
+               nfs4_stateid *stateid)
 {
-       struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, mirror_idx);
-
-       if (!ff_layout_mirror_valid(lseg, mirror, false)) {
-               pr_err_ratelimited("NFS: %s: No data server for mirror offset index %d\n",
-                       __func__, mirror_idx);
-               goto out;
-       }
-
-       nfs4_stateid_copy(stateid, &mirror->stateid);
-       return 1;
-out:
-       return 0;
+       if (nfs4_ff_layout_ds_version(mirror) == 4)
+               nfs4_stateid_copy(stateid, &mirror->stateid);
 }
 
 /**