From patchwork Wed Feb 8 01:54:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 9561589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 952DD60572 for ; Wed, 8 Feb 2017 01:54:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88914283F6 for ; Wed, 8 Feb 2017 01:54:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D4F82848E; Wed, 8 Feb 2017 01:54:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1ECB28479 for ; Wed, 8 Feb 2017 01:54:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932644AbdBHByu (ORCPT ); Tue, 7 Feb 2017 20:54:50 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:34142 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932282AbdBHByt (ORCPT ); Tue, 7 Feb 2017 20:54:49 -0500 Received: by mail-io0-f194.google.com with SMTP id c80so14604240iod.1 for ; Tue, 07 Feb 2017 17:54:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=WPDhUjqPaj7wargKW7Jygcy7ACATf7Gtm+c/EcpoZCs=; b=AAWiNrBu9zRw5ikDvTJ4oM9NeQwZcrE0JpJ0G0ujWyzIyNXLQKJuQFQGml49q2Embz cpMWZ+c+HcxsavwbhBmIwjixucj9znKNsv5wbsLRDqSA3wxD/Ia2oNOnHjQTfJuzzw12 3WJgrOVYuNWqdpqUU2erTKyZZ0fSKjAUgec9YmKWkt+xbrwDa1TtAb1l95q1EU6QzSwz OL37UNLovMt3fkZQw2734PA/P6utdLIKLhXr4CI4zNBN7RU8GV8XfL7TTxhvVSgcIGDE VO0kUw09KckU88Z9Lpd3R895C6RUjYsyBKYV4OC8KfVYl0jjVrsYhqbJtw5n3d/ZQoxH 0YiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=WPDhUjqPaj7wargKW7Jygcy7ACATf7Gtm+c/EcpoZCs=; b=VMU3dQCpCHfZ1P4zeBCVycJ8VeKPWWFEiPh7de5Jn9NRLsG0QmdeFtbrXIZD/XwXqu K/JTPnz1Vxd/LWEiLPgKq/eKkIabOg1QVgQIaoY6P5GKWHjIFxLwG7Cl8RYIrWSwWY4W 0Fk99yvv/D0/5YCl5NDswB1ALif7wu29plFkXmAWQusQzIJt1C1aFRMulyENatnVd0Bd AYJoRG+PyOzWBkw6lRjFEfQdByL9TIyQvY+qqUhIShsh9kAIjyjdBB/w2giZlMTfNafq KMORWjhEdqPvfQGjybVnTtO2LO7zTKC3JhF3FTPwzZHlbBanw+876LKgB2cc8dhoAvxx LlBw== X-Gm-Message-State: AMke39ngvrkT2KBuZTAsbBcTc4wk5m9JEdEnKol+UMB4TKvjl152YSJ6Gdx4Ht31/ex1nw== X-Received: by 10.107.2.138 with SMTP id 132mr6488827ioc.67.1486518888613; Tue, 07 Feb 2017 17:54:48 -0800 (PST) Received: from [192.168.0.107] ([182.139.118.29]) by smtp.gmail.com with ESMTPSA id 16sm252013itu.17.2017.02.07.17.54.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 17:54:48 -0800 (PST) To: "J. Bruce Fields" , linux-nfs@vger.kernel.org Cc: Trond Myklebust , NeilBrown , Kinglong Mee From: Kinglong Mee Subject: [PATCH 2/2 v3] SUNRPC/Cache: Always treat the invalid cache as unexpired Message-ID: Date: Wed, 8 Feb 2017 09:54:42 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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." v3, change the order of the two patches v2, change the checking of CACHE_PENDING to CACHE_VALID Reviewed-by: NeilBrown Signed-off-by: Kinglong Mee --- 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); }