Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8606041ybl; Thu, 16 Jan 2020 20:45:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxQTypXzIqIicQTI8h3seazUaL3PeluxlwzbC3jrFys27863bKCnHt0I4g3D2p6ypbpRhEu X-Received: by 2002:a05:6830:10c6:: with SMTP id z6mr5031050oto.203.1579236355765; Thu, 16 Jan 2020 20:45:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579236355; cv=none; d=google.com; s=arc-20160816; b=FmSJTcilbfy2RrtRhvi0sj7dRkBTzhTBNHxUCP990nn61NCatR661ZvL3cPS5uf50N CoWPz3Vs++M77+4eTfY4W2Tw9GC20o58LoyQVsfQVk9f/EwT2skc5+qOCY1z5b1oHYfg 6FmIsxVvjPl/5tixIMotBWK+8DwmqNlLJ2edjgK4kfW3G33lWFjwtsdjXp6YxHBuXOWR VG0hL2jOSO7e4FFK6b9auQS/SLk5CX3rRZwJlRw932fEd57SD3lMYD9q4325+pyTY24N xobL54Fqc6Xwe+ZQ9VZSsEHMWif+zLeGLwTriCdj4PXVdkncrFIbBF2/TW8II2duJ4ip 5Jfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4/3wH5cwDl0eBt+H1DYnbP6yc9zZQUG4FnZpyhRdJJU=; b=SiFiub6klRWN26ikykw+86U4f8DWuKWFOtKx4N3auta2ZOoplEWU//OUubxIkEzxJ/ 30LwcosdK9182Xw1E6qED2bmLgoLxVhn7GsrSlmQ1v3mVf0/WfgkTzH4BhULj7bDTUHj vKRtMO5+Hq0/NHEbHe2DCRUJEZLMMsfCUA+umn/fG+9xoU8VM6/qJKG3FKaZQN9g/9ph RaUD+8XYWuNtg02n6MFYsVRZKXbYQi2eehdsEj/sKD66rnuERp/WWmafcvNHJMdXJ97t lTXvgEoTqRBZFFeK34xrV3JRZg5fsIpM7/Q5lPzQqrcJww6kznLhRWEGjow1RJa8b60G 5WpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=goYJoRB5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si14286337otk.251.2020.01.16.20.45.44; Thu, 16 Jan 2020 20:45:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=goYJoRB5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391874AbgAPXoi (ORCPT + 99 others); Thu, 16 Jan 2020 18:44:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:52796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730969AbgAPXYB (ORCPT ); Thu, 16 Jan 2020 18:24:01 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B42E7206D9; Thu, 16 Jan 2020 23:23:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217040; bh=ldsUpBwdcBBX6zPRy6kx1Lh2h6EqBnpsrUOw2AZ4JBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=goYJoRB5SfYMdhUvoULFovOoYG3nhFiiJuecuDhskSZeAdkj1bH0QoIL55hQs6IEK 54KUyeRIjnPcViMiDz5vNeRjH9w1wvpFuxCutIulKp5nL8YtU1GTTwj0LJu/6d783l os0BBLpUCWH8pm3GQl+kKSE8291G+9vqBYj9zpuo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 5.4 107/203] NFSv4.x: Handle bad/dead sessions correctly in nfs41_sequence_process() Date: Fri, 17 Jan 2020 00:17:04 +0100 Message-Id: <20200116231754.887877704@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust commit 5c441544f045e679afd6c3c6d9f7aaf5fa5f37b0 upstream. If the server returns a bad or dead session error, the we don't want to update the session slot number, but just immediately schedule recovery and allow it to proceed. We can/should then remove handling in other places Fixes: 3453d5708b33 ("NFSv4.1: Avoid false retries when RPC calls are interrupted") Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/nfs4proc.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -521,9 +521,7 @@ static int nfs4_do_handle_exception(stru case -NFS4ERR_DEADSESSION: case -NFS4ERR_SEQ_FALSE_RETRY: case -NFS4ERR_SEQ_MISORDERED: - dprintk("%s ERROR: %d Reset session\n", __func__, - errorcode); - nfs4_schedule_session_recovery(clp->cl_session, errorcode); + /* Handled in nfs41_sequence_process() */ goto wait_on_recovery; #endif /* defined(CONFIG_NFS_V4_1) */ case -NFS4ERR_FILE_OPEN: @@ -782,6 +780,7 @@ static int nfs41_sequence_process(struct struct nfs4_session *session; struct nfs4_slot *slot = res->sr_slot; struct nfs_client *clp; + int status; int ret = 1; if (slot == NULL) @@ -793,8 +792,13 @@ static int nfs41_sequence_process(struct session = slot->table->session; trace_nfs4_sequence_done(session, res); + + status = res->sr_status; + if (task->tk_status == -NFS4ERR_DEADSESSION) + status = -NFS4ERR_DEADSESSION; + /* Check the SEQUENCE operation status */ - switch (res->sr_status) { + switch (status) { case 0: /* Mark this sequence number as having been acked */ nfs4_slot_sequence_acked(slot, slot->seq_nr); @@ -866,6 +870,10 @@ static int nfs41_sequence_process(struct */ slot->seq_nr = slot->seq_nr_highest_sent; goto out_retry; + case -NFS4ERR_BADSESSION: + case -NFS4ERR_DEADSESSION: + case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: + goto session_recover; default: /* Just update the slot sequence no. */ slot->seq_done = 1; @@ -876,8 +884,10 @@ out: out_noaction: return ret; session_recover: - nfs4_schedule_session_recovery(session, res->sr_status); - goto retry_nowait; + nfs4_schedule_session_recovery(session, status); + dprintk("%s ERROR: %d Reset session\n", __func__, status); + nfs41_sequence_free_slot(res); + goto out; retry_new_seq: ++slot->seq_nr; retry_nowait: @@ -2188,7 +2198,6 @@ static int nfs4_handle_delegation_recall case -NFS4ERR_BAD_HIGH_SLOT: case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: case -NFS4ERR_DEADSESSION: - nfs4_schedule_session_recovery(server->nfs_client->cl_session, err); return -EAGAIN; case -NFS4ERR_STALE_CLIENTID: case -NFS4ERR_STALE_STATEID: @@ -7820,6 +7829,15 @@ nfs41_same_server_scope(struct nfs41_ser static void nfs4_bind_one_conn_to_session_done(struct rpc_task *task, void *calldata) { + struct nfs41_bind_conn_to_session_args *args = task->tk_msg.rpc_argp; + struct nfs_client *clp = args->client; + + switch (task->tk_status) { + case -NFS4ERR_BADSESSION: + case -NFS4ERR_DEADSESSION: + nfs4_schedule_session_recovery(clp->cl_session, + task->tk_status); + } } static const struct rpc_call_ops nfs4_bind_one_conn_to_session_ops = { @@ -8867,8 +8885,6 @@ static int nfs41_reclaim_complete_handle case -NFS4ERR_BADSESSION: case -NFS4ERR_DEADSESSION: case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: - nfs4_schedule_session_recovery(clp->cl_session, - task->tk_status); break; default: nfs4_schedule_lease_recovery(clp);