aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/dns_resolve.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/dns_resolve.c')
-rw-r--r--fs/nfs/dns_resolve.c67
1 files changed, 28 insertions, 39 deletions
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index ca4b11ec87a2..945527092295 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/sunrpc/clnt.h> 12#include <linux/sunrpc/clnt.h>
13#include <linux/sunrpc/addr.h>
13#include <linux/dns_resolver.h> 14#include <linux/dns_resolver.h>
14#include "dns_resolve.h" 15#include "dns_resolve.h"
15 16
@@ -42,6 +43,7 @@ EXPORT_SYMBOL_GPL(nfs_dns_resolve_name);
42#include <linux/seq_file.h> 43#include <linux/seq_file.h>
43#include <linux/inet.h> 44#include <linux/inet.h>
44#include <linux/sunrpc/clnt.h> 45#include <linux/sunrpc/clnt.h>
46#include <linux/sunrpc/addr.h>
45#include <linux/sunrpc/cache.h> 47#include <linux/sunrpc/cache.h>
46#include <linux/sunrpc/svcauth.h> 48#include <linux/sunrpc/svcauth.h>
47#include <linux/sunrpc/rpc_pipe_fs.h> 49#include <linux/sunrpc/rpc_pipe_fs.h>
@@ -142,7 +144,7 @@ static int nfs_dns_upcall(struct cache_detail *cd,
142 144
143 ret = nfs_cache_upcall(cd, key->hostname); 145 ret = nfs_cache_upcall(cd, key->hostname);
144 if (ret) 146 if (ret)
145 ret = sunrpc_cache_pipe_upcall(cd, ch, nfs_dns_request); 147 ret = sunrpc_cache_pipe_upcall(cd, ch);
146 return ret; 148 return ret;
147} 149}
148 150
@@ -351,60 +353,47 @@ ssize_t nfs_dns_resolve_name(struct net *net, char *name,
351} 353}
352EXPORT_SYMBOL_GPL(nfs_dns_resolve_name); 354EXPORT_SYMBOL_GPL(nfs_dns_resolve_name);
353 355
356static struct cache_detail nfs_dns_resolve_template = {
357 .owner = THIS_MODULE,
358 .hash_size = NFS_DNS_HASHTBL_SIZE,
359 .name = "dns_resolve",
360 .cache_put = nfs_dns_ent_put,
361 .cache_upcall = nfs_dns_upcall,
362 .cache_request = nfs_dns_request,
363 .cache_parse = nfs_dns_parse,
364 .cache_show = nfs_dns_show,
365 .match = nfs_dns_match,
366 .init = nfs_dns_ent_init,
367 .update = nfs_dns_ent_update,
368 .alloc = nfs_dns_ent_alloc,
369};
370
371
354int nfs_dns_resolver_cache_init(struct net *net) 372int nfs_dns_resolver_cache_init(struct net *net)
355{ 373{
356 int err = -ENOMEM; 374 int err;
357 struct nfs_net *nn = net_generic(net, nfs_net_id); 375 struct nfs_net *nn = net_generic(net, nfs_net_id);
358 struct cache_detail *cd;
359 struct cache_head **tbl;
360 376
361 cd = kzalloc(sizeof(struct cache_detail), GFP_KERNEL); 377 nn->nfs_dns_resolve = cache_create_net(&nfs_dns_resolve_template, net);
362 if (cd == NULL) 378 if (IS_ERR(nn->nfs_dns_resolve))
363 goto err_cd; 379 return PTR_ERR(nn->nfs_dns_resolve);
364 380
365 tbl = kzalloc(NFS_DNS_HASHTBL_SIZE * sizeof(struct cache_head *), 381 err = nfs_cache_register_net(net, nn->nfs_dns_resolve);
366 GFP_KERNEL);
367 if (tbl == NULL)
368 goto err_tbl;
369
370 cd->owner = THIS_MODULE,
371 cd->hash_size = NFS_DNS_HASHTBL_SIZE,
372 cd->hash_table = tbl,
373 cd->name = "dns_resolve",
374 cd->cache_put = nfs_dns_ent_put,
375 cd->cache_upcall = nfs_dns_upcall,
376 cd->cache_parse = nfs_dns_parse,
377 cd->cache_show = nfs_dns_show,
378 cd->match = nfs_dns_match,
379 cd->init = nfs_dns_ent_init,
380 cd->update = nfs_dns_ent_update,
381 cd->alloc = nfs_dns_ent_alloc,
382
383 nfs_cache_init(cd);
384 err = nfs_cache_register_net(net, cd);
385 if (err) 382 if (err)
386 goto err_reg; 383 goto err_reg;
387 nn->nfs_dns_resolve = cd;
388 return 0; 384 return 0;
389 385
390err_reg: 386err_reg:
391 nfs_cache_destroy(cd); 387 cache_destroy_net(nn->nfs_dns_resolve, net);
392 kfree(cd->hash_table);
393err_tbl:
394 kfree(cd);
395err_cd:
396 return err; 388 return err;
397} 389}
398 390
399void nfs_dns_resolver_cache_destroy(struct net *net) 391void nfs_dns_resolver_cache_destroy(struct net *net)
400{ 392{
401 struct nfs_net *nn = net_generic(net, nfs_net_id); 393 struct nfs_net *nn = net_generic(net, nfs_net_id);
402 struct cache_detail *cd = nn->nfs_dns_resolve;
403 394
404 nfs_cache_unregister_net(net, cd); 395 nfs_cache_unregister_net(net, nn->nfs_dns_resolve);
405 nfs_cache_destroy(cd); 396 cache_destroy_net(nn->nfs_dns_resolve, net);
406 kfree(cd->hash_table);
407 kfree(cd);
408} 397}
409 398
410static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event, 399static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,