Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3583646pxb; Mon, 24 Jan 2022 12:49:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIn7vsPiBVBsE7DM+SxKenI5QBpYlGAZr0rqR1jpZgHHB5bsWHSXt9Hd2Os60z7vW5gUSu X-Received: by 2002:a63:be45:: with SMTP id g5mr13115316pgo.309.1643057342283; Mon, 24 Jan 2022 12:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057342; cv=none; d=google.com; s=arc-20160816; b=PHwFHz+DkRNunBgqNhAWkSdyv9MqwUIwjX8rQ5d684bdxmcW6LJ2gcVo9DdLYDEGDF KirkrxwzAeLizN9dpf77iPqH1rcTuAC7MpxiX/OUl/wzHzUMJIld+LyE77o8LLAcmeJW 4W1tDE7hSXlKjSEsr6lSEnzbXZxWAagk+txxnDd/oYMl2X05bA/cukrdIEi2f89zbBfE D3f7T/NDj1Q6hkD/255I8JwXafzvI6735S44KzXo8oqigsn7WlDmlRKiYPL0G6LIYA5H eXHhO51RgieZB0t6Xtol3zyo2/aWNunW1LQnQb8QiBM91Ldq/sb2+MdP48YWuAQclrWI v6Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Pv/cTIFYOa5q5RhSE+83z1WhGez7S1VGipG5eUVgpRk=; b=GqHU0dCfFoQ/p59L7vJj0VquJV9BqkWboqaF970Mi3SS5nPPohPTfO+F3e28rMGYhC yNNZutHY5mAZdRoEiT7drikztNZ5fnfe0e3aF9yJD4qZMreNof+7p/Lyeyca10VbauVB GWHVq86J3I+O5XbPuKbgn/ogWF5OJKZ+Zk7p/ek8CRx/0edTpPqZwqVvgo9ceLrPtosi yIQ4ASmqqkKFRUqQAt740qrv43aLAFY+tWVTADZVH42I47vn9nkF7msYQjTPchkot2cA hbDMRUL5lWJpKaw6DC1TpSys1FTeKs4Ago1pXi27PBBbsHZzdJH6JjWMcy0/Gj4l38RJ 7AHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=syak8bdG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v69si10893655pfc.153.2022.01.24.12.48.39; Mon, 24 Jan 2022 12:49:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=syak8bdG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354525AbiAXUDK (ORCPT + 99 others); Mon, 24 Jan 2022 15:03:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238002AbiAXT01 (ORCPT ); Mon, 24 Jan 2022 14:26:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D845CC02B879; Mon, 24 Jan 2022 11:12:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7F81DB8121A; Mon, 24 Jan 2022 19:12:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A88A7C340EA; Mon, 24 Jan 2022 19:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051536; bh=1IvSxe8xKZxSOH1osGJiqjMhR5Nf6Fmyo66KyHc0iLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=syak8bdGY/9AFvq+ux/NiTyWrTjfrrMXzEN8qowHGjojSHZLN6ETSDD9+8Lh1f0Mw ZDwHDo9yWOdeiqLYvaOZixGQu7aPcKT4W/q68nbcVlgPL6MsYdWLFaplKkb3uxEYoj xyzRMwfu6KAUTVyaYoQY3+JM5Yucpe0+hTxIAbF4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Wakabayashi , Trond Myklebust Subject: [PATCH 4.14 186/186] NFSv4: Initialise connection to the server in nfs4_alloc_client() Date: Mon, 24 Jan 2022 19:44:21 +0100 Message-Id: <20220124183943.090675630@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust commit dd99e9f98fbf423ff6d365b37a98e8879170f17c upstream. Set up the connection to the NFSv4 server in nfs4_alloc_client(), before we've added the struct nfs_client to the net-namespace's nfs_client_list so that a downed server won't cause other mounts to hang in the trunking detection code. Reported-by: Michael Wakabayashi Fixes: 5c6e5b60aae4 ("NFS: Fix an Oops in the pNFS files and flexfiles connection setup to the DS") Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/nfs4client.c | 82 ++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 40 deletions(-) --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -177,8 +177,11 @@ void nfs40_shutdown_client(struct nfs_cl struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init) { - int err; + char buf[INET6_ADDRSTRLEN + 1]; + const char *ip_addr = cl_init->ip_addr; struct nfs_client *clp = nfs_alloc_client(cl_init); + int err; + if (IS_ERR(clp)) return clp; @@ -202,6 +205,44 @@ struct nfs_client *nfs4_alloc_client(con #if IS_ENABLED(CONFIG_NFS_V4_1) init_waitqueue_head(&clp->cl_lock_waitq); #endif + + if (cl_init->minorversion != 0) + __set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags); + __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags); + __set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags); + + /* + * Set up the connection to the server before we add add to the + * global list. + */ + err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_GSS_KRB5I); + if (err == -EINVAL) + err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX); + if (err < 0) + goto error; + + /* If no clientaddr= option was specified, find a usable cb address */ + if (ip_addr == NULL) { + struct sockaddr_storage cb_addr; + struct sockaddr *sap = (struct sockaddr *)&cb_addr; + + err = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr)); + if (err < 0) + goto error; + err = rpc_ntop(sap, buf, sizeof(buf)); + if (err < 0) + goto error; + ip_addr = (const char *)buf; + } + strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); + + err = nfs_idmap_new(clp); + if (err < 0) { + dprintk("%s: failed to create idmapper. Error = %d\n", + __func__, err); + goto error; + } + __set_bit(NFS_CS_IDMAP, &clp->cl_res_state); return clp; error: @@ -354,8 +395,6 @@ static int nfs4_init_client_minor_versio struct nfs_client *nfs4_init_client(struct nfs_client *clp, const struct nfs_client_initdata *cl_init) { - char buf[INET6_ADDRSTRLEN + 1]; - const char *ip_addr = cl_init->ip_addr; struct nfs_client *old; int error; @@ -363,43 +402,6 @@ struct nfs_client *nfs4_init_client(stru /* the client is initialised already */ return clp; - /* Check NFS protocol revision and initialize RPC op vector */ - clp->rpc_ops = &nfs_v4_clientops; - - if (clp->cl_minorversion != 0) - __set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags); - __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags); - __set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags); - - error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_GSS_KRB5I); - if (error == -EINVAL) - error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX); - if (error < 0) - goto error; - - /* If no clientaddr= option was specified, find a usable cb address */ - if (ip_addr == NULL) { - struct sockaddr_storage cb_addr; - struct sockaddr *sap = (struct sockaddr *)&cb_addr; - - error = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr)); - if (error < 0) - goto error; - error = rpc_ntop(sap, buf, sizeof(buf)); - if (error < 0) - goto error; - ip_addr = (const char *)buf; - } - strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); - - error = nfs_idmap_new(clp); - if (error < 0) { - dprintk("%s: failed to create idmapper. Error = %d\n", - __func__, error); - goto error; - } - __set_bit(NFS_CS_IDMAP, &clp->cl_res_state); - error = nfs4_init_client_minor_version(clp); if (error < 0) goto error;