* [PATCH 01/18] NLM: nlm_privileged_requester() doesn't recognize mapped loopback address
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
@ 2008-11-05 17:19 ` Chuck Lever
2008-11-05 17:19 ` [PATCH 02/18] NSM: Support IPv6 version of mon_name Chuck Lever
` (17 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:19 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Commit b85e4676 added the nlm_privileged_requester() helper to check
whether an RPC request was sent from a local privileged caller. It
recognizes IPv4 privileged callers (from "127.0.0.1"), and IPv6
privileged callers (from "::1").
However, IPV6_ADDR_LOOPBACK is not set for the mapped IPv4 loopback
address (::ffff:7f00:0001), so the test breaks when the kernel's RPC
service is IPv6-enabled but user space is calling via the IPv4
loopback address. This is actually the most common case for IPv6-
enabled RPC services on Linux.
Rewrite the IPv6 check to handle the mapped IPv4 loopback address as
well as a normal IPv6 loopback address. For consistency, rewrite the
IPv4 check to match the same style as the IPv6 check, which is now
somewhat more broad than a strict check for 127.0.0.1.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
include/linux/lockd/lockd.h | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index b56d5aa..830148e 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -280,16 +280,25 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
static inline int __nlm_privileged_request4(const struct sockaddr *sap)
{
const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
- return (sin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) &&
- (ntohs(sin->sin_port) < 1024);
+
+ if (ntohs(sin->sin_port) > 1023)
+ return 0;
+
+ return ipv4_is_loopback(sin->sin_addr.s_addr);
}
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
static inline int __nlm_privileged_request6(const struct sockaddr *sap)
{
const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
- return (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LOOPBACK) &&
- (ntohs(sin6->sin6_port) < 1024);
+
+ if (ntohs(sin6->sin6_port) > 1023)
+ return 0;
+
+ if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED)
+ return ipv4_is_loopback(sin6->sin6_addr.s6_addr32[3]);
+
+ return ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LOOPBACK;
}
#else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
static inline int __nlm_privileged_request6(const struct sockaddr *sap)
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 02/18] NSM: Support IPv6 version of mon_name
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-11-05 17:19 ` [PATCH 01/18] NLM: nlm_privileged_requester() doesn't recognize mapped loopback address Chuck Lever
@ 2008-11-05 17:19 ` Chuck Lever
2008-11-05 17:19 ` [PATCH 03/18] NLM: Support IPv6 scope IDs in nlm_display_address() Chuck Lever
` (16 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:19 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
When the "nsm_use_hostnames" sysctl is set to zero, the kernel's NSM
provides a presentation format IP address in the mon_name argument of
SM_MON upcalls. This is part of the private interface between Linux's
rpc.statd and the kernel's lockd implementation. Linux's rpc.statd
can then resolve this address with DNS as a sanity check.
To support IPv6 addresses for the mon_name argument, just point the
XDR encoder to the nsm_handle's eye-catcher, which already contains a
presentation format address string.
Finally, provide some debugging message clean up.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 43 +++++++++++++++----------------------------
1 files changed, 15 insertions(+), 28 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 4e7e958..d03d1ea 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -18,8 +18,6 @@
#define NLMDBG_FACILITY NLMDBG_MONITOR
-#define XDR_ADDRBUF_LEN (20)
-
static struct rpc_clnt * nsm_create(void);
static struct rpc_program nsm_program;
@@ -37,7 +35,14 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res)
{
struct rpc_clnt *clnt;
int status;
- struct nsm_args args;
+ struct nsm_args args = {
+ .addr = nsm_addr_in(nsm)->sin_addr.s_addr,
+ .prog = NLM_PROGRAM,
+ .vers = 3,
+ .proc = NLMPROC_NSM_NOTIFY,
+ .mon_name = nsm_use_hostnames ?
+ nsm->sm_name : nsm->sm_addrbuf,
+ };
struct rpc_message msg = {
.rpc_argp = &args,
.rpc_resp = res,
@@ -46,24 +51,21 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res)
clnt = nsm_create();
if (IS_ERR(clnt)) {
status = PTR_ERR(clnt);
+ dprintk("lockd: failed to create nsm transport, "
+ "status=%d\n", status);
goto out;
}
- memset(&args, 0, sizeof(args));
- args.mon_name = nsm->sm_name;
- args.addr = nsm_addr_in(nsm)->sin_addr.s_addr;
- args.prog = NLM_PROGRAM;
- args.vers = 3;
- args.proc = NLMPROC_NSM_NOTIFY;
memset(res, 0, sizeof(*res));
msg.rpc_proc = &clnt->cl_procinfo[proc];
status = rpc_call_sync(clnt, &msg, 0);
if (status < 0)
- printk(KERN_DEBUG "nsm_mon_unmon: rpc failed, status=%d\n",
- status);
- else
+ dprintk("lockd: nsm rpc failed, status=%d\n", status);
+ else {
status = 0;
+ dprintk("lockd: monitoring '%s'\n", args.mon_name);
+ }
rpc_shutdown_client(clnt);
out:
return status;
@@ -165,25 +167,10 @@ static __be32 *xdr_encode_nsm_string(__be32 *p, char *string)
/*
* "mon_name" specifies the host to be monitored.
- *
- * Linux uses a text version of the IP address of the remote
- * host as the host identifier (the "mon_name" argument).
- *
- * Linux statd always looks up the canonical hostname first for
- * whatever remote hostname it receives, so this works alright.
*/
static __be32 *xdr_encode_mon_name(__be32 *p, struct nsm_args *argp)
{
- char buffer[XDR_ADDRBUF_LEN + 1];
- char *name = argp->mon_name;
-
- if (!nsm_use_hostnames) {
- snprintf(buffer, XDR_ADDRBUF_LEN,
- NIPQUAD_FMT, NIPQUAD(argp->addr));
- name = buffer;
- }
-
- return xdr_encode_nsm_string(p, name);
+ return xdr_encode_nsm_string(p, argp->mon_name);
}
/*
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 03/18] NLM: Support IPv6 scope IDs in nlm_display_address()
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-11-05 17:19 ` [PATCH 01/18] NLM: nlm_privileged_requester() doesn't recognize mapped loopback address Chuck Lever
2008-11-05 17:19 ` [PATCH 02/18] NSM: Support IPv6 version of mon_name Chuck Lever
@ 2008-11-05 17:19 ` Chuck Lever
2008-11-05 17:19 ` [PATCH 04/18] NSM: Move nsm_find() to fs/lockd/mon.c Chuck Lever
` (15 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:19 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Scope ID support is needed since NSM now uses these displayed addresses
as a mon_name in some cases. Without scope ID support, NSM will fail
to handle peers that contact us via a link-local address (if
nsm_use_hostnames is zero). Link-local addresses do not work without
an interface ID, which is stored in the sockaddr's sin6_scope_id field.
As a clean up, create a LOCKD_ADDRBUF_SIZE macro to control the size of
the buffers used to store presentation format addresses, and increase the size
of these buffers to accomodate an interface ID for IPv6 addresses with a
non-zero scope ID.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/host.c | 33 ++++++++++++++++++++++++---------
include/linux/lockd/lockd.h | 11 ++++++++---
2 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 9fd8889..50b7787 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -104,25 +104,40 @@ static void nlm_clear_port(struct sockaddr *sap)
}
}
-static void nlm_display_address(const struct sockaddr *sap,
- char *buf, const size_t len)
+static void nlm_display_ipv4_address(const struct sockaddr *sap, char *buf,
+ const size_t len)
{
const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
+ snprintf(buf, len, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr));
+}
+
+static void nlm_display_ipv6_address(const struct sockaddr *sap, char *buf,
+ const size_t len)
+{
const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
+ if (ipv6_addr_v4mapped(&sin6->sin6_addr))
+ snprintf(buf, len, NIPQUAD_FMT,
+ NIPQUAD(sin6->sin6_addr.s6_addr32[3]));
+ else if (sin6->sin6_scope_id != 0)
+ snprintf(buf, len, NIP6_FMT "%%%u", NIP6(sin6->sin6_addr),
+ sin6->sin6_scope_id);
+ else
+ snprintf(buf, len, NIP6_FMT, NIP6(sin6->sin6_addr));
+}
+
+static void nlm_display_address(const struct sockaddr *sap,
+ char *buf, const size_t len)
+{
switch (sap->sa_family) {
case AF_UNSPEC:
- snprintf(buf, len, "unspecified");
+ snprintf(buf, len, "unspecified address");
break;
case AF_INET:
- snprintf(buf, len, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr));
+ nlm_display_ipv4_address(sap, buf, len);
break;
case AF_INET6:
- if (ipv6_addr_v4mapped(&sin6->sin6_addr))
- snprintf(buf, len, NIPQUAD_FMT,
- NIPQUAD(sin6->sin6_addr.s6_addr32[3]));
- else
- snprintf(buf, len, NIP6_FMT, NIP6(sin6->sin6_addr));
+ nlm_display_ipv6_address(sap, buf, len);
break;
default:
snprintf(buf, len, "unsupported address family");
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 830148e..3e0b7a8 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -36,6 +36,11 @@
#define LOCKD_DFLT_TIMEO 10
/*
+ * Size of presentation format address buffer
+ */
+#define LOCKD_ADDRBUF_SIZE 63
+
+/*
* Lockd host handle (used both by the client and server personality).
*/
struct nlm_host {
@@ -65,8 +70,8 @@ struct nlm_host {
struct list_head h_reclaim; /* Locks in RECLAIM state */
struct nsm_handle * h_nsmhandle; /* NSM status handle */
- char h_addrbuf[48], /* address eyecatchers */
- h_srcaddrbuf[48];
+ char h_addrbuf[LOCKD_ADDRBUF_SIZE],
+ h_srcaddrbuf[LOCKD_ADDRBUF_SIZE];
};
struct nsm_handle {
@@ -77,7 +82,7 @@ struct nsm_handle {
size_t sm_addrlen;
unsigned int sm_monitored : 1,
sm_sticky : 1; /* don't unmonitor */
- char sm_addrbuf[48]; /* address eyecatcher */
+ char sm_addrbuf[LOCKD_ADDRBUF_SIZE];
};
/*
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 04/18] NSM: Move nsm_find() to fs/lockd/mon.c
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (2 preceding siblings ...)
2008-11-05 17:19 ` [PATCH 03/18] NLM: Support IPv6 scope IDs in nlm_display_address() Chuck Lever
@ 2008-11-05 17:19 ` Chuck Lever
2008-11-05 17:19 ` [PATCH 05/18] NSM: move nsm_create() Chuck Lever
` (14 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:19 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Start coalescing NSM-related functions into fs/lockd/mon.c by moving
the nsm_find() function (and associated static variables) into
fs/lockd/mon.c.
Add dprintk()s (enabled via NLMDBG_MONITOR) to indicate when an
nsm_handle has been created, found, or destroyed.
It doesn't currently seem possible to call nsm_release() with a NULL
argument, so I'm removing that check.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/host.c | 102 ++++---------------------------------------
fs/lockd/mon.c | 101 +++++++++++++++++++++++++++++++++++++++++++
include/linux/lockd/lockd.h | 11 ++++-
3 files changed, 120 insertions(+), 94 deletions(-)
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 50b7787..50dcf79 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -32,11 +32,6 @@ static int nrhosts;
static DEFINE_MUTEX(nlm_host_mutex);
static void nlm_gc_hosts(void);
-static struct nsm_handle *nsm_find(const struct sockaddr *sap,
- const size_t salen,
- const char *hostname,
- const size_t hostname_len,
- const int create);
struct nlm_lookup_host_info {
const int server; /* search for server|client */
@@ -126,8 +121,15 @@ static void nlm_display_ipv6_address(const struct sockaddr *sap, char *buf,
snprintf(buf, len, NIP6_FMT, NIP6(sin6->sin6_addr));
}
-static void nlm_display_address(const struct sockaddr *sap,
- char *buf, const size_t len)
+/**
+ * nlm_display_address - Convert sockaddr to presentation format
+ * @sap: pointer to socket address
+ * @buf: pointer to buffer to fill in
+ * @len: length of buffer
+ *
+ */
+void nlm_display_address(const struct sockaddr *sap, char *buf,
+ const size_t len)
{
switch (sap->sa_family) {
case AF_UNSPEC:
@@ -635,89 +637,3 @@ nlm_gc_hosts(void)
next_gc = jiffies + NLM_HOST_COLLECT;
}
-
-
-/*
- * Manage NSM handles
- */
-static LIST_HEAD(nsm_handles);
-static DEFINE_SPINLOCK(nsm_lock);
-
-static struct nsm_handle *nsm_find(const struct sockaddr *sap,
- const size_t salen,
- const char *hostname,
- const size_t hostname_len,
- const int create)
-{
- struct nsm_handle *nsm = NULL;
- struct nsm_handle *pos;
-
- if (!sap)
- return NULL;
-
- if (hostname && memchr(hostname, '/', hostname_len) != NULL) {
- if (printk_ratelimit()) {
- printk(KERN_WARNING "Invalid hostname \"%.*s\" "
- "in NFS lock request\n",
- (int)hostname_len, hostname);
- }
- return NULL;
- }
-
-retry:
- spin_lock(&nsm_lock);
- list_for_each_entry(pos, &nsm_handles, sm_link) {
-
- if (hostname && nsm_use_hostnames) {
- if (strlen(pos->sm_name) != hostname_len
- || memcmp(pos->sm_name, hostname, hostname_len))
- continue;
- } else if (!nlm_cmp_addr(nsm_addr(pos), sap))
- continue;
- atomic_inc(&pos->sm_count);
- kfree(nsm);
- nsm = pos;
- goto found;
- }
- if (nsm) {
- list_add(&nsm->sm_link, &nsm_handles);
- goto found;
- }
- spin_unlock(&nsm_lock);
-
- if (!create)
- return NULL;
-
- nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL);
- if (nsm == NULL)
- return NULL;
-
- memcpy(nsm_addr(nsm), sap, salen);
- nsm->sm_addrlen = salen;
- nsm->sm_name = (char *) (nsm + 1);
- memcpy(nsm->sm_name, hostname, hostname_len);
- nsm->sm_name[hostname_len] = '\0';
- nlm_display_address((struct sockaddr *)&nsm->sm_addr,
- nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
- atomic_set(&nsm->sm_count, 1);
- goto retry;
-
-found:
- spin_unlock(&nsm_lock);
- return nsm;
-}
-
-/*
- * Release an NSM handle
- */
-void
-nsm_release(struct nsm_handle *nsm)
-{
- if (!nsm)
- return;
- if (atomic_dec_and_lock(&nsm->sm_count, &nsm_lock)) {
- list_del(&nsm->sm_link);
- spin_unlock(&nsm_lock);
- kfree(nsm);
- }
-}
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index d03d1ea..3811485 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -21,6 +21,8 @@
static struct rpc_clnt * nsm_create(void);
static struct rpc_program nsm_program;
+static LIST_HEAD(nsm_handles);
+static DEFINE_SPINLOCK(nsm_lock);
/*
* Local NSM state
@@ -125,6 +127,105 @@ nsm_unmonitor(struct nlm_host *host)
return status;
}
+/**
+ * nsm_find - Find or create a cached nsm_handle
+ * @sap: pointer to socket address of handle to find
+ * @salen: length of socket address
+ * @hostname: pointer to C string containing hostname to find
+ * @hostname_len: length of C string
+ * @create: one means create new handle if not found in cache
+ *
+ * Behavior is modulated by the global nsm_use_hostnames variable
+ * and by the @create argument.
+ *
+ * Returns a cached nsm_handle after bumping its ref count, or if
+ * @create is set, returns a fresh nsm_handle if a handle that
+ * matches @sap and/or @hostname cannot be found in the handle cache.
+ * Returns NULL if an error occurs.
+ */
+struct nsm_handle *nsm_find(const struct sockaddr *sap, const size_t salen,
+ const char *hostname, const size_t hostname_len,
+ const int create)
+{
+ struct nsm_handle *nsm = NULL;
+ struct nsm_handle *pos;
+
+ if (!sap)
+ return NULL;
+
+ if (hostname && memchr(hostname, '/', hostname_len) != NULL) {
+ if (printk_ratelimit()) {
+ printk(KERN_WARNING "Invalid hostname \"%.*s\" "
+ "in NFS lock request\n",
+ (int)hostname_len, hostname);
+ }
+ return NULL;
+ }
+
+retry:
+ spin_lock(&nsm_lock);
+ list_for_each_entry(pos, &nsm_handles, sm_link) {
+ if (hostname && nsm_use_hostnames) {
+ if (strlen(pos->sm_name) != hostname_len
+ || memcmp(pos->sm_name, hostname, hostname_len))
+ continue;
+ } else if (!nlm_cmp_addr(nsm_addr(pos), sap))
+ continue;
+
+ atomic_inc(&pos->sm_count);
+ spin_unlock(&nsm_lock);
+ kfree(nsm);
+ dprintk("lockd: found nsm_handle for %s (%s), cnt %d\n",
+ pos->sm_name, pos->sm_addrbuf,
+ atomic_read(&pos->sm_count));
+ return pos;
+ }
+
+ if (nsm) {
+ list_add(&nsm->sm_link, &nsm_handles);
+ spin_unlock(&nsm_lock);
+ dprintk("lockd: created nsm_handle for %s (%s)\n",
+ nsm->sm_name, nsm->sm_addrbuf);
+ return nsm;
+ }
+
+ spin_unlock(&nsm_lock);
+
+ if (!create)
+ return NULL;
+
+ nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL);
+ if (nsm == NULL)
+ return NULL;
+
+ memcpy(nsm_addr(nsm), sap, salen);
+ nsm->sm_addrlen = salen;
+ nsm->sm_name = (char *) (nsm + 1);
+ memcpy(nsm->sm_name, hostname, hostname_len);
+ nsm->sm_name[hostname_len] = '\0';
+ nlm_display_address((struct sockaddr *)&nsm->sm_addr,
+ nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
+ atomic_set(&nsm->sm_count, 1);
+ goto retry;
+}
+
+/**
+ * nsm_release - Release an NSM handle
+ * @nsm: pointer to handle to be released
+ *
+ */
+void nsm_release(struct nsm_handle *nsm)
+{
+ if (!atomic_dec_and_lock(&nsm->sm_count, &nsm_lock))
+ return;
+
+ list_del(&nsm->sm_link);
+ spin_unlock(&nsm_lock);
+ dprintk("lockd: destroyed nsm_handle for %s (%s)\n",
+ nsm->sm_name, nsm->sm_addrbuf);
+ kfree(nsm);
+}
+
/*
* Create NSM client for the local host
*/
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 3e0b7a8..34f0101 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -229,6 +229,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
const char *hostname,
const size_t hostname_len);
+void nlm_display_address(const struct sockaddr *sap,
+ char *buf, const size_t len);
struct rpc_clnt * nlm_bind_host(struct nlm_host *);
void nlm_rebind_host(struct nlm_host *);
struct nlm_host * nlm_get_host(struct nlm_host *);
@@ -236,8 +238,15 @@ void nlm_release_host(struct nlm_host *);
void nlm_shutdown_hosts(void);
extern void nlm_host_rebooted(const struct sockaddr_in *, const char *,
unsigned int, u32);
-void nsm_release(struct nsm_handle *);
+/*
+ * Host monitoring
+ */
+struct nsm_handle *nsm_find(const struct sockaddr *sap, const size_t salen,
+ const char *hostname,
+ const size_t hostname_len,
+ const int create);
+void nsm_release(struct nsm_handle *nsm);
/*
* This is used in garbage collection and resource reclaim
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 05/18] NSM: move nsm_create()
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (3 preceding siblings ...)
2008-11-05 17:19 ` [PATCH 04/18] NSM: Move nsm_find() to fs/lockd/mon.c Chuck Lever
@ 2008-11-05 17:19 ` Chuck Lever
2008-11-05 17:20 ` [PATCH 06/18] NSM: Move NSM-related function and variable declarations to lockd.h Chuck Lever
` (13 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:19 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Clean up: relocate nsm_create() to eliminate its forward declaration, and
move it next to the only function that uses it.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 47 ++++++++++++++++++++++-------------------------
1 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 3811485..9c9406d 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -18,8 +18,6 @@
#define NLMDBG_FACILITY NLMDBG_MONITOR
-static struct rpc_clnt * nsm_create(void);
-
static struct rpc_program nsm_program;
static LIST_HEAD(nsm_handles);
static DEFINE_SPINLOCK(nsm_lock);
@@ -30,6 +28,28 @@ static DEFINE_SPINLOCK(nsm_lock);
int nsm_local_state;
/*
+ * Create NSM client for the local host
+ */
+static struct rpc_clnt *nsm_create(void)
+{
+ struct sockaddr_in sin = {
+ .sin_family = AF_INET,
+ .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
+ };
+ struct rpc_create_args args = {
+ .protocol = XPRT_TRANSPORT_UDP,
+ .address = (struct sockaddr *)&sin,
+ .addrsize = sizeof(sin),
+ .servername = "localhost",
+ .program = &nsm_program,
+ .version = SM_VERSION,
+ .authflavor = RPC_AUTH_NULL,
+ };
+
+ return rpc_create(&args);
+}
+
+/*
* Common procedure for SM_MON/SM_UNMON calls
*/
static int
@@ -226,29 +246,6 @@ void nsm_release(struct nsm_handle *nsm)
kfree(nsm);
}
-/*
- * Create NSM client for the local host
- */
-static struct rpc_clnt *
-nsm_create(void)
-{
- struct sockaddr_in sin = {
- .sin_family = AF_INET,
- .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
- .sin_port = 0,
- };
- struct rpc_create_args args = {
- .protocol = XPRT_TRANSPORT_UDP,
- .address = (struct sockaddr *)&sin,
- .addrsize = sizeof(sin),
- .servername = "localhost",
- .program = &nsm_program,
- .version = SM_VERSION,
- .authflavor = RPC_AUTH_NULL,
- };
-
- return rpc_create(&args);
-}
/*
* XDR functions for NSM.
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 06/18] NSM: Move NSM-related function and variable declarations to lockd.h
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (4 preceding siblings ...)
2008-11-05 17:19 ` [PATCH 05/18] NSM: move nsm_create() Chuck Lever
@ 2008-11-05 17:20 ` Chuck Lever
2008-11-05 17:20 ` [PATCH 07/18] NSM: Move NSM-related XDR data structures to lockd's xdr.h Chuck Lever
` (12 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:20 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Clean up: Keep the NSM function declarations together with the
declarations already in lockd.h, and modernize the documenting
comments.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 18 ++++++++++--------
include/linux/lockd/lockd.h | 4 ++++
include/linux/lockd/sm_inter.h | 4 ----
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 9c9406d..4ffd556 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -93,11 +93,12 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res)
return status;
}
-/*
- * Set up monitoring of a remote host
+/**
+ * nsm_monitor - Set up monitoring of a remote host
+ * @host: pointer to nlm_host of peer to start monitoring
+ *
*/
-int
-nsm_monitor(struct nlm_host *host)
+int nsm_monitor(struct nlm_host *host)
{
struct nsm_handle *nsm = host->h_nsmhandle;
struct nsm_res res;
@@ -118,11 +119,12 @@ nsm_monitor(struct nlm_host *host)
return status;
}
-/*
- * Cease to monitor remote host
+/**
+ * nsm_unmonitor - Cease to monitor remote host
+ * @host: pointer to nlm_host of peer to stop monitoring
+ *
*/
-int
-nsm_unmonitor(struct nlm_host *host)
+int nsm_unmonitor(struct nlm_host *host)
{
struct nsm_handle *nsm = host->h_nsmhandle;
struct nsm_res res;
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 34f0101..d8fa8d3 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -200,7 +200,9 @@ extern struct svc_procedure nlmsvc_procedures4[];
#endif
extern int nlmsvc_grace_period;
extern unsigned long nlmsvc_timeout;
+
extern int nsm_use_hostnames;
+extern int nsm_local_state;
/*
* Lockd client functions
@@ -247,6 +249,8 @@ struct nsm_handle *nsm_find(const struct sockaddr *sap, const size_t salen,
const size_t hostname_len,
const int create);
void nsm_release(struct nsm_handle *nsm);
+int nsm_monitor(struct nlm_host *host);
+int nsm_unmonitor(struct nlm_host *host);
/*
* This is used in garbage collection and resource reclaim
diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h
index 5a5448b..f75d3ea 100644
--- a/include/linux/lockd/sm_inter.h
+++ b/include/linux/lockd/sm_inter.h
@@ -41,8 +41,4 @@ struct nsm_res {
u32 state;
};
-int nsm_monitor(struct nlm_host *);
-int nsm_unmonitor(struct nlm_host *);
-extern int nsm_local_state;
-
#endif /* LINUX_LOCKD_SM_INTER_H */
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 07/18] NSM: Move NSM-related XDR data structures to lockd's xdr.h
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (5 preceding siblings ...)
2008-11-05 17:20 ` [PATCH 06/18] NSM: Move NSM-related function and variable declarations to lockd.h Chuck Lever
@ 2008-11-05 17:20 ` Chuck Lever
2008-11-05 17:20 ` [PATCH 08/18] NSM: Move NSM program and procedure numbers to fs/lockd/mon.c Chuck Lever
` (11 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:20 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Clean up: NSM's XDR data structures are used only in fs/lockd/mon.c,
so move them out of the public header sm_inter.h.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 14 ++++++++++++++
include/linux/lockd/sm_inter.h | 20 --------------------
2 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 4ffd556..6fafc06 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -18,6 +18,20 @@
#define NLMDBG_FACILITY NLMDBG_MONITOR
+struct nsm_args {
+ __be32 addr; /* remote address */
+ u32 prog; /* RPC callback info */
+ u32 vers;
+ u32 proc;
+
+ char *mon_name;
+};
+
+struct nsm_res {
+ u32 status;
+ u32 state;
+};
+
static struct rpc_program nsm_program;
static LIST_HEAD(nsm_handles);
static DEFINE_SPINLOCK(nsm_lock);
diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h
index f75d3ea..29f0206 100644
--- a/include/linux/lockd/sm_inter.h
+++ b/include/linux/lockd/sm_inter.h
@@ -21,24 +21,4 @@
#define SM_MAXSTRLEN 1024
#define SM_PRIV_SIZE 16
-/*
- * Arguments for all calls to statd
- */
-struct nsm_args {
- __be32 addr; /* remote address */
- u32 prog; /* RPC callback info */
- u32 vers;
- u32 proc;
-
- char * mon_name;
-};
-
-/*
- * Result returned by statd
- */
-struct nsm_res {
- u32 status;
- u32 state;
-};
-
#endif /* LINUX_LOCKD_SM_INTER_H */
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 08/18] NSM: Move NSM program and procedure numbers to fs/lockd/mon.c
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (6 preceding siblings ...)
2008-11-05 17:20 ` [PATCH 07/18] NSM: Move NSM-related XDR data structures to lockd's xdr.h Chuck Lever
@ 2008-11-05 17:20 ` Chuck Lever
2008-11-05 17:20 ` [PATCH 09/18] NSM: Generate "priv" argument to NSMPROC_MON when nsm_handle is created Chuck Lever
` (10 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:20 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Clean up: Move the RPC program and procedure numbers for NSM into the
one source file that needs them: fs/lockd/mon.c.
And, as with NLM, NFS, and rpcbind calls, use NSMPROC_FOO instead of
SM_FOO for NSM procedure numbers.
Finally, make a couple of comments more precise: what is referred to
here as SM_NOTIFY is really the NLM (lockd) call NLMPROC_SM_NOTIFY,
not NSMPROC_NOTIFY. The Linux kernel's NSM implementation does not
support NSMPROC_NOTIFY -- it's handled by rpc.statd and sm-notify
in user space.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 42 ++++++++++++++++++++++++++--------------
include/linux/lockd/sm_inter.h | 9 ---------
2 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 6fafc06..d245856 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -17,6 +17,18 @@
#define NLMDBG_FACILITY NLMDBG_MONITOR
+#define NSM_PROGRAM 100024
+#define NSM_VERSION 1
+
+enum {
+ NSMPROC_NULL,
+ NSMPROC_STAT,
+ NSMPROC_MON,
+ NSMPROC_UNMON,
+ NSMPROC_UNMON_ALL,
+ NSMPROC_SIMU_CRASH,
+ NSMPROC_NOTIFY,
+};
struct nsm_args {
__be32 addr; /* remote address */
@@ -56,7 +68,7 @@ static struct rpc_clnt *nsm_create(void)
.addrsize = sizeof(sin),
.servername = "localhost",
.program = &nsm_program,
- .version = SM_VERSION,
+ .version = NSM_VERSION,
.authflavor = RPC_AUTH_NULL,
};
@@ -64,7 +76,7 @@ static struct rpc_clnt *nsm_create(void)
}
/*
- * Common procedure for SM_MON/SM_UNMON calls
+ * Common procedure for NSMPROC_MON/NSMPROC_UNMON calls
*/
static int
nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res)
@@ -124,7 +136,7 @@ int nsm_monitor(struct nlm_host *host)
if (nsm->sm_monitored)
return 0;
- status = nsm_mon_unmon(nsm, SM_MON, &res);
+ status = nsm_mon_unmon(nsm, NSMPROC_MON, &res);
if (status < 0 || res.status != 0)
printk(KERN_NOTICE "lockd: cannot monitor %s\n", host->h_name);
@@ -152,7 +164,7 @@ int nsm_unmonitor(struct nlm_host *host)
&& nsm->sm_monitored && !nsm->sm_sticky) {
dprintk("lockd: nsm_unmonitor(%s)\n", host->h_name);
- status = nsm_mon_unmon(nsm, SM_UNMON, &res);
+ status = nsm_mon_unmon(nsm, NSMPROC_UNMON, &res);
if (status < 0)
printk(KERN_NOTICE "lockd: cannot unmonitor %s\n",
host->h_name);
@@ -290,7 +302,7 @@ static __be32 *xdr_encode_mon_name(__be32 *p, struct nsm_args *argp)
/*
* The "my_id" argument specifies the hostname and RPC procedure
* to be called when the status manager receives notification
- * (via the SM_NOTIFY call) that the state of host "mon_name"
+ * (via the NLMPROC_SM_NOTIFY call) that the state of host "mon_name"
* has changed.
*/
static __be32 *xdr_encode_my_id(__be32 *p, struct nsm_args *argp)
@@ -308,7 +320,7 @@ static __be32 *xdr_encode_my_id(__be32 *p, struct nsm_args *argp)
/*
* The "mon_id" argument specifies the non-private arguments
- * of an SM_MON or SM_UNMON call.
+ * of an NSMPROC_MON or NSMPROC_UNMON call.
*/
static __be32 *xdr_encode_mon_id(__be32 *p, struct nsm_args *argp)
{
@@ -321,8 +333,8 @@ static __be32 *xdr_encode_mon_id(__be32 *p, struct nsm_args *argp)
/*
* The "priv" argument may contain private information required
- * by the SM_MON call. This information will be supplied in the
- * SM_NOTIFY call.
+ * by the NSMPROC_MON call. This information will be supplied in the
+ * NLMPROC_SM_NOTIFY call.
*
* Linux provides the raw IP address of the monitored host,
* left in network byte order.
@@ -389,22 +401,22 @@ xdr_decode_stat(struct rpc_rqst *rqstp, __be32 *p, struct nsm_res *resp)
#define SM_unmonres_sz 1
static struct rpc_procinfo nsm_procedures[] = {
-[SM_MON] = {
- .p_proc = SM_MON,
+[NSMPROC_MON] = {
+ .p_proc = NSMPROC_MON,
.p_encode = (kxdrproc_t) xdr_encode_mon,
.p_decode = (kxdrproc_t) xdr_decode_stat_res,
.p_arglen = SM_mon_sz,
.p_replen = SM_monres_sz,
- .p_statidx = SM_MON,
+ .p_statidx = NSMPROC_MON,
.p_name = "MONITOR",
},
-[SM_UNMON] = {
- .p_proc = SM_UNMON,
+[NSMPROC_UNMON] = {
+ .p_proc = NSMPROC_UNMON,
.p_encode = (kxdrproc_t) xdr_encode_unmon,
.p_decode = (kxdrproc_t) xdr_decode_stat,
.p_arglen = SM_mon_id_sz,
.p_replen = SM_unmonres_sz,
- .p_statidx = SM_UNMON,
+ .p_statidx = NSMPROC_UNMON,
.p_name = "UNMONITOR",
},
};
@@ -423,7 +435,7 @@ static struct rpc_stat nsm_stats;
static struct rpc_program nsm_program = {
.name = "statd",
- .number = SM_PROGRAM,
+ .number = NSM_PROGRAM,
.nrvers = ARRAY_SIZE(nsm_version),
.version = nsm_version,
.stats = &nsm_stats
diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h
index 29f0206..da72872 100644
--- a/include/linux/lockd/sm_inter.h
+++ b/include/linux/lockd/sm_inter.h
@@ -9,15 +9,6 @@
#ifndef LINUX_LOCKD_SM_INTER_H
#define LINUX_LOCKD_SM_INTER_H
-#define SM_PROGRAM 100024
-#define SM_VERSION 1
-#define SM_STAT 1
-#define SM_MON 2
-#define SM_UNMON 3
-#define SM_UNMON_ALL 4
-#define SM_SIMU_CRASH 5
-#define SM_NOTIFY 6
-
#define SM_MAXSTRLEN 1024
#define SM_PRIV_SIZE 16
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 09/18] NSM: Generate "priv" argument to NSMPROC_MON when nsm_handle is created
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (7 preceding siblings ...)
2008-11-05 17:20 ` [PATCH 08/18] NSM: Move NSM program and procedure numbers to fs/lockd/mon.c Chuck Lever
@ 2008-11-05 17:20 ` Chuck Lever
2008-11-05 17:20 ` [PATCH 10/18] NLM: Change nlm_host_rebooted() to take a single nlm_reboot argument Chuck Lever
` (9 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:20 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Construct the "priv" cookie when the nsm_handle is created, and pass
that to NSMPROC_MON's XDR encoder, instead of creating the "priv"
cookie in the encoder at call time.
This patch should not cause a behavioral change: the contents of the
cookie remain the same for the time being.
Collect NSM XDR data type definitions in the same header as NLM XDR
data type definitions, since lockd uses NSM XDR data types too. The
nlm_reboot data structure, for example, is used in both lockd and in
the NSM implementation.
The new definition of nsm_private is placed in xdr.h, and the
definition of SM_PRIV_SIZE is placed in the same header.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 30 +++++++++++++++++++-----------
include/linux/lockd/lockd.h | 1 +
include/linux/lockd/sm_inter.h | 1 -
include/linux/lockd/xdr.h | 6 ++++++
4 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index d245856..efbb2ea 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -31,7 +31,7 @@ enum {
};
struct nsm_args {
- __be32 addr; /* remote address */
+ struct nsm_private *priv;
u32 prog; /* RPC callback info */
u32 vers;
u32 proc;
@@ -84,7 +84,7 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res)
struct rpc_clnt *clnt;
int status;
struct nsm_args args = {
- .addr = nsm_addr_in(nsm)->sin_addr.s_addr,
+ .priv = &nsm->sm_priv,
.prog = NLM_PROGRAM,
.vers = 3,
.proc = NLMPROC_NSM_NOTIFY,
@@ -175,6 +175,20 @@ int nsm_unmonitor(struct nlm_host *host)
return status;
}
+/*
+ * Construct a unique cookie to identify this nsm_handle. It is
+ * passed to our statd via NSMPROC_MON, and returned via
+ * NLMPROC_SM_NOTIFY, in the "priv" field of these requests.
+ *
+ * Linux provides the raw IP address of the monitored host,
+ * left in network byte order.
+ */
+static void nsm_init_private(struct nsm_handle *nsm)
+{
+ __be32 *p = (__be32 *)&nsm->sm_priv.data;
+ *p = nsm_addr_in(nsm)->sin_addr.s_addr;
+}
+
/**
* nsm_find - Find or create a cached nsm_handle
* @sap: pointer to socket address of handle to find
@@ -251,6 +265,7 @@ retry:
nsm->sm_name = (char *) (nsm + 1);
memcpy(nsm->sm_name, hostname, hostname_len);
nsm->sm_name[hostname_len] = '\0';
+ nsm_init_private(nsm);
nlm_display_address((struct sockaddr *)&nsm->sm_addr,
nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
atomic_set(&nsm->sm_count, 1);
@@ -335,18 +350,11 @@ static __be32 *xdr_encode_mon_id(__be32 *p, struct nsm_args *argp)
* The "priv" argument may contain private information required
* by the NSMPROC_MON call. This information will be supplied in the
* NLMPROC_SM_NOTIFY call.
- *
- * Linux provides the raw IP address of the monitored host,
- * left in network byte order.
*/
static __be32 *xdr_encode_priv(__be32 *p, struct nsm_args *argp)
{
- *p++ = argp->addr;
- *p++ = 0;
- *p++ = 0;
- *p++ = 0;
-
- return p;
+ return xdr_encode_opaque_fixed(p, argp->priv->data,
+ sizeof(argp->priv->data));
}
static int
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index d8fa8d3..6178fcc 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -82,6 +82,7 @@ struct nsm_handle {
size_t sm_addrlen;
unsigned int sm_monitored : 1,
sm_sticky : 1; /* don't unmonitor */
+ struct nsm_private sm_priv;
char sm_addrbuf[LOCKD_ADDRBUF_SIZE];
};
diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h
index da72872..7f22d6f 100644
--- a/include/linux/lockd/sm_inter.h
+++ b/include/linux/lockd/sm_inter.h
@@ -10,6 +10,5 @@
#define LINUX_LOCKD_SM_INTER_H
#define SM_MAXSTRLEN 1024
-#define SM_PRIV_SIZE 16
#endif /* LINUX_LOCKD_SM_INTER_H */
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
index d6b3a80..6b51992 100644
--- a/include/linux/lockd/xdr.h
+++ b/include/linux/lockd/xdr.h
@@ -13,6 +13,12 @@
#include <linux/nfs.h>
#include <linux/sunrpc/xdr.h>
+#define SM_PRIV_SIZE 16
+
+struct nsm_private {
+ unsigned char data[SM_PRIV_SIZE];
+};
+
struct svc_rqst;
#define NLM_MAXCOOKIELEN 32
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 10/18] NLM: Change nlm_host_rebooted() to take a single nlm_reboot argument
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (8 preceding siblings ...)
2008-11-05 17:20 ` [PATCH 09/18] NSM: Generate "priv" argument to NSMPROC_MON when nsm_handle is created Chuck Lever
@ 2008-11-05 17:20 ` Chuck Lever
2008-11-05 17:20 ` [PATCH 11/18] NLM: Decode "priv" argument of NLMPROC_SM_NOTIFY as an opaque Chuck Lever
` (8 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:20 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Pass the nlm_reboot data structure directly from the NLMPROC_SM_NOTIFY
XDR decoders to nlm_host_rebooted(). This eliminates some packing and
unpacking of the NLMPROC_SM_NOTIFY results, and prepares for passing
NLMPROC_SM_NOTIFY's "priv" argument directly to nsm_find().
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/host.c | 31 +++++++++++++++++--------------
fs/lockd/svc4proc.c | 11 +----------
fs/lockd/svcproc.c | 11 +----------
include/linux/lockd/lockd.h | 3 +--
4 files changed, 20 insertions(+), 36 deletions(-)
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 50dcf79..7071acb 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -489,31 +489,34 @@ void nlm_release_host(struct nlm_host *host)
}
}
-/*
- * We were notified that the host indicated by address &sin
- * has rebooted.
- * Release all resources held by that peer.
+/**
+ * nlm_host_rebooted - Release all resources held by rebooted host
+ * @info: pointer to decoded results of NLM_SM_NOTIFY call
+ *
+ * We were notified that the specified host has rebooted. Release
+ * all resources held by that peer.
*/
-void nlm_host_rebooted(const struct sockaddr_in *sin,
- const char *hostname,
- unsigned int hostname_len,
- u32 new_state)
+void nlm_host_rebooted(struct nlm_reboot *info)
{
+ const struct sockaddr_in sin = {
+ .sin_family = AF_INET,
+ .sin_addr.s_addr = info->addr,
+ };
struct hlist_head *chain;
struct hlist_node *pos;
struct nsm_handle *nsm;
struct nlm_host *host;
- nsm = nsm_find((struct sockaddr *)sin, sizeof(*sin),
- hostname, hostname_len, 0);
+ nsm = nsm_find((struct sockaddr *)&sin, sizeof(sin),
+ info->mon, info->len, 0);
if (nsm == NULL) {
dprintk("lockd: never saw rebooted peer '%.*s' before\n",
- hostname_len, hostname);
+ info->len, info->mon);
return;
}
dprintk("lockd: nlm_host_rebooted(%.*s, %s)\n",
- hostname_len, hostname, nsm->sm_addrbuf);
+ info->len, info->mon, nsm->sm_addrbuf);
/* When reclaiming locks on this peer, make sure that
* we set up a new notification */
@@ -528,8 +531,8 @@ again: mutex_lock(&nlm_host_mutex);
for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) {
hlist_for_each_entry(host, pos, chain, h_hash) {
if (host->h_nsmhandle == nsm
- && host->h_nsmstate != new_state) {
- host->h_nsmstate = new_state;
+ && host->h_nsmstate != info->state) {
+ host->h_nsmstate = info->state;
host->h_state++;
nlm_get_host(host);
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index 4dfdcbc..bb79a53 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -419,8 +419,6 @@ static __be32
nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
void *resp)
{
- struct sockaddr_in saddr;
-
dprintk("lockd: SM_NOTIFY called\n");
if (!nlm_privileged_requester(rqstp)) {
@@ -430,14 +428,7 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
return rpc_system_err;
}
- /* Obtain the host pointer for this NFS server and try to
- * reclaim all locks we hold on this server.
- */
- memset(&saddr, 0, sizeof(saddr));
- saddr.sin_family = AF_INET;
- saddr.sin_addr.s_addr = argp->addr;
- nlm_host_rebooted(&saddr, argp->mon, argp->len, argp->state);
-
+ nlm_host_rebooted(argp);
return rpc_success;
}
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 3ca89e2..e44310c 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -451,8 +451,6 @@ static __be32
nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
void *resp)
{
- struct sockaddr_in saddr;
-
dprintk("lockd: SM_NOTIFY called\n");
if (!nlm_privileged_requester(rqstp)) {
@@ -462,14 +460,7 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
return rpc_system_err;
}
- /* Obtain the host pointer for this NFS server and try to
- * reclaim all locks we hold on this server.
- */
- memset(&saddr, 0, sizeof(saddr));
- saddr.sin_family = AF_INET;
- saddr.sin_addr.s_addr = argp->addr;
- nlm_host_rebooted(&saddr, argp->mon, argp->len, argp->state);
-
+ nlm_host_rebooted(argp);
return rpc_success;
}
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 6178fcc..8f6369d 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -239,8 +239,7 @@ void nlm_rebind_host(struct nlm_host *);
struct nlm_host * nlm_get_host(struct nlm_host *);
void nlm_release_host(struct nlm_host *);
void nlm_shutdown_hosts(void);
-extern void nlm_host_rebooted(const struct sockaddr_in *, const char *,
- unsigned int, u32);
+void nlm_host_rebooted(struct nlm_reboot *);
/*
* Host monitoring
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 11/18] NLM: Decode "priv" argument of NLMPROC_SM_NOTIFY as an opaque
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (9 preceding siblings ...)
2008-11-05 17:20 ` [PATCH 10/18] NLM: Change nlm_host_rebooted() to take a single nlm_reboot argument Chuck Lever
@ 2008-11-05 17:20 ` Chuck Lever
2008-11-05 17:20 ` [PATCH 12/18] NSM: Add nsm_lookup() function Chuck Lever
` (7 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:20 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
The NLM XDR decoders for the NLMPROC_SM_NOTIFY procedure should treat
their "priv" argument truly as an opaque, as defined by the protocol,
and let the upper layers figure out what is in it.
This will make it easier to modify the contents and interpretation of
the "priv" argument, and keep knowledge about what's in "priv" local
to fs/lockd/mon.c. For now NLM and NSM should behave exactly as they
did before.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/host.c | 3 ++-
fs/lockd/xdr.c | 4 ++--
fs/lockd/xdr4.c | 4 ++--
include/linux/lockd/xdr.h | 8 ++++----
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 7071acb..7f82c65 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -498,9 +498,10 @@ void nlm_release_host(struct nlm_host *host)
*/
void nlm_host_rebooted(struct nlm_reboot *info)
{
+ __be32 *p = (__be32 *)&info->priv.data;
const struct sockaddr_in sin = {
.sin_family = AF_INET,
- .sin_addr.s_addr = info->addr,
+ .sin_addr.s_addr = *p,
};
struct hlist_head *chain;
struct hlist_node *pos;
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 1f22629..4cc7d01 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -349,8 +349,8 @@ nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
return 0;
argp->state = ntohl(*p++);
- /* Preserve the address in network byte order */
- argp->addr = *p++;
+ memcpy(&argp->priv.data, p, sizeof(argp->priv.data));
+ p += XDR_QUADLEN(SM_PRIV_SIZE);
return xdr_argsize_check(rqstp, p);
}
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
index 50c493a..61d1714 100644
--- a/fs/lockd/xdr4.c
+++ b/fs/lockd/xdr4.c
@@ -356,8 +356,8 @@ nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp
if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
return 0;
argp->state = ntohl(*p++);
- /* Preserve the address in network byte order */
- argp->addr = *p++;
+ memcpy(&argp->priv.data, p, sizeof(argp->priv.data));
+ p += XDR_QUADLEN(SM_PRIV_SIZE);
return xdr_argsize_check(rqstp, p);
}
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
index 6b51992..6338866 100644
--- a/include/linux/lockd/xdr.h
+++ b/include/linux/lockd/xdr.h
@@ -83,10 +83,10 @@ struct nlm_res {
* statd callback when client has rebooted
*/
struct nlm_reboot {
- char * mon;
- unsigned int len;
- u32 state;
- __be32 addr;
+ char *mon;
+ unsigned int len;
+ u32 state;
+ struct nsm_private priv;
};
/*
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 12/18] NSM: Add nsm_lookup() function
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (10 preceding siblings ...)
2008-11-05 17:20 ` [PATCH 11/18] NLM: Decode "priv" argument of NLMPROC_SM_NOTIFY as an opaque Chuck Lever
@ 2008-11-05 17:20 ` Chuck Lever
2008-11-05 17:20 ` [PATCH 13/18] NSM: Replace IP address as our nlm_reboot lookup key Chuck Lever
` (6 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:20 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Introduce a new function to fs/lockd/mon.c that allows nlm_host_rebooted()
to lookup up nsm_handles by their "priv".
This should not introduce a behavioral change, but finishes the job of
collecting all logic in fs/lockd/mon.c that cares what's inside an
nsm_private structure.
This will make it easier to modify the contents and interpretation of
the "priv" argument, but for now NLM and NSM should behave exactly as
they did before.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/host.c | 8 +-----
fs/lockd/mon.c | 53 +++++++++++++++++++++++++++++++++++++++++++
include/linux/lockd/lockd.h | 1 +
3 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 7f82c65..2c3406d 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -498,18 +498,12 @@ void nlm_release_host(struct nlm_host *host)
*/
void nlm_host_rebooted(struct nlm_reboot *info)
{
- __be32 *p = (__be32 *)&info->priv.data;
- const struct sockaddr_in sin = {
- .sin_family = AF_INET,
- .sin_addr.s_addr = *p,
- };
struct hlist_head *chain;
struct hlist_node *pos;
struct nsm_handle *nsm;
struct nlm_host *host;
- nsm = nsm_find((struct sockaddr *)&sin, sizeof(sin),
- info->mon, info->len, 0);
+ nsm = nsm_reboot_lookup(info);
if (nsm == NULL) {
dprintk("lockd: never saw rebooted peer '%.*s' before\n",
info->len, info->mon);
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index efbb2ea..612f0ea 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -175,6 +175,29 @@ int nsm_unmonitor(struct nlm_host *host)
return status;
}
+static struct nsm_handle *nsm_lookup_priv(const struct nsm_private *priv)
+{
+ struct nsm_handle *nsm;
+
+ list_for_each_entry(nsm, &nsm_handles, sm_link)
+ if (memcmp(nsm->sm_priv.data, priv->data,
+ sizeof(priv->data)) == 0)
+ return nsm;
+ return NULL;
+}
+
+static struct nsm_handle *nsm_lookup_hostname(const char *hostname,
+ const size_t len)
+{
+ struct nsm_handle *nsm;
+
+ list_for_each_entry(nsm, &nsm_handles, sm_link)
+ if (strlen(nsm->sm_name) == len &&
+ memcmp(nsm->sm_name, hostname, len) == 0)
+ return nsm;
+ return NULL;
+}
+
/*
* Construct a unique cookie to identify this nsm_handle. It is
* passed to our statd via NSMPROC_MON, and returned via
@@ -273,6 +296,36 @@ retry:
}
/**
+ * nsm_reboot_lookup - match NLMPROC_SM_NOTIFY arguments to an nsm_handle
+ * @info: pointer to NLMPROC_SM_NOTIFY arguments
+ *
+ * Returns a matching nsm_handle if found in the nsm cache; otherwise
+ * returns NULL;
+ */
+struct nsm_handle *nsm_reboot_lookup(const struct nlm_reboot *info)
+{
+ struct nsm_handle *cached;
+
+ spin_lock(&nsm_lock);
+
+ if (nsm_use_hostnames && info->mon)
+ cached = nsm_lookup_hostname(info->mon, info->len);
+ else
+ cached = nsm_lookup_priv(&info->priv);
+
+ if (cached) {
+ atomic_inc(&cached->sm_count);
+ spin_unlock(&nsm_lock);
+ dprintk("lockd: found nsm_handle for rebooted host %s (%s), "
+ "cnt %d\n", cached->sm_name, cached->sm_addrbuf,
+ atomic_read(&cached->sm_count));
+ } else
+ spin_unlock(&nsm_lock);
+
+ return cached;
+}
+
+/**
* nsm_release - Release an NSM handle
* @nsm: pointer to handle to be released
*
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 8f6369d..09a600e 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -251,6 +251,7 @@ struct nsm_handle *nsm_find(const struct sockaddr *sap, const size_t salen,
void nsm_release(struct nsm_handle *nsm);
int nsm_monitor(struct nlm_host *host);
int nsm_unmonitor(struct nlm_host *host);
+struct nsm_handle *nsm_reboot_lookup(const struct nlm_reboot *info);
/*
* This is used in garbage collection and resource reclaim
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 13/18] NSM: Replace IP address as our nlm_reboot lookup key
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (11 preceding siblings ...)
2008-11-05 17:20 ` [PATCH 12/18] NSM: Add nsm_lookup() function Chuck Lever
@ 2008-11-05 17:20 ` Chuck Lever
2008-11-05 17:21 ` [PATCH 14/18] NSM: Remove include/linux/lockd/sm_inter.h Chuck Lever
` (5 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:20 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
NLM provides file locking services for NFS files. Part of this
service includes a second protocol, known as NSM, which monitors host
reboots. NLM uses this service to determine when to release locks or
enter a grace period after a client or server reboots.
The NLM service (lockd in the Linux kernel) contacts its local NSM
service (rpc.statd in Linux user space) via a special protocol to
request a callback when a particular remote peer reboots. To identify
the remote peer, the NLM service constructs a cookie that it passes in
the request. The NSM service passes that cookie back to the NLM
service when it is notified that the given remote peer has indeed
rebooted.
Currently on Linux, the cookie is the raw 32-bit IPv4 address of the
remote peer. To support IPv6 addresses, which are larger, we could
use all 16 bytes of the cookie to represent a full IPv6 address,
although we still can't represent an IPv6 address with a scope ID in
just 16 bytes.
Instead, to avoid the need for future changes to support additional
address types, we'll use a manufactured value for the cookie, and use
that to find the corresponding nsm_handle struct in the kernel during
the notification callback.
This should provide complete support in the kernel's NSM
implementation for IPv6 hosts.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 32 ++++++++++++++++++++++++++++----
1 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 612f0ea..692edad 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -203,13 +203,37 @@ static struct nsm_handle *nsm_lookup_hostname(const char *hostname,
* passed to our statd via NSMPROC_MON, and returned via
* NLMPROC_SM_NOTIFY, in the "priv" field of these requests.
*
- * Linux provides the raw IP address of the monitored host,
- * left in network byte order.
+ * These cookies are not required to last across reboots, but they
+ * must be unique for each nsm_handle during the same boot.
+ * Uniqueness is guaranteed by using the memory address of the
+ * handle data structure. Such memory addresses are only reused if
+ * the nsm_handle is destroyed by an NSMPROC_UNMON.
+ *
+ * For safety, the cookie returned via NLM_SM_NOTIFY is treated as
+ * an opaque -- the address is not used directly to access the
+ * associated nsm_handle. This also means it would be simple to
+ * change the cookie generator again at some later point without
+ * having to mess with the nsm_handle lookup code.
+ *
+ * A time stamp is added in case rpc.statd returns a stale cookie.
+ * That would be a bug in rpc.statd, but it would result in some
+ * client losing its locks inappropriately, which we would like to
+ * avoid.
+ *
+ * The cookies are exposed only to local user space via loopback.
+ * They do not appear on the physical network. If we want greater
+ * security, however, nsm_init_private() could perform a one-way
+ * hash to obscure the contents of the cookie.
*/
static void nsm_init_private(struct nsm_handle *nsm)
{
- __be32 *p = (__be32 *)&nsm->sm_priv.data;
- *p = nsm_addr_in(nsm)->sin_addr.s_addr;
+ u64 *p = (u64 *)&nsm->sm_priv.data;
+ struct timeval tv;
+
+ do_gettimeofday(&tv);
+
+ *p++ = (unsigned long)nsm;
+ *p = timeval_to_ns(&tv);
}
/**
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 14/18] NSM: Remove include/linux/lockd/sm_inter.h
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (12 preceding siblings ...)
2008-11-05 17:20 ` [PATCH 13/18] NSM: Replace IP address as our nlm_reboot lookup key Chuck Lever
@ 2008-11-05 17:21 ` Chuck Lever
2008-11-05 17:21 ` [PATCH 15/18] NLM: Remove "create" argument from nsm_find() Chuck Lever
` (4 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:21 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Clean up: The include/linux/lockd/sm_inter.h header has a single item in it
now. Move that item to include/linux/lockd/xdr.h, and remove sm_inter.h.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/clntproc.c | 1 -
fs/lockd/host.c | 1 -
fs/lockd/mon.c | 2 --
fs/lockd/svc.c | 1 -
fs/lockd/svc4proc.c | 2 --
fs/lockd/svcproc.c | 2 --
fs/lockd/svcsubs.c | 1 -
fs/lockd/xdr.c | 1 -
fs/lockd/xdr4.c | 1 -
include/linux/lockd/sm_inter.h | 14 --------------
include/linux/lockd/xdr.h | 1 +
11 files changed, 1 insertions(+), 26 deletions(-)
delete mode 100644 include/linux/lockd/sm_inter.h
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 31668b6..366099b 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -16,7 +16,6 @@
#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/svc.h>
#include <linux/lockd/lockd.h>
-#include <linux/lockd/sm_inter.h>
#define NLMDBG_FACILITY NLMDBG_CLIENT
#define NLMCLNT_GRACE_WAIT (5*HZ)
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 2c3406d..ad2347b 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -15,7 +15,6 @@
#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/svc.h>
#include <linux/lockd/lockd.h>
-#include <linux/lockd/sm_inter.h>
#include <linux/mutex.h>
#include <net/ipv6.h>
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 692edad..6c5d918 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -13,8 +13,6 @@
#include <linux/sunrpc/xprtsock.h>
#include <linux/sunrpc/svc.h>
#include <linux/lockd/lockd.h>
-#include <linux/lockd/sm_inter.h>
-
#define NLMDBG_FACILITY NLMDBG_MONITOR
#define NSM_PROGRAM 100024
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index c631a83..50de426 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -35,7 +35,6 @@
#include <linux/sunrpc/svcsock.h>
#include <net/ip.h>
#include <linux/lockd/lockd.h>
-#include <linux/lockd/sm_inter.h>
#include <linux/nfs.h>
#define NLMDBG_FACILITY NLMDBG_SVC
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index bb79a53..1725037 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -16,8 +16,6 @@
#include <linux/nfsd/nfsd.h>
#include <linux/lockd/lockd.h>
#include <linux/lockd/share.h>
-#include <linux/lockd/sm_inter.h>
-
#define NLMDBG_FACILITY NLMDBG_CLIENT
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index e44310c..3688e55 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -16,8 +16,6 @@
#include <linux/nfsd/nfsd.h>
#include <linux/lockd/lockd.h>
#include <linux/lockd/share.h>
-#include <linux/lockd/sm_inter.h>
-
#define NLMDBG_FACILITY NLMDBG_CLIENT
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 34c2766..9e4d6aa 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -17,7 +17,6 @@
#include <linux/nfsd/export.h>
#include <linux/lockd/lockd.h>
#include <linux/lockd/share.h>
-#include <linux/lockd/sm_inter.h>
#include <linux/module.h>
#include <linux/mount.h>
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 4cc7d01..0336f2b 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -16,7 +16,6 @@
#include <linux/sunrpc/svc.h>
#include <linux/sunrpc/stats.h>
#include <linux/lockd/lockd.h>
-#include <linux/lockd/sm_inter.h>
#define NLMDBG_FACILITY NLMDBG_XDR
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
index 61d1714..e1d5286 100644
--- a/fs/lockd/xdr4.c
+++ b/fs/lockd/xdr4.c
@@ -17,7 +17,6 @@
#include <linux/sunrpc/svc.h>
#include <linux/sunrpc/stats.h>
#include <linux/lockd/lockd.h>
-#include <linux/lockd/sm_inter.h>
#define NLMDBG_FACILITY NLMDBG_XDR
diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h
deleted file mode 100644
index 7f22d6f..0000000
--- a/include/linux/lockd/sm_inter.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * linux/include/linux/lockd/sm_inter.h
- *
- * Declarations for the kernel statd client.
- *
- * Copyright (C) 1996, Olaf Kirch <okir-pn4DOG8n3UYbFoVRYvo4fw@public.gmane.org>
- */
-
-#ifndef LINUX_LOCKD_SM_INTER_H
-#define LINUX_LOCKD_SM_INTER_H
-
-#define SM_MAXSTRLEN 1024
-
-#endif /* LINUX_LOCKD_SM_INTER_H */
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
index 6338866..7dc5b6c 100644
--- a/include/linux/lockd/xdr.h
+++ b/include/linux/lockd/xdr.h
@@ -13,6 +13,7 @@
#include <linux/nfs.h>
#include <linux/sunrpc/xdr.h>
+#define SM_MAXSTRLEN 1024
#define SM_PRIV_SIZE 16
struct nsm_private {
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 15/18] NLM: Remove "create" argument from nsm_find()
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (13 preceding siblings ...)
2008-11-05 17:21 ` [PATCH 14/18] NSM: Remove include/linux/lockd/sm_inter.h Chuck Lever
@ 2008-11-05 17:21 ` Chuck Lever
2008-11-05 17:21 ` [PATCH 16/18] NSM: factor nsm_handle initialization out of nsm_get_handle() Chuck Lever
` (3 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:21 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Clean up: nsm_find() now has only one caller, and that caller
unconditionally sets the @create argument. Thus the @create
argument is no longer needed.
Since nsm_find() now has a more specific purpose, pick a more
appropriate name for it.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/host.c | 4 ++--
fs/lockd/mon.c | 23 +++++++++--------------
include/linux/lockd/lockd.h | 6 +++---
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index ad2347b..bda5f9e 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -204,8 +204,8 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
atomic_inc(&nsm->sm_count);
else {
host = NULL;
- nsm = nsm_find(ni->sap, ni->salen,
- ni->hostname, ni->hostname_len, 1);
+ nsm = nsm_get_handle(ni->sap, ni->salen,
+ ni->hostname, ni->hostname_len);
if (!nsm) {
dprintk("lockd: nlm_lookup_host failed; "
"no nsm handle\n");
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 6c5d918..7d80c56 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -235,24 +235,22 @@ static void nsm_init_private(struct nsm_handle *nsm)
}
/**
- * nsm_find - Find or create a cached nsm_handle
+ * nsm_get_handle - Find or create a cached nsm_handle
* @sap: pointer to socket address of handle to find
* @salen: length of socket address
* @hostname: pointer to C string containing hostname to find
* @hostname_len: length of C string
- * @create: one means create new handle if not found in cache
*
- * Behavior is modulated by the global nsm_use_hostnames variable
- * and by the @create argument.
+ * Behavior is modulated by the global nsm_use_hostnames variable.
*
- * Returns a cached nsm_handle after bumping its ref count, or if
- * @create is set, returns a fresh nsm_handle if a handle that
- * matches @sap and/or @hostname cannot be found in the handle cache.
- * Returns NULL if an error occurs.
+ * Returns a cached nsm_handle after bumping its ref count, or
+ * returns a fresh nsm_handle if a handle that matches @sap and/or
+ * @hostname cannot be found in the handle cache. Returns NULL if
+ * an error occurs.
*/
-struct nsm_handle *nsm_find(const struct sockaddr *sap, const size_t salen,
- const char *hostname, const size_t hostname_len,
- const int create)
+struct nsm_handle *nsm_get_handle(const struct sockaddr *sap,
+ const size_t salen, const char *hostname,
+ const size_t hostname_len)
{
struct nsm_handle *nsm = NULL;
struct nsm_handle *pos;
@@ -298,9 +296,6 @@ retry:
spin_unlock(&nsm_lock);
- if (!create)
- return NULL;
-
nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL);
if (nsm == NULL)
return NULL;
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 09a600e..ad1f848 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -244,10 +244,10 @@ void nlm_host_rebooted(struct nlm_reboot *);
/*
* Host monitoring
*/
-struct nsm_handle *nsm_find(const struct sockaddr *sap, const size_t salen,
+struct nsm_handle *nsm_get_handle(const struct sockaddr *sap,
+ const size_t salen,
const char *hostname,
- const size_t hostname_len,
- const int create);
+ const size_t hostname_len);
void nsm_release(struct nsm_handle *nsm);
int nsm_monitor(struct nlm_host *host);
int nsm_unmonitor(struct nlm_host *host);
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 16/18] NSM: factor nsm_handle initialization out of nsm_get_handle()
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (14 preceding siblings ...)
2008-11-05 17:21 ` [PATCH 15/18] NLM: Remove "create" argument from nsm_find() Chuck Lever
@ 2008-11-05 17:21 ` Chuck Lever
2008-11-05 17:21 ` [PATCH 17/18] NSM: Use same helpers in nsm_get_handle() and nsm_lookup_rebooted() Chuck Lever
` (2 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:21 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Clean up: move nsm_handle initialization to a helper function.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 39 ++++++++++++++++++++++++++++-----------
1 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 7d80c56..427d915 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -234,6 +234,33 @@ static void nsm_init_private(struct nsm_handle *nsm)
*p = timeval_to_ns(&tv);
}
+static struct nsm_handle *nsm_init_handle(const struct sockaddr *sap,
+ const size_t salen,
+ const char *hostname,
+ const size_t hostname_len)
+{
+ struct nsm_handle *nsm;
+
+ nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL);
+ if (nsm == NULL)
+ return NULL;
+
+ atomic_set(&nsm->sm_count, 1);
+
+ nsm->sm_name = (char *)(nsm + 1);
+ memcpy(nsm->sm_name, hostname, hostname_len);
+ nsm->sm_name[hostname_len] = '\0';
+
+ memcpy(nsm_addr(nsm), sap, salen);
+ nsm->sm_addrlen = salen;
+
+ nsm_init_private(nsm);
+ nlm_display_address((struct sockaddr *)&nsm->sm_addr,
+ nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
+
+ return nsm;
+}
+
/**
* nsm_get_handle - Find or create a cached nsm_handle
* @sap: pointer to socket address of handle to find
@@ -296,19 +323,9 @@ retry:
spin_unlock(&nsm_lock);
- nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL);
+ nsm = nsm_init_handle(sap, salen, hostname, hostname_len);
if (nsm == NULL)
return NULL;
-
- memcpy(nsm_addr(nsm), sap, salen);
- nsm->sm_addrlen = salen;
- nsm->sm_name = (char *) (nsm + 1);
- memcpy(nsm->sm_name, hostname, hostname_len);
- nsm->sm_name[hostname_len] = '\0';
- nsm_init_private(nsm);
- nlm_display_address((struct sockaddr *)&nsm->sm_addr,
- nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
- atomic_set(&nsm->sm_count, 1);
goto retry;
}
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 17/18] NSM: Use same helpers in nsm_get_handle() and nsm_lookup_rebooted()
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (15 preceding siblings ...)
2008-11-05 17:21 ` [PATCH 16/18] NSM: factor nsm_handle initialization out of nsm_get_handle() Chuck Lever
@ 2008-11-05 17:21 ` Chuck Lever
2008-11-05 17:21 ` [PATCH 18/18] NSM: Move nsm_addr() to fs/lockd/mon.c Chuck Lever
2008-11-05 19:49 ` [PATCH 00/18] kernel NSM support for IPv6 (take 2) J. Bruce Fields
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:21 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Refactor the nsm_get_handle() function so it uses the same lookup
helpers as the newly added nsm_reboot_lookup() function, and use
do {} while() instead of a goto; for the retry loop.
This makes it easier if some day we want to use a more sophisticated
lookup algorithm than a linked list search for finding nsm_handles
in both nsm_get_handle() and nsm_reboot_lookup().
There is an additional micro-optimization here. This change moves the
"hostname & nsm_use_hostnames" test out of the list_for_each_entry()
clause in nsm_get_handle(), since it is loop-invariant.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 70 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 39 insertions(+), 31 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 427d915..8538180 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -196,6 +196,16 @@ static struct nsm_handle *nsm_lookup_hostname(const char *hostname,
return NULL;
}
+static struct nsm_handle *nsm_lookup_addr(const struct sockaddr *sap)
+{
+ struct nsm_handle *nsm;
+
+ list_for_each_entry(nsm, &nsm_handles, sm_link)
+ if (nlm_cmp_addr(nsm_addr(nsm), sap))
+ return nsm;
+ return NULL;
+}
+
/*
* Construct a unique cookie to identify this nsm_handle. It is
* passed to our statd via NSMPROC_MON, and returned via
@@ -279,8 +289,7 @@ struct nsm_handle *nsm_get_handle(const struct sockaddr *sap,
const size_t salen, const char *hostname,
const size_t hostname_len)
{
- struct nsm_handle *nsm = NULL;
- struct nsm_handle *pos;
+ struct nsm_handle *new, *cached;
if (!sap)
return NULL;
@@ -294,39 +303,38 @@ struct nsm_handle *nsm_get_handle(const struct sockaddr *sap,
return NULL;
}
-retry:
- spin_lock(&nsm_lock);
- list_for_each_entry(pos, &nsm_handles, sm_link) {
- if (hostname && nsm_use_hostnames) {
- if (strlen(pos->sm_name) != hostname_len
- || memcmp(pos->sm_name, hostname, hostname_len))
- continue;
- } else if (!nlm_cmp_addr(nsm_addr(pos), sap))
- continue;
-
- atomic_inc(&pos->sm_count);
- spin_unlock(&nsm_lock);
- kfree(nsm);
- dprintk("lockd: found nsm_handle for %s (%s), cnt %d\n",
- pos->sm_name, pos->sm_addrbuf,
- atomic_read(&pos->sm_count));
- return pos;
- }
+ new = NULL;
+ do {
+ spin_lock(&nsm_lock);
+
+ if (nsm_use_hostnames && hostname)
+ cached = nsm_lookup_hostname(hostname, hostname_len);
+ else
+ cached = nsm_lookup_addr(sap);
+
+ if (cached) {
+ atomic_inc(&cached->sm_count);
+ spin_unlock(&nsm_lock);
+ kfree(new);
+ dprintk("lockd: found nsm_handle for %s (%s), "
+ "cnt %d\n", cached->sm_name,
+ cached->sm_addrbuf,
+ atomic_read(&cached->sm_count));
+ return cached;
+ } else if (new) {
+ list_add(&new->sm_link, &nsm_handles);
+ spin_unlock(&nsm_lock);
+ dprintk("lockd: created nsm_handle for %s (%s)\n",
+ new->sm_name, new->sm_addrbuf);
+ return new;
+ }
- if (nsm) {
- list_add(&nsm->sm_link, &nsm_handles);
spin_unlock(&nsm_lock);
- dprintk("lockd: created nsm_handle for %s (%s)\n",
- nsm->sm_name, nsm->sm_addrbuf);
- return nsm;
- }
- spin_unlock(&nsm_lock);
+ new = nsm_init_handle(sap, salen, hostname, hostname_len);
+ } while (new);
- nsm = nsm_init_handle(sap, salen, hostname, hostname_len);
- if (nsm == NULL)
- return NULL;
- goto retry;
+ return NULL;
}
/**
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 18/18] NSM: Move nsm_addr() to fs/lockd/mon.c
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (16 preceding siblings ...)
2008-11-05 17:21 ` [PATCH 17/18] NSM: Use same helpers in nsm_get_handle() and nsm_lookup_rebooted() Chuck Lever
@ 2008-11-05 17:21 ` Chuck Lever
2008-11-05 19:49 ` [PATCH 00/18] kernel NSM support for IPv6 (take 2) J. Bruce Fields
18 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 17:21 UTC (permalink / raw)
To: bfields; +Cc: linux-nfs
Clean up: nsm_addr_in() is no longer used, and nsm_addr() is used only in
fs/lockd/mon.c, so move it there.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/lockd/mon.c | 5 +++++
include/linux/lockd/lockd.h | 10 ----------
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 8538180..b233b01 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -73,6 +73,11 @@ static struct rpc_clnt *nsm_create(void)
return rpc_create(&args);
}
+static inline struct sockaddr *nsm_addr(const struct nsm_handle *nsm)
+{
+ return (struct sockaddr *)&nsm->sm_addr;
+}
+
/*
* Common procedure for NSMPROC_MON/NSMPROC_UNMON calls
*/
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index ad1f848..6fc4f3e 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -109,16 +109,6 @@ static inline struct sockaddr *nlm_srcaddr(const struct nlm_host *host)
return (struct sockaddr *)&host->h_srcaddr;
}
-static inline struct sockaddr_in *nsm_addr_in(const struct nsm_handle *handle)
-{
- return (struct sockaddr_in *)&handle->sm_addr;
-}
-
-static inline struct sockaddr *nsm_addr(const struct nsm_handle *handle)
-{
- return (struct sockaddr *)&handle->sm_addr;
-}
-
/*
* Map an fl_owner_t into a unique 32-bit "pid"
*/
^ permalink raw reply related [flat|nested] 24+ messages in thread* Re: [PATCH 00/18] kernel NSM support for IPv6 (take 2)
[not found] ` <20081105171300.6773.40121.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (17 preceding siblings ...)
2008-11-05 17:21 ` [PATCH 18/18] NSM: Move nsm_addr() to fs/lockd/mon.c Chuck Lever
@ 2008-11-05 19:49 ` J. Bruce Fields
2008-11-05 20:45 ` J. Bruce Fields
18 siblings, 1 reply; 24+ messages in thread
From: J. Bruce Fields @ 2008-11-05 19:49 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
On Wed, Nov 05, 2008 at 12:19:18PM -0500, Chuck Lever wrote:
> Hi Bruce-
>
> Here are patches to implement IPv6 support for the kernel's NSM.
> These are different enough from the last pass that you should look
> these over again. I've tried to respond to your previous comments,
> and I've provided some additional clean up and enhancement.
>
> I've tested these patches to ensure that NFSv2/v3 lock recovery over
> IPv4 continues to work with lockd IPv6 support enabled (by a later
> patch).
>
> Please consider these for 2.6.29.
Thanks, I'll take a look.
By the way, I did some miscellaneous nsm cleanup a few months ago and
never got around to sending it out. I'll pass that along in a moment.
--b.
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [PATCH 00/18] kernel NSM support for IPv6 (take 2)
2008-11-05 19:49 ` [PATCH 00/18] kernel NSM support for IPv6 (take 2) J. Bruce Fields
@ 2008-11-05 20:45 ` J. Bruce Fields
2008-11-05 21:34 ` Chuck Lever
0 siblings, 1 reply; 24+ messages in thread
From: J. Bruce Fields @ 2008-11-05 20:45 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
On Wed, Nov 05, 2008 at 02:49:55PM -0500, bfields wrote:
> By the way, I did some miscellaneous nsm cleanup a few months ago and
> never got around to sending it out. I'll pass that along in a moment.
For which I meant to send out a cover letter and forgot, sorry!
Anyway, the first four patches are just small cleanup and bugfixing in
the same area. The remaining patches split up the client's and server's
host lists into two separate tables.
They could all use another look-over and some testing; just thought you
might be interested as long as you're in the neighborhood.
Also todo in vaguely the same area:
- nlmsvc_invalidate_all should be done on nfsd shutdown, but
we're doing shutdown per transport for some reason, which
seems dumb. So fix that reference counting so there's just
one count for the whole server.
- it would be nice to be able to shutdown the server
independently of the client; currently there's no way to do
that, as there's no way for sm-notify to distinguish client
from server hosts. (There may be no solution in the case
where a single host has both client and server relationships
with us--but people probably shouldn't be doing that anyway
(it seems deadlock prone.)
- the debugging code in nlm_shutdown_hosts() may be overkill.
--b.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 00/18] kernel NSM support for IPv6 (take 2)
2008-11-05 20:45 ` J. Bruce Fields
@ 2008-11-05 21:34 ` Chuck Lever
2008-11-05 21:50 ` J. Bruce Fields
0 siblings, 1 reply; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 21:34 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: linux-nfs
On Nov 5, 2008, at 3:45 PM, J. Bruce Fields wrote:
> On Wed, Nov 05, 2008 at 02:49:55PM -0500, bfields wrote:
>> By the way, I did some miscellaneous nsm cleanup a few months ago and
>> never got around to sending it out. I'll pass that along in a
>> moment.
>
> For which I meant to send out a cover letter and forgot, sorry!
These look similar to some prototype patches I've played with to split
the host cache, except for the elimination of h_server and sm_sticky,
which would be dandy if we can get away with it. I also went to the
trouble of adding a SLAB for the nlm_host structures.
Basically they look OK to me, except I would rename expire_hosts() as
nlm_expire_hosts().
Would you like me to port these up to 2.6.28 and add an nlm_host SLAB?
> Anyway, the first four patches are just small cleanup and bugfixing in
> the same area. The remaining patches split up the client's and
> server's
> host lists into two separate tables.
>
> They could all use another look-over and some testing; just thought
> you
> might be interested as long as you're in the neighborhood.
>
> Also todo in vaguely the same area:
> - nlmsvc_invalidate_all should be done on nfsd shutdown, but
> we're doing shutdown per transport for some reason, which
> seems dumb. So fix that reference counting so there's just
> one count for the whole server.
> - it would be nice to be able to shutdown the server
> independently of the client; currently there's no way to do
> that, as there's no way for sm-notify to distinguish client
> from server hosts. (There may be no solution in the case
> where a single host has both client and server relationships
> with us--but people probably shouldn't be doing that anyway
> (it seems deadlock prone.)
> - the debugging code in nlm_shutdown_hosts() may be overkill.
>
> --b.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 00/18] kernel NSM support for IPv6 (take 2)
2008-11-05 21:34 ` Chuck Lever
@ 2008-11-05 21:50 ` J. Bruce Fields
2008-11-05 22:41 ` Chuck Lever
0 siblings, 1 reply; 24+ messages in thread
From: J. Bruce Fields @ 2008-11-05 21:50 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
On Wed, Nov 05, 2008 at 04:34:01PM -0500, Chuck Lever wrote:
> On Nov 5, 2008, at 3:45 PM, J. Bruce Fields wrote:
>> On Wed, Nov 05, 2008 at 02:49:55PM -0500, bfields wrote:
>>> By the way, I did some miscellaneous nsm cleanup a few months ago and
>>> never got around to sending it out. I'll pass that along in a
>>> moment.
>>
>> For which I meant to send out a cover letter and forgot, sorry!
>
> These look similar to some prototype patches I've played with to split
> the host cache, except for the elimination of h_server and sm_sticky,
> which would be dandy if we can get away with it. I also went to the
> trouble of adding a SLAB for the nlm_host structures.
>
> Basically they look OK to me, except I would rename expire_hosts() as
> nlm_expire_hosts().
>
> Would you like me to port these up to 2.6.28 and add an nlm_host SLAB?
That would be fine. Or use your patches instead in any places where you
think there's an advantage. The versions I sent were generated against
2.6.28-rc3, so should be recent enough.
There's a couple places (e.g. sm_sticky removal) where we need to audit
and ensure nothing's broken, and leave notes in the commit message
sufficient to reconstruct the audit.
And it'd be nice to figure out how to test nsm changes.
--b.
>
>> Anyway, the first four patches are just small cleanup and bugfixing in
>> the same area. The remaining patches split up the client's and
>> server's
>> host lists into two separate tables.
>>
>> They could all use another look-over and some testing; just thought
>> you
>> might be interested as long as you're in the neighborhood.
>>
>> Also todo in vaguely the same area:
>> - nlmsvc_invalidate_all should be done on nfsd shutdown, but
>> we're doing shutdown per transport for some reason, which
>> seems dumb. So fix that reference counting so there's just
>> one count for the whole server.
>> - it would be nice to be able to shutdown the server
>> independently of the client; currently there's no way to do
>> that, as there's no way for sm-notify to distinguish client
>> from server hosts. (There may be no solution in the case
>> where a single host has both client and server relationships
>> with us--but people probably shouldn't be doing that anyway
>> (it seems deadlock prone.)
>> - the debugging code in nlm_shutdown_hosts() may be overkill.
>>
>> --b.
>
> --
> Chuck Lever
> chuck[dot]lever[at]oracle[dot]com
>
>
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 00/18] kernel NSM support for IPv6 (take 2)
2008-11-05 21:50 ` J. Bruce Fields
@ 2008-11-05 22:41 ` Chuck Lever
0 siblings, 0 replies; 24+ messages in thread
From: Chuck Lever @ 2008-11-05 22:41 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: linux-nfs
On Nov 5, 2008, at 4:50 PM, J. Bruce Fields wrote:
> On Wed, Nov 05, 2008 at 04:34:01PM -0500, Chuck Lever wrote:
>> On Nov 5, 2008, at 3:45 PM, J. Bruce Fields wrote:
>>> On Wed, Nov 05, 2008 at 02:49:55PM -0500, bfields wrote:
>>>> By the way, I did some miscellaneous nsm cleanup a few months ago
>>>> and
>>>> never got around to sending it out. I'll pass that along in a
>>>> moment.
>>>
>>> For which I meant to send out a cover letter and forgot, sorry!
>>
>> These look similar to some prototype patches I've played with to
>> split
>> the host cache, except for the elimination of h_server and sm_sticky,
>> which would be dandy if we can get away with it. I also went to the
>> trouble of adding a SLAB for the nlm_host structures.
>>
>> Basically they look OK to me, except I would rename expire_hosts() as
>> nlm_expire_hosts().
>>
>> Would you like me to port these up to 2.6.28 and add an nlm_host
>> SLAB?
>
> That would be fine. Or use your patches instead in any places where
> you
> think there's an advantage. The versions I sent were generated
> against
> 2.6.28-rc3, so should be recent enough.
OK, I can do that. I'll apply most of your patches after the NSM IPv6
patches and the SLAB-ify patches. There might be some additional
optimizations, and I haven't figured out what to do about the
"redundant RPC client shutdown" question you raised.
> There's a couple places (e.g. sm_sticky removal) where we need to
> audit
> and ensure nothing's broken, and leave notes in the commit message
> sufficient to reconstruct the audit.
I might postpone these (either drop them, or put them at the end) so
we can have some more time to think carefully about what needs to be
done here. As I said before, IMO it would be cleaner to go without
h_server and sm_sticky, so I'm in favor of making these patches work
if possible.
> And it'd be nice to figure out how to test nsm changes.
Hah! ;-)
> --b.
>
>>
>>> Anyway, the first four patches are just small cleanup and
>>> bugfixing in
>>> the same area. The remaining patches split up the client's and
>>> server's
>>> host lists into two separate tables.
>>>
>>> They could all use another look-over and some testing; just thought
>>> you
>>> might be interested as long as you're in the neighborhood.
>>>
>>> Also todo in vaguely the same area:
>>> - nlmsvc_invalidate_all should be done on nfsd shutdown, but
>>> we're doing shutdown per transport for some reason, which
>>> seems dumb. So fix that reference counting so there's just
>>> one count for the whole server.
>>> - it would be nice to be able to shutdown the server
>>> independently of the client; currently there's no way to do
>>> that, as there's no way for sm-notify to distinguish client
>>> from server hosts. (There may be no solution in the case
>>> where a single host has both client and server relationships
>>> with us--but people probably shouldn't be doing that anyway
>>> (it seems deadlock prone.)
>>> - the debugging code in nlm_shutdown_hosts() may be overkill.
>>>
>>> --b.
>>
>> --
>> Chuck Lever
>> chuck[dot]lever[at]oracle[dot]com
>>
>>
>>
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 24+ messages in thread