]> git.baikalelectronics.ru Git - kernel.git/commitdiff
NFS/flexfiles: Simplify ff_layout_get_ds_cred()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 28 Feb 2019 15:41:57 +0000 (10:41 -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 88b9190b761b543d0e63bd5e4252cb27c01a5cb0..24a7d74743ffac3f2e068662e85a07193d56ee53 100644 (file)
@@ -1783,7 +1783,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
        if (IS_ERR(ds_clnt))
                goto out_failed;
 
-       ds_cred = ff_layout_get_ds_cred(lseg, idx, hdr->cred);
+       ds_cred = ff_layout_get_ds_cred(mirror, &lseg->pls_range, hdr->cred);
        if (!ds_cred)
                goto out_failed;
 
@@ -1848,7 +1848,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
        if (IS_ERR(ds_clnt))
                goto out_failed;
 
-       ds_cred = ff_layout_get_ds_cred(lseg, idx, hdr->cred);
+       ds_cred = ff_layout_get_ds_cred(mirror, &lseg->pls_range, hdr->cred);
        if (!ds_cred)
                goto out_failed;
 
@@ -1933,7 +1933,7 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how)
        if (IS_ERR(ds_clnt))
                goto out_err;
 
-       ds_cred = ff_layout_get_ds_cred(lseg, idx, data->cred);
+       ds_cred = ff_layout_get_ds_cred(mirror, &lseg->pls_range, data->cred);
        if (!ds_cred)
                goto out_err;
 
index 2bda4baa655acf422f7e259e904d3faa0d913cab..e0b2c3deae5a9e2e3bd3f05f156063dfecab0eed 100644 (file)
@@ -218,8 +218,9 @@ struct rpc_clnt *
 nfs4_ff_find_or_create_ds_client(struct nfs4_ff_layout_mirror *mirror,
                                 struct nfs_client *ds_clp,
                                 struct inode *inode);
-const struct cred *ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg,
-                                      u32 ds_idx, const struct cred *mdscred);
+const struct cred *ff_layout_get_ds_cred(struct nfs4_ff_layout_mirror *mirror,
+                                        const struct pnfs_layout_range *range,
+                                        const struct cred *mdscred);
 bool ff_layout_avoid_mds_available_ds(struct pnfs_layout_segment *lseg);
 bool ff_layout_avoid_read_on_rw(struct pnfs_layout_segment *lseg);
 
index 1fe66745f452b83a0105810a4b379211586aec24..1673935074ccb7e5fefe073755b63ad12f42f648 100644 (file)
@@ -446,14 +446,14 @@ out:
 }
 
 const struct cred *
-ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg, u32 ds_idx,
+ff_layout_get_ds_cred(struct nfs4_ff_layout_mirror *mirror,
+                     const struct pnfs_layout_range *range,
                      const struct cred *mdscred)
 {
-       struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, ds_idx);
        const struct cred *cred;
 
        if (mirror && !mirror->mirror_ds->ds_versions[0].tightly_coupled) {
-               cred = ff_layout_get_mirror_cred(mirror, lseg->pls_range.iomode);
+               cred = ff_layout_get_mirror_cred(mirror, range->iomode);
                if (!cred)
                        cred = get_cred(mdscred);
        } else {