public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: NeilBrown <neilb@suse.de>
Cc: "J. Bruce Fields" <bfields@fieldses.org>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 6/9] sunrpc: close connection when a request is irretrievably lost.
Date: Wed, 03 Feb 2010 10:43:04 -0500	[thread overview]
Message-ID: <4B699988.9000209@oracle.com> (raw)
In-Reply-To: <20100203063131.12945.34978.stgit@notabene.brown>

On 02/03/2010 01:31 AM, NeilBrown wrote:
> If we drop a request in the sunrpc layer, either due kmalloc failure,
> or due to a cache miss when we could not queue the request for later
> replay, then close the connection to encourage the client to retry sooner.

I studied connection dropping behavior a few years back, and decided 
that dropping the connection on a retransmit is nearly always 
counterproductive.  Any other pending requests on a connection that is 
dropped must also be retransmitted, which means one retransmit suddenly 
turns into many.  And then you get into issues of idempotency and all 
the extra traffic and the long delays and the risk of reconnecting on a 
different port so that XID replay is undetectable...

I don't think dropping the connection will cause the client to 
retransmit sooner.  Clients I have encountered will reconnect and 
retransmit only after their retransmit timeout fires, never sooner.

Unfortunately NFSv4 requires a connection drop before a retransmit, but 
NFSv3 does not.  NFSv4 servers are rather supposed to try very hard not 
to drop requests.

How often do you expect this kind of recovery to be necessary?  Would it 
be possible to drop only for NFSv4 connections?

> Note that if the drop happens in the NFS layer, NFSERR_JUKEBOX
> (aka NFS4ERR_DELAY) is returned to guide the client concerning
> replay.
>
> Signed-off-by: NeilBrown<neilb@suse.de>
> ---
>   include/linux/sunrpc/svcauth.h    |   10 +++++++---
>   net/sunrpc/auth_gss/svcauth_gss.c |   12 ++++++------
>   net/sunrpc/svc.c                  |    3 +++
>   net/sunrpc/svcauth_unix.c         |   11 ++++++++---
>   4 files changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
> index d39dbdc..1126693 100644
> --- a/include/linux/sunrpc/svcauth.h
> +++ b/include/linux/sunrpc/svcauth.h
> @@ -108,9 +108,13 @@ struct auth_ops {
>   #define	SVC_NEGATIVE	4
>   #define	SVC_OK		5
>   #define	SVC_DROP	6
> -#define	SVC_DENIED	7
> -#define	SVC_PENDING	8
> -#define	SVC_COMPLETE	9
> +#define	SVC_CLOSE	7	/* Like SVC_DROP, but request is definitely
> +				 * lost so if there is a tcp connection, it
> +				 * should be closed
> +				 */
> +#define	SVC_DENIED	8
> +#define	SVC_PENDING	9
> +#define	SVC_COMPLETE	10
>
>
>   extern int	svc_authenticate(struct svc_rqst *rqstp, __be32 *authp);
> diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
> index e34bc53..4db9562 100644
> --- a/net/sunrpc/auth_gss/svcauth_gss.c
> +++ b/net/sunrpc/auth_gss/svcauth_gss.c
> @@ -963,7 +963,7 @@ svcauth_gss_set_client(struct svc_rqst *rqstp)
>   	if (rqstp->rq_gssclient == NULL)
>   		return SVC_DENIED;
>   	stat = svcauth_unix_set_client(rqstp);
> -	if (stat == SVC_DROP)
> +	if (stat == SVC_DROP || stat == SVC_CLOSE)
>   		return stat;
>   	return SVC_OK;
>   }
> @@ -1017,7 +1017,7 @@ static int svcauth_gss_handle_init(struct svc_rqst *rqstp,
>   		return SVC_DENIED;
>   	memset(&rsikey, 0, sizeof(rsikey));
>   	if (dup_netobj(&rsikey.in_handle,&gc->gc_ctx))
> -		return SVC_DROP;
> +		return SVC_CLOSE;
>   	*authp = rpc_autherr_badverf;
>   	if (svc_safe_getnetobj(argv,&tmpobj)) {
>   		kfree(rsikey.in_handle.data);
> @@ -1025,22 +1025,22 @@ static int svcauth_gss_handle_init(struct svc_rqst *rqstp,
>   	}
>   	if (dup_netobj(&rsikey.in_token,&tmpobj)) {
>   		kfree(rsikey.in_handle.data);
> -		return SVC_DROP;
> +		return SVC_CLOSE;
>   	}
>
>   	/* Perform upcall, or find upcall result: */
>   	rsip = rsi_lookup(&rsikey);
>   	rsi_free(&rsikey);
>   	if (!rsip)
> -		return SVC_DROP;
> +		return SVC_CLOSE;
>   	switch (cache_check(&rsi_cache,&rsip->h,&rqstp->rq_chandle)) {
>   	case -EAGAIN:
>   	case -ETIMEDOUT:
>   	case -ENOENT:
>   		/* No upcall result: */
> -		return SVC_DROP;
> +		return SVC_CLOSE;
>   	case 0:
> -		ret = SVC_DROP;
> +		ret = SVC_CLOSE;
>   		/* Got an answer to the upcall; use it: */
>   		if (gss_write_init_verf(rqstp, rsip))
>   			goto out;
> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
> index 538ca43..e750988 100644
> --- a/net/sunrpc/svc.c
> +++ b/net/sunrpc/svc.c
> @@ -1050,6 +1050,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
>   		goto err_bad;
>   	case SVC_DENIED:
>   		goto err_bad_auth;
> +	case SVC_CLOSE:
> +		if (test_bit(XPT_TEMP,&rqstp->rq_xprt->xpt_flags))
> +			svc_close_xprt(rqstp->rq_xprt);
>   	case SVC_DROP:
>   		goto dropit;
>   	case SVC_COMPLETE:
> diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
> index d8c0411..a25f8ba 100644
> --- a/net/sunrpc/svcauth_unix.c
> +++ b/net/sunrpc/svcauth_unix.c
> @@ -668,6 +668,8 @@ static struct group_info *unix_gid_find(uid_t uid, struct svc_rqst *rqstp)
>   	switch (ret) {
>   	case -ENOENT:
>   		return ERR_PTR(-ENOENT);
> +	case -ETIMEDOUT:
> +		return ERR_PTR(-ESHUTDOWN);
>   	case 0:
>   		gi = get_group_info(ug->gi);
>   		cache_put(&ug->h,&unix_gid_cache);
> @@ -714,8 +716,9 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
>   	switch (cache_check(&ip_map_cache,&ipm->h,&rqstp->rq_chandle)) {
>   		default:
>   			BUG();
> -		case -EAGAIN:
>   		case -ETIMEDOUT:
> +			return SVC_CLOSE;
> +		case -EAGAIN:
>   			return SVC_DROP;
>   		case -ENOENT:
>   			return SVC_DENIED;
> @@ -730,6 +733,8 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
>   	switch (PTR_ERR(gi)) {
>   	case -EAGAIN:
>   		return SVC_DROP;
> +	case -ESHUTDOWN:
> +		return SVC_CLOSE;
>   	case -ENOENT:
>   		break;
>   	default:
> @@ -770,7 +775,7 @@ svcauth_null_accept(struct svc_rqst *rqstp, __be32 *authp)
>   	cred->cr_gid = (gid_t) -1;
>   	cred->cr_group_info = groups_alloc(0);
>   	if (cred->cr_group_info == NULL)
> -		return SVC_DROP; /* kmalloc failure - client must retry */
> +		return SVC_CLOSE; /* kmalloc failure - client must retry */
>
>   	/* Put NULL verifier */
>   	svc_putnl(resv, RPC_AUTH_NULL);
> @@ -834,7 +839,7 @@ svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp)
>   		goto badcred;
>   	cred->cr_group_info = groups_alloc(slen);
>   	if (cred->cr_group_info == NULL)
> -		return SVC_DROP;
> +		return SVC_CLOSE;
>   	for (i = 0; i<  slen; i++)
>   		GROUP_AT(cred->cr_group_info, i) = svc_getnl(argv);
>   	if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
chuck[dot]lever[at]oracle[dot]com

  reply	other threads:[~2010-02-03 15:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-03  6:31 [PATCH 0/9] Cache deferal improvements - try++ NeilBrown
     [not found] ` <20100203060657.12945.27293.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-02-03  6:31   ` [PATCH 6/9] sunrpc: close connection when a request is irretrievably lost NeilBrown
2010-02-03 15:43     ` Chuck Lever [this message]
2010-02-03 21:23       ` Neil Brown
2010-02-03 22:20         ` Trond Myklebust
2010-02-03 22:34           ` J. Bruce Fields
2010-02-03 22:40           ` Chuck Lever
2010-02-03 23:13             ` Trond Myklebust
2010-02-04  0:06               ` Chuck Lever
2010-02-04  0:24                 ` Trond Myklebust
2010-02-03 22:34         ` Chuck Lever
2010-02-03  6:31   ` [PATCH 3/9] sunrpc: never return expired entries in sunrpc_cache_lookup NeilBrown
     [not found]     ` <20100203063131.12945.97779.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-03-17 21:33       ` J. Bruce Fields
2010-03-24  1:22         ` Neil Brown
2010-03-30 15:11           ` J. Bruce Fields
2010-02-03  6:31   ` [PATCH 8/9] svcauth_gss: replace a trivial 'switch' with an 'if' NeilBrown
2010-02-03  6:31   ` [PATCH 2/9] sunrpc/cache: factor out cache_is_expired NeilBrown
     [not found]     ` <20100203063131.12945.65321.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-03-15  0:58       ` J. Bruce Fields
2010-02-03  6:31   ` [PATCH 5/9] nfsd/idmap: drop special request deferal in favour of improved default NeilBrown
2010-02-03  6:31   ` [PATCH 1/9] sunrpc: don't keep expired entries in the auth caches NeilBrown
     [not found]     ` <20100203063130.12945.29226.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-03-15  0:58       ` J. Bruce Fields
2010-02-03  6:31   ` [PATCH 4/9] sunrpc/cache: allow threads to block while waiting for cache update NeilBrown
2010-04-15 15:55     ` J. Bruce Fields
2010-02-03  6:31   ` [PATCH 7/9] nfsd: factor out hash functions for export caches NeilBrown
     [not found]     ` <20100203063131.12945.38791.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-03-17 19:35       ` J. Bruce Fields
2010-02-03  6:31   ` [PATCH 9/9] sunrpc/cache: change deferred-request hash table to use hlist NeilBrown
2010-02-03 19:43   ` [PATCH 0/9] Cache deferal improvements - try++ 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=4B699988.9000209@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    /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