aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4recover.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-03-21 09:52:08 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-03-26 11:49:48 -0400
commit813fd320c16691eac508fe350b4ee7362c6c4a56 (patch)
tree3ec14685fb13b2f5fba6ed1ce78e5e6bdb7c173e /fs/nfsd/nfs4recover.c
parentf3f8014862d813cca81a597c83bd1dbf0fb2b8f6 (diff)
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.c44
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 @@
38#include <linux/crypto.h> 38#include <linux/crypto.h>
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <linux/fs.h> 40#include <linux/fs.h>
41#include <linux/module.h>
41#include <net/net_namespace.h> 42#include <net/net_namespace.h>
42#include <linux/sunrpc/rpc_pipe_fs.h> 43#include <linux/sunrpc/rpc_pipe_fs.h>
43#include <linux/sunrpc/clnt.h> 44#include <linux/sunrpc/clnt.h>
@@ -982,3 +983,46 @@ nfsd4_record_grace_done(struct net *net, time_t boot_time)
982 if (client_tracking_ops) 983 if (client_tracking_ops)
983 client_tracking_ops->grace_done(net, boot_time); 984 client_tracking_ops->grace_done(net, boot_time);
984} 985}
986
987static int
988rpc_pipefs_event(struct notifier_block *nb, unsigned long event, void *ptr)
989{
990 struct super_block *sb = ptr;
991 struct net *net = sb->s_fs_info;
992 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
993 struct cld_net *cn = nn->cld_net;
994 struct dentry *dentry;
995 int ret = 0;
996
997 if (!try_module_get(THIS_MODULE))
998 return 0;
999
1000 if (!cn) {
1001 module_put(THIS_MODULE);
1002 return 0;
1003 }
1004
1005 switch (event) {
1006 case RPC_PIPEFS_MOUNT:
1007 dentry = nfsd4_cld_register_sb(sb, cn->cn_pipe);
1008 if (IS_ERR(dentry)) {
1009 ret = PTR_ERR(dentry);
1010 break;
1011 }
1012 cn->cn_pipe->dentry = dentry;
1013 break;
1014 case RPC_PIPEFS_UMOUNT:
1015 if (cn->cn_pipe->dentry)
1016 nfsd4_cld_unregister_sb(cn->cn_pipe);
1017 break;
1018 default:
1019 ret = -ENOTSUPP;
1020 break;
1021 }
1022 module_put(THIS_MODULE);
1023 return ret;
1024}
1025
1026struct notifier_block nfsd4_cld_block = {
1027 .notifier_call = rpc_pipefs_event,
1028};