From patchwork Thu Oct 16 19:40:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 5093991 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8A88E9F30B for ; Thu, 16 Oct 2014 19:40:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99DC7201EF for ; Thu, 16 Oct 2014 19:40:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1D84201F5 for ; Thu, 16 Oct 2014 19:40:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751854AbaJPTkV (ORCPT ); Thu, 16 Oct 2014 15:40:21 -0400 Received: from mail-ig0-f173.google.com ([209.85.213.173]:53844 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752708AbaJPTkT (ORCPT ); Thu, 16 Oct 2014 15:40:19 -0400 Received: by mail-ig0-f173.google.com with SMTP id h18so265457igc.12 for ; Thu, 16 Oct 2014 12:40:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=MbfLebsqExwv41hzund01XJGwSQbwXeU+YnlVb3vK0U=; b=n7wGBfqE1r0bfSXq2LIYypnaAK6bYC8V8KilClFB7TigZvzV6iYCNj2PHf2QloFGr9 YcJrX+foLLzFcRSGJvQhJsisUSaTn3w4GNd2xqR8GPGwUO2YoXxQx809ES/XCdPi5cM7 MaEwbMhmhP/zXE29BxahD/semjHpTp7jXIbTiygtuCwxjzQse9+w/rTjUIn+4DT9bPyD znqxGd6NEJdK9m1u0YiiqblsvDYLtLM+kRjjjQ5GoEvaa0rk2KcfH3oawJhXfDwIZSMh uXohE16YzjuZUDPwPR1BercrB4NB122hOptUUfiOlTfi+7idmeeGIqtY1XoyPxjxGzyJ XRlw== X-Received: by 10.43.76.199 with SMTP id zf7mr5971934icb.57.1413488417645; Thu, 16 Oct 2014 12:40:17 -0700 (PDT) Received: from manet.1015granger.net ([2604:8800:100:81fc:82ee:73ff:fe43:d64f]) by mx.google.com with ESMTPSA id ro6sm14834946igb.3.2014.10.16.12.40.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Oct 2014 12:40:17 -0700 (PDT) Subject: [PATCH v1 15/16] NFS: Bind side-car connection to session From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Thu, 16 Oct 2014 15:40:16 -0400 Message-ID: <20141016194016.13414.14921.stgit@manet.1015granger.net> In-Reply-To: <20141016192919.13414.3151.stgit@manet.1015granger.net> References: <20141016192919.13414.3151.stgit@manet.1015granger.net> User-Agent: StGit/0.17.1-3-g7d0f MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When recovering from a network partition, a client must identify both the forward and backchannel it wants bound to a session. Usually these use the same transport, which can be re-bound to the session with a single BIND_CONN_TO_SESSION operation. But with a sidecar backchannel, the fore and back channels use separate transports that must be bound to the transport connection using separate BC2S operations. Signed-off-by: Chuck Lever --- fs/nfs/nfs4client.c | 5 ++++- fs/nfs/nfs4proc.c | 48 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 11 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/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index b1cc35e..97cc170 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -246,7 +246,10 @@ static int nfs4_init_callback(struct nfs_client *clp) struct rpc_xprt *xprt; int error; - xprt = rcu_dereference_raw(clp->cl_rpcclient->cl_xprt); + if (clp->cl_bc_rpcclient) + xprt = rcu_dereference_raw(clp->cl_bc_rpcclient->cl_xprt); + else + xprt = rcu_dereference_raw(clp->cl_rpcclient->cl_xprt); if (nfs4_has_session(clp)) { error = xprt_setup_backchannel(xprt, NFS41_BC_MIN_CALLBACKS); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 9a8ffb7..2eaf7ec 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6569,18 +6569,16 @@ nfs41_same_server_scope(struct nfs41_server_scope *a, return false; } -/* - * nfs4_proc_bind_conn_to_session() - * - * The 4.1 client currently uses the same TCP connection for the - * fore and backchannel. - */ -int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred) +static int _nfs4_proc_bind_conn_to_session(struct nfs_client *clp, + struct rpc_cred *cred, + struct rpc_clnt *clnt, + u32 dir_from_client, + u32 dir_from_server) { int status; struct nfs41_bind_conn_to_session_args args = { .client = clp, - .dir = NFS4_CDFC4_BACK_OR_BOTH, + .dir = dir_from_client, }; struct nfs41_bind_conn_to_session_res res; struct rpc_message msg = { @@ -6599,7 +6597,7 @@ int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred goto out; } - status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); + status = rpc_call_sync(clnt, &msg, RPC_TASK_TIMEOUT); trace_nfs4_bind_conn_to_session(clp, status); if (status == 0) { if (memcmp(res.session->sess_id.data, @@ -6608,7 +6606,7 @@ int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred status = -EIO; goto out_session; } - if (res.dir != NFS4_CDFS4_BOTH) { + if (res.dir != dir_from_server) { dprintk("NFS: %s: Unexpected direction from server\n", __func__); status = -EIO; @@ -6628,6 +6626,36 @@ out: return status; } +/** + * nfs4_proc_bind_conn_to_session - (re)bind fore/back channels to session + * @clp: per-server state + * @cred: credential for managing state + * + * Returns zero on success, or a negative errno or negative NFS4ERR. + */ +int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, + struct rpc_cred *cred) +{ + int ret; + + if (!clp->cl_bc_rpcclient) + return _nfs4_proc_bind_conn_to_session(clp, cred, + clp->cl_rpcclient, + NFS4_CDFC4_BACK_OR_BOTH, + NFS4_CDFS4_BOTH); + + ret = _nfs4_proc_bind_conn_to_session(clp, cred, + clp->cl_bc_rpcclient, + NFS4_CDFC4_BACK, + NFS4_CDFS4_BACK); + if (ret) + return ret; + return _nfs4_proc_bind_conn_to_session(clp, cred, + clp->cl_rpcclient, + NFS4_CDFC4_FORE, + NFS4_CDFS4_FORE); +} + /* * Minimum set of SP4_MACH_CRED operations from RFC 5661 in the enforce map * and operations we'd like to see to enable certain features in the allow map