From patchwork Wed Nov 30 00:53:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9453335 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 C4EE560756 for ; Wed, 30 Nov 2016 00:55:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6AB2285B6 for ; Wed, 30 Nov 2016 00:55:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAE75285B9; Wed, 30 Nov 2016 00:55:27 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 4CF2B285B6 for ; Wed, 30 Nov 2016 00:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754554AbcK3Az0 (ORCPT ); Tue, 29 Nov 2016 19:55:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:56747 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755185AbcK3AzY (ORCPT ); Tue, 29 Nov 2016 19:55:24 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C6479ACBA; Wed, 30 Nov 2016 00:54:47 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Wed, 30 Nov 2016 11:53:52 +1100 Subject: [PATCH 2/2] mount: take history into account when assessing if an error is permanent. Cc: Linux NFS Mailing List Message-ID: <148046723208.21092.12537997642943826780.stgit@noble> In-Reply-To: <148046718451.21092.10685567606499960786.stgit@noble> References: <148046718451.21092.10685567606499960786.stgit@noble> User-Agent: StGit/0.17.1-dirty 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 attempting an NFSv3 mount request, it is possible to catch the server at an "awkward" moment while it is still starting up. In these cases it is possible to get an error that would otherwise indiciate a permanent error, but which should be considered temporary during the start-up window. In particular: ECONNREFUSED will be returned between the time the network interface is configured, and the time that rpcbind starts EOPNOTSUPP (representing RPC_PROGNOTREGISTERED) will be returned between the time that rpcbind starts and the time when nfsd registers, and ESTALE will be returned between the time nfsd starts and when filesystems are exported (this windown can be removed with correct configuration). So these errors only deserve a relatively small timeout. So change nfs_is_permanent_error() to record the previous error and the number of times the same error has been seen. If ESTALE or EOPNOTSUPP is seen 3 times (over 3 seconds or more) or ECONNREFUSED is seen 5 times (15 seconds), report a permanent error, others assume it could be temporary. A result of this is that if you try a UDP mount from a server which doesn't support UDP, you get an error without a few seconds, rather than a 2-minute timeout. Signed-off-by: NeilBrown --- utils/mount/stropts.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) -- 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 diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index 7b1ad93effc0..ba6593036a50 100644 --- a/utils/mount/stropts.c +++ b/utils/mount/stropts.c @@ -935,20 +935,37 @@ static int nfs_try_mount(struct nfsmount_info *mi) * failed so far, but fail immediately if there is a local * error (like a bad mount option). * - * ESTALE is also a temporary error because some servers - * return ESTALE when a share is temporarily offline. + * If there is a remote error, like ESTALE or RPC_PROGNOTREGISTERED + * then it is probably permanent, but there is a small chance + * the it is temporary can we caught the server at an awkward + * time during start-up. So require that we see three of those + * before treating them as permanent. + * For ECONNREFUSED, wait a bit longer as there is often a longer + * gap between the network being ready and the NFS server starting. * * Returns 1 if we should fail immediately, or 0 if we * should retry. */ static int nfs_is_permanent_error(int error) { + static int prev_error; + static int rpt_cnt; + + if (error == prev_error) + rpt_cnt += 1; + else + rpt_cnt = 1; + prev_error = error; + switch (error) { case ESTALE: - case ETIMEDOUT: + case EOPNOTSUPP: /* aka RPC_PROGNOTREGISTERED */ + /* If two in a row, assume permanent */ + return rpt_cnt >= 3; case ECONNREFUSED: + return rpt_cnt >= 5; + case ETIMEDOUT: case EHOSTUNREACH: - case EOPNOTSUPP: /* aka RPC_PROGNOTREGISTERED */ case EAGAIN: return 0; /* temporary */ default: @@ -1000,7 +1017,7 @@ static int nfsmount_fg(struct nfsmount_info *mi) if (secs > 10) secs = 10; } - }; + } mount_error(mi->spec, mi->node, errno); return EX_FAIL;