Commit 462b8f6b authored by Stanislav Kinsbursky's avatar Stanislav Kinsbursky Committed by J. Bruce Fields

NFS: simplify and clean cache library

This is a cleanup patch.
Such helpers like nfs_cache_init() and nfs_cache_destroy() are redundant,
because they are just a wrappers around sunrpc_init_cache_detail() and
sunrpc_destroy_cache_detail() respectively.
So let's remove them completely and move corresponding logic to
nfs_cache_register_net() and nfs_cache_unregister_net() respectively (since
they are called together anyway).
Signed-off-by: default avatarStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 483479c2
...@@ -128,10 +128,13 @@ int nfs_cache_register_net(struct net *net, struct cache_detail *cd) ...@@ -128,10 +128,13 @@ int nfs_cache_register_net(struct net *net, struct cache_detail *cd)
struct super_block *pipefs_sb; struct super_block *pipefs_sb;
int ret = 0; int ret = 0;
sunrpc_init_cache_detail(cd);
pipefs_sb = rpc_get_sb_net(net); pipefs_sb = rpc_get_sb_net(net);
if (pipefs_sb) { if (pipefs_sb) {
ret = nfs_cache_register_sb(pipefs_sb, cd); ret = nfs_cache_register_sb(pipefs_sb, cd);
rpc_put_sb_net(net); rpc_put_sb_net(net);
if (ret)
sunrpc_destroy_cache_detail(cd);
} }
return ret; return ret;
} }
...@@ -151,14 +154,5 @@ void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd) ...@@ -151,14 +154,5 @@ void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd)
nfs_cache_unregister_sb(pipefs_sb, cd); nfs_cache_unregister_sb(pipefs_sb, cd);
rpc_put_sb_net(net); rpc_put_sb_net(net);
} }
}
void nfs_cache_init(struct cache_detail *cd)
{
sunrpc_init_cache_detail(cd);
}
void nfs_cache_destroy(struct cache_detail *cd)
{
sunrpc_destroy_cache_detail(cd); sunrpc_destroy_cache_detail(cd);
} }
...@@ -23,8 +23,6 @@ extern struct nfs_cache_defer_req *nfs_cache_defer_req_alloc(void); ...@@ -23,8 +23,6 @@ extern struct nfs_cache_defer_req *nfs_cache_defer_req_alloc(void);
extern void nfs_cache_defer_req_put(struct nfs_cache_defer_req *dreq); extern void nfs_cache_defer_req_put(struct nfs_cache_defer_req *dreq);
extern int nfs_cache_wait_for_upcall(struct nfs_cache_defer_req *dreq); extern int nfs_cache_wait_for_upcall(struct nfs_cache_defer_req *dreq);
extern void nfs_cache_init(struct cache_detail *cd);
extern void nfs_cache_destroy(struct cache_detail *cd);
extern int nfs_cache_register_net(struct net *net, struct cache_detail *cd); extern int nfs_cache_register_net(struct net *net, struct cache_detail *cd);
extern void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd); extern void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd);
extern int nfs_cache_register_sb(struct super_block *sb, extern int nfs_cache_register_sb(struct super_block *sb,
......
...@@ -377,14 +377,12 @@ int nfs_dns_resolver_cache_init(struct net *net) ...@@ -377,14 +377,12 @@ int nfs_dns_resolver_cache_init(struct net *net)
if (IS_ERR(nn->nfs_dns_resolve)) if (IS_ERR(nn->nfs_dns_resolve))
return PTR_ERR(nn->nfs_dns_resolve); return PTR_ERR(nn->nfs_dns_resolve);
nfs_cache_init(nn->nfs_dns_resolve);
err = nfs_cache_register_net(net, nn->nfs_dns_resolve); err = nfs_cache_register_net(net, nn->nfs_dns_resolve);
if (err) if (err)
goto err_reg; goto err_reg;
return 0; return 0;
err_reg: err_reg:
nfs_cache_destroy(nn->nfs_dns_resolve);
cache_destroy_net(nn->nfs_dns_resolve, net); cache_destroy_net(nn->nfs_dns_resolve, net);
return err; return err;
} }
...@@ -392,10 +390,8 @@ int nfs_dns_resolver_cache_init(struct net *net) ...@@ -392,10 +390,8 @@ int nfs_dns_resolver_cache_init(struct net *net)
void nfs_dns_resolver_cache_destroy(struct net *net) void nfs_dns_resolver_cache_destroy(struct net *net)
{ {
struct nfs_net *nn = net_generic(net, nfs_net_id); struct nfs_net *nn = net_generic(net, nfs_net_id);
struct cache_detail *cd = nn->nfs_dns_resolve;
nfs_cache_unregister_net(net, cd); nfs_cache_unregister_net(net, nn->nfs_dns_resolve);
nfs_cache_destroy(cd);
cache_destroy_net(nn->nfs_dns_resolve, net); cache_destroy_net(nn->nfs_dns_resolve, net);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment