Skip to content

Commit

Permalink
NFS: Convert v4 into a module
Browse files Browse the repository at this point in the history
This patch exports symbols needed by the v4 module.  In addition, I also
switch over to using IS_ENABLED() to check if CONFIG_NFS_V4 or
CONFIG_NFS_V4_MODULE are set.

The module (nfs4.ko) will be created in the same directory as nfs.ko and
will be automatically loaded the first time you try to mount over NFS v4.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Bryan Schumaker authored and Trond Myklebust committed Jul 30, 2012
1 parent 1c606fb commit 89d77c8
Show file tree
Hide file tree
Showing 25 changed files with 155 additions and 116 deletions.
2 changes: 1 addition & 1 deletion fs/nfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ config NFS_V3_ACL
If unsure, say N.

config NFS_V4
bool "NFS client support for NFS version 4"
tristate "NFS client support for NFS version 4"
depends on NFS_FS
select SUNRPC_GSS
select KEYS
Expand Down
19 changes: 8 additions & 11 deletions fs/nfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,7 @@ 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_V4) += 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
nfs-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o

ifeq ($(CONFIG_SYSCTL), y)
nfs-y += sysctl.o
nfs-$(CONFIG_NFS_V4) += nfs4sysctl.o
endif

nfs-$(CONFIG_SYSCTL) += sysctl.o
nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o

obj-$(CONFIG_NFS_V2) += nfs2.o
Expand All @@ -29,6 +19,13 @@ obj-$(CONFIG_NFS_V3) += nfs3.o
nfs3-y := nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o
nfs3-$(CONFIG_NFS_V3_ACL) += nfs3acl.o

obj-$(CONFIG_NFS_V4) += nfs4.o
nfs4-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
nfs4-$(CONFIG_SYSCTL) += nfs4sysctl.o
nfs4-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o

obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o
nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o

Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
struct cb_process_state *cps);
extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy,
struct cb_process_state *cps);
#ifdef CONFIG_NFS_V4
#if IS_ENABLED(CONFIG_NFS_V4)
extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
extern void nfs_callback_down(int minorversion);
extern int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation,
Expand Down
34 changes: 14 additions & 20 deletions fs/nfs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,24 +142,6 @@ void unregister_nfs_version(struct nfs_subversion *nfs)
}
EXPORT_SYMBOL_GPL(unregister_nfs_version);

/*
* Preload all configured NFS versions during module init.
* This function should be edited after each protocol is converted,
* and eventually removed.
*/
int __init nfs_register_versions(void)
{
return init_nfs_v4();
}

/*
* Remove each pre-loaded NFS version
*/
void nfs_unregister_versions(void)
{
exit_nfs_v4();
}

/*
* Allocate a shared client record
*
Expand Down Expand Up @@ -214,7 +196,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
}
EXPORT_SYMBOL_GPL(nfs_alloc_client);

#ifdef CONFIG_NFS_V4
#if IS_ENABLED(CONFIG_NFS_V4)
/* idr_remove_all is not needed as all id's are removed by nfs_put_client */
void nfs_cleanup_cb_ident_idr(struct net *net)
{
Expand Down Expand Up @@ -390,6 +372,7 @@ int nfs_sockaddr_match_ipaddr(const struct sockaddr *sa1,
}
return 0;
}
EXPORT_SYMBOL_GPL(nfs_sockaddr_match_ipaddr);
#endif /* CONFIG_NFS_V4_1 */

/*
Expand Down Expand Up @@ -456,6 +439,7 @@ int nfs_wait_client_init_complete(const struct nfs_client *clp)
return wait_event_killable(nfs_client_active_wq,
nfs_client_init_is_complete(clp));
}
EXPORT_SYMBOL_GPL(nfs_wait_client_init_complete);

/*
* Found an existing client. Make sure it's ready before returning.
Expand Down Expand Up @@ -530,6 +514,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
cl_init->hostname ?: "", PTR_ERR(new));
return new;
}
EXPORT_SYMBOL_GPL(nfs_get_client);

/*
* Mark a server as ready or failed
Expand All @@ -540,6 +525,7 @@ void nfs_mark_client_ready(struct nfs_client *clp, int state)
clp->cl_cons_state = state;
wake_up_all(&nfs_client_active_wq);
}
EXPORT_SYMBOL_GPL(nfs_mark_client_ready);

/*
* Initialise the timeout values for a connection
Expand Down Expand Up @@ -581,6 +567,7 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
BUG();
}
}
EXPORT_SYMBOL_GPL(nfs_init_timeout_values);

/*
* Create an RPC client handle
Expand Down Expand Up @@ -620,6 +607,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
clp->cl_rpcclient = clnt;
return 0;
}
EXPORT_SYMBOL_GPL(nfs_create_rpc_client);

/*
* Version 2 or 3 client destruction
Expand Down Expand Up @@ -706,6 +694,7 @@ int nfs_init_server_rpcclient(struct nfs_server *server,

return 0;
}
EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);

/**
* nfs_init_client - Initialise an NFS2 or NFS3 client
Expand Down Expand Up @@ -932,6 +921,7 @@ int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, struct nfs
dprintk("nfs_probe_fsinfo: error = %d\n", -error);
return error;
}
EXPORT_SYMBOL_GPL(nfs_probe_fsinfo);

/*
* Copy useful information when duplicating a server record
Expand All @@ -948,6 +938,7 @@ void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *sour
target->caps = source->caps;
target->options = source->options;
}
EXPORT_SYMBOL_GPL(nfs_server_copy_userdata);

void nfs_server_insert_lists(struct nfs_server *server)
{
Expand All @@ -961,6 +952,7 @@ void nfs_server_insert_lists(struct nfs_server *server)
spin_unlock(&nn->nfs_client_lock);

}
EXPORT_SYMBOL_GPL(nfs_server_insert_lists);

static void nfs_server_remove_lists(struct nfs_server *server)
{
Expand Down Expand Up @@ -1020,6 +1012,7 @@ struct nfs_server *nfs_alloc_server(void)

return server;
}
EXPORT_SYMBOL_GPL(nfs_alloc_server);

/*
* Free up a server record
Expand Down Expand Up @@ -1048,6 +1041,7 @@ void nfs_free_server(struct nfs_server *server)
nfs_release_automount_timer();
dprintk("<-- nfs_free_server()\n");
}
EXPORT_SYMBOL_GPL(nfs_free_server);

/*
* Create a version 2 or 3 volume record
Expand Down Expand Up @@ -1193,7 +1187,7 @@ void nfs_clients_init(struct net *net)

INIT_LIST_HEAD(&nn->nfs_client_list);
INIT_LIST_HEAD(&nn->nfs_volume_list);
#ifdef CONFIG_NFS_V4
#if IS_ENABLED(CONFIG_NFS_V4)
idr_init(&nn->cb_ident_idr);
#endif
spin_lock_init(&nn->nfs_client_lock);
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/delegation.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FS_NFS_DELEGATION_H
#define FS_NFS_DELEGATION_H

#if defined(CONFIG_NFS_V4)
#if IS_ENABLED(CONFIG_NFS_V4)
/*
* NFSv4 delegation
*/
Expand Down
6 changes: 5 additions & 1 deletion fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ void nfs_force_lookup_revalidate(struct inode *dir)
{
NFS_I(dir)->cache_change_attribute++;
}
EXPORT_SYMBOL_GPL(nfs_force_lookup_revalidate);

/*
* A check for whether or not the parent directory has changed.
Expand Down Expand Up @@ -1267,7 +1268,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
}
EXPORT_SYMBOL_GPL(nfs_lookup);

#ifdef CONFIG_NFS_V4
#if IS_ENABLED(CONFIG_NFS_V4)
static int nfs4_lookup_revalidate(struct dentry *, unsigned int);

const struct dentry_operations nfs4_dentry_operations = {
Expand All @@ -1277,6 +1278,7 @@ const struct dentry_operations nfs4_dentry_operations = {
.d_automount = nfs_d_automount,
.d_release = nfs_d_release,
};
EXPORT_SYMBOL_GPL(nfs4_dentry_operations);

static fmode_t flags_to_mode(int flags)
{
Expand Down Expand Up @@ -1419,6 +1421,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,

return finish_no_open(file, res);
}
EXPORT_SYMBOL_GPL(nfs_atomic_open);

static int nfs4_lookup_revalidate(struct dentry *dentry, unsigned int flags)
{
Expand Down Expand Up @@ -2142,6 +2145,7 @@ int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags)
{
return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags));
}
EXPORT_SYMBOL_GPL(nfs_may_open);

int nfs_permission(struct inode *inode, int mask)
{
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ static void nfs_inode_dio_write_done(struct inode *inode)
inode_dio_done(inode);
}

#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
{
struct nfs_pageio_descriptor desc;
Expand Down
4 changes: 4 additions & 0 deletions fs/nfs/dns_resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#ifdef CONFIG_NFS_USE_KERNEL_DNS

#include <linux/module.h>
#include <linux/sunrpc/clnt.h>
#include <linux/dns_resolver.h>
#include "dns_resolve.h"
Expand All @@ -27,9 +28,11 @@ 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

#include <linux/module.h>
#include <linux/hash.h>
#include <linux/string.h>
#include <linux/kmod.h>
Expand Down Expand Up @@ -345,6 +348,7 @@ ssize_t nfs_dns_resolve_name(struct net *net, char *name,
ret = -ESRCH;
return ret;
}
EXPORT_SYMBOL_GPL(nfs_dns_resolve_name);

int nfs_dns_resolver_cache_init(struct net *net)
{
Expand Down
13 changes: 13 additions & 0 deletions fs/nfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ int nfs_check_flags(int flags)

return 0;
}
EXPORT_SYMBOL_GPL(nfs_check_flags);

/*
* Open file
Expand Down Expand Up @@ -85,6 +86,7 @@ nfs_file_release(struct inode *inode, struct file *filp)
nfs_inc_stats(inode, NFSIOS_VFSRELEASE);
return nfs_release(inode, filp);
}
EXPORT_SYMBOL_GPL(nfs_file_release);

/**
* nfs_revalidate_size - Revalidate the file size
Expand Down Expand Up @@ -138,6 +140,7 @@ loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)

return generic_file_llseek(filp, offset, origin);
}
EXPORT_SYMBOL_GPL(nfs_file_llseek);

/*
* Flush all dirty pages, and check for write errors.
Expand Down Expand Up @@ -166,6 +169,7 @@ nfs_file_flush(struct file *file, fl_owner_t id)
/* Flush writes to the server and return any errors */
return vfs_fsync(file, 0);
}
EXPORT_SYMBOL_GPL(nfs_file_flush);

ssize_t
nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
Expand All @@ -190,6 +194,7 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
}
return result;
}
EXPORT_SYMBOL_GPL(nfs_file_read);

ssize_t
nfs_file_splice_read(struct file *filp, loff_t *ppos,
Expand All @@ -212,6 +217,7 @@ nfs_file_splice_read(struct file *filp, loff_t *ppos,
}
return res;
}
EXPORT_SYMBOL_GPL(nfs_file_splice_read);

int
nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
Expand All @@ -233,6 +239,7 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
}
return status;
}
EXPORT_SYMBOL_GPL(nfs_file_mmap);

/*
* Flush any dirty pages for this process, and check for write errors.
Expand Down Expand Up @@ -271,6 +278,7 @@ nfs_file_fsync_commit(struct file *file, loff_t start, loff_t end, int datasync)
ret = status;
return ret;
}
EXPORT_SYMBOL_GPL(nfs_file_fsync_commit);

static int
nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
Expand Down Expand Up @@ -615,6 +623,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
printk(KERN_INFO "NFS: attempt to write to active swap file!\n");
goto out;
}
EXPORT_SYMBOL_GPL(nfs_file_write);

ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe,
struct file *filp, loff_t *ppos,
Expand Down Expand Up @@ -646,6 +655,7 @@ ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe,
nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written);
return ret;
}
EXPORT_SYMBOL_GPL(nfs_file_splice_write);

static int
do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
Expand Down Expand Up @@ -806,6 +816,7 @@ int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
out_err:
return ret;
}
EXPORT_SYMBOL_GPL(nfs_lock);

/*
* Lock a (portion of) a file
Expand Down Expand Up @@ -835,6 +846,7 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl)
return do_unlk(filp, cmd, fl, is_local);
return do_setlk(filp, cmd, fl, is_local);
}
EXPORT_SYMBOL_GPL(nfs_flock);

/*
* There is no protocol support for leases, so we have no way to implement
Expand All @@ -847,6 +859,7 @@ int nfs_setlease(struct file *file, long arg, struct file_lock **fl)
file->f_path.dentry->d_name.name, arg);
return -EINVAL;
}
EXPORT_SYMBOL_GPL(nfs_setlease);

const struct file_operations nfs_file_operations = {
.llseek = nfs_file_llseek,
Expand Down
Loading

0 comments on commit 89d77c8

Please sign in to comment.