diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-03-21 09:52:08 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-03-26 11:49:48 -0400 |
commit | 813fd320c16691eac508fe350b4ee7362c6c4a56 (patch) | |
tree | 3ec14685fb13b2f5fba6ed1ce78e5e6bdb7c173e /fs/nfsd/nfs4recover.c | |
parent | f3f8014862d813cca81a597c83bd1dbf0fb2b8f6 (diff) | |
download | blackbird-obmc-linux-813fd320c16691eac508fe350b4ee7362c6c4a56.tar.gz blackbird-obmc-linux-813fd320c16691eac508fe350b4ee7362c6c4a56.zip |
nfsd: add notifier to handle mount/unmount of rpc_pipefs sb
In the event that rpc_pipefs isn't mounted when nfsd starts, we
must register a notifier to handle creating the dentry once it
is mounted, and to remove the dentry on unmount.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4recover.c')
-rw-r--r-- | fs/nfsd/nfs4recover.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index cec62ed2a064..6f13281635ba 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -38,6 +38,7 @@ #include <linux/crypto.h> #include <linux/sched.h> #include <linux/fs.h> +#include <linux/module.h> #include <net/net_namespace.h> #include <linux/sunrpc/rpc_pipe_fs.h> #include <linux/sunrpc/clnt.h> @@ -982,3 +983,46 @@ nfsd4_record_grace_done(struct net *net, time_t boot_time) if (client_tracking_ops) client_tracking_ops->grace_done(net, boot_time); } + +static int +rpc_pipefs_event(struct notifier_block *nb, unsigned long event, void *ptr) +{ + struct super_block *sb = ptr; + struct net *net = sb->s_fs_info; + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + struct cld_net *cn = nn->cld_net; + struct dentry *dentry; + int ret = 0; + + if (!try_module_get(THIS_MODULE)) + return 0; + + if (!cn) { + module_put(THIS_MODULE); + return 0; + } + + switch (event) { + case RPC_PIPEFS_MOUNT: + dentry = nfsd4_cld_register_sb(sb, cn->cn_pipe); + if (IS_ERR(dentry)) { + ret = PTR_ERR(dentry); + break; + } + cn->cn_pipe->dentry = dentry; + break; + case RPC_PIPEFS_UMOUNT: + if (cn->cn_pipe->dentry) + nfsd4_cld_unregister_sb(cn->cn_pipe); + break; + default: + ret = -ENOTSUPP; + break; + } + module_put(THIS_MODULE); + return ret; +} + +struct notifier_block nfsd4_cld_block = { + .notifier_call = rpc_pipefs_event, +}; |