Skip to content

Commit

Permalink
NFSv4: Move the DNS resolver into the NFSv4 module
Browse files Browse the repository at this point in the history
The other protocols don't use it, so make it local to NFSv4, and
remove the EXPORT.
Also ensure that we only compile in cache_lib.o if we're using
the legacy DNS resolver.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Bryan Schumaker <bjschuma@netapp.com>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Jun 18, 2013
1 parent e401452 commit c8d74d9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
6 changes: 3 additions & 3 deletions fs/nfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ obj-$(CONFIG_NFS_FS) += nfs.o

nfs-y := client.o dir.o file.o getroot.o inode.o super.o \
direct.o pagelist.o read.o symlink.o unlink.o \
write.o namespace.o mount_clnt.o \
dns_resolve.o cache_lib.o
write.o namespace.o mount_clnt.o
nfs-$(CONFIG_ROOT_NFS) += nfsroot.o
nfs-$(CONFIG_SYSCTL) += sysctl.o
nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
Expand All @@ -22,7 +21,8 @@ nfsv3-$(CONFIG_NFS_V3_ACL) += nfs3acl.o
obj-$(CONFIG_NFS_V4) += nfsv4.o
nfsv4-y := nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o nfs4super.o nfs4file.o \
delegation.o idmap.o callback.o callback_xdr.o callback_proc.o \
nfs4namespace.o nfs4getroot.o nfs4client.o
nfs4namespace.o nfs4getroot.o nfs4client.o dns_resolve.o
nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o
nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o
nfsv4-$(CONFIG_NFS_V4_1) += nfs4session.o pnfs.o pnfs_dev.o

Expand Down
32 changes: 29 additions & 3 deletions fs/nfs/dns_resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ ssize_t nfs_dns_resolve_name(struct net *net, char *name, size_t namelen,
kfree(ip_addr);
return ret;
}
EXPORT_SYMBOL_GPL(nfs_dns_resolve_name);

#else

Expand Down Expand Up @@ -351,7 +350,6 @@ ssize_t nfs_dns_resolve_name(struct net *net, char *name,
ret = -ESRCH;
return ret;
}
EXPORT_SYMBOL_GPL(nfs_dns_resolve_name);

static struct cache_detail nfs_dns_resolve_template = {
.owner = THIS_MODULE,
Expand Down Expand Up @@ -396,6 +394,21 @@ void nfs_dns_resolver_cache_destroy(struct net *net)
cache_destroy_net(nn->nfs_dns_resolve, net);
}

static int nfs4_dns_net_init(struct net *net)
{
return nfs_dns_resolver_cache_init(net);
}

static void nfs4_dns_net_exit(struct net *net)
{
nfs_dns_resolver_cache_destroy(net);
}

static struct pernet_operations nfs4_dns_resolver_ops = {
.init = nfs4_dns_net_init,
.exit = nfs4_dns_net_exit,
};

static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
void *ptr)
{
Expand Down Expand Up @@ -432,11 +445,24 @@ static struct notifier_block nfs_dns_resolver_block = {

int nfs_dns_resolver_init(void)
{
return rpc_pipefs_notifier_register(&nfs_dns_resolver_block);
int err;

err = register_pernet_subsys(&nfs4_dns_resolver_ops);
if (err < 0)
goto out;
err = rpc_pipefs_notifier_register(&nfs_dns_resolver_block);
if (err < 0)
goto out1;
return 0;
out1:
unregister_pernet_subsys(&nfs4_dns_resolver_ops);
out:
return err;
}

void nfs_dns_resolver_destroy(void)
{
rpc_pipefs_notifier_unregister(&nfs_dns_resolver_block);
unregister_pernet_subsys(&nfs4_dns_resolver_ops);
}
#endif
11 changes: 1 addition & 10 deletions fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "iostat.h"
#include "internal.h"
#include "fscache.h"
#include "dns_resolve.h"
#include "pnfs.h"
#include "nfs.h"
#include "netns.h"
Expand Down Expand Up @@ -1646,12 +1645,11 @@ EXPORT_SYMBOL_GPL(nfs_net_id);
static int nfs_net_init(struct net *net)
{
nfs_clients_init(net);
return nfs_dns_resolver_cache_init(net);
return 0;
}

static void nfs_net_exit(struct net *net)
{
nfs_dns_resolver_cache_destroy(net);
nfs_cleanup_cb_ident_idr(net);
}

Expand All @@ -1669,10 +1667,6 @@ static int __init init_nfs_fs(void)
{
int err;

err = nfs_dns_resolver_init();
if (err < 0)
goto out10;;

err = register_pernet_subsys(&nfs_net_ops);
if (err < 0)
goto out9;
Expand Down Expand Up @@ -1738,8 +1732,6 @@ static int __init init_nfs_fs(void)
out8:
unregister_pernet_subsys(&nfs_net_ops);
out9:
nfs_dns_resolver_destroy();
out10:
return err;
}

Expand All @@ -1752,7 +1744,6 @@ static void __exit exit_nfs_fs(void)
nfs_destroy_nfspagecache();
nfs_fscache_unregister();
unregister_pernet_subsys(&nfs_net_ops);
nfs_dns_resolver_destroy();
#ifdef CONFIG_PROC_FS
rpc_proc_unregister(&init_net, "nfs");
#endif
Expand Down
14 changes: 11 additions & 3 deletions fs/nfs/nfs4super.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "delegation.h"
#include "internal.h"
#include "nfs4_fs.h"
#include "dns_resolve.h"
#include "pnfs.h"
#include "nfs.h"

Expand Down Expand Up @@ -331,18 +332,24 @@ static int __init init_nfs_v4(void)
{
int err;

err = nfs_idmap_init();
err = nfs_dns_resolver_init();
if (err)
goto out;

err = nfs4_register_sysctl();
err = nfs_idmap_init();
if (err)
goto out1;

err = nfs4_register_sysctl();
if (err)
goto out2;

register_nfs_version(&nfs_v4);
return 0;
out1:
out2:
nfs_idmap_quit();
out1:
nfs_dns_resolver_destroy();
out:
return err;
}
Expand All @@ -352,6 +359,7 @@ static void __exit exit_nfs_v4(void)
unregister_nfs_version(&nfs_v4);
nfs4_unregister_sysctl();
nfs_idmap_quit();
nfs_dns_resolver_destroy();
}

MODULE_LICENSE("GPL");
Expand Down

0 comments on commit c8d74d9

Please sign in to comment.