linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: bjschuma@netapp.com
To: Trond.Myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org, Bryan Schumaker <bjschuma@netapp.com>
Subject: [PATCH 07/44] NFS: Convert NFS v2 into a module
Date: Fri, 13 Jan 2012 15:10:16 -0500	[thread overview]
Message-ID: <1326485453-1350-8-git-send-email-bjschuma@netapp.com> (raw)
In-Reply-To: <1326485453-1350-1-git-send-email-bjschuma@netapp.com>

From: Bryan Schumaker <bjschuma@netapp.com>

You need to run `modprobe nfs2` before you can use it.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
 fs/nfs/Kconfig          |    2 +-
 fs/nfs/Makefile         |    2 +-
 fs/nfs/client.c         |   15 +--------------
 fs/nfs/file.c           |    6 ------
 fs/nfs/nfs2/Makefile    |    5 +++++
 fs/nfs/nfs2/dir.c       |   30 ++++++++++++++++++++++++++++++
 fs/nfs/nfs2/file.c      |   32 ++++++++++++++++++++++++++++++++
 fs/nfs/nfs2/module.c    |   45 +++++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/nfs2/nfs2.h      |   17 +++++++++++++++++
 fs/nfs/nfs2/proc.c      |    1 +
 include/linux/nfs_xdr.h |    3 +--
 11 files changed, 134 insertions(+), 24 deletions(-)
 create mode 100644 fs/nfs/nfs2/Makefile
 create mode 100644 fs/nfs/nfs2/dir.c
 create mode 100644 fs/nfs/nfs2/file.c
 create mode 100644 fs/nfs/nfs2/module.c
 create mode 100644 fs/nfs/nfs2/nfs2.h

diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index 5419166..b28e56f 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -30,7 +30,7 @@ config NFS_FS
 	  If unsure, say N.
 
 config NFS_V2
-	bool "NFS client support for NFS version 2"
+	tristate "NFS client support for NFS version 2"
 	depends on NFS_FS
 	help
 	  This option enables support for version 2 of the NFS protocol
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index 44db87d..5733451 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -9,7 +9,6 @@ nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o \
 			   write.o namespace.o mount_clnt.o \
 			   dns_resolve.o cache_lib.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
-nfs-$(CONFIG_NFS_V2)	+= nfs2/proc.o nfs2/xdr.o
 nfs-$(CONFIG_NFS_V3)	+= nfs3proc.o nfs3xdr.o
 nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
@@ -23,5 +22,6 @@ nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
 obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o
 nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o
 
+obj-$(CONFIG_NFS_V2) += nfs2/
 obj-$(CONFIG_PNFS_OBJLAYOUT) += objlayout/
 obj-$(CONFIG_PNFS_BLOCK) += blocklayout/
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 168b469..20d1708 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -121,22 +121,12 @@ struct rpc_stat nfs_rpcstat = {
  * Once everything has been converted this function will
  * be removed.
  */
-#if defined(CONFIG_NFS_V2) || defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
 static void nfs_module_null_function(void)
 {
 }
 #endif
 
-#ifdef CONFIG_NFS_V2
-static struct nfs_subversion nfs_v2_mod = {
-	.version  = 2,
-	.rpc_vers = &nfs_version2,
-	.rpc_ops  = &nfs_v2_clientops,
-	.reference = nfs_module_null_function,
-	.unreference = nfs_module_null_function,
-};
-#endif /* CONFIG_NFS_V2 */
-
 #ifdef CONFIG_NFS_V3
 static struct nfs_subversion nfs_v3_mod = {
 	.version  = 3,
@@ -242,9 +232,6 @@ EXPORT_SYMBOL_GPL(unregister_nfs_version);
  */
 void __init nfs_register_versions(void)
 {
-#ifdef CONFIG_NFS_V2
-	register_nfs_version(&nfs_v2_mod);
-#endif
 #ifdef CONFIG_NFS_V3
 	register_nfs_version(&nfs_v3_mod);
 #endif
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 227694e..4ac4dae 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -44,12 +44,6 @@
 
 static const struct vm_operations_struct nfs_file_vm_ops;
 
-const struct inode_operations nfs_file_inode_operations = {
-	.permission	= nfs_permission,
-	.getattr	= nfs_getattr,
-	.setattr	= nfs_setattr,
-};
-
 #ifdef CONFIG_NFS_V3
 const struct inode_operations nfs3_file_inode_operations = {
 	.permission	= nfs_permission,
diff --git a/fs/nfs/nfs2/Makefile b/fs/nfs/nfs2/Makefile
new file mode 100644
index 0000000..0ca3b59
--- /dev/null
+++ b/fs/nfs/nfs2/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for NFS v2
+#
+obj-$(CONFIG_NFS_V2) += nfs2.o
+nfs2-y := module.o dir.o file.o proc.o xdr.o
diff --git a/fs/nfs/nfs2/dir.c b/fs/nfs/nfs2/dir.c
new file mode 100644
index 0000000..64e2154
--- /dev/null
+++ b/fs/nfs/nfs2/dir.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 1992  Rick Sladkey
+ */
+#include <linux/fs.h>
+
+#include "../nfs.h"
+#include "nfs2.h"
+
+const struct inode_operations nfs_dir_inode_operations = {
+	.create		= nfs_create,
+	.lookup		= nfs_lookup,
+	.link		= nfs_link,
+	.unlink		= nfs_unlink,
+	.symlink	= nfs_symlink,
+	.mkdir		= nfs_mkdir,
+	.rmdir		= nfs_rmdir,
+	.mknod		= nfs_mknod,
+	.rename		= nfs_rename,
+	.permission	= nfs_permission,
+	.getattr	= nfs_getattr,
+	.setattr	= nfs_setattr,
+};
+
+const struct dentry_operations nfs_dentry_operations = {
+	.d_revalidate	= nfs_lookup_revalidate,
+	.d_delete	= nfs_dentry_delete,
+	.d_iput		= nfs_dentry_iput,
+	.d_automount	= nfs_d_automount,
+	.d_release	= nfs_d_release,
+};
diff --git a/fs/nfs/nfs2/file.c b/fs/nfs/nfs2/file.c
new file mode 100644
index 0000000..bfe6412
--- /dev/null
+++ b/fs/nfs/nfs2/file.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 1992  Rick Sladkey
+ */
+#include <linux/fs.h>
+
+#include "../nfs.h"
+#include "nfs2.h"
+
+const struct inode_operations nfs_file_inode_operations = {
+	.permission	= nfs_permission,
+	.getattr	= nfs_getattr,
+	.setattr	= nfs_setattr,
+};
+
+const struct file_operations nfs_file_operations = {
+	.llseek		= nfs_file_llseek,
+	.read		= do_sync_read,
+	.write		= do_sync_write,
+	.aio_read	= nfs_file_read,
+	.aio_write	= nfs_file_write,
+	.mmap		= nfs_file_mmap,
+	.open		= nfs_file_open,
+	.flush		= nfs_file_flush,
+	.release	= nfs_file_release,
+	.fsync		= nfs_file_fsync,
+	.lock		= nfs_lock,
+	.flock		= nfs_flock,
+	.splice_read	= nfs_file_splice_read,
+	.splice_write	= nfs_file_splice_write,
+	.check_flags	= nfs_check_flags,
+	.setlease	= nfs_setlease,
+};
diff --git a/fs/nfs/nfs2/module.c b/fs/nfs/nfs2/module.c
new file mode 100644
index 0000000..04d415a
--- /dev/null
+++ b/fs/nfs/nfs2/module.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012 Netapp, Inc. All rights reserved.
+ *
+ * Initialize the NFS v2 module
+ */
+
+#include <linux/module.h>
+#include "../nfs.h"
+
+#include "nfs2.h"
+
+static void nfs2_reference(void)
+{
+	try_module_get(THIS_MODULE);
+}
+
+static void nfs2_unreference(void)
+{
+	module_put(THIS_MODULE);
+}
+
+struct nfs_subversion nfs_v2 = {
+	.version  = 2,
+	.rpc_vers = &nfs_version2,
+	.rpc_ops  = &nfs_v2_clientops,
+
+	.reference = nfs2_reference,
+	.unreference = nfs2_unreference,
+};
+
+static int __init init_nfs_v2(void)
+{
+	register_nfs_version(&nfs_v2);
+	return 0;
+}
+
+static void __exit exit_nfs_v2(void)
+{
+	unregister_nfs_version(&nfs_v2);
+}
+
+MODULE_LICENSE("GPL");
+
+module_init(init_nfs_v2);
+module_exit(exit_nfs_v2);
diff --git a/fs/nfs/nfs2/nfs2.h b/fs/nfs/nfs2/nfs2.h
new file mode 100644
index 0000000..6274821
--- /dev/null
+++ b/fs/nfs/nfs2/nfs2.h
@@ -0,0 +1,17 @@
+#ifndef __LINUX_FS_NFS_NFS2_H
+#define __LINUX_FS_NFS_NFS2_H
+
+#include <linux/fs.h>
+#include <linux/sunrpc/clnt.h>
+
+extern struct rpc_version nfs_version2;
+extern const struct nfs_rpc_ops nfs_v2_clientops;
+
+extern const struct inode_operations nfs_file_inode_operations;
+extern const struct file_operations nfs_file_operations;
+
+extern const struct inode_operations nfs_dir_inode_operations;
+extern const struct file_operations nfs_dir_operations;
+extern const struct dentry_operations nfs_dentry_operations;
+
+#endif /* __LINUX_FS_NFS_NFS2_H */
diff --git a/fs/nfs/nfs2/proc.c b/fs/nfs/nfs2/proc.c
index 65eafa3..6590fc7 100644
--- a/fs/nfs/nfs2/proc.c
+++ b/fs/nfs/nfs2/proc.c
@@ -42,6 +42,7 @@
 #include <linux/nfs_page.h>
 #include <linux/lockd/bind.h>
 #include "../internal.h"
+#include "nfs2.h"
 
 #define NFSDBG_FACILITY		NFSDBG_PROC
 
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index a764cef..0ca9f10 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -3,6 +3,7 @@
 
 #include <linux/nfsacl.h>
 #include <linux/nfs3.h>
+#include <linux/nfs4.h>
 #include <linux/sunrpc/gss_api.h>
 
 /*
@@ -1272,10 +1273,8 @@ struct nfs_rpc_ops {
 /*
  * Function vectors etc. for the NFS client
  */
-extern const struct nfs_rpc_ops	nfs_v2_clientops;
 extern const struct nfs_rpc_ops	nfs_v3_clientops;
 extern const struct nfs_rpc_ops	nfs_v4_clientops;
-extern struct rpc_version	nfs_version2;
 extern struct rpc_version	nfs_version3;
 extern struct rpc_version	nfs_version4;
 
-- 
1.7.8.3


  parent reply	other threads:[~2012-01-13 20:11 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-13 20:10 [PATCH 00/44] NFS: Create NFS Modules bjschuma
2012-01-13 20:10 ` [PATCH 01/44] NFS: ifndef guard internal.h bjschuma
2012-01-13 20:10 ` [PATCH 02/44] NFS: Relocate the stat_to_errno() function bjschuma
2012-01-13 20:10 ` [PATCH 03/44] NFS: Make v2 configurable bjschuma
2012-01-13 20:10 ` [PATCH 04/44] NFS: Add version registering framework bjschuma
2012-01-13 20:10 ` [PATCH 05/44] NFS: Move v2 to new subdirectory bjschuma
2012-01-13 20:10 ` [PATCH 06/44] NFS: Export symbols needed by a v2 module bjschuma
2012-01-13 20:10 ` bjschuma [this message]
2012-01-13 20:10 ` [PATCH 08/44] NFS: Created custom init_aclclient() functions bjschuma
2012-01-13 20:10 ` [PATCH 09/44] NFS: Move v3 to its own subdirectory bjschuma
2012-01-13 20:10 ` [PATCH 10/44] NFS: Export symbols needed by a v3 module bjschuma
2012-01-13 20:10 ` [PATCH 11/44] NFS: Switch to using the IS_ENABLED macro for CONFIG_NFS_V3 bjschuma
2012-01-13 20:10 ` [PATCH 12/44] NFS: Convert NFS v3 into a module bjschuma
2012-01-13 20:10 ` [PATCH 13/44] NFS: Remove unused code bjschuma
2012-01-13 20:10 ` [PATCH 14/44] NFS: Move v4 to its own subdirectory bjschuma
2012-01-13 20:10 ` [PATCH 15/44] NFS: Move init_aclclient() into the v4 subdirectory bjschuma
2012-01-13 20:10 ` [PATCH 16/44] NFS: Create a version-specific do_submount() function bjschuma
2012-01-13 20:10 ` [PATCH 17/44] NFS: Added in a custom do_clone_mount() function bjschuma
2012-01-13 20:10 ` [PATCH 18/44] NFS: Give versions a custom have_delegation() function bjschuma
2012-01-13 20:10 ` [PATCH 19/44] NFS: Give versions a custom have_delegated_attributes() function bjschuma
2012-01-13 20:10 ` [PATCH 20/44] NFS: Give versions a custom return_delegation() function bjschuma
2012-01-13 20:10 ` [PATCH 21/44] NFS: Add a function to run when shutting down a client bjschuma
2012-01-13 20:10 ` [PATCH 22/44] NFS: Split nfs_fs_mount() into two functions bjschuma
2012-01-13 20:10 ` [PATCH 23/44] NFS: Create a custom try_mount() function for each version bjschuma
2012-01-13 20:10 ` [PATCH 24/44] NFS: Create a separate valadet_text_mount_data() function bjschuma
2012-01-13 20:10 ` [PATCH 25/44] NFS: Create a custom validate_mount_data() function bjschuma
2012-01-13 20:10 ` [PATCH 26/44] NFS: Create an idr_lock to protect the cb_idr bjschuma
2012-01-13 20:10 ` [PATCH 27/44] NFS: Create a custom alloc_client() function bjschuma
2012-01-13 20:10 ` [PATCH 28/44] NFS: Create a custom put_client() function bjschuma
2012-01-13 20:10 ` [PATCH 29/44] NFS: Create the nfs4/module.c file bjschuma
2012-01-13 20:10 ` [PATCH 30/44] NFS: Move over NFS v4 sysctls bjschuma
2012-01-13 20:10 ` [PATCH 31/44] NFS: Move v4 getroot code to the v4 directory bjschuma
2012-01-13 20:10 ` [PATCH 32/44] NFS: Move a v4 block from inode.c bjschuma
2012-01-13 20:10 ` [PATCH 33/44] NFS: Move over the v4_file_operations structure bjschuma
2012-01-13 20:10 ` [PATCH 34/44] NFS: Move v4-only functions from dir.c bjschuma
2012-01-13 20:10 ` [PATCH 35/44] NFS: Register the v4 filesystem type from nfs4/module.c bjschuma
2012-01-13 20:10 ` [PATCH 36/44] NFS: Export functions from super.c bjschuma
2012-01-13 20:10 ` [PATCH 37/44] NFS: Move v4 super code to the nfs4/ directory bjschuma
2012-01-13 20:10 ` [PATCH 38/44] NFS: Only initialize pnfs in the v4.x case bjschuma
2012-01-13 20:10 ` [PATCH 39/44] NFS: Create accessor functions for the nfs_client_list() bjschuma
2012-01-13 20:10 ` [PATCH 40/44] NFS: Export functions from client.c bjschuma
2012-01-13 20:10 ` [PATCH 41/44] NFS: Move v4 client.c code to nfs4/client.c bjschuma
2012-01-13 20:10 ` [PATCH 42/44] NFS: Switch to using IS_ENABLED macro for CONFIG_NFS_V4 bjschuma
2012-01-13 20:10 ` [PATCH 43/44] NFS: Export functions needed by a v4 module bjschuma
2012-01-13 20:48   ` Chuck Lever
2012-01-13 21:05     ` Bryan Schumaker
2012-01-13 21:12       ` Bryan Schumaker
2012-01-13 21:25         ` Chuck Lever
2012-01-13 21:36           ` Bryan Schumaker
2012-01-14  0:55       ` NeilBrown
2012-01-13 20:10 ` [PATCH 44/44] NFS: Convert NFS v4 into a module bjschuma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1326485453-1350-8-git-send-email-bjschuma@netapp.com \
    --to=bjschuma@netapp.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).