NFSv4: Move the DNS resolver into the NFSv4 module
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Sat, 1 Jun 2013 15:50:58 +0000 (11:50 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 18 Jun 2013 17:47:18 +0000 (13:47 -0400)
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>
fs/nfs/Makefile
fs/nfs/dns_resolve.c
fs/nfs/inode.c
fs/nfs/nfs4super.c

index cce2c057bd2d61142d63ed6feb6232bbfd29fcab..e0bb048e9576209181fb127d109f9e353e802984 100644 (file)
@@ -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
@@ -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
 
index 9455270922958f420a7f31101cac1b6ac7b14bfb..fc0f95ec73587f9fbcfa7fca24438da29012b5b9 100644 (file)
@@ -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
 
@@ -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,
@@ -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)
 {
@@ -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
index c121982659a27c534ceb21cfee177dbb329a3846..e09920cacd8bffadb764b9264a3f3e02133a2997 100644 (file)
@@ -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"
@@ -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);
 }
 
@@ -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;
@@ -1738,8 +1732,6 @@ out7:
 out8:
        unregister_pernet_subsys(&nfs_net_ops);
 out9:
-       nfs_dns_resolver_destroy();
-out10:
        return err;
 }
 
@@ -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
index a5e1a3026d489240cb7a44ae87eec07df019ce3a..5dbe2d269210f000132547d3c21daa33e7e1b224 100644 (file)
@@ -9,6 +9,7 @@
 #include "delegation.h"
 #include "internal.h"
 #include "nfs4_fs.h"
+#include "dns_resolve.h"
 #include "pnfs.h"
 #include "nfs.h"
 
@@ -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;
 }
@@ -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");