Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3857282pxv; Mon, 19 Jul 2021 10:23:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz1rkqXthT5LYVo8dRYUUo8uQbk/VoUgbWUwQpM6kDbTZSdmEVUNFETxVKwx6vtDEgc2C6 X-Received: by 2002:a17:906:3616:: with SMTP id q22mr27618169ejb.276.1626715422464; Mon, 19 Jul 2021 10:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626715422; cv=none; d=google.com; s=arc-20160816; b=xmQ3NrGjgb88R2iWabRHFAc8c4KMcSy3+0UXFgBwjKK8wu0PsM5D88w+L5BrLps+2d oHCSzzGU+6lviduwrmj3f9zJCJXyERQEJLDEAPUm+Cp/wTJD0FPHctC+A5qCT3n+wEQC u++uHys0KzWzAD2xBTnNFx6B69Brq/jwfmddFRY+9mneVOjYcgY9V2459sGbd6TkKFVO hCGCIwVesbeukBnvPhLTNKFrZHqqF0lEOUMijm/TnygBfG4KwDdUV2BETIG3JdTIpCQv kOXWnhbOAc9wVqD2KeNmqP2t2wM81Jtny9ci0nOA5BVWXi88QXSdbqA6nLbeJV2q+deV amoA== 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=AScwYlCY5Zg6JKYplRUKX6H2beyfkXWsa4Pds5zT90M=; b=M1IR5UTNoyUdgrz2JEVg6V1WQSxIXUO7LYYH5dVU1Qbe0pz74i3a6jbIwd0Nlm/ahg +x6tVKmbmM7zQKODeghQMXbBFfCXGSUfnWbzxtiOGgQGluqrF0LLKihI5HaB+oHBDip4 B7IXgapVWC8KTl3Dlzc+hmQ+3yuc7muLFPJ4OE38Ve8RQVRjSCb3CAQPMT7APgyVVCMN kmwGAop3PzSEJI3Cb8o0Pkg0gZp6cMC68jKw6i2363smEOJ6CHeMHLo6LOhHw82t3D8t ZRVpUqKnt3JsB3IDXd1z6Y5MiNhAJRAqNQUMl9FyKHH4gkIEkpjGTB4ja0qCm9epxsUs I+tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cRqH+vSw; 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 a26si3072867edr.155.2021.07.19.10.23.20; Mon, 19 Jul 2021 10:23:42 -0700 (PDT) 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=cRqH+vSw; 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 S1356126AbhGSQko (ORCPT + 99 others); Mon, 19 Jul 2021 12:40:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:56908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346900AbhGSPST (ORCPT ); Mon, 19 Jul 2021 11:18:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E9DCD6140C; Mon, 19 Jul 2021 15:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710286; bh=iaom5LMGMUcs5cgKGLW7PvOCY5RHyoSGxIBVI4rq93w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRqH+vSwaI4mhTmIY6rET54yb5bCOk6Xl8wInLVA+FCYwHrSb2BeyobucugFi2WtQ sgLeCccMC5iALTUUPWSjtjit3BVlJIfoHLC4nz6W3JgRDp/tVwCBkfBgCXdNb5UgIV wmrRmMc6PYgy/nI67O4CuUUqNBAnEVKsceuMme1g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Wakabayashi , Trond Myklebust , Sasha Levin Subject: [PATCH 5.10 154/243] NFSv4: Initialise connection to the server in nfs4_alloc_client() Date: Mon, 19 Jul 2021 16:53:03 +0200 Message-Id: <20210719144945.880910336@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@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 [ Upstream commit dd99e9f98fbf423ff6d365b37a98e8879170f17c ] 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: Sasha Levin --- fs/nfs/nfs4client.c | 82 +++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 7491323a5820..6d74f2e2de46 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -197,8 +197,11 @@ void nfs40_shutdown_client(struct nfs_client *clp) 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; @@ -222,6 +225,44 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init) init_waitqueue_head(&clp->cl_lock_waitq); #endif INIT_LIST_HEAD(&clp->pending_cb_stateids); + + 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: @@ -372,8 +413,6 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) 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; @@ -381,43 +420,6 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp, /* 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; -- 2.30.2