From patchwork Mon Feb 6 04:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 9557073 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 20C3F602B1 for ; Mon, 6 Feb 2017 04:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06904269E2 for ; Mon, 6 Feb 2017 04:00:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDB5C26E82; Mon, 6 Feb 2017 04:00:45 +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 9AB2C269E2 for ; Mon, 6 Feb 2017 04:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752878AbdBFEAi (ORCPT ); Sun, 5 Feb 2017 23:00:38 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:36029 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752294AbdBFEAi (ORCPT ); Sun, 5 Feb 2017 23:00:38 -0500 Received: by mail-it0-f66.google.com with SMTP id f200so7446688itf.3 for ; Sun, 05 Feb 2017 20:00:37 -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=F6jJjWHt+rq8r/76hDPNYEKyWSufWzNjMNCHeY6ljfg=; b=XHNMaI3I0IP6r3Wgi2zC0rhWu2ylV+vOC0f9eFfixuxvdFvWAdRc/frSlbIF7yvx8J ne2BIIhujryFHxHuebt2R6R1444xWw7+472obpXQog3sAl2L6vWJ76KW71uP0n66m2u7 cFBKFaFsJcjx+MQu7SRTqTUijDSu4x5FpxV5UVkAzVJirXR6kh6iLVAXq9mTEwl9kXpU sTzjUdDxc5cm/OXjTDm2cMEZQ+yQJCVVlDlJyiePvxb8dXNbgUFllyzm+puiJ1/CBh1z gT0Tr7DspfGFkQjxEoIo0imgpQE1QosobR7raqM8cZ91vpyRfPmLwOE2SbPnrQ0Ah/IR P2Og== 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=F6jJjWHt+rq8r/76hDPNYEKyWSufWzNjMNCHeY6ljfg=; b=IlnYGAbeEZSNcyqAvmRapJ3SyvKNPdPRaJt1WtS+6qXepFNvpKi31Cq2sSHPLCJw+k Bg7YkSa8BNHDbP8kBir4OuAIj2wmcTAV+yAhS0y4B9RqzKgE+GfKLvb3/4LJ5xc8dvQz DiH+yLb2c+Fxx/cO3qNNHH5bLO79f4t93Xha+qWMY1MPbdDE8DRwQZHUW7dtoQ/JRtWx Ijlj4Ozdk7uWqYY+qzqf6ziLHSzEJxZeYH7Z7UNBTQJEcst/WCN8FuBgwNNWjUt13qWP LtJbNbC+uIm3p6Agm0L9ZoG4JFRMjHxijHEFfvCIpkU2peRCw3JVChWLXTNUHeiQKd8o r04A== X-Gm-Message-State: AIkVDXLkzotkpcKCGj0KUEhpf8BUZtBYYE2U3TADWogu6XFxnjphcN1I8YiKJkjrSKTIvQ== X-Received: by 10.36.51.68 with SMTP id k65mr5719390itk.64.1486353637293; Sun, 05 Feb 2017 20:00:37 -0800 (PST) Received: from [192.168.0.107] ([182.139.117.200]) by smtp.gmail.com with ESMTPSA id z125sm7149020iod.23.2017.02.05.20.00.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Feb 2017 20:00:36 -0800 (PST) To: "J. Bruce Fields" , linux-nfs@vger.kernel.org Cc: NeilBrown , Trond Myklebust , Kinglong Mee From: Kinglong Mee Subject: [PATCH 1/2] SUNRPC/Cache: Always treat the invalid cache as unexpired Message-ID: Date: Mon, 6 Feb 2017 12:00:05 +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." v2, change the checking of CACHE_PENDING to CACHE_VALID 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); }