From: Jeff Layton <jlayton@redhat.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, skinsbursky@parallels.com
Subject: [PATCH v9 6/6] nfsd: add notifier to handle mount/unmount of rpc_pipefs sb
Date: Tue, 6 Mar 2012 10:28:53 -0500 [thread overview]
Message-ID: <1331047733-1641-7-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1331047733-1641-1-git-send-email-jlayton@redhat.com>
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>
---
fs/nfsd/netns.h | 1 +
fs/nfsd/nfs4recover.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
fs/nfsd/nfsctl.c | 9 ++++++++-
3 files changed, 53 insertions(+), 1 deletions(-)
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h
index 12e0cff..66eac33 100644
--- a/fs/nfsd/netns.h
+++ b/fs/nfsd/netns.h
@@ -31,4 +31,5 @@ struct nfsd_net {
};
extern int nfsd_net_id;
+extern struct notifier_block nfsd4_cld_block;
#endif /* __NFSD_NETNS_H__ */
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index bc4b189..d2f3680 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>
@@ -975,3 +976,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,
+};
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 141197e..dee6c1b 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -13,6 +13,7 @@
#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/gss_api.h>
#include <linux/sunrpc/gss_krb5_enctypes.h>
+#include <linux/sunrpc/rpc_pipe_fs.h>
#include <linux/module.h>
#include "idmap.h"
@@ -1136,9 +1137,12 @@ static int __init init_nfsd(void)
int retval;
printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
+ retval = rpc_pipefs_notifier_register(&nfsd4_cld_block);
+ if (retval)
+ return retval;
retval = register_pernet_subsys(&nfsd_net_ops);
if (retval < 0)
- return retval;
+ goto out_unregister_notifier;
retval = nfsd4_init_slabs();
if (retval)
goto out_unregister_pernet;
@@ -1181,6 +1185,8 @@ out_free_slabs:
nfsd4_free_slabs();
out_unregister_pernet:
unregister_pernet_subsys(&nfsd_net_ops);
+out_unregister_notifier:
+ rpc_pipefs_notifier_unregister(&nfsd4_cld_block);
return retval;
}
@@ -1197,6 +1203,7 @@ static void __exit exit_nfsd(void)
nfsd_fault_inject_cleanup();
unregister_filesystem(&nfsd_fs_type);
unregister_pernet_subsys(&nfsd_net_ops);
+ rpc_pipefs_notifier_unregister(&nfsd4_cld_block);
}
MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
--
1.7.7.6
next prev parent reply other threads:[~2012-03-06 15:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-06 15:28 [PATCH v9 0/6] nfsd: overhaul the client name tracking code Jeff Layton
2012-03-06 15:28 ` [PATCH v9 1/6] nfsd: add nfsd4_client_tracking_ops struct and a way to set it Jeff Layton
2012-03-06 15:28 ` [PATCH v9 2/6] sunrpc: create nfsd dir in rpc_pipefs Jeff Layton
2012-03-06 15:28 ` [PATCH v9 3/6] nfsd: add a per-net-namespace struct for nfsd Jeff Layton
2012-03-06 17:43 ` Stanislav Kinsbursky
2012-03-06 18:31 ` Jeff Layton
2012-03-06 20:48 ` Jeff Layton
2012-03-07 8:46 ` Stanislav Kinsbursky
2012-03-11 7:44 ` Stanislav Kinsbursky
2012-03-06 15:28 ` [PATCH v9 4/6] nfsd: add a header describing upcall to nfsdcld Jeff Layton
2012-03-06 15:28 ` [PATCH v9 5/6] nfsd: add the infrastructure to handle the cld upcall Jeff Layton
2012-03-06 15:28 ` Jeff Layton [this message]
2012-03-11 7:45 ` [PATCH v9 6/6] nfsd: add notifier to handle mount/unmount of rpc_pipefs sb Stanislav Kinsbursky
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=1331047733-1641-7-git-send-email-jlayton@redhat.com \
--to=jlayton@redhat.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
--cc=skinsbursky@parallels.com \
/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).