From: Tom Tucker <tom@opengridcomputing.com>
To: chuck.lever@oracle.com
Cc: nfs@lists.sourceforge.net
Subject: Re: [RFC,PATCH 10/20] svc: Add generic refcount services
Date: Wed, 29 Aug 2007 15:19:40 -0500 [thread overview]
Message-ID: <1188418780.7502.32.camel@trinity.ogc.int> (raw)
In-Reply-To: <46D5C115.1080302@oracle.com>
On Wed, 2007-08-29 at 14:55 -0400, Chuck Lever wrote:
> Tom Tucker wrote:
> > Add inline svc_sock_get() so that service transport code will not
> > need to manipulate sk_inuse directly. Also, make svc_sock_put()
> > available so that transport code outside svcsock.c can use it.
>
> If svc_sock_get/put is meant to be generic, then you should probably
> rename them, move them to a generic source file, and have them take
> something other than "svc_sock *".
>
> Would it make sense to add a kref to these objects instead of
> manipulating a naked atomic_t reference count?
I think this is interesting. Basically svc_xxx_get and put go away and
we use the generic kref services instead. The cleanup code in
svc_xxx_put would become the release method.
I think this is a good idea.
>
> > Signed-off-by: Greg Banks <gnb@melbourne.sgi.com>
> > Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
> > ---
> >
> > include/linux/sunrpc/svcsock.h | 15 +++++++++++++++
> > net/sunrpc/svcsock.c | 29 ++++++++++++++---------------
> > 2 files changed, 29 insertions(+), 15 deletions(-)
> >
> > diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
> > index ea8b62b..9f37f30 100644
> > --- a/include/linux/sunrpc/svcsock.h
> > +++ b/include/linux/sunrpc/svcsock.h
> > @@ -115,6 +115,7 @@ int svc_addsock(struct svc_serv *serv,
> > int *proto);
> > void svc_sock_enqueue(struct svc_sock *svsk);
> > void svc_sock_received(struct svc_sock *svsk);
> > +void __svc_sock_put(struct svc_sock *svsk);
> >
> > /*
> > * svc_makesock socket characteristics
> > @@ -123,4 +124,18 @@ #define SVC_SOCK_DEFAULTS (0U)
> > #define SVC_SOCK_ANONYMOUS (1U << 0) /* don't register with pmap */
> > #define SVC_SOCK_TEMPORARY (1U << 1) /* flag socket as temporary */
> >
> > +/*
> > + * Take and drop a temporary reference count on the svc_sock.
> > + */
> > +static inline void svc_sock_get(struct svc_sock *svsk)
> > +{
> > + atomic_inc(&svsk->sk_inuse);
> > +}
> > +
> > +static inline void svc_sock_put(struct svc_sock *svsk)
> > +{
> > + if (atomic_dec_and_test(&svsk->sk_inuse))
> > + __svc_sock_put(svsk);
> > +}
> > +
> > #endif /* SUNRPC_SVCSOCK_H */
> > diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> > index dcb5c7a..02f682a 100644
> > --- a/net/sunrpc/svcsock.c
> > +++ b/net/sunrpc/svcsock.c
> > @@ -273,7 +273,7 @@ svc_sock_enqueue(struct svc_sock *svsk)
> > "svc_sock_enqueue: server %p, rq_sock=%p!\n",
> > rqstp, rqstp->rq_sock);
> > rqstp->rq_sock = svsk;
> > - atomic_inc(&svsk->sk_inuse);
> > + svc_sock_get(svsk);
> > rqstp->rq_reserved = serv->sv_max_mesg;
> > atomic_add(rqstp->rq_reserved, &svsk->sk_reserved);
> > BUG_ON(svsk->sk_pool != pool);
> > @@ -351,17 +351,16 @@ void svc_reserve(struct svc_rqst *rqstp,
> > /*
> > * Release a socket after use.
> > */
> > -static inline void
> > -svc_sock_put(struct svc_sock *svsk)
> > +void
> > +__svc_sock_put(struct svc_sock *svsk)
> > {
> > - if (atomic_dec_and_test(&svsk->sk_inuse)) {
> > - BUG_ON(! test_bit(SK_DEAD, &svsk->sk_flags));
> > + BUG_ON(! test_bit(SK_DEAD, &svsk->sk_flags));
> >
> > - if (svsk->sk_info_authunix != NULL)
> > - svcauth_unix_info_release(svsk->sk_info_authunix);
> > - svsk->sk_xprt->xpt_free(svsk);
> > - }
> > + if (svsk->sk_info_authunix != NULL)
> > + svcauth_unix_info_release(svsk->sk_info_authunix);
> > + svsk->sk_xprt->xpt_free(svsk);
> > }
> > +EXPORT_SYMBOL_GPL(__svc_sock_put);
>
> I see here that you are integrating the detach and free methods into
> "svc_sock_put". It might make sense to reorder your patches so that
> this comes earlier in the series (or is integrated somehow with the
> patch that introduces detach and free).
>
This is a good suggestion. Note comment about kref...
> > static void
> > svc_sock_release(struct svc_rqst *rqstp)
> > @@ -1109,7 +1108,7 @@ svc_tcp_accept(struct svc_sock *svsk)
> > struct svc_sock,
> > sk_list);
> > set_bit(SK_CLOSE, &svsk->sk_flags);
> > - atomic_inc(&svsk->sk_inuse);
> > + svc_sock_get(svsk);
> > }
> > spin_unlock_bh(&serv->sv_lock);
> >
> > @@ -1481,7 +1480,7 @@ svc_recv(struct svc_rqst *rqstp, long ti
> > spin_lock_bh(&pool->sp_lock);
> > if ((svsk = svc_sock_dequeue(pool)) != NULL) {
> > rqstp->rq_sock = svsk;
> > - atomic_inc(&svsk->sk_inuse);
> > + svc_sock_get(svsk);
> > rqstp->rq_reserved = serv->sv_max_mesg;
> > atomic_add(rqstp->rq_reserved, &svsk->sk_reserved);
> > } else {
> > @@ -1620,7 +1619,7 @@ svc_age_temp_sockets(unsigned long closu
> > continue;
> > if (atomic_read(&svsk->sk_inuse) || test_bit(SK_BUSY, &svsk->sk_flags))
> > continue;
> > - atomic_inc(&svsk->sk_inuse);
> > + svc_sock_get(svsk);
> > list_move(le, &to_be_aged);
> > set_bit(SK_CLOSE, &svsk->sk_flags);
> > set_bit(SK_DETACHED, &svsk->sk_flags);
> > @@ -1868,7 +1867,7 @@ svc_delete_socket(struct svc_sock *svsk)
> > */
> > if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags)) {
> > BUG_ON(atomic_read(&svsk->sk_inuse)<2);
> > - atomic_dec(&svsk->sk_inuse);
> > + svc_sock_put(svsk);
> > if (test_bit(SK_TEMP, &svsk->sk_flags))
> > serv->sv_tmpcnt--;
> > }
> > @@ -1883,7 +1882,7 @@ static void svc_close_socket(struct svc_
> > /* someone else will have to effect the close */
> > return;
> >
> > - atomic_inc(&svsk->sk_inuse);
> > + svc_sock_get(svsk);
> > svc_delete_socket(svsk);
> > clear_bit(SK_BUSY, &svsk->sk_flags);
> > svc_sock_put(svsk);
> > @@ -1976,7 +1975,7 @@ svc_defer(struct cache_req *req)
> > dr->argslen = rqstp->rq_arg.len >> 2;
> > memcpy(dr->args, rqstp->rq_arg.head[0].iov_base-skip, dr->argslen<<2);
> > }
> > - atomic_inc(&rqstp->rq_sock->sk_inuse);
> > + svc_sock_get(rqstp->rq_sock);
> > dr->svsk = rqstp->rq_sock;
> >
> > dr->handle.revisit = svc_revisit;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
next prev parent reply other threads:[~2007-08-29 20:21 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-20 16:20 [RFC,PATCH 00/20] svc: Server Side Transport Switch Tom Tucker
2007-08-20 16:23 ` [RFC, PATCH 01/20] svc: Add svc_xprt transport switch structure Tom Tucker
2007-08-20 16:23 ` [RFC,PATCH 02/20] svc: xpt_detach and xpt_free Tom Tucker
2007-08-29 17:05 ` Chuck Lever
2007-08-29 17:08 ` J. Bruce Fields
2007-08-20 16:23 ` [RFC,PATCH 03/20] svc: xpt_prep_reply_hdr Tom Tucker
2007-08-29 17:15 ` Chuck Lever
2007-08-29 18:28 ` Tom Tucker
2007-08-20 16:23 ` [RFC,PATCH 05/20] svc: xpt_max_payload Tom Tucker
2007-08-29 17:40 ` Chuck Lever
2007-08-29 19:06 ` Tom Tucker
2007-08-20 16:23 ` [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received Tom Tucker
2007-08-21 16:03 ` Chuck Lever
2007-08-21 18:08 ` Tom Tucker
2007-08-20 16:23 ` [RFC,PATCH 07/20] svc: centralise close handling Tom Tucker
2007-08-29 18:16 ` Chuck Lever
2007-08-20 16:23 ` [RFC,PATCH 08/20] svc: centralise accept handling Tom Tucker
2007-08-29 18:40 ` Chuck Lever
2007-08-29 23:56 ` Tom Tucker
2007-08-20 16:23 ` [RFC,PATCH 09/20] svc: Add SK_LISTENER flag Tom Tucker
2007-08-29 18:41 ` Chuck Lever
2007-08-20 16:23 ` [RFC,PATCH 10/20] svc: Add generic refcount services Tom Tucker
2007-08-29 18:55 ` Chuck Lever
2007-08-29 20:19 ` Tom Tucker [this message]
2007-08-20 16:23 ` [RFC,PATCH 11/20] svc: cleanup svc_sock initialization Tom Tucker
2007-08-29 19:07 ` Chuck Lever
2007-08-20 16:23 ` [RFC,PATCH 13/20] svc: Add svc_[un]register_transport Tom Tucker
2007-08-29 19:12 ` Chuck Lever
2007-08-29 20:32 ` Tom Tucker
2007-08-20 16:23 ` [RFC,PATCH 14/20] svc: Register TCP/UDP Transports Tom Tucker
2007-08-20 16:23 ` [RFC,PATCH 15/20] svc: transport file implementation Tom Tucker
2007-08-29 19:15 ` Chuck Lever
2007-08-29 20:37 ` Tom Tucker
2007-08-20 16:23 ` [RFC,PATCH 16/20] svc: xpt_create_svc Tom Tucker
2007-08-29 19:21 ` Chuck Lever
2007-08-29 20:43 ` Tom Tucker
2007-08-20 16:23 ` [RFC,PATCH 17/20] svc: Add xpt_get_name service Tom Tucker
2007-08-20 16:23 ` [RFC,PATCH 18/20] svc: Add xpt_defer transport function Tom Tucker
2007-08-29 19:29 ` Chuck Lever
2007-08-29 21:34 ` Tom Tucker
2007-08-20 16:24 ` [RFC,PATCH 19/20] knfsd: call svc_create_svcsock Tom Tucker
2007-08-20 16:24 ` [RFC,PATCH 20/20] knfsd: create listener via portlist write Tom Tucker
2007-08-29 16:50 ` [RFC,PATCH 00/20] svc: Server Side Transport Switch Chuck Lever
2007-08-29 17:01 ` Talpey, Thomas
2007-08-29 17:59 ` Tom Tucker
2007-08-30 21:12 ` Chuck Lever
2007-08-31 1:19 ` Talpey, Thomas
2007-08-29 16:55 ` J. Bruce Fields
[not found] ` <20070820162329.15224.29032.stgit@dell3.ogc.int>
2007-08-29 17:32 ` [RFC,PATCH 04/20] svc: xpt_has_wspace Chuck Lever
2007-08-29 18:50 ` Tom Tucker
2007-08-29 17:35 ` J. Bruce Fields
2007-08-29 18:52 ` Tom Tucker
2007-08-29 18:53 ` J. Bruce Fields
2007-08-29 19:31 ` J. Bruce Fields
2007-08-29 20:11 ` Tom Tucker
2007-08-29 20:26 ` Tom Tucker
2007-08-29 20:29 ` J. Bruce Fields
2007-08-29 20:28 ` J. Bruce Fields
-- strict thread matches above, loose matches on Subject: below --
2007-07-10 5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
2007-07-10 5:34 ` [RFC,PATCH 10/20] svc: Add generic refcount services Tom Tucker
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=1188418780.7502.32.camel@trinity.ogc.int \
--to=tom@opengridcomputing.com \
--cc=chuck.lever@oracle.com \
--cc=nfs@lists.sourceforge.net \
/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