Skip to content

Commit 2a75cfa

Browse files
Stanislav KinsburskyJ. Bruce Fields
authored andcommitted
nfsd: pass pointer to export cache down to stack wherever possible.
This cache will be per-net soon. And it's easier to get the pointer to desired per-net instance only once and then pass it down instead of discovering it in every place were required. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent b89109b commit 2a75cfa

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

‎fs/nfsd/export.c‎

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,8 @@ exp_find_key(struct cache_detail *cd, svc_client *clp, int fsid_type,
785785
}
786786

787787

788-
static svc_export *exp_get_by_name(svc_client *clp, const struct path *path,
789-
struct cache_req *reqp)
788+
static svc_export *exp_get_by_name(struct cache_detail *cd, svc_client *clp,
789+
const struct path *path, struct cache_req *reqp)
790790
{
791791
struct svc_export *exp, key;
792792
int err;
@@ -796,12 +796,12 @@ static svc_export *exp_get_by_name(svc_client *clp, const struct path *path,
796796

797797
key.ex_client = clp;
798798
key.ex_path = *path;
799-
key.cd = &svc_export_cache;
799+
key.cd = cd;
800800

801801
exp = svc_export_lookup(&key);
802802
if (exp == NULL)
803803
return ERR_PTR(-ENOMEM);
804-
err = cache_check(&svc_export_cache, &exp->h, reqp);
804+
err = cache_check(cd, &exp->h, reqp);
805805
if (err)
806806
return ERR_PTR(err);
807807
return exp;
@@ -810,16 +810,17 @@ static svc_export *exp_get_by_name(svc_client *clp, const struct path *path,
810810
/*
811811
* Find the export entry for a given dentry.
812812
*/
813-
static struct svc_export *exp_parent(svc_client *clp, struct path *path)
813+
static struct svc_export *exp_parent(struct cache_detail *cd, svc_client *clp,
814+
struct path *path)
814815
{
815816
struct dentry *saved = dget(path->dentry);
816-
svc_export *exp = exp_get_by_name(clp, path, NULL);
817+
svc_export *exp = exp_get_by_name(cd, clp, path, NULL);
817818

818819
while (PTR_ERR(exp) == -ENOENT && !IS_ROOT(path->dentry)) {
819820
struct dentry *parent = dget_parent(path->dentry);
820821
dput(path->dentry);
821822
path->dentry = parent;
822-
exp = exp_get_by_name(clp, path, NULL);
823+
exp = exp_get_by_name(cd, clp, path, NULL);
823824
}
824825
dput(path->dentry);
825826
path->dentry = saved;
@@ -834,13 +835,15 @@ static struct svc_export *exp_parent(svc_client *clp, struct path *path)
834835
* since its harder to fool a kernel module than a user space program.
835836
*/
836837
int
837-
exp_rootfh(svc_client *clp, char *name, struct knfsd_fh *f, int maxsize)
838+
exp_rootfh(svc_client *clp, char *name,
839+
struct knfsd_fh *f, int maxsize)
838840
{
839841
struct svc_export *exp;
840842
struct path path;
841843
struct inode *inode;
842844
struct svc_fh fh;
843845
int err;
846+
struct cache_detail *cd = &svc_export_cache;
844847

845848
err = -EPERM;
846849
/* NB: we probably ought to check that it's NUL-terminated */
@@ -853,7 +856,7 @@ exp_rootfh(svc_client *clp, char *name, struct knfsd_fh *f, int maxsize)
853856
dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n",
854857
name, path.dentry, clp->name,
855858
inode->i_sb->s_id, inode->i_ino);
856-
exp = exp_parent(clp, &path);
859+
exp = exp_parent(cd, clp, &path);
857860
if (IS_ERR(exp)) {
858861
err = PTR_ERR(exp);
859862
goto out;
@@ -875,15 +878,16 @@ exp_rootfh(svc_client *clp, char *name, struct knfsd_fh *f, int maxsize)
875878
return err;
876879
}
877880

878-
static struct svc_export *exp_find(struct auth_domain *clp, int fsid_type,
881+
static struct svc_export *exp_find(struct cache_detail *cd,
882+
struct auth_domain *clp, int fsid_type,
879883
u32 *fsidv, struct cache_req *reqp)
880884
{
881885
struct svc_export *exp;
882886
struct svc_expkey *ek = exp_find_key(&svc_expkey_cache, clp, fsid_type, fsidv, reqp);
883887
if (IS_ERR(ek))
884888
return ERR_CAST(ek);
885889

886-
exp = exp_get_by_name(clp, &ek->ek_path, reqp);
890+
exp = exp_get_by_name(cd, clp, &ek->ek_path, reqp);
887891
cache_put(&ek->h, &svc_expkey_cache);
888892

889893
if (IS_ERR(exp))
@@ -926,12 +930,13 @@ struct svc_export *
926930
rqst_exp_get_by_name(struct svc_rqst *rqstp, struct path *path)
927931
{
928932
struct svc_export *gssexp, *exp = ERR_PTR(-ENOENT);
933+
struct cache_detail *cd = &svc_export_cache;
929934

930935
if (rqstp->rq_client == NULL)
931936
goto gss;
932937

933938
/* First try the auth_unix client: */
934-
exp = exp_get_by_name(rqstp->rq_client, path, &rqstp->rq_chandle);
939+
exp = exp_get_by_name(cd, rqstp->rq_client, path, &rqstp->rq_chandle);
935940
if (PTR_ERR(exp) == -ENOENT)
936941
goto gss;
937942
if (IS_ERR(exp))
@@ -943,7 +948,7 @@ rqst_exp_get_by_name(struct svc_rqst *rqstp, struct path *path)
943948
/* Otherwise, try falling back on gss client */
944949
if (rqstp->rq_gssclient == NULL)
945950
return exp;
946-
gssexp = exp_get_by_name(rqstp->rq_gssclient, path, &rqstp->rq_chandle);
951+
gssexp = exp_get_by_name(cd, rqstp->rq_gssclient, path, &rqstp->rq_chandle);
947952
if (PTR_ERR(gssexp) == -ENOENT)
948953
return exp;
949954
if (!IS_ERR(exp))
@@ -955,12 +960,14 @@ struct svc_export *
955960
rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv)
956961
{
957962
struct svc_export *gssexp, *exp = ERR_PTR(-ENOENT);
963+
struct cache_detail *cd = &svc_export_cache;
958964

959965
if (rqstp->rq_client == NULL)
960966
goto gss;
961967

962968
/* First try the auth_unix client: */
963-
exp = exp_find(rqstp->rq_client, fsid_type, fsidv, &rqstp->rq_chandle);
969+
exp = exp_find(cd, rqstp->rq_client, fsid_type,
970+
fsidv, &rqstp->rq_chandle);
964971
if (PTR_ERR(exp) == -ENOENT)
965972
goto gss;
966973
if (IS_ERR(exp))
@@ -972,7 +979,7 @@ rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv)
972979
/* Otherwise, try falling back on gss client */
973980
if (rqstp->rq_gssclient == NULL)
974981
return exp;
975-
gssexp = exp_find(rqstp->rq_gssclient, fsid_type, fsidv,
982+
gssexp = exp_find(cd, rqstp->rq_gssclient, fsid_type, fsidv,
976983
&rqstp->rq_chandle);
977984
if (PTR_ERR(gssexp) == -ENOENT)
978985
return exp;

0 commit comments

Comments
 (0)