From patchwork Mon Nov 9 21:10:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11892581 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A78F0921 for ; Mon, 9 Nov 2020 21:20:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84BCD206ED for ; Mon, 9 Nov 2020 21:20:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="isEGDJxB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729854AbgKIVUo (ORCPT ); Mon, 9 Nov 2020 16:20:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730490AbgKIVUn (ORCPT ); Mon, 9 Nov 2020 16:20:43 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83349C0613CF for ; Mon, 9 Nov 2020 13:20:43 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id v11so6725991qtq.12 for ; Mon, 09 Nov 2020 13:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=VVMQUbJ4iznq9ND4iOH8VfAwBPVr6YZBnHjxRO8Npmc=; b=isEGDJxBLKuwAPFwY3EanSDcpN7f12pclu407bvwfkQDK6HYIzcy9qfEcdBk5p6z9m 9fBM1bHHGnfevGwEVjQJT+ZKZ0RBn6KRebScjXCD1NDQIh17q/Z1LTSUsPkP+LAX/iUd Sm1pm1/AV2bBQA5nnonLh79dFFth5IAX4PDg1A0zS1YifnTzwlfZgBF3xjOErVWuwzxp 4KrSj8UWX3eISK2vg+L0gD4jRPxxpo3acDSbLOxV+aGpqkifND48drsUhARPmiv8M40K 75/606afeoA6dtD8GkNMAlkybjASXmnYirRAnSFXJG/ZMH+/rN34eO7qrr22R/+vuHWA 1HKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VVMQUbJ4iznq9ND4iOH8VfAwBPVr6YZBnHjxRO8Npmc=; b=jc7fhg6wiViY78759JjZRSwSE3hDs1Aog/8zPf99qUQhW83445z10IQ0yNRhxr/ySH ViQWtaZmD1bAo/t9cRXgZjaV6VRCmnFW2LCX56e+q8TvyZm2cPGGmsBJE/Mhtl3j/xsP q1XXTo8q79YUXap8YMds7joiZDJJ0aknYwY8a3Q2/3gdkyuD7wySN8RDu76UhDgPc07G gm/me9qWVz8rBFtO0zccgn640//2TgMlVTHQu1PVLlF2KsOCrgWhW95bDaMb3AHfIRCe 0muXVSqDML7oG5JYa1QXiCbu/0P2XiFwc0DvH0RbxZXu0CLE6Mhv2WwMl1tdZTBJNfLl 6OgA== X-Gm-Message-State: AOAM531bldZY20qQLNi7X7mQH/2kRNb4i29WZBqxm6y3X3IrEyg4Md7Z HFzmtrpisNcAiknxXe5M+zYBTnuypivr X-Google-Smtp-Source: ABdhPJxITZz/V5F+GMrOGI0ykE66yW+t5XFghupqPR/RclDQpibHlznT433m4cx3OyklIqFf3MEKNg== X-Received: by 2002:ac8:46cb:: with SMTP id h11mr10060132qto.121.1604956842445; Mon, 09 Nov 2020 13:20:42 -0800 (PST) Received: from localhost.localdomain (c-68-36-133-222.hsd1.mi.comcast.net. [68.36.133.222]) by smtp.gmail.com with ESMTPSA id d188sm7025241qkb.10.2020.11.09.13.20.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 13:20:41 -0800 (PST) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH v2 1/5] SUNRPC: xprt_load_transport() needs to support the netid "rdma6" Date: Mon, 9 Nov 2020 16:10:25 -0500 Message-Id: <20201109211029.540993-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109211029.540993-1-trond.myklebust@hammerspace.com> References: <20201109211029.540993-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust According to RFC5666, the correct netid for an IPv6 addressed RDMA transport is "rdma6", which we've supported as a mount option since Linux-4.7. The problem is when we try to load the module "xprtrdma6", that will fail, since there is no modulealias of that name. Fixes: 181342c5ebe8 ("xprtrdma: Add rdma6 option to support NFS/RDMA IPv6") Signed-off-by: Trond Myklebust --- net/sunrpc/xprtrdma/module.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sunrpc/xprtrdma/module.c b/net/sunrpc/xprtrdma/module.c index 620327c01302..fb55983628b4 100644 --- a/net/sunrpc/xprtrdma/module.c +++ b/net/sunrpc/xprtrdma/module.c @@ -23,7 +23,9 @@ MODULE_AUTHOR("Open Grid Computing and Network Appliance, Inc."); MODULE_DESCRIPTION("RPC/RDMA Transport"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_ALIAS("svcrdma"); +MODULE_ALIAS("svcrdma6"); MODULE_ALIAS("xprtrdma"); +MODULE_ALIAS("xprtrdma6"); static void __exit rpc_rdma_cleanup(void) { From patchwork Mon Nov 9 21:10:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11892583 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D68AA921 for ; Mon, 9 Nov 2020 21:20:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEF0C206CB for ; Mon, 9 Nov 2020 21:20:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B9HpvBh/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730646AbgKIVUp (ORCPT ); Mon, 9 Nov 2020 16:20:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730490AbgKIVUo (ORCPT ); Mon, 9 Nov 2020 16:20:44 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A61EDC0613D3 for ; Mon, 9 Nov 2020 13:20:44 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id p12so7107602qtp.7 for ; Mon, 09 Nov 2020 13:20:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=areiMMXZzlnhm2wpgeZFwm/3fbilrhaLYUTcNjpnIv8=; b=B9HpvBh/MNXu2M9eSgNLiiT6p+sCWevAqFN88QbHr0tv9aI7A32lVzsXN+7OYa3ZA/ ouCAXEMIVJO+F1VN0SYvz3CpJDiYzmwcXqEjB0q9IdfBdxRaFG57dfJIM354s28nguo+ dDOGZJr+JigXbr1z1xPdjqGCjgFcZl9sI7iyWD5VppqdKvQwdBE10sHFFHkIEPk5WL5P aVfWeJAne0GPpVZMW899zJHavl56ibohMjYUYJCSft0LnUucKvjk4Cv3Z56FgCZmwcGI myVOGiJEebCOYQdkTKPYuN1QiuSGEUgUfizOu/mZvgQsAbAnivTPVH8b/zdVS6kqAbHs ywNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=areiMMXZzlnhm2wpgeZFwm/3fbilrhaLYUTcNjpnIv8=; b=G9EunCWO9OFmYOFdYF7TK/8BtZOLdZCOmvkskHlLsMpK0FkSKYi3j8zYIWoycM0LsO qa0GBzeAAniP3VZiXSw4GeS0gotnDIPbbPTq00RRkWJ125NtQd6mkFOVHyiLpybPdbWk 5vDIlhod4HAvFGP/nA6vTjoERwZgyx8rnJ56MOH2oT0aAC/FdBCXGbFMKvNcS/rGg1LZ M56EV7sqgx7VLVx95FhEbpFsgLPBDxtw7idmyeKoukATMxk52NWyLUKvXYCp8n2zSZex n7J9ltHfXNWdqxIkSw+iEfuOI7ufQ75+pHDRefpP32+5HbuliiX5KVG3QIooB5D3DGRa XImw== X-Gm-Message-State: AOAM533+3wUsu/slkdhNX3Z5pkgJnfCoFmXIKPBB04iXVAxPntZIwBy2 Kl5PPyMPzzMaKp1+4/H1DoipgmCBXkPk X-Google-Smtp-Source: ABdhPJyxXs8hlgb0RNHs6Pbjdgs8ReMLMdo8fIWeCwjWc1L3Jyia4PcJ2U8UV65/uZ7uo6t0noz3kw== X-Received: by 2002:aed:3865:: with SMTP id j92mr3354810qte.318.1604956843557; Mon, 09 Nov 2020 13:20:43 -0800 (PST) Received: from localhost.localdomain (c-68-36-133-222.hsd1.mi.comcast.net. [68.36.133.222]) by smtp.gmail.com with ESMTPSA id d188sm7025241qkb.10.2020.11.09.13.20.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 13:20:42 -0800 (PST) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH v2 2/5] NFSv4/pNFS: Use connections to a DS that are all of the same protocol family Date: Mon, 9 Nov 2020 16:10:26 -0500 Message-Id: <20201109211029.540993-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109211029.540993-2-trond.myklebust@hammerspace.com> References: <20201109211029.540993-1-trond.myklebust@hammerspace.com> <20201109211029.540993-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust If the pNFS metadata server advertises multiple addresses for the same data server, we should try to connect to just one protocol family and transport type on the assumption that homogeneity will improve performance. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs_nfs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c index 679767ac258d..7027dac41cc7 100644 --- a/fs/nfs/pnfs_nfs.c +++ b/fs/nfs/pnfs_nfs.c @@ -860,6 +860,9 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, .addrlen = da->da_addrlen, .servername = clp->cl_hostname, }; + + if (da->da_addr.ss_family != clp->cl_addr.ss_family) + continue; /* Add this address as an alias */ rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args, rpc_clnt_test_and_add_xprt, NULL); @@ -920,6 +923,8 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv, .data = &xprtdata, }; + if (da->da_addr.ss_family != clp->cl_addr.ss_family) + continue; /** * Test this address for session trunking and * add as an alias From patchwork Mon Nov 9 21:10:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11892585 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 466B9921 for ; Mon, 9 Nov 2020 21:20:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17DFA206ED for ; Mon, 9 Nov 2020 21:20:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kx349ksS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729740AbgKIVUq (ORCPT ); Mon, 9 Nov 2020 16:20:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730490AbgKIVUp (ORCPT ); Mon, 9 Nov 2020 16:20:45 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3AF0C0613CF for ; Mon, 9 Nov 2020 13:20:45 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id 7so2727992qtp.1 for ; Mon, 09 Nov 2020 13:20:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3YMYsfzCKFWvDxH+k2fwaV0VgjexShy3TrQPd/Tm0DY=; b=kx349ksSm2ScPDE0jPO1MnGkoEwn1kwtF2SgWNGVyU0C9HnBq8gFmHmxsLi15SYVbH t41jDcN01FK3MmAtw5KWnti129AT4kTaZV+/I1HcKCQbwVXKXlUeECh3PfCGMCihP+YZ 6xOygR9UJQgrbBDsViFwmteOkl1p6VDlpA9/liZfWi0aYcxDwnkms/TckApjFj8EEeMp 1KC3+O59H9Vb7szwT9bgcbW50N7AkivMOpUrERZ0ixmIRs94zw5aGra3hCyRlr11wKVO pmRW971VRlDW7ngRh3X+rQKDYSthPKUsQqnGm+EBRqmUCxBbbeXe8P04mz+dVJCcpF6d 7BcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3YMYsfzCKFWvDxH+k2fwaV0VgjexShy3TrQPd/Tm0DY=; b=eYihF/5uwLm22nlstUljR49OO8vLOEOZyBz1xa62X0qJ8zbn86Clqi6Sud25+4BX1n nYoHTUCU5xW8w57IvxlQCVTSsgagw7KcP3azY9gB/F7gIkr9/TKr/xshBJikuGmVwNFe CrSJHs0ZL+WfWKkiyuuQ6fHeMP28ibZQVAE59fJNWZS2WfzImWs1CQF5+cYhV0zZtiQp 6jO5NFkw+WjT9ErkxWLwBvIh7prIJ3j9dtl+cOYdTS8MmIpQ/iRZOxlKdw1T/Kdcqnm7 OBTzXY2+dp78tFfM7MnHsX2F7tZlhVX4Zt4QwjKgbTUoPCvmrAnp8EcGe72Lt6WR3oTj cPUg== X-Gm-Message-State: AOAM532sQ6LJSZK9W6yadN28FAyGPfJSha006adXmrNLLJKCVpYOs8V4 q236mEb+FkRQaTZo/wdEhxv10N//hCQF X-Google-Smtp-Source: ABdhPJxVfBZ7mq5xEFX3bZp0CgU8HNzbqZ44VA10iEb2CsFVS/aSNRKH/gsB3W+1D1bBr7yjjNU+XQ== X-Received: by 2002:ac8:7555:: with SMTP id b21mr15212480qtr.119.1604956844564; Mon, 09 Nov 2020 13:20:44 -0800 (PST) Received: from localhost.localdomain (c-68-36-133-222.hsd1.mi.comcast.net. [68.36.133.222]) by smtp.gmail.com with ESMTPSA id d188sm7025241qkb.10.2020.11.09.13.20.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 13:20:43 -0800 (PST) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH v2 3/5] NFSv4/pNFS: Store the transport type in struct nfs4_pnfs_ds_addr Date: Mon, 9 Nov 2020 16:10:27 -0500 Message-Id: <20201109211029.540993-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109211029.540993-3-trond.myklebust@hammerspace.com> References: <20201109211029.540993-1-trond.myklebust@hammerspace.com> <20201109211029.540993-2-trond.myklebust@hammerspace.com> <20201109211029.540993-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust We want to enable RDMA and UDP as valid transport methods if a GETDEVICEINFO call specifies it. Do so by adding a parser for the netid that translates it to an appropriate argument for the RPC transport layer. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.h | 1 + fs/nfs/pnfs_nfs.c | 66 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 2661c44c62db..20ee37b751e3 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -51,6 +51,7 @@ struct nfs4_pnfs_ds_addr { size_t da_addrlen; struct list_head da_node; /* nfs4_pnfs_dev_hlist dev_dslist */ char *da_remotestr; /* human readable addr+port */ + int da_transport; }; struct nfs4_pnfs_ds { diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c index 7027dac41cc7..d00750743100 100644 --- a/fs/nfs/pnfs_nfs.c +++ b/fs/nfs/pnfs_nfs.c @@ -854,13 +854,15 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, if (!IS_ERR(clp)) { struct xprt_create xprt_args = { - .ident = XPRT_TRANSPORT_TCP, + .ident = da->da_transport, .net = clp->cl_net, .dstaddr = (struct sockaddr *)&da->da_addr, .addrlen = da->da_addrlen, .servername = clp->cl_hostname, }; + if (da->da_transport != clp->cl_proto) + continue; if (da->da_addr.ss_family != clp->cl_addr.ss_family) continue; /* Add this address as an alias */ @@ -870,7 +872,7 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, } clp = get_v3_ds_connect(mds_srv, (struct sockaddr *)&da->da_addr, - da->da_addrlen, IPPROTO_TCP, + da->da_addrlen, da->da_transport, timeo, retrans); if (IS_ERR(clp)) continue; @@ -908,7 +910,7 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv, if (!IS_ERR(clp) && clp->cl_mvops->session_trunk) { struct xprt_create xprt_args = { - .ident = XPRT_TRANSPORT_TCP, + .ident = da->da_transport, .net = clp->cl_net, .dstaddr = (struct sockaddr *)&da->da_addr, .addrlen = da->da_addrlen, @@ -923,6 +925,8 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv, .data = &xprtdata, }; + if (da->da_transport != clp->cl_proto) + continue; if (da->da_addr.ss_family != clp->cl_addr.ss_family) continue; /** @@ -937,8 +941,9 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv, } else { clp = nfs4_set_ds_client(mds_srv, (struct sockaddr *)&da->da_addr, - da->da_addrlen, IPPROTO_TCP, - timeo, retrans, minor_version); + da->da_addrlen, + da->da_transport, timeo, + retrans, minor_version); if (IS_ERR(clp)) continue; @@ -1017,6 +1022,41 @@ int nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, } EXPORT_SYMBOL_GPL(nfs4_pnfs_ds_connect); +struct xprt_lookup_transport { + const char *name; + sa_family_t protofamily; + int type; +}; + +static const struct xprt_lookup_transport xl_xprt[] = { + { "tcp", AF_INET, XPRT_TRANSPORT_TCP }, + { "tcp6", AF_INET6, XPRT_TRANSPORT_TCP }, + { "rdma", AF_INET, XPRT_TRANSPORT_RDMA }, + { "rdma6", AF_INET6, XPRT_TRANSPORT_RDMA }, + { "udp", AF_INET, XPRT_TRANSPORT_UDP }, + { "udp6", AF_INET6, XPRT_TRANSPORT_UDP }, + { NULL, 0, -1 }, +}; + +static int +nfs4_decode_transport(const char *str, size_t len, sa_family_t protofamily) +{ + const struct xprt_lookup_transport *p; + + for (p = xl_xprt; p->name; p++) { + if (p->protofamily != protofamily) + continue; + if (strlen(p->name) != len) + continue; + if (memcmp(p->name, str, len) != 0) + continue; + if (xprt_load_transport(p->name) != 0) + continue; + return p->type; + } + return -1; +} + /* * Currently only supports ipv4, ipv6 and one multi-path address. */ @@ -1029,8 +1069,8 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags) int nlen, rlen; int tmp[2]; __be32 *p; - char *netid, *match_netid; - size_t len, match_netid_len; + char *netid; + size_t len; char *startsep = ""; char *endsep = ""; @@ -1114,15 +1154,11 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags) case AF_INET: ((struct sockaddr_in *)&da->da_addr)->sin_port = port; da->da_addrlen = sizeof(struct sockaddr_in); - match_netid = "tcp"; - match_netid_len = 3; break; case AF_INET6: ((struct sockaddr_in6 *)&da->da_addr)->sin6_port = port; da->da_addrlen = sizeof(struct sockaddr_in6); - match_netid = "tcp6"; - match_netid_len = 4; startsep = "["; endsep = "]"; break; @@ -1133,9 +1169,11 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags) goto out_free_da; } - if (nlen != match_netid_len || strncmp(netid, match_netid, nlen)) { - dprintk("%s: ERROR: r_netid \"%s\" != \"%s\"\n", - __func__, netid, match_netid); + da->da_transport = nfs4_decode_transport(netid, nlen, + da->da_addr.ss_family); + if (da->da_transport == -1) { + dprintk("%s: ERROR: unknown r_netid \"%*s\"\n", + __func__, nlen, netid); goto out_free_da; } From patchwork Mon Nov 9 21:10:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11892587 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06253921 for ; Mon, 9 Nov 2020 21:20:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA8C6206ED for ; Mon, 9 Nov 2020 21:20:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h64RT1B/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730490AbgKIVUr (ORCPT ); Mon, 9 Nov 2020 16:20:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730459AbgKIVUq (ORCPT ); Mon, 9 Nov 2020 16:20:46 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B50D2C0613CF for ; Mon, 9 Nov 2020 13:20:46 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id p12so7107668qtp.7 for ; Mon, 09 Nov 2020 13:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sHV5eOK+G8n9EPQWL9oMmz3WBFmv12mVOlCUiLjD0qM=; b=h64RT1B/KDmNu5aC+Dl+VfsHCmM7Gv8XWAhUVYnU7FULcRPrJt8AUiJRzYv2f3xChc WQxKEOA/ynCR+4N0SYbJCAmiC01Z2EFxpvaNyryV9V2eGpoKcU5PrUw9822MxvactObv WTgGEgUgmunUMfrCxP9ERtDDo911DbcK4vpBuT+44rs6ml9v2moAaVC1cDzcLBrUINas Lo/MmfPPamHEj1jau6gC9JB4wt6+2cUTOk253jHUyzRwxgZJ7H7x/mJImkthAvZqg02x jif0ACWLSgr0V7J5yvNg39x3GmRNmWU37ayD0aaHPwkNr6/IrhJnxVLPiu4gv/o4c0+v b0aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sHV5eOK+G8n9EPQWL9oMmz3WBFmv12mVOlCUiLjD0qM=; b=KakoJCtN1X7W+tVAn+XR4E7S/SRnQxGWpGAdnNkNnb5n3QF3wpNWFuWz6ZOZX+QL0i K3V5+bGkrEPTugg9/YyTlwo4Zo0XWcbl1jaEllySX8JxzdwZ3VOBRjzh7Q2Q0zkWBfhY +LmU7NxNRQmaJX0fj+L5mz7pTsbeJMhxgnH4Oo6YqnOMTI93V/1UzYDBTgpN6a7IECPj ZSuokEJ5/KLvhQWEdAZSGC2AOzglbcspaJGrTO+xnAmE4MOz0wu9BNo1+E6lCOT/Ijhx tji3s5kNJBTWIbBoEanywLzQaVBrJAxJol8ky/QBIqKcNZLV5OsoLVBrXkMkA1kiKMBq J1FA== X-Gm-Message-State: AOAM531TUwjBuWU3EPyOiXBWHyMp9zjB9OcAZQqPlUWbgSao447u+9O4 EXNR5O6EXc4/TbaunbJHLw3+HEEtPbQG X-Google-Smtp-Source: ABdhPJx+uqGgqZ/YPXt0OxEYOY2xQ5St3OQp5NF9ofNpXn7YONkQhaKZUJUJTJiWru5oP5/+CVWxJg== X-Received: by 2002:a05:622a:86:: with SMTP id o6mr1631168qtw.147.1604956845676; Mon, 09 Nov 2020 13:20:45 -0800 (PST) Received: from localhost.localdomain (c-68-36-133-222.hsd1.mi.comcast.net. [68.36.133.222]) by smtp.gmail.com with ESMTPSA id d188sm7025241qkb.10.2020.11.09.13.20.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 13:20:44 -0800 (PST) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH v2 4/5] pNFS/flexfiles: Fix up layoutstats reporting for non-TCP transports Date: Mon, 9 Nov 2020 16:10:28 -0500 Message-Id: <20201109211029.540993-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109211029.540993-4-trond.myklebust@hammerspace.com> References: <20201109211029.540993-1-trond.myklebust@hammerspace.com> <20201109211029.540993-2-trond.myklebust@hammerspace.com> <20201109211029.540993-3-trond.myklebust@hammerspace.com> <20201109211029.540993-4-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Ensure that we report the correct netid when using UDP or RDMA transports to the DSes. Signed-off-by: Trond Myklebust --- fs/nfs/flexfilelayout/flexfilelayout.c | 34 ++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index a163533446fa..c760238ba649 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -2279,18 +2279,41 @@ ff_layout_encode_netaddr(struct xdr_stream *xdr, struct nfs4_pnfs_ds_addr *da) if (ff_layout_ntop4(sap, addrbuf, sizeof(addrbuf)) == 0) return; port = ntohs(((struct sockaddr_in *)sap)->sin_port); - netid = "tcp"; - netid_len = 3; + switch (da->da_transport) { + case XPRT_TRANSPORT_TCP: + netid = "tcp"; + break; + case XPRT_TRANSPORT_RDMA: + netid = "rdma"; + break; + case XPRT_TRANSPORT_UDP: + netid = "udp"; + break; + default: + WARN_ON_ONCE(1); + return; + } break; case AF_INET6: if (ff_layout_ntop6_noscopeid(sap, addrbuf, sizeof(addrbuf)) == 0) return; port = ntohs(((struct sockaddr_in6 *)sap)->sin6_port); - netid = "tcp6"; - netid_len = 4; + switch (da->da_transport) { + case XPRT_TRANSPORT_TCP: + netid = "tcp6"; + break; + case XPRT_TRANSPORT_RDMA: + netid = "rdma6"; + break; + case XPRT_TRANSPORT_UDP: + netid = "udp6"; + break; + default: + WARN_ON_ONCE(1); + return; + } break; default: - /* we only support tcp and tcp6 */ WARN_ON_ONCE(1); return; } @@ -2298,6 +2321,7 @@ ff_layout_encode_netaddr(struct xdr_stream *xdr, struct nfs4_pnfs_ds_addr *da) snprintf(portbuf, sizeof(portbuf), ".%u.%u", port >> 8, port & 0xff); len = strlcat(addrbuf, portbuf, sizeof(addrbuf)); + netid_len = strlen(netid); p = xdr_reserve_space(xdr, 4 + netid_len); xdr_encode_opaque(p, netid, netid_len); From patchwork Mon Nov 9 21:10:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11892589 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 311591130 for ; Mon, 9 Nov 2020 21:20:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1299A206ED for ; Mon, 9 Nov 2020 21:20:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RJKJn/x7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730459AbgKIVUt (ORCPT ); Mon, 9 Nov 2020 16:20:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729776AbgKIVUt (ORCPT ); Mon, 9 Nov 2020 16:20:49 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5541C0613CF for ; Mon, 9 Nov 2020 13:20:47 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id i7so7102241qti.6 for ; Mon, 09 Nov 2020 13:20:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UH44+8kxlFN6tu42KNQaihbAbclJRhUfbzPO2/XsY2k=; b=RJKJn/x7xoIyKr1ImFlCwLCQ+z378twK4szYTu5I9Hy0IdPudd2MnyKqMG01d2fz1I 1hDFEeRU43olppX6AYeTv51wRQg6xpVHtGtJPd8UGDooapXWSfXebm15B3F6FjUoPhNx PgG1UAKmnljwgopPAGYej3FA8oytG6Cak9ostL+nIH3H/0mJ563OWwaUVtwLxmHAgofi KRTlbhCYlZQ0bWG6b6yVi8qsemk/Dum5VZPYKaJRAekB2k5lmnTG+Ux/Otng0kVnjh31 hXVYh+GTLP9It8s5H1FXaFMmWwiaDDrF7zIIh+WRbxBdJF95Gptmhy8uyBxxfH9RGO9G wPIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UH44+8kxlFN6tu42KNQaihbAbclJRhUfbzPO2/XsY2k=; b=o031+eKx+bvQN2VERYFKY5g2X2P/Cu/4qioRFxTrLAhWlM2bA9lSROa1JiO5ciAJ8d xeu8VVVM3zDOK9bG1kuTBuxPTjYEhA/2klR40Kb9KTBGivUGw4uob97jqcg1hPr4D5QE 3XONONexGpz3YaW97tssJzssULo/kcENxeGpj410IOMpu5VscKW++t7M4DC5ht2L1JD1 mRINhqyUaUHEfYED36TJUJYB4Hk19mQ6/5PF1CN+WrDPpm6w0ucqadTYbcCyyxum+Cyn aueb2P/MKISAca1BNTRU8gCuzwPAcBh2itoTkms5grEAPsmvPRJ8OXuaC8CbL7ZuZnxq osIQ== X-Gm-Message-State: AOAM530BHbGjiywdfRp4AUAmTzJGlNVN0lpSqokFs2HNsFiYuM2WwDzk UdjhdxI36Wx5N3Sa4RztroR5ltQq0JBg X-Google-Smtp-Source: ABdhPJzzvmOtO66mOpdGOtp3F/MghaojxA73NiMMywiqadj8tWOXBkMLCBa0/JGsLOyTmEJwPqUJfg== X-Received: by 2002:ac8:6c2a:: with SMTP id k10mr7332000qtu.89.1604956846717; Mon, 09 Nov 2020 13:20:46 -0800 (PST) Received: from localhost.localdomain (c-68-36-133-222.hsd1.mi.comcast.net. [68.36.133.222]) by smtp.gmail.com with ESMTPSA id d188sm7025241qkb.10.2020.11.09.13.20.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 13:20:46 -0800 (PST) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH v2 5/5] pNFS: Clean up open coded kmemdup_nul() Date: Mon, 9 Nov 2020 16:10:29 -0500 Message-Id: <20201109211029.540993-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109211029.540993-5-trond.myklebust@hammerspace.com> References: <20201109211029.540993-1-trond.myklebust@hammerspace.com> <20201109211029.540993-2-trond.myklebust@hammerspace.com> <20201109211029.540993-3-trond.myklebust@hammerspace.com> <20201109211029.540993-4-trond.myklebust@hammerspace.com> <20201109211029.540993-5-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Signed-off-by: Trond Myklebust --- fs/nfs/pnfs_nfs.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c index d00750743100..5acddd14ffe8 100644 --- a/fs/nfs/pnfs_nfs.c +++ b/fs/nfs/pnfs_nfs.c @@ -1085,13 +1085,10 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags) if (unlikely(!p)) goto out_err; - netid = kmalloc(nlen+1, gfp_flags); + netid = kmemdup_nul(p, nlen, gfp_flags); if (unlikely(!netid)) goto out_err; - netid[nlen] = '\0'; - memcpy(netid, p, nlen); - /* r_addr: ip/ip6addr with port in dec octets - see RFC 5665 */ p = xdr_inline_decode(xdr, 4); if (unlikely(!p)) @@ -1108,13 +1105,11 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags) rlen); goto out_free_netid; } - buf = kmalloc(rlen + 1, gfp_flags); + buf = kmemdup_nul(p, rlen, gfp_flags); if (!buf) { dprintk("%s: Not enough memory\n", __func__); goto out_free_netid; } - buf[rlen] = '\0'; - memcpy(buf, p, rlen); /* replace port '.' with '-' */ portstr = strrchr(buf, '.');