diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2013-02-04 06:02:35 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2013-02-15 10:43:12 -0500 |
commit | 483479c26a65e5f0cc95e9324f313bc95c7dc6fd (patch) | |
tree | c5b72368672a50a7a43cb3e2f4e70c089bc0a360 /fs/nfs/dns_resolve.c | |
parent | e56a316214d0f1e2446fa7a717309f9414564d9d (diff) |
NFS: use SUNRPC cache creation and destruction helper for DNS cache
This cache was the first containerized and doesn't use net-aware cache
creation and destruction helpers.
This is a cleanup patch which just makes code looks clearer and reduce amount
of lines of code.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfs/dns_resolve.c')
-rw-r--r-- | fs/nfs/dns_resolve.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c index 62c8c4127219..d5ce5f4f0f5f 100644 --- a/fs/nfs/dns_resolve.c +++ b/fs/nfs/dns_resolve.c | |||
@@ -353,48 +353,39 @@ ssize_t nfs_dns_resolve_name(struct net *net, char *name, | |||
353 | } | 353 | } |
354 | EXPORT_SYMBOL_GPL(nfs_dns_resolve_name); | 354 | EXPORT_SYMBOL_GPL(nfs_dns_resolve_name); |
355 | 355 | ||
356 | static 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_parse = nfs_dns_parse, | ||
363 | .cache_show = nfs_dns_show, | ||
364 | .match = nfs_dns_match, | ||
365 | .init = nfs_dns_ent_init, | ||
366 | .update = nfs_dns_ent_update, | ||
367 | .alloc = nfs_dns_ent_alloc, | ||
368 | }; | ||
369 | |||
370 | |||
356 | int nfs_dns_resolver_cache_init(struct net *net) | 371 | int nfs_dns_resolver_cache_init(struct net *net) |
357 | { | 372 | { |
358 | int err = -ENOMEM; | 373 | int err; |
359 | struct nfs_net *nn = net_generic(net, nfs_net_id); | 374 | struct nfs_net *nn = net_generic(net, nfs_net_id); |
360 | struct cache_detail *cd; | ||
361 | struct cache_head **tbl; | ||
362 | 375 | ||
363 | cd = kzalloc(sizeof(struct cache_detail), GFP_KERNEL); | 376 | nn->nfs_dns_resolve = cache_create_net(&nfs_dns_resolve_template, net); |
364 | if (cd == NULL) | 377 | if (IS_ERR(nn->nfs_dns_resolve)) |
365 | goto err_cd; | 378 | return PTR_ERR(nn->nfs_dns_resolve); |
366 | 379 | ||
367 | tbl = kzalloc(NFS_DNS_HASHTBL_SIZE * sizeof(struct cache_head *), | 380 | nfs_cache_init(nn->nfs_dns_resolve); |
368 | GFP_KERNEL); | 381 | err = nfs_cache_register_net(net, nn->nfs_dns_resolve); |
369 | if (tbl == NULL) | ||
370 | goto err_tbl; | ||
371 | |||
372 | cd->owner = THIS_MODULE, | ||
373 | cd->hash_size = NFS_DNS_HASHTBL_SIZE, | ||
374 | cd->hash_table = tbl, | ||
375 | cd->name = "dns_resolve", | ||
376 | cd->cache_put = nfs_dns_ent_put, | ||
377 | cd->cache_upcall = nfs_dns_upcall, | ||
378 | cd->cache_parse = nfs_dns_parse, | ||
379 | cd->cache_show = nfs_dns_show, | ||
380 | cd->match = nfs_dns_match, | ||
381 | cd->init = nfs_dns_ent_init, | ||
382 | cd->update = nfs_dns_ent_update, | ||
383 | cd->alloc = nfs_dns_ent_alloc, | ||
384 | |||
385 | nfs_cache_init(cd); | ||
386 | err = nfs_cache_register_net(net, cd); | ||
387 | if (err) | 382 | if (err) |
388 | goto err_reg; | 383 | goto err_reg; |
389 | nn->nfs_dns_resolve = cd; | ||
390 | return 0; | 384 | return 0; |
391 | 385 | ||
392 | err_reg: | 386 | err_reg: |
393 | nfs_cache_destroy(cd); | 387 | nfs_cache_destroy(nn->nfs_dns_resolve); |
394 | kfree(cd->hash_table); | 388 | cache_destroy_net(nn->nfs_dns_resolve, net); |
395 | err_tbl: | ||
396 | kfree(cd); | ||
397 | err_cd: | ||
398 | return err; | 389 | return err; |
399 | } | 390 | } |
400 | 391 | ||
@@ -405,8 +396,7 @@ void nfs_dns_resolver_cache_destroy(struct net *net) | |||
405 | 396 | ||
406 | nfs_cache_unregister_net(net, cd); | 397 | nfs_cache_unregister_net(net, cd); |
407 | nfs_cache_destroy(cd); | 398 | nfs_cache_destroy(cd); |
408 | kfree(cd->hash_table); | 399 | cache_destroy_net(nn->nfs_dns_resolve, net); |
409 | kfree(cd); | ||
410 | } | 400 | } |
411 | 401 | ||
412 | static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event, | 402 | static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event, |