From: "J. Bruce Fields" <bfields@fieldses.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: trond.myklebust@netapp.com, trond.myklebust@fys.uio.no,
linux-nfs@vger.kernel.org
Subject: Re: [PATCH 6/8] SUNRPC: Refactor svc_register()
Date: Thu, 14 Aug 2008 16:36:40 -0400 [thread overview]
Message-ID: <20080814203640.GJ23859@fieldses.org> (raw)
In-Reply-To: <20080813224016.13068.29786.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
On Wed, Aug 13, 2008 at 06:40:17PM -0400, Chuck Lever wrote:
> Clean up: refactor the rpcb_register() call out of svc_register().
>
> The next patch will choose the correct registration subroutine to use
> based on whether IPv6 support is desired for RPC services.
>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>
> include/linux/sunrpc/svc.h | 4 +++-
> net/sunrpc/svc.c | 40 +++++++++++++++++++++++++++-------------
> 2 files changed, 30 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
> index a794d4a..2a41d29 100644
> --- a/include/linux/sunrpc/svc.h
> +++ b/include/linux/sunrpc/svc.h
> @@ -395,7 +395,9 @@ struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
> int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
> void svc_destroy(struct svc_serv *);
> int svc_process(struct svc_rqst *);
> -int svc_register(struct svc_serv *, int, unsigned short);
> +int svc_register(const struct svc_serv *, const unsigned short,
> + const unsigned short);
> +
> void svc_wake_up(struct svc_serv *);
> void svc_reserve(struct svc_rqst *rqstp, int space);
> struct svc_pool * svc_pool_for_cpu(struct svc_serv *serv, int cpu);
> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
> index 58a8012..aa334c2 100644
> --- a/net/sunrpc/svc.c
> +++ b/net/sunrpc/svc.c
> @@ -720,17 +720,32 @@ svc_exit_thread(struct svc_rqst *rqstp)
> }
> EXPORT_SYMBOL(svc_exit_thread);
>
> -/*
> - * Register an RPC service with the local portmapper.
> - * To unregister a service, call this routine with
> - * proto and port == 0.
> +static int __svc_register(const u32 program, const u32 version,
> + sa_family_t family,
> + const unsigned short protocol,
> + const unsigned short port)
> +{
> + int error, result;
> +
> + error = rpcb_register(program, version, protocol, port, &result);
> + if (!result)
> + error = -EACCES;
> + return error;
Isn't "result" 0 whenever error is nonzero? In that case the above is
really equivalent to
rpcb_register(program, version, protocol, port, &result);
return result ? 0 : -EACCES;
Is that what's intended? I don't believe it's the behavior of the
original code.
I understand why they're there, but the separate "result" and "error"
returns are kinda confusing. If the distinction's not needed then I
wonder whether it should just be buried as deep in rpcb_register() as
possible so we don't have to think about it.
--b.
> +}
> +
> +/**
> + * svc_register - register an RPC service with the local portmapper
> + * @serv: svc_serv struct for the service to register
> + * @proto: transport protocol number to advertise
> + * @port: port to advertise
> + *
> */
> -int
> -svc_register(struct svc_serv *serv, int proto, unsigned short port)
> +int svc_register(const struct svc_serv *serv, const unsigned short proto,
> + const unsigned short port)
> {
> struct svc_program *progp;
> unsigned int i;
> - int error = 0, dummy;
> + int error = 0;
>
> BUG_ON(proto == 0 && port == 0);
>
> @@ -739,8 +754,9 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)
> if (progp->pg_vers[i] == NULL)
> continue;
>
> - dprintk("svc: svc_register(%s, %s, %d, %d)%s\n",
> + dprintk("svc: svc_register(%s, %u, %s, %u, %d)%s\n",
> progp->pg_name,
> + serv->sv_family,
> proto == IPPROTO_UDP? "udp" : "tcp",
> port,
> i,
> @@ -750,13 +766,11 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)
> if (progp->pg_vers[i]->vs_hidden)
> continue;
>
> - error = rpcb_register(progp->pg_prog, i, proto, port, &dummy);
> + error = __svc_register(progp->pg_prog, i,
> + serv->sv_family, proto,
> + port);
> if (error < 0)
> break;
> - if (!dummy) {
> - error = -EACCES;
> - break;
> - }
> }
> }
>
>
next prev parent reply other threads:[~2008-08-14 20:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-13 22:39 [PATCH 0/8] Support rpcbind v4 in kernel's RPC server Chuck Lever
[not found] ` <20080813223653.13068.9467.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-08-13 22:39 ` [PATCH 1/8] NFS: nfs_parsed_mount_options can use unsigned int Chuck Lever
[not found] ` <20080813223937.13068.47032.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-23 19:42 ` Trond Myklebust
2008-08-13 22:39 ` [PATCH 2/8] SUNRPC: Add address family field to svc_serv data structure Chuck Lever
2008-08-13 22:39 ` [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets Chuck Lever
[not found] ` <20080813223953.13068.97829.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-08-14 20:05 ` J. Bruce Fields
2008-08-14 20:34 ` Chuck Lever
2008-08-14 20:38 ` J. Bruce Fields
2008-08-14 20:45 ` Chuck Lever
2008-08-20 19:31 ` J. Bruce Fields
2008-08-21 12:11 ` Le Rouzic
2008-08-21 14:41 ` J. Bruce Fields
2008-08-21 15:32 ` Le Rouzic
2008-08-21 16:20 ` Chuck Lever
[not found] ` <76bd70e30808210920y3db1b07cyccbe40e1b4582c12-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-08-21 21:26 ` J. Bruce Fields
2008-08-13 22:40 ` [PATCH 4/8] SUNRPC: Use proper INADDR_ANY when setting up RPC services on IPv6 Chuck Lever
2008-08-13 22:40 ` [PATCH 5/8] SUNRPC: Split portmap unregister API into separate function Chuck Lever
2008-08-13 22:40 ` [PATCH 6/8] SUNRPC: Refactor svc_register() Chuck Lever
[not found] ` <20080813224016.13068.29786.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-08-14 20:36 ` J. Bruce Fields [this message]
2008-08-14 21:11 ` Chuck Lever
2008-08-13 22:40 ` [PATCH 7/8] SUNRPC: Use new rpcb_v4_register() interface in svc_register() Chuck Lever
2008-08-13 22:40 ` [PATCH 8/8] SUNRPC: Add kernel build option to disable server-side use of rpcbind v3/v4 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=20080814203640.GJ23859@fieldses.org \
--to=bfields@fieldses.org \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@fys.uio.no \
--cc=trond.myklebust@netapp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox