aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2013-02-04 06:02:50 -0500
committerJ. Bruce Fields <bfields@redhat.com>2013-02-15 10:43:46 -0500
commit2d4383383b0b04ca380b67aa2d7397d0b399dcbf (patch)
treef9e8bddc466c2c8dfdcf039aca4d53752e524fb9
parent73fb847a44224d5708550e4be7baba9da75e00af (diff)
SUNRPC: rework cache upcall logic
For most of SUNRPC caches (except NFS DNS cache) cache_detail->cache_upcall is redundant since all that it's implementations are doing is calling sunrpc_cache_pipe_upcall() with proper function address argument. Cache request function address is now stored on cache_detail structure and thus all the code can be simplified. Now, for those cache details, which doesn't have cache_upcall callback (the only one, which still has is nfs_dns_resolve_template) sunrpc_cache_pipe_upcall will be called instead. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--fs/nfsd/export.c12
-rw-r--r--fs/nfsd/nfs4idmap.c14
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c7
-rw-r--r--net/sunrpc/cache.c11
-rw-r--r--net/sunrpc/svcauth_unix.c12
5 files changed, 7 insertions, 49 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 0e16c7fa6800..15ebf91982b0 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -67,11 +67,6 @@ static void expkey_request(struct cache_detail *cd,
67 (*bpp)[-1] = '\n'; 67 (*bpp)[-1] = '\n';
68} 68}
69 69
70static int expkey_upcall(struct cache_detail *cd, struct cache_head *h)
71{
72 return sunrpc_cache_pipe_upcall(cd, h, cd->cache_request);
73}
74
75static struct svc_expkey *svc_expkey_update(struct cache_detail *cd, struct svc_expkey *new, 70static struct svc_expkey *svc_expkey_update(struct cache_detail *cd, struct svc_expkey *new,
76 struct svc_expkey *old); 71 struct svc_expkey *old);
77static struct svc_expkey *svc_expkey_lookup(struct cache_detail *cd, struct svc_expkey *); 72static struct svc_expkey *svc_expkey_lookup(struct cache_detail *cd, struct svc_expkey *);
@@ -245,7 +240,6 @@ static struct cache_detail svc_expkey_cache_template = {
245 .hash_size = EXPKEY_HASHMAX, 240 .hash_size = EXPKEY_HASHMAX,
246 .name = "nfsd.fh", 241 .name = "nfsd.fh",
247 .cache_put = expkey_put, 242 .cache_put = expkey_put,
248 .cache_upcall = expkey_upcall,
249 .cache_request = expkey_request, 243 .cache_request = expkey_request,
250 .cache_parse = expkey_parse, 244 .cache_parse = expkey_parse,
251 .cache_show = expkey_show, 245 .cache_show = expkey_show,
@@ -339,11 +333,6 @@ static void svc_export_request(struct cache_detail *cd,
339 (*bpp)[-1] = '\n'; 333 (*bpp)[-1] = '\n';
340} 334}
341 335
342static int svc_export_upcall(struct cache_detail *cd, struct cache_head *h)
343{
344 return sunrpc_cache_pipe_upcall(cd, h, cd->cache_request);
345}
346
347static struct svc_export *svc_export_update(struct svc_export *new, 336static struct svc_export *svc_export_update(struct svc_export *new,
348 struct svc_export *old); 337 struct svc_export *old);
349static struct svc_export *svc_export_lookup(struct svc_export *); 338static struct svc_export *svc_export_lookup(struct svc_export *);
@@ -714,7 +703,6 @@ static struct cache_detail svc_export_cache_template = {
714 .hash_size = EXPORT_HASHMAX, 703 .hash_size = EXPORT_HASHMAX,
715 .name = "nfsd.export", 704 .name = "nfsd.export",
716 .cache_put = svc_export_put, 705 .cache_put = svc_export_put,
717 .cache_upcall = svc_export_upcall,
718 .cache_request = svc_export_request, 706 .cache_request = svc_export_request,
719 .cache_parse = svc_export_parse, 707 .cache_parse = svc_export_parse,
720 .cache_show = svc_export_show, 708 .cache_show = svc_export_show,
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 9033dfde1812..d9402ea9d751 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -140,12 +140,6 @@ idtoname_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
140} 140}
141 141
142static int 142static int
143idtoname_upcall(struct cache_detail *cd, struct cache_head *ch)
144{
145 return sunrpc_cache_pipe_upcall(cd, ch, cd->cache_request);
146}
147
148static int
149idtoname_match(struct cache_head *ca, struct cache_head *cb) 143idtoname_match(struct cache_head *ca, struct cache_head *cb)
150{ 144{
151 struct ent *a = container_of(ca, struct ent, h); 145 struct ent *a = container_of(ca, struct ent, h);
@@ -192,7 +186,6 @@ static struct cache_detail idtoname_cache_template = {
192 .hash_size = ENT_HASHMAX, 186 .hash_size = ENT_HASHMAX,
193 .name = "nfs4.idtoname", 187 .name = "nfs4.idtoname",
194 .cache_put = ent_put, 188 .cache_put = ent_put,
195 .cache_upcall = idtoname_upcall,
196 .cache_request = idtoname_request, 189 .cache_request = idtoname_request,
197 .cache_parse = idtoname_parse, 190 .cache_parse = idtoname_parse,
198 .cache_show = idtoname_show, 191 .cache_show = idtoname_show,
@@ -322,12 +315,6 @@ nametoid_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
322} 315}
323 316
324static int 317static int
325nametoid_upcall(struct cache_detail *cd, struct cache_head *ch)
326{
327 return sunrpc_cache_pipe_upcall(cd, ch, cd->cache_request);
328}
329
330static int
331nametoid_match(struct cache_head *ca, struct cache_head *cb) 318nametoid_match(struct cache_head *ca, struct cache_head *cb)
332{ 319{
333 struct ent *a = container_of(ca, struct ent, h); 320 struct ent *a = container_of(ca, struct ent, h);
@@ -366,7 +353,6 @@ static struct cache_detail nametoid_cache_template = {
366 .hash_size = ENT_HASHMAX, 353 .hash_size = ENT_HASHMAX,
367 .name = "nfs4.nametoid", 354 .name = "nfs4.nametoid",
368 .cache_put = ent_put, 355 .cache_put = ent_put,
369 .cache_upcall = nametoid_upcall,
370 .cache_request = nametoid_request, 356 .cache_request = nametoid_request,
371 .cache_parse = nametoid_parse, 357 .cache_parse = nametoid_parse,
372 .cache_show = nametoid_show, 358 .cache_show = nametoid_show,
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 1b0df530b59d..eb2b1f74d054 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -182,12 +182,6 @@ static void rsi_request(struct cache_detail *cd,
182 (*bpp)[-1] = '\n'; 182 (*bpp)[-1] = '\n';
183} 183}
184 184
185static int rsi_upcall(struct cache_detail *cd, struct cache_head *h)
186{
187 return sunrpc_cache_pipe_upcall(cd, h, cd->cache_request);
188}
189
190
191static int rsi_parse(struct cache_detail *cd, 185static int rsi_parse(struct cache_detail *cd,
192 char *mesg, int mlen) 186 char *mesg, int mlen)
193{ 187{
@@ -275,7 +269,6 @@ static struct cache_detail rsi_cache_template = {
275 .hash_size = RSI_HASHMAX, 269 .hash_size = RSI_HASHMAX,
276 .name = "auth.rpcsec.init", 270 .name = "auth.rpcsec.init",
277 .cache_put = rsi_put, 271 .cache_put = rsi_put,
278 .cache_upcall = rsi_upcall,
279 .cache_request = rsi_request, 272 .cache_request = rsi_request,
280 .cache_parse = rsi_parse, 273 .cache_parse = rsi_parse,
281 .match = rsi_match, 274 .match = rsi_match,
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 9f8470353362..51853d8ed0bc 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -196,9 +196,9 @@ EXPORT_SYMBOL_GPL(sunrpc_cache_update);
196 196
197static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h) 197static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h)
198{ 198{
199 if (!cd->cache_upcall) 199 if (cd->cache_upcall)
200 return -EINVAL; 200 return cd->cache_upcall(cd, h);
201 return cd->cache_upcall(cd, h); 201 return sunrpc_cache_pipe_upcall(cd, h, cd->cache_request);
202} 202}
203 203
204static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h) 204static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h)
@@ -1152,6 +1152,9 @@ int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h,
1152 char *bp; 1152 char *bp;
1153 int len; 1153 int len;
1154 1154
1155 if (!detail->cache_request)
1156 return -EINVAL;
1157
1155 if (!cache_listeners_exist(detail)) { 1158 if (!cache_listeners_exist(detail)) {
1156 warn_no_listener(detail); 1159 warn_no_listener(detail);
1157 return -EINVAL; 1160 return -EINVAL;
@@ -1605,7 +1608,7 @@ static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
1605 if (p == NULL) 1608 if (p == NULL)
1606 goto out_nomem; 1609 goto out_nomem;
1607 1610
1608 if (cd->cache_upcall || cd->cache_parse) { 1611 if (cd->cache_request || cd->cache_parse) {
1609 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR, 1612 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR,
1610 cd->u.procfs.proc_ent, 1613 cd->u.procfs.proc_ent,
1611 &cache_file_operations_procfs, cd); 1614 &cache_file_operations_procfs, cd);
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 18b8742eaa50..5085804ec8a7 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -157,11 +157,6 @@ static void ip_map_request(struct cache_detail *cd,
157 (*bpp)[-1] = '\n'; 157 (*bpp)[-1] = '\n';
158} 158}
159 159
160static int ip_map_upcall(struct cache_detail *cd, struct cache_head *h)
161{
162 return sunrpc_cache_pipe_upcall(cd, h, cd->cache_request);
163}
164
165static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class, struct in6_addr *addr); 160static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class, struct in6_addr *addr);
166static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, struct unix_domain *udom, time_t expiry); 161static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, struct unix_domain *udom, time_t expiry);
167 162
@@ -470,11 +465,6 @@ static void unix_gid_request(struct cache_detail *cd,
470 (*bpp)[-1] = '\n'; 465 (*bpp)[-1] = '\n';
471} 466}
472 467
473static int unix_gid_upcall(struct cache_detail *cd, struct cache_head *h)
474{
475 return sunrpc_cache_pipe_upcall(cd, h, cd->cache_request);
476}
477
478static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, uid_t uid); 468static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, uid_t uid);
479 469
480static int unix_gid_parse(struct cache_detail *cd, 470static int unix_gid_parse(struct cache_detail *cd,
@@ -577,7 +567,6 @@ static struct cache_detail unix_gid_cache_template = {
577 .hash_size = GID_HASHMAX, 567 .hash_size = GID_HASHMAX,
578 .name = "auth.unix.gid", 568 .name = "auth.unix.gid",
579 .cache_put = unix_gid_put, 569 .cache_put = unix_gid_put,
580 .cache_upcall = unix_gid_upcall,
581 .cache_request = unix_gid_request, 570 .cache_request = unix_gid_request,
582 .cache_parse = unix_gid_parse, 571 .cache_parse = unix_gid_parse,
583 .cache_show = unix_gid_show, 572 .cache_show = unix_gid_show,
@@ -875,7 +864,6 @@ static struct cache_detail ip_map_cache_template = {
875 .hash_size = IP_HASHMAX, 864 .hash_size = IP_HASHMAX,
876 .name = "auth.unix.ip", 865 .name = "auth.unix.ip",
877 .cache_put = ip_map_put, 866 .cache_put = ip_map_put,
878 .cache_upcall = ip_map_upcall,
879 .cache_request = ip_map_request, 867 .cache_request = ip_map_request,
880 .cache_parse = ip_map_parse, 868 .cache_parse = ip_map_parse,
881 .cache_show = ip_map_show, 869 .cache_show = ip_map_show,