From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 02/11] lockd: Add /sys/fs/lockd/hosts/
Date: Thu, 01 Apr 2010 15:02:38 -0400 [thread overview]
Message-ID: <20100401190238.6395.13353.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100401183724.6395.60353.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
Add parent directory to contain directories representing entries in
lockd's host cache.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/host.c | 46 +++++++++++++++++++++++++++++++++++++++++++
fs/lockd/svc.c | 7 +++++++
include/linux/lockd/lockd.h | 2 ++
3 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 4600c20..3fbb0a5 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -45,6 +45,10 @@ struct nlm_lookup_host_info {
const int noresvport; /* use non-priv port */
};
+static struct kobject *nlm_hosts_kobj;
+static struct kobject *nlm_hosts_client_kobj;
+static struct kobject *nlm_hosts_server_kobj;
+
/*
* Hash function must work well on big- and little-endian platforms
*/
@@ -567,3 +571,45 @@ nlm_gc_hosts(void)
next_gc = jiffies + NLM_HOST_COLLECT;
}
+
+/**
+ * nlm_host_init - Called when lockd module is loaded
+ *
+ */
+int nlm_host_init(void)
+{
+ nlm_hosts_kobj = kobject_create_and_add("hosts", nlm_kobj);
+ if (nlm_hosts_kobj == NULL)
+ return -ENOMEM;
+
+ nlm_hosts_server_kobj = kobject_create_and_add("server", nlm_hosts_kobj);
+ if (nlm_hosts_server_kobj == NULL) {
+ kobject_put(nlm_hosts_kobj);
+ return -ENOMEM;
+ }
+
+ nlm_hosts_client_kobj = kobject_create_and_add("client", nlm_hosts_kobj);
+ if (nlm_hosts_client_kobj == NULL) {
+ kobject_put(nlm_hosts_server_kobj);
+ kobject_put(nlm_hosts_kobj);
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+/**
+ * nlm_host_shutdown - Called when lockd module is about to be unloaded
+ *
+ */
+void nlm_host_shutdown(void)
+{
+ if (nrhosts != 0) {
+ printk(KERN_WARNING "NLM hosts remain at shutdown");
+ return;
+ }
+
+ kobject_put(nlm_hosts_client_kobj);
+ kobject_put(nlm_hosts_server_kobj);
+ kobject_put(nlm_hosts_kobj);
+}
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 94e0d4b..acfb6d7 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -521,9 +521,15 @@ static int __init init_nlm(void)
if (!nlm_kobj)
return -ENOMEM;
+ if (nlm_host_init()) {
+ kobject_put(nlm_kobj);
+ return -ENOMEM;
+ }
+
#ifdef CONFIG_SYSCTL
nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root);
if (!nlm_sysctl_table) {
+ nlm_host_shutdown();
kobject_put(nlm_kobj);
return -ENOMEM;
}
@@ -539,6 +545,7 @@ static void __exit exit_nlm(void)
#ifdef CONFIG_SYSCTL
unregister_sysctl_table(nlm_sysctl_table);
#endif
+ nlm_host_shutdown();
kobject_put(nlm_kobj);
}
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 56c749e..2d89cdb 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -217,6 +217,8 @@ void nlmclnt_next_cookie(struct nlm_cookie *);
/*
* Host cache
*/
+int nlm_host_init(void);
+void nlm_host_shutdown(void);
struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
const size_t salen,
const unsigned short protocol,
next prev parent reply other threads:[~2010-04-01 19:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-01 19:02 [PATCH 00/11] [RFC] possible NFSv2/v3 lock recovery enhancements Chuck Lever
[not found] ` <20100401183724.6395.60353.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-04-01 19:02 ` [PATCH 01/11] lockd: Add /sys/fs/lockd Chuck Lever
2010-04-01 19:02 ` Chuck Lever [this message]
2010-04-01 19:02 ` [PATCH 03/11] lockd: Add /sys/fs/lockd/hosts/* Chuck Lever
2010-04-01 19:02 ` [PATCH 04/11] lockd: Add attributes to /sys/fs/lockd/hosts/*/ Chuck Lever
2010-04-01 19:03 ` [PATCH 05/11] lockd: Add /sys/fs/lockd/mon Chuck Lever
2010-04-01 19:03 ` [PATCH 06/11] lockd: Add /sys/fs/lockd/nsm_handle/* Chuck Lever
2010-04-01 19:03 ` [PATCH 07/11] lockd: Refactor nlm_host_rebooted() Chuck Lever
2010-04-01 19:03 ` [PATCH 08/11] lockd: Add "reboot" attribute to nsm_handles Chuck Lever
2010-04-01 19:03 ` [PATCH 09/11] lockd: Keep my_name in nsm_handle Chuck Lever
2010-04-01 19:03 ` [PATCH 10/11] lockd: use sm_my_name for nsm_handle lookups Chuck Lever
2010-04-01 19:04 ` [PATCH 11/11] lockd: Allow mount option to specify caller_name Chuck Lever
[not found] ` <20100401190400.6395.52787.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-04-01 19:45 ` Trond Myklebust
[not found] ` <1270151136.13329.8.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-04-01 20:01 ` Trond Myklebust
2010-04-01 21:08 ` Chuck Lever
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=20100401190238.6395.13353.stgit@localhost.localdomain \
--to=chuck.lever@oracle.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