From: "J. Bruce Fields" <bfields@fieldses.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 6/7] lockd: Combine __nsm_find() and nsm_find().
Date: Fri, 12 Sep 2008 17:56:37 -0400 [thread overview]
Message-ID: <20080912215637.GF22126@fieldses.org> (raw)
In-Reply-To: <20080903183615.16867.58815.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
On Wed, Sep 03, 2008 at 02:36:16PM -0400, Chuck Lever wrote:
> Clean up: Having two separate functions doesn't add clarity, so
> eliminate one of them.
Yeah, agreed, there's no way to guess what the difference between
__nsm_find(...,0) and nsm_find(...) is without looking up the prototype,
so why bother?--there's no loss here in just using nsm_find(...,0) and
nsm_find(...,1) instead.
That said, with a couple wrappers, say nsm_lookup() and nsm_create(),
you might be able to save the reader the trouble of having to go look at
the implementation.
Up to you. I'll apply this and you can send an incremental patch if you
want.
--b.
> Use contemporary kernel coding conventions
> where appropriate.
>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>
> fs/lockd/host.c | 32 +++++++++++---------------------
> 1 files changed, 11 insertions(+), 21 deletions(-)
>
> diff --git a/fs/lockd/host.c b/fs/lockd/host.c
> index 1f9d72a..b9eeafe 100644
> --- a/fs/lockd/host.c
> +++ b/fs/lockd/host.c
> @@ -31,13 +31,11 @@ static unsigned long next_gc;
> static int nrhosts;
> static DEFINE_MUTEX(nlm_host_mutex);
>
> -
> static void nlm_gc_hosts(void);
> -static struct nsm_handle * __nsm_find(const struct sockaddr_in *,
> - const char *, unsigned int, int);
> -static struct nsm_handle * nsm_find(const struct sockaddr_in *sin,
> - const char *hostname,
> - unsigned int hostname_len);
> +static struct nsm_handle *nsm_find(const struct sockaddr_in *sin,
> + const char *hostname,
> + const size_t hostname_len,
> + const int create);
>
> /*
> * Hash function must work well on big- and little-endian platforms
> @@ -187,7 +185,7 @@ static struct nlm_host *nlm_lookup_host(int server,
> atomic_inc(&nsm->sm_count);
> else {
> host = NULL;
> - nsm = nsm_find(sin, hostname, hostname_len);
> + nsm = nsm_find(sin, hostname, hostname_len, 1);
> if (!nsm) {
> dprintk("lockd: nlm_lookup_host failed; "
> "no nsm handle\n");
> @@ -419,8 +417,7 @@ void nlm_host_rebooted(const struct sockaddr_in *sin,
> struct nsm_handle *nsm;
> struct nlm_host *host;
>
> - /* Find the NSM handle for this peer */
> - nsm = __nsm_find(sin, hostname, hostname_len, 0);
> + nsm = nsm_find(sin, hostname, hostname_len, 0);
> if (nsm == NULL) {
> dprintk("lockd: never saw rebooted peer '%.*s' before\n",
> hostname_len, hostname);
> @@ -560,10 +557,10 @@ nlm_gc_hosts(void)
> static LIST_HEAD(nsm_handles);
> static DEFINE_SPINLOCK(nsm_lock);
>
> -static struct nsm_handle *
> -__nsm_find(const struct sockaddr_in *sin,
> - const char *hostname, unsigned int hostname_len,
> - int create)
> +static struct nsm_handle *nsm_find(const struct sockaddr_in *sin,
> + const char *hostname,
> + const size_t hostname_len,
> + const int create)
> {
> struct nsm_handle *nsm = NULL;
> struct nsm_handle *pos;
> @@ -575,7 +572,7 @@ __nsm_find(const struct sockaddr_in *sin,
> if (printk_ratelimit()) {
> printk(KERN_WARNING "Invalid hostname \"%.*s\" "
> "in NFS lock request\n",
> - hostname_len, hostname);
> + (int)hostname_len, hostname);
> }
> return NULL;
> }
> @@ -623,13 +620,6 @@ found:
> return nsm;
> }
>
> -static struct nsm_handle *
> -nsm_find(const struct sockaddr_in *sin, const char *hostname,
> - unsigned int hostname_len)
> -{
> - return __nsm_find(sin, hostname, hostname_len, 1);
> -}
> -
> /*
> * Release an NSM handle
> */
>
next prev parent reply other threads:[~2008-09-12 21:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-03 18:35 [PATCH 0/7] More IPv6 support for lockd Chuck Lever
[not found] ` <20080903183411.16867.33715.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-03 18:35 ` [PATCH 1/7] lockd: Use sockaddr_storage + length for h_addr field Chuck Lever
[not found] ` <20080903183539.16867.8416.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-04 17:46 ` J. Bruce Fields
2008-09-03 18:35 ` [PATCH 2/7] lockd: Use sockaddr_storage for h_saddr field Chuck Lever
[not found] ` <20080903183546.16867.90601.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-12 1:41 ` J. Bruce Fields
2008-09-12 3:14 ` Chuck Lever
[not found] ` <76bd70e30809112014m52af6961ja83522100203300b-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-12 22:07 ` J. Bruce Fields
2008-09-03 18:35 ` [PATCH 3/7] NSM: Use sockaddr_storage for sm_addr field Chuck Lever
2008-09-03 18:36 ` [PATCH 4/7] lockd: Teach nlm_cmp_addr() to support AF_INET6 addresses Chuck Lever
2008-09-03 18:36 ` [PATCH 5/7] lockd: Support AF_INET6 when hashing addresses in nlm_lookup_host Chuck Lever
[not found] ` <20080903183608.16867.80962.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-12 21:59 ` J. Bruce Fields
2008-09-03 18:36 ` [PATCH 6/7] lockd: Combine __nsm_find() and nsm_find() Chuck Lever
[not found] ` <20080903183615.16867.58815.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-12 21:56 ` J. Bruce Fields [this message]
2008-09-03 18:36 ` [PATCH 7/7] lockd: Update nsm_find() to support non-AF_INET addresses Chuck Lever
2008-09-12 22:12 ` [PATCH 0/7] More IPv6 support for lockd J. Bruce Fields
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=20080912215637.GF22126@fieldses.org \
--to=bfields@fieldses.org \
--cc=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