linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] SUNRPC/Cache: Always treat the invalid cache as unexpired
@ 2017-02-06  4:00 Kinglong Mee
  2017-02-07 23:16 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: Kinglong Mee @ 2017-02-06  4:00 UTC (permalink / raw)
  To: J. Bruce Fields, linux-nfs; +Cc: NeilBrown, Trond Myklebust, Kinglong Mee

When the first time pynfs runs after rpc/nfsd startup, always get the warning,

"Got error: Connection closed"

I found the problem is caused by,
1. A new startup of nfsd, rpc.mountd, etc,
2. A rpc request from client (pynfs test, or normal mounting),
3. An ip_map cache is created but invalid, so upcall to rpc.mountd,
4. rpc.mountd process the ip_map upcall, before write the valid data to nfsd,
   do auth_reload(), and check_useipaddr(),
5. For the first time, old_use_ipaddr = -1, it causes rpc.mountd do write_flush    that doing cache_clean,
6. The ip_map cache will be treat as expired and clean,
7. When rpc.mountd write the valid data to nfsd, a new ip_map is created
   and updated, the cache_check of old ip_map(doing the upcall) will
   return -ETIMEDOUT.
8. RPC layer return SVC_CLOSE and close the xprt after commit 4d712ef1db05
   "svcauth_gss: Close connection when dropping an incoming message"

NeilBrown suggest in another email,

"If CACHE_VALID is not set, then there is no data in the cache item,
 so there is nothing to expire. So it would be nice if cache items that
 don't have CACHE_VALID are never treated as expired."

v2, change the checking of CACHE_PENDING to CACHE_VALID

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 include/linux/sunrpc/cache.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index 62a60ee..782024e 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -204,8 +204,11 @@ static inline void cache_put(struct cache_head *h, struct cache_detail *cd)
 	kref_put(&h->ref, cd->cache_put);
 }
 
-static inline int cache_is_expired(struct cache_detail *detail, struct cache_head *h)
+static inline bool cache_is_expired(struct cache_detail *detail, struct cache_head *h)
 {
+	if (!test_bit(CACHE_VALID, &h->flags))
+		return false;
+
 	return  (h->expiry_time < seconds_since_boot()) ||
 		(detail->flush_time >= h->last_refresh);
 }
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] SUNRPC/Cache: Always treat the invalid cache as unexpired
  2017-02-06  4:00 [PATCH 1/2] SUNRPC/Cache: Always treat the invalid cache as unexpired Kinglong Mee
@ 2017-02-07 23:16 ` NeilBrown
  0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2017-02-07 23:16 UTC (permalink / raw)
  To: Kinglong Mee, J. Bruce Fields, linux-nfs; +Cc: Trond Myklebust, Kinglong Mee

[-- Attachment #1: Type: text/plain, Size: 2457 bytes --]

On Mon, Feb 06 2017, Kinglong Mee wrote:

> When the first time pynfs runs after rpc/nfsd startup, always get the warning,
>
> "Got error: Connection closed"
>
> I found the problem is caused by,
> 1. A new startup of nfsd, rpc.mountd, etc,
> 2. A rpc request from client (pynfs test, or normal mounting),
> 3. An ip_map cache is created but invalid, so upcall to rpc.mountd,
> 4. rpc.mountd process the ip_map upcall, before write the valid data to nfsd,
>    do auth_reload(), and check_useipaddr(),
> 5. For the first time, old_use_ipaddr = -1, it causes rpc.mountd do write_flush    that doing cache_clean,
> 6. The ip_map cache will be treat as expired and clean,
> 7. When rpc.mountd write the valid data to nfsd, a new ip_map is created
>    and updated, the cache_check of old ip_map(doing the upcall) will
>    return -ETIMEDOUT.
> 8. RPC layer return SVC_CLOSE and close the xprt after commit 4d712ef1db05
>    "svcauth_gss: Close connection when dropping an incoming message"
>
> NeilBrown suggest in another email,
>
> "If CACHE_VALID is not set, then there is no data in the cache item,
>  so there is nothing to expire. So it would be nice if cache items that
>  don't have CACHE_VALID are never treated as expired."
>
> v2, change the checking of CACHE_PENDING to CACHE_VALID
>
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
>  include/linux/sunrpc/cache.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
> index 62a60ee..782024e 100644
> --- a/include/linux/sunrpc/cache.h
> +++ b/include/linux/sunrpc/cache.h
> @@ -204,8 +204,11 @@ static inline void cache_put(struct cache_head *h, struct cache_detail *cd)
>  	kref_put(&h->ref, cd->cache_put);
>  }
>  
> -static inline int cache_is_expired(struct cache_detail *detail, struct cache_head *h)
> +static inline bool cache_is_expired(struct cache_detail *detail, struct cache_head *h)
>  {
> +	if (!test_bit(CACHE_VALID, &h->flags))
> +		return false;
> +
>  	return  (h->expiry_time < seconds_since_boot()) ||
>  		(detail->flush_time >= h->last_refresh);
>  }
> -- 
> 2.9.3

Thanks for this.
I think it would be best if this patch were applied *after* the change
to cache_purge(), to avoid possible issues if a git-bisect lands between
these two.
Apart from that:\
 Reviewed-by: NeilBrown <neilb@suse.com>

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-07 23:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-06  4:00 [PATCH 1/2] SUNRPC/Cache: Always treat the invalid cache as unexpired Kinglong Mee
2017-02-07 23:16 ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).