From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 04/11] lockd: Add attributes to /sys/fs/lockd/hosts/*/
Date: Thu, 01 Apr 2010 15:02:57 -0400 [thread overview]
Message-ID: <20100401190257.6395.49271.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100401183724.6395.60353.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
Expose fields in each nlm_host cache entry via files under
/sys/fs/lockd/hosts/{client,server}/*/.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/host.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 137 insertions(+), 0 deletions(-)
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 2414ef7..b15579b 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -83,7 +83,144 @@ static struct sysfs_ops nlm_kobj_sysfs_ops = {
.store = nlm_kobj_store,
};
+static ssize_t address_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n", host->h_addrbuf);
+}
+
+static ssize_t source_address_show(struct nlm_host *host, char *buf)
+{
+ struct sockaddr *sap = (struct sockaddr *)(char *)&host->h_srcaddr;
+ switch (sap->sa_family) {
+ case AF_UNSPEC:
+ return snprintf(buf, PAGE_SIZE, "unspecified address\n");
+ case AF_INET:
+ return snprintf(buf, PAGE_SIZE, "%pI4\n", sap);
+ case AF_INET6:
+ return snprintf(buf, PAGE_SIZE, "%pI6c\n", sap);
+ }
+ return snprintf(buf, PAGE_SIZE, "unrecognized address\n");
+}
+
+static ssize_t name_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n", host->h_name);
+}
+
+static ssize_t nlm_version_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%u\n", host->h_version);
+}
+
+static ssize_t transport_show(struct nlm_host *host, char *buf)
+{
+ switch (host->h_proto) {
+ case IPPROTO_UDP:
+ return snprintf(buf, PAGE_SIZE, "udp\n");
+ case IPPROTO_TCP:
+ return snprintf(buf, PAGE_SIZE, "tcp\n");
+ }
+ return snprintf(buf, PAGE_SIZE, "unknown\n");
+}
+
+static ssize_t reclaiming_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n",
+ host->h_reclaiming ? "in progress" : "no");
+}
+
+static ssize_t peer_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n",
+ host->h_server ? "client" : "server");
+}
+
+static ssize_t resvport_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n",
+ host->h_noresvport ? "no" : "yes");
+}
+
+static ssize_t in_use_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n",
+ host->h_inuse ? "yes" : "no");
+}
+
+static ssize_t pseudo_state_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%u\n", host->h_state);
+}
+
+static ssize_t nsm_state_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%u\n", host->h_nsmstate);
+}
+
+static ssize_t pidcount_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%u\n", host->h_pidcount);
+}
+
+static ssize_t refcount_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&host->h_count));
+}
+
+static ssize_t nextrebind_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%lu seconds \n",
+ (host->h_nextrebind - jiffies) / HZ);
+}
+
+static ssize_t expires_show(struct nlm_host *host, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%lu seconds\n",
+ (host->h_expires - jiffies) / HZ);
+}
+
+#ifdef __ATTR_RO
+#undef __ATTR_RO
+#endif
+
+#define __ATTR_RO(_name) { \
+ .attr = { .name = __stringify(_name), .mode = S_IRUSR, }, \
+ .show = _name##_show, \
+}
+
+static struct nlm_host_attr address_attr = __ATTR_RO(address);
+static struct nlm_host_attr source_address_attr = __ATTR_RO(source_address);
+static struct nlm_host_attr name_attr = __ATTR_RO(name);
+static struct nlm_host_attr nlm_version_attr = __ATTR_RO(nlm_version);
+static struct nlm_host_attr transport_attr = __ATTR_RO(transport);
+static struct nlm_host_attr reclaiming_attr = __ATTR_RO(reclaiming);
+static struct nlm_host_attr peer_attr = __ATTR_RO(peer);
+static struct nlm_host_attr resvport_attr = __ATTR_RO(resvport);
+static struct nlm_host_attr in_use_attr = __ATTR_RO(in_use);
+static struct nlm_host_attr pseudo_state_attr = __ATTR_RO(pseudo_state);
+static struct nlm_host_attr nsm_state_attr = __ATTR_RO(nsm_state);
+static struct nlm_host_attr pidcount_attr = __ATTR_RO(pidcount);
+static struct nlm_host_attr refcount_attr = __ATTR_RO(refcount);
+static struct nlm_host_attr nextrebind_attr = __ATTR_RO(nextrebind);
+static struct nlm_host_attr expires_attr = __ATTR_RO(expires);
+
static struct attribute *nlm_kobj_attrs[] = {
+ &address_attr.attr,
+ &source_address_attr.attr,
+ &name_attr.attr,
+ &nlm_version_attr.attr,
+ &transport_attr.attr,
+ &reclaiming_attr.attr,
+ &peer_attr.attr,
+ &resvport_attr.attr,
+ &in_use_attr.attr,
+ &pseudo_state_attr.attr,
+ &nsm_state_attr.attr,
+ &pidcount_attr.attr,
+ &refcount_attr.attr,
+ &nextrebind_attr.attr,
+ &expires_attr.attr,
+ NULL,
};
static struct kobj_type nlm_host_ktype = {
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 ` [PATCH 02/11] lockd: Add /sys/fs/lockd/hosts/ Chuck Lever
2010-04-01 19:02 ` [PATCH 03/11] lockd: Add /sys/fs/lockd/hosts/* Chuck Lever
2010-04-01 19:02 ` Chuck Lever [this message]
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=20100401190257.6395.49271.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