Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stanislav Kinsbursky and committed by
J. Bruce Fields
2a75cfa6 b89109be

+22 -15
+22 -15
fs/nfsd/export.c
··· 785 785 } 786 786 787 787 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) 790 790 { 791 791 struct svc_export *exp, key; 792 792 int err; ··· 796 796 797 797 key.ex_client = clp; 798 798 key.ex_path = *path; 799 - key.cd = &svc_export_cache; 799 + key.cd = cd; 800 800 801 801 exp = svc_export_lookup(&key); 802 802 if (exp == NULL) 803 803 return ERR_PTR(-ENOMEM); 804 - err = cache_check(&svc_export_cache, &exp->h, reqp); 804 + err = cache_check(cd, &exp->h, reqp); 805 805 if (err) 806 806 return ERR_PTR(err); 807 807 return exp; ··· 810 810 /* 811 811 * Find the export entry for a given dentry. 812 812 */ 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) 814 815 { 815 816 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); 817 818 818 819 while (PTR_ERR(exp) == -ENOENT && !IS_ROOT(path->dentry)) { 819 820 struct dentry *parent = dget_parent(path->dentry); 820 821 dput(path->dentry); 821 822 path->dentry = parent; 822 - exp = exp_get_by_name(clp, path, NULL); 823 + exp = exp_get_by_name(cd, clp, path, NULL); 823 824 } 824 825 dput(path->dentry); 825 826 path->dentry = saved; ··· 835 834 * since its harder to fool a kernel module than a user space program. 836 835 */ 837 836 int 838 - exp_rootfh(svc_client *clp, char *name, struct knfsd_fh *f, int maxsize) 837 + exp_rootfh(svc_client *clp, char *name, 838 + struct knfsd_fh *f, int maxsize) 839 839 { 840 840 struct svc_export *exp; 841 841 struct path path; 842 842 struct inode *inode; 843 843 struct svc_fh fh; 844 844 int err; 845 + struct cache_detail *cd = &svc_export_cache; 845 846 846 847 err = -EPERM; 847 848 /* NB: we probably ought to check that it's NUL-terminated */ ··· 856 853 dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n", 857 854 name, path.dentry, clp->name, 858 855 inode->i_sb->s_id, inode->i_ino); 859 - exp = exp_parent(clp, &path); 856 + exp = exp_parent(cd, clp, &path); 860 857 if (IS_ERR(exp)) { 861 858 err = PTR_ERR(exp); 862 859 goto out; ··· 878 875 return err; 879 876 } 880 877 881 - static struct svc_export *exp_find(struct auth_domain *clp, int fsid_type, 878 + static struct svc_export *exp_find(struct cache_detail *cd, 879 + struct auth_domain *clp, int fsid_type, 882 880 u32 *fsidv, struct cache_req *reqp) 883 881 { 884 882 struct svc_export *exp; ··· 887 883 if (IS_ERR(ek)) 888 884 return ERR_CAST(ek); 889 885 890 - exp = exp_get_by_name(clp, &ek->ek_path, reqp); 886 + exp = exp_get_by_name(cd, clp, &ek->ek_path, reqp); 891 887 cache_put(&ek->h, &svc_expkey_cache); 892 888 893 889 if (IS_ERR(exp)) ··· 930 926 rqst_exp_get_by_name(struct svc_rqst *rqstp, struct path *path) 931 927 { 932 928 struct svc_export *gssexp, *exp = ERR_PTR(-ENOENT); 929 + struct cache_detail *cd = &svc_export_cache; 933 930 934 931 if (rqstp->rq_client == NULL) 935 932 goto gss; 936 933 937 934 /* First try the auth_unix client: */ 938 - exp = exp_get_by_name(rqstp->rq_client, path, &rqstp->rq_chandle); 935 + exp = exp_get_by_name(cd, rqstp->rq_client, path, &rqstp->rq_chandle); 939 936 if (PTR_ERR(exp) == -ENOENT) 940 937 goto gss; 941 938 if (IS_ERR(exp)) ··· 948 943 /* Otherwise, try falling back on gss client */ 949 944 if (rqstp->rq_gssclient == NULL) 950 945 return exp; 951 - gssexp = exp_get_by_name(rqstp->rq_gssclient, path, &rqstp->rq_chandle); 946 + gssexp = exp_get_by_name(cd, rqstp->rq_gssclient, path, &rqstp->rq_chandle); 952 947 if (PTR_ERR(gssexp) == -ENOENT) 953 948 return exp; 954 949 if (!IS_ERR(exp)) ··· 960 955 rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv) 961 956 { 962 957 struct svc_export *gssexp, *exp = ERR_PTR(-ENOENT); 958 + struct cache_detail *cd = &svc_export_cache; 963 959 964 960 if (rqstp->rq_client == NULL) 965 961 goto gss; 966 962 967 963 /* First try the auth_unix client: */ 968 - exp = exp_find(rqstp->rq_client, fsid_type, fsidv, &rqstp->rq_chandle); 964 + exp = exp_find(cd, rqstp->rq_client, fsid_type, 965 + fsidv, &rqstp->rq_chandle); 969 966 if (PTR_ERR(exp) == -ENOENT) 970 967 goto gss; 971 968 if (IS_ERR(exp)) ··· 979 972 /* Otherwise, try falling back on gss client */ 980 973 if (rqstp->rq_gssclient == NULL) 981 974 return exp; 982 - gssexp = exp_find(rqstp->rq_gssclient, fsid_type, fsidv, 975 + gssexp = exp_find(cd, rqstp->rq_gssclient, fsid_type, fsidv, 983 976 &rqstp->rq_chandle); 984 977 if (PTR_ERR(gssexp) == -ENOENT) 985 978 return exp;