From patchwork Thu Dec 9 19:53:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12668187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F40A4C433EF for ; Thu, 9 Dec 2021 19:53:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231189AbhLIT5Q (ORCPT ); Thu, 9 Dec 2021 14:57:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbhLIT5N (ORCPT ); Thu, 9 Dec 2021 14:57:13 -0500 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2D5FC061746 for ; Thu, 9 Dec 2021 11:53:39 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id 14so7956242ioe.2 for ; Thu, 09 Dec 2021 11:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wETAeGy7W2wwlJkHGrZYM2gQKo8gGqneSHIIprrf6UU=; b=HRcZ/zAYzCuhD0jX9SBmaA4kH2Vh4KaE3odamnrLBvXNKR5FWaBIGH/z9LZgsvHvl/ 8qRkJQTPiopHOXrKtwvcRbaTI9Tz3CAKQtAwTuvitB1w9SdNnTfgXbSTi4rtzaFKblxx qymlqXnDvJDBosoZA9ut9nmcyVDd+iQTa+1/HnTEDKY79IP6cBx6MP3GtdhOrMwHgdJP Dn45SzaGuZm/iNfpqb0DMtRDE9HJ3hFcq0HcotqHNj8hBIy5lwKrbfDqem58vc7TGXnt 0fh2j3G7TTDRqThY93Y6CzA3TP5ijYgLJ7kIBVchyLc35IjKM5FzhBLdq4xV5uHX4+/H nyaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wETAeGy7W2wwlJkHGrZYM2gQKo8gGqneSHIIprrf6UU=; b=diNKhudyBu7pvV2CcCeR8o1QCxXkr/XU4yiIDfTPsujFOmOQvxOd5OQKuVLutAvrvg Ki7m27gr0t9w4a2WBytAAwmhGdsheDX7RSv45oEm5PW+/vw40P4LbRFXU03ZRHFurq+u S8mUcd9TrPLHvOXVfvcRIB/OGKuWhHpyRdoqimyxEj4FPOazeccHR7qvjXJyAwbjB0nj jFaBVFwAhQGa1cdmgjCmiePF5+cez/QWO8L6LxhjYspfMdr/4DrKXN3mULR80Rc2M4CA DC7NPvmMXsLhmbsl+qC0NJRh5K+Icx34/uHQFsv7XrguTNMOe/b/K0DsaZb0v8OQMIk5 r1tA== X-Gm-Message-State: AOAM532SB3kbH0g4F9EyHXtkgPXyxUzbSSAmMxYMAR1X25qorwaOy7/k PFMD9IXe9nhSQlR9tBwuos4= X-Google-Smtp-Source: ABdhPJw+mP/6c6LsyciS//e5850ieMNokfjfnj0Iz+rVsYptUpSSFgX1hQ5PFxDtOreFzShMc9MUzA== X-Received: by 2002:a05:6602:15cf:: with SMTP id f15mr17901928iow.129.1639079619217; Thu, 09 Dec 2021 11:53:39 -0800 (PST) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:554d:272f:69a0:1745]) by smtp.gmail.com with ESMTPSA id k9sm383541ilv.61.2021.12.09.11.53.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 11:53:38 -0800 (PST) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/7] NFSv4 remove zero number of fs_locations entries error check Date: Thu, 9 Dec 2021 14:53:29 -0500 Message-Id: <20211209195335.32404-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211209195335.32404-1-olga.kornievskaia@gmail.com> References: <20211209195335.32404-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Remove the check for the zero length fs_locations reply in the xdr decoding, and instead check for that in the migration code. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4state.c | 3 +++ fs/nfs/nfs4xdr.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index f63dfa01001c..f3265575c28d 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -2106,6 +2106,9 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred } result = -NFS4ERR_NXIO; + if (!locations->nlocations) + goto out; + if (!(locations->fattr.valid & NFS_ATTR_FATTR_V4_LOCATIONS)) { dprintk("<-- %s: No fs_locations data, migration skipped\n", __func__); diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 801119b7a596..71a00e48bd2d 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -3696,8 +3696,6 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st if (unlikely(!p)) goto out_eio; n = be32_to_cpup(p); - if (n <= 0) - goto out_eio; for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { u32 m; struct nfs4_fs_location *loc; From patchwork Thu Dec 9 19:53:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12668189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88B92C433FE for ; Thu, 9 Dec 2021 19:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbhLIT5S (ORCPT ); Thu, 9 Dec 2021 14:57:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231185AbhLIT5O (ORCPT ); Thu, 9 Dec 2021 14:57:14 -0500 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2F00C0617A1 for ; Thu, 9 Dec 2021 11:53:40 -0800 (PST) Received: by mail-il1-x130.google.com with SMTP id d14so4037577ila.1 for ; Thu, 09 Dec 2021 11:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S5Rskj1Nwf4FPH1sEExJitDHdUW/0NpzKDoBKlnwmK8=; b=ZzEpzD6KXPTkxWJo8wBHWuHO1/2mE+uHZIy6Z57k2+wOKtpKsAcoekqMjS83K9jpXQ N/yhaA+TyZOD6GhHB5PqOytiokFf3Ujpv9PbQcbqoVOH0PwtTQ+kJiWvTH50W49gEHNm BfoaMAnlBsGc+7YAGyTUrpXXah9L7SSffDcp9wRhETIQRthFukYSuyvCwwTvL05jn46j zggIyR4lBUZHkCJejkjFzKjeOPT8jf5IhlgwgCLP0C4cnto8zEUqORD+pktKQpjQiQD3 lLRG+rDMn8ejNyUTx8nhF7mDOj6aE/cDeGqJD92ccLgzfJAxnplJZJdjS++wEbaYSuyw Sg1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S5Rskj1Nwf4FPH1sEExJitDHdUW/0NpzKDoBKlnwmK8=; b=1ehIB559bsRz7027hxIgsOlPPmmmY92iAEmjP1KP8VSSYDcaFrgPOW7B5/o13Z3s/X lMYp+SzX28BIjt0BA1wgSlC0UGln01XzQSlrw57f+q+AIUPkt/k1zqAbeU0Sz5c32VIM pO0UlIUfoxLPn/KJANWkaY1LAg+8d41JCyL8aApVfh/oeScI85Z8gjP9PgB0vo0TqSNL SfLYYFHg4ArCMcUVY3pVwnFwuurbZfLGdiG1fkvkJvl62NDY6kQ6eTKW+zhFB8D2sfkB XCqUFIxCIX3luzvq9NpG+OtcfTpOEXC6G7F9O7P4oVqT8wq8cULbkZHBUngZrUg34naJ 5OGQ== X-Gm-Message-State: AOAM5309mxzb577FpnmhYhXThAbspmb/rN8qpjc3LrORBXHQ1tuAB40m GeDJk5CEZY6YvEO2xHZN0J7FvkkTg9Y= X-Google-Smtp-Source: ABdhPJzaowN3GKKEJgbTtYRU/XWE6gL4+L/TNSJF8bEyfd3RsIqAL2O0W8Gj3NtT9G6AxmU6tYaG6Q== X-Received: by 2002:a05:6e02:1a21:: with SMTP id g1mr15058832ile.71.1639079620289; Thu, 09 Dec 2021 11:53:40 -0800 (PST) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:554d:272f:69a0:1745]) by smtp.gmail.com with ESMTPSA id k9sm383541ilv.61.2021.12.09.11.53.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 11:53:39 -0800 (PST) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/7] NFSv4 store server support for fs_location attribute Date: Thu, 9 Dec 2021 14:53:30 -0500 Message-Id: <20211209195335.32404-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211209195335.32404-1-olga.kornievskaia@gmail.com> References: <20211209195335.32404-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Define and store if server returns it supports fs_locations attribute as a capability. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4proc.c | 2 ++ include/linux/nfs_fs_sb.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 535436dbdc9a..199f03c9d0b2 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3873,6 +3873,8 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f if (res.attr_bitmask[2] & FATTR4_WORD2_SECURITY_LABEL) server->caps |= NFS_CAP_SECURITY_LABEL; #endif + if (res.attr_bitmask[0] & FATTR4_WORD0_FS_LOCATIONS) + server->caps |= NFS_CAP_FS_LOCATIONS; if (!(res.attr_bitmask[0] & FATTR4_WORD0_FILEID)) server->fattr_valid &= ~NFS_ATTR_FATTR_FILEID; if (!(res.attr_bitmask[1] & FATTR4_WORD1_MODE)) diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 2a9acbfe00f0..9a6e70ccde56 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -287,5 +287,5 @@ struct nfs_server { #define NFS_CAP_COPY_NOTIFY (1U << 27) #define NFS_CAP_XATTR (1U << 28) #define NFS_CAP_READ_PLUS (1U << 29) - +#define NFS_CAP_FS_LOCATIONS (1U << 30) #endif From patchwork Thu Dec 9 19:53:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12668191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79071C4332F for ; Thu, 9 Dec 2021 19:53:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230488AbhLIT5T (ORCPT ); Thu, 9 Dec 2021 14:57:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbhLIT5P (ORCPT ); Thu, 9 Dec 2021 14:57:15 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17B18C061746 for ; Thu, 9 Dec 2021 11:53:42 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id c3so7980938iob.6 for ; Thu, 09 Dec 2021 11:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MHl02dwAYkBDWZNRlGpbllrmkJ9HL+wOCoOLgYoToWA=; b=ZSwbCaxG2Guk4BUP+ZRkmMBnf4PYNJvIKg7FNyoft/tzUjfFOoLkEji4/bGD33rSxU 7Tp5fITmWGfk/u25vYIQcoJNnb9hi/VaEAbDsxEt/c2qIqm8BxuClaol+ACrGcQHV/Or CkdwqhTcJbxKzJBGUByUtzyRwId+84dXyNhKoyIOny3bNUu+9fvQy+sm/WF8/l+Rz3FJ go5R2wXLyCC5ruzpgy1D0Q72cfezHJaJ+Fg8pnxCuldxtpzHgPsmtVrMa0a65Bu4dvB9 g4sFNMpdE8uHjVH1VZfjZDd6MKrfOMNLQfizzNLose9O3AFN8Y9AvWa82pXQlxRhSdpH IjiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MHl02dwAYkBDWZNRlGpbllrmkJ9HL+wOCoOLgYoToWA=; b=7dh9ssEjLOAiOUolJZSB71IFEVLud9aGWv96y2QWQ5Ek6zy/UJ5gmRsU4ESHzy3hxI 00jUDv+CBqAG/blm8ZpbAxyMLLdzHIlw8tOOcAWVc2eFHSBTqQ85FFdqrGDSR6yH0KVo 8Y8hbANl2MIEh9lybw3LY6GLE2YEpZcuxMCY+Ih40evqme8GHXD+pMbiw1+abI7a99OT a9RoRL6cm+Ow5K6SakKiHBmXuuSgaf5iEhARsCI1FB2KGNYW8j3+XnzNG+NisGgaAPGx z6bXtC+4mB3QFec7a6sXsu2lx3kschp9us2I0h+Crhrgri6jd+0o2VJ7tkF8pYyDLRLe xX5g== X-Gm-Message-State: AOAM532IaO6SDSSZPGxrKrgiMSSaeXKYvsBWW9e6HinBCL3E/WzIKQil V5Eb+g2mxdsNGmqS1mBomfJ0C1mMvbg= X-Google-Smtp-Source: ABdhPJyyeDvnIaok2uVBg1MgpbV6C0rOJok6juRvwG/Q8jjP7t+qMmoVPoKZHUWkOE8DJ7PGVYH84Q== X-Received: by 2002:a02:ccb3:: with SMTP id t19mr11560046jap.145.1639079621363; Thu, 09 Dec 2021 11:53:41 -0800 (PST) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:554d:272f:69a0:1745]) by smtp.gmail.com with ESMTPSA id k9sm383541ilv.61.2021.12.09.11.53.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 11:53:40 -0800 (PST) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 3/7] NFSv4.1 query for fs_location attr on a new file system Date: Thu, 9 Dec 2021 14:53:31 -0500 Message-Id: <20211209195335.32404-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211209195335.32404-1-olga.kornievskaia@gmail.com> References: <20211209195335.32404-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Query the server for other possible trunkable locations for a given file system on a 4.1+ mount. Signed-off-by: Olga Kornievskaia --- fs/nfs/client.c | 7 ++++ fs/nfs/nfs4_fs.h | 9 ++--- fs/nfs/nfs4proc.c | 75 +++++++++++++++++++++++++++++++++++------ fs/nfs/nfs4state.c | 3 +- include/linux/nfs_xdr.h | 1 + 5 files changed, 80 insertions(+), 15 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 1e4dc1ab9312..f7e39cc4472b 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -860,6 +860,13 @@ static int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, str server->namelen = pathinfo.max_namelen; } + if (clp->rpc_ops->discover_trunking != NULL && + (server->caps & NFS_CAP_FS_LOCATIONS)) { + error = clp->rpc_ops->discover_trunking(server, mntfh); + if (error < 0) + return error; + } + return 0; } diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index ed5eaca6801e..2402a3d8ba99 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -260,8 +260,8 @@ struct nfs4_state_maintenance_ops { }; struct nfs4_mig_recovery_ops { - int (*get_locations)(struct inode *, struct nfs4_fs_locations *, - struct page *, const struct cred *); + int (*get_locations)(struct nfs_server *, struct nfs_fh *, + struct nfs4_fs_locations *, struct page *, const struct cred *); int (*fsid_present)(struct inode *, const struct cred *); }; @@ -302,8 +302,9 @@ extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait); extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *, struct nfs4_fs_locations *, struct page *); -extern int nfs4_proc_get_locations(struct inode *, struct nfs4_fs_locations *, - struct page *page, const struct cred *); +extern int nfs4_proc_get_locations(struct nfs_server *, struct nfs_fh *, + struct nfs4_fs_locations *, + struct page *page, const struct cred *); extern int nfs4_proc_fsid_present(struct inode *, const struct cred *); extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, struct dentry *, diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 199f03c9d0b2..9a6b53ec0eaa 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3933,6 +3933,59 @@ int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) return err; } +static int _nfs4_discover_trunking(struct nfs_server *server, + struct nfs_fh *fhandle) +{ + struct nfs4_fs_locations *locations = NULL; + struct page *page; + const struct cred *cred; + struct nfs_client *clp = server->nfs_client; + const struct nfs4_state_maintenance_ops *ops = + clp->cl_mvops->state_renewal_ops; + int status = -ENOMEM; + + cred = ops->get_state_renewal_cred(clp); + if (cred == NULL) { + cred = nfs4_get_clid_cred(clp); + if (cred == NULL) + return -ENOKEY; + } + + page = alloc_page(GFP_KERNEL); + locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL); + if (page == NULL || locations == NULL) + goto out; + + status = nfs4_proc_get_locations(server, fhandle, locations, page, + cred); + if (status) + goto out; +out: + if (page) + __free_page(page); + kfree(locations); + return status; +} + +int nfs4_discover_trunking(struct nfs_server *server, struct nfs_fh *fhandle) +{ + struct nfs4_exception exception = { + .interruptible = true, + }; + struct nfs_client *clp = server->nfs_client; + int err = 0; + + if (!nfs4_has_session(clp)) + goto out; + do { + err = nfs4_handle_exception(server, + _nfs4_discover_trunking(server, fhandle), + &exception); + } while (exception.retry); +out: + return err; +} + static int _nfs4_lookup_root(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *info) { @@ -7819,18 +7872,18 @@ int nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir, * appended to this compound to identify the client ID which is * performing recovery. */ -static int _nfs40_proc_get_locations(struct inode *inode, +static int _nfs40_proc_get_locations(struct nfs_server *server, + struct nfs_fh *fhandle, struct nfs4_fs_locations *locations, struct page *page, const struct cred *cred) { - struct nfs_server *server = NFS_SERVER(inode); struct rpc_clnt *clnt = server->client; u32 bitmask[2] = { [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS, }; struct nfs4_fs_locations_arg args = { .clientid = server->nfs_client->cl_clientid, - .fh = NFS_FH(inode), + .fh = fhandle, .page = page, .bitmask = bitmask, .migration = 1, /* skip LOOKUP */ @@ -7876,17 +7929,17 @@ static int _nfs40_proc_get_locations(struct inode *inode, * When the client supports GETATTR(fs_locations_info), it can * be plumbed in here. */ -static int _nfs41_proc_get_locations(struct inode *inode, +static int _nfs41_proc_get_locations(struct nfs_server *server, + struct nfs_fh *fhandle, struct nfs4_fs_locations *locations, struct page *page, const struct cred *cred) { - struct nfs_server *server = NFS_SERVER(inode); struct rpc_clnt *clnt = server->client; u32 bitmask[2] = { [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS, }; struct nfs4_fs_locations_arg args = { - .fh = NFS_FH(inode), + .fh = fhandle, .page = page, .bitmask = bitmask, .migration = 1, /* skip LOOKUP */ @@ -7935,11 +7988,11 @@ static int _nfs41_proc_get_locations(struct inode *inode, * -NFS4ERR_LEASE_MOVED is returned if the server still has leases * from this client that require migration recovery. */ -int nfs4_proc_get_locations(struct inode *inode, +int nfs4_proc_get_locations(struct nfs_server *server, + struct nfs_fh *fhandle, struct nfs4_fs_locations *locations, struct page *page, const struct cred *cred) { - struct nfs_server *server = NFS_SERVER(inode); struct nfs_client *clp = server->nfs_client; const struct nfs4_mig_recovery_ops *ops = clp->cl_mvops->mig_recovery_ops; @@ -7952,10 +8005,11 @@ int nfs4_proc_get_locations(struct inode *inode, (unsigned long long)server->fsid.major, (unsigned long long)server->fsid.minor, clp->cl_hostname); - nfs_display_fhandle(NFS_FH(inode), __func__); + nfs_display_fhandle(fhandle, __func__); do { - status = ops->get_locations(inode, locations, page, cred); + status = ops->get_locations(server, fhandle, locations, page, + cred); if (status != -NFS4ERR_DELAY) break; nfs4_handle_exception(server, status, &exception); @@ -10424,6 +10478,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = { .free_client = nfs4_free_client, .create_server = nfs4_create_server, .clone_server = nfs_clone_server, + .discover_trunking = nfs4_discover_trunking, }; static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = { diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index f3265575c28d..499bef9fe118 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -2098,7 +2098,8 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred } inode = d_inode(server->super->s_root); - result = nfs4_proc_get_locations(inode, locations, page, cred); + result = nfs4_proc_get_locations(server, NFS_FH(inode), locations, + page, cred); if (result) { dprintk("<-- %s: failed to retrieve fs_locations: %d\n", __func__, result); diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 967a0098f0a9..695fa84611b6 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1795,6 +1795,7 @@ struct nfs_rpc_ops { struct nfs_server *(*create_server)(struct fs_context *); struct nfs_server *(*clone_server)(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, rpc_authflavor_t); + int (*discover_trunking)(struct nfs_server *, struct nfs_fh *); }; /* From patchwork Thu Dec 9 19:53:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12668193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2F19C433F5 for ; Thu, 9 Dec 2021 19:53:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231185AbhLIT5U (ORCPT ); Thu, 9 Dec 2021 14:57:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbhLIT5Q (ORCPT ); Thu, 9 Dec 2021 14:57:16 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 148EAC0617A1 for ; Thu, 9 Dec 2021 11:53:43 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id p65so7994719iof.3 for ; Thu, 09 Dec 2021 11:53:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FgWdsQIw7iIOvaTzUWwihr9PsUnhK9q2bYCCmb5oIDc=; b=WXnDCA9WJ+KTC7M5nOSkCHkKBLkeoxLfigNUxbSkbFbD/qD7vTwdLWr1ULsAO0Ge++ IBF2O1+BKLo18FFvpF5/iifYtQswhduwOuOrgEVgq3LgHrqnsR0Icu7Tbe7xNSJV6xEP ZZzrhHk4mk6xv2qEqzimzk767a4i6Slau7iVRYvtvI14iTzmA9uMrbpo/pzYMlLZ9++b qQgh56z1LLLQ8NlF1aQBGMtTePIwsQsKfFeOs4FGnoSYJx0l7yWhJPuoB+uFTVpzbuMf HgalhZ6C+UC0YFbj6hLI+nfoiUcAEEDoyhogfitNpBer3iziz8xSedq2DeoK2RWdtEGL IipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FgWdsQIw7iIOvaTzUWwihr9PsUnhK9q2bYCCmb5oIDc=; b=L8lesB8C4YQdm5dFphCOufn6fP2fqNZDY0VYHpf9vuH/KOji7exyiFX0Ad4uDMDQvu SAOEPfmaNbbyCORKjHsqpJ9/O0eoMDOfLQD9n3eiIJCwMdlRwt+xwrk4H7Rk6o3drVrt 3+5v2zB9yQeHQavyORznxs6fP7z69d7HQrnR6dn4RT41UkV/ZUkZPrCgXXn7RE0Y823e 5HoQNp3XA3ij7NUtr3VAhHRyShM7giRnas0u19IGgPIMGxUPKTKDMfHK1Y8aUFeVHIom CnaK74KF9/GvFtaXeDUe0aHmDLUmfBAZb2arxjRLY2l9jpe2OwaL6W95O0KIp2+zbgPM Vapg== X-Gm-Message-State: AOAM5305jKPOzVxWG7RFr9Xan1BfOfKJyT75ymn0sMULxu4lXvr63B/V bi6oOtbDog4S3hVKWfTBPAR0SDqfaT8= X-Google-Smtp-Source: ABdhPJzIzOTEyTs/9bjkA7sqIyX4peqF4mXfNz6C0hn+WGyW8v40IhgH8BNlwg9mViI5rB+qPu+gDQ== X-Received: by 2002:a02:1949:: with SMTP id b70mr11786736jab.7.1639079622453; Thu, 09 Dec 2021 11:53:42 -0800 (PST) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:554d:272f:69a0:1745]) by smtp.gmail.com with ESMTPSA id k9sm383541ilv.61.2021.12.09.11.53.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 11:53:41 -0800 (PST) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 4/7] NFSv4 expose nfs_parse_server_name function Date: Thu, 9 Dec 2021 14:53:32 -0500 Message-Id: <20211209195335.32404-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211209195335.32404-1-olga.kornievskaia@gmail.com> References: <20211209195335.32404-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Make nfs_parse_server_name available outside of nfs4namespace.c. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4_fs.h | 3 ++- fs/nfs/nfs4namespace.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 2402a3d8ba99..734ac09becf7 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -280,7 +280,8 @@ struct rpc_clnt *nfs4_negotiate_security(struct rpc_clnt *, struct inode *, int nfs4_submount(struct fs_context *, struct nfs_server *); int nfs4_replace_transport(struct nfs_server *server, const struct nfs4_fs_locations *locations); - +size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa, + size_t salen, struct net *net); /* nfs4proc.c */ extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *); extern int nfs4_async_handle_error(struct rpc_task *task, diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c index 873342308dc0..f1ed4f60a7f3 100644 --- a/fs/nfs/nfs4namespace.c +++ b/fs/nfs/nfs4namespace.c @@ -164,8 +164,8 @@ static int nfs4_validate_fspath(struct dentry *dentry, return 0; } -static size_t nfs_parse_server_name(char *string, size_t len, - struct sockaddr *sa, size_t salen, struct net *net) +size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa, + size_t salen, struct net *net) { ssize_t ret; From patchwork Thu Dec 9 19:53:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12668195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52064C433EF for ; Thu, 9 Dec 2021 19:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231191AbhLIT5V (ORCPT ); Thu, 9 Dec 2021 14:57:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231193AbhLIT5S (ORCPT ); Thu, 9 Dec 2021 14:57:18 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6006CC061746 for ; Thu, 9 Dec 2021 11:53:44 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id s11so6440521ilv.3 for ; Thu, 09 Dec 2021 11:53:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4jtbUus3x2mijhthivfWTrn47zByzbDnzBGITE/pGuE=; b=g+BpSGSYTbXX2PLZqYh4GSTWJjCdyGv1itVdysbxxONNhQ9RM4684h51eadnekaj6B zg2Ld0ZIWQXuLSw5cFAyM6mwVTMyrEwWnMnAUFge8NvDkFnDVnT8jC6/skRCxYhuhlNG lbAESFjYtsVSao79SdTiYYy0qRzcg+Sl4+m3yfwOq/c25rrK7o3Y5ViBEz4uG2RiVZw3 uTIaKiRjF2tldY/6mk+CmP4n2ISKVOauJp6iadUsmn1f/oKs/pTVWuiUiYn7gRrQ0LBW 8ca97DJVcPXrMWx6qcw1opElmXrSjlSQQGXOHsooEmGKMCUpQbucGcOBWxs0N37SWAbW phgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4jtbUus3x2mijhthivfWTrn47zByzbDnzBGITE/pGuE=; b=IqmAtgAcLFjDeh3CWr8AxP2FeMA65ufhSfOfua15OPGdn+GgsqEsozq3o+cHeiA212 kc1TydpGK7tJy7a7Um8qySi9e3I4QeNj2YDw+d/wqtJQm9DEYvtdcRvSzftU6HIsRwGg 9V0IqsoH1o3/O3Z4h7WGHxILRwlkv6xBEIrEDRcIVonj4FGC8TUSt2KRigQhJ6l+yO9L nWeJVptzUZm041mU8YWVnlOxOicQzgGnMwYtwXY2KA+K6SUaSmP7/QVtxqKTKqQ1fOQ5 wiuULwYNc41BA/2MnAmsc0JtqPkS0TUrxRe8hFKVgsrlyvvuK3Do2xFMhdderiD+AVO2 nWag== X-Gm-Message-State: AOAM530THiXa1DISChMmu26TkkGhb1ycbZBFeF1O8hNmRUdaD+7cl4l9 n1KHl/CCwuqKBVBBzIbj4P32qn7InMA= X-Google-Smtp-Source: ABdhPJwKdIUlmvCZaBgzVB5YYERsw6O0v6BKfsKNWSMMSYUZECAun3VezBqx6/zNFG6t7yczhZ1yWg== X-Received: by 2002:a05:6e02:1c2e:: with SMTP id m14mr17948160ilh.172.1639079623724; Thu, 09 Dec 2021 11:53:43 -0800 (PST) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:554d:272f:69a0:1745]) by smtp.gmail.com with ESMTPSA id k9sm383541ilv.61.2021.12.09.11.53.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 11:53:43 -0800 (PST) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 5/7] NFSv4 handle port presence in fs_location server string Date: Thu, 9 Dec 2021 14:53:33 -0500 Message-Id: <20211209195335.32404-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211209195335.32404-1-olga.kornievskaia@gmail.com> References: <20211209195335.32404-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia An fs_location attribute returns a string that can be ipv4, ipv6, or DNS name. An ip location can have a port appended to it and if no port is present a default port needs to be set. If rpc_pton() fails to parse, try calling rpc_uaddr2socaddr() that can convert an universal address. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4_fs.h | 2 +- fs/nfs/nfs4namespace.c | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 734ac09becf7..85c5d08dfa9c 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -281,7 +281,7 @@ int nfs4_submount(struct fs_context *, struct nfs_server *); int nfs4_replace_transport(struct nfs_server *server, const struct nfs4_fs_locations *locations); size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa, - size_t salen, struct net *net); + size_t salen, struct net *net, int port); /* nfs4proc.c */ extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *); extern int nfs4_async_handle_error(struct rpc_task *task, diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c index f1ed4f60a7f3..3680c8da510c 100644 --- a/fs/nfs/nfs4namespace.c +++ b/fs/nfs/nfs4namespace.c @@ -165,15 +165,20 @@ static int nfs4_validate_fspath(struct dentry *dentry, } size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa, - size_t salen, struct net *net) + size_t salen, struct net *net, int port) { ssize_t ret; ret = rpc_pton(net, string, len, sa, salen); if (ret == 0) { - ret = nfs_dns_resolve_name(net, string, len, sa, salen); - if (ret < 0) - ret = 0; + ret = rpc_uaddr2sockaddr(net, string, len, sa, salen); + if (ret == 0) { + ret = nfs_dns_resolve_name(net, string, len, sa, salen); + if (ret < 0) + ret = 0; + } + } else if (port) { + rpc_set_port(sa, port); } return ret; } @@ -328,7 +333,7 @@ static int try_location(struct fs_context *fc, nfs_parse_server_name(buf->data, buf->len, &ctx->nfs_server.address, sizeof(ctx->nfs_server._address), - fc->net_ns); + fc->net_ns, 0); if (ctx->nfs_server.addrlen == 0) continue; @@ -496,7 +501,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server, continue; salen = nfs_parse_server_name(buf->data, buf->len, - sap, addr_bufsize, net); + sap, addr_bufsize, net, 0); if (salen == 0) continue; rpc_set_port(sap, NFS_PORT); From patchwork Thu Dec 9 19:53:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12668197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B26B2C433FE for ; Thu, 9 Dec 2021 19:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbhLIT5W (ORCPT ); Thu, 9 Dec 2021 14:57:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230503AbhLIT5T (ORCPT ); Thu, 9 Dec 2021 14:57:19 -0500 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94AC6C061746 for ; Thu, 9 Dec 2021 11:53:45 -0800 (PST) Received: by mail-il1-x130.google.com with SMTP id j21so6438558ila.5 for ; Thu, 09 Dec 2021 11:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ikQR/pBQ4nY3PwJ+F4JPe7aDRKbicW62aNksWPUjyb0=; b=NqJgr0wtbLMCusmW2zg0fz8duuhDIiciPyyzimpoVehfjdQJ2GzruKaAgQs09/xPy2 4mR2NJKgnvJNFtyLntaboWz7wApKLLrVigo9SpfkuxsTHirtGK5k/Nx7+gJ17aGrcC0f 46D68vMtXIzngMIlLYD84TZ8tEuFTcNFE2jix5uqYwTfKxh1Krhc6mCN38hMm97qjvrQ fniyR5biQLhqw2T9A/eO0ZrLbTSwmi/1WdaSyRjEGvTbsb/LhddJB6rUv/Web7VsYPdp YXkxMN4ntkXVQxV/rL/ijWsGWZdZz6lv8AVsrZ5TBowjqre1sAzvpOZx6sWouonENoLb 9ckw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ikQR/pBQ4nY3PwJ+F4JPe7aDRKbicW62aNksWPUjyb0=; b=xa/q0KkSBRMuJgkfr+NaEhmL8wF9iZDq0QWMCRZ4Ii0Nm3hA3DADyrhLw2F4++vTm/ 3KvqKXxfat82ogFNR+gO4xwpduMLOLjPel8gSPdFjwXuxoBc7rr8V1A5U4iKOchy5OTz /iFR7K7W042OjSabkH0AOpJ+Zm6AtTjOJtaPrd1/6JQ+0yqjMDY4wdeNWKYnE6R6UPiB zt6I6fZkxqd53jR92nGpMaNuL0jgPpSkEKswffouJhoPfNbTn5ra+o6fd+Z6Jp1JODNK gjLeq5HpoMu0n7+XiPq0eZgjpzc37RxAGsuY2PeYiNCacJvn7ToflnXNlP/5+k2VxhLF 8oxg== X-Gm-Message-State: AOAM533zNQSWjusFFK9SXrlHGQDFkMTZRbbpm/jJML1dLClN2UBVSQc9 4321Mu4h1KL4JjZnVaHv1RzN2STjU3U= X-Google-Smtp-Source: ABdhPJz1nnhgrzGSlFZgoMMQJn5BpIFpBD9rLpkRiZtnyV4agXqdEDEUBQTf83Qe52b04E69R6xx0Q== X-Received: by 2002:a05:6e02:b2a:: with SMTP id e10mr18282739ilu.80.1639079625045; Thu, 09 Dec 2021 11:53:45 -0800 (PST) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:554d:272f:69a0:1745]) by smtp.gmail.com with ESMTPSA id k9sm383541ilv.61.2021.12.09.11.53.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 11:53:44 -0800 (PST) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 6/7] SUNRPC allow for unspecified transport time in rpc_clnt_add_xprt Date: Thu, 9 Dec 2021 14:53:34 -0500 Message-Id: <20211209195335.32404-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211209195335.32404-1-olga.kornievskaia@gmail.com> References: <20211209195335.32404-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia If the supplied argument doesn't specify the transport type, use the type of the existing rpc clnt and its existing transport. Signed-off-by: Olga Kornievskaia --- net/sunrpc/clnt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index a312ea2bc440..c83fe618767c 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2900,7 +2900,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, unsigned long connect_timeout; unsigned long reconnect_timeout; unsigned char resvport, reuseport; - int ret = 0; + int ret = 0, ident; rcu_read_lock(); xps = xprt_switch_get(rcu_dereference(clnt->cl_xpi.xpi_xpswitch)); @@ -2914,8 +2914,11 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, reuseport = xprt->reuseport; connect_timeout = xprt->connect_timeout; reconnect_timeout = xprt->max_reconnect_timeout; + ident = xprt->xprt_class->ident; rcu_read_unlock(); + if (!xprtargs->ident) + xprtargs->ident = ident; xprt = xprt_create_transport(xprtargs); if (IS_ERR(xprt)) { ret = PTR_ERR(xprt); From patchwork Thu Dec 9 19:53:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12668199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07FBAC4332F for ; Thu, 9 Dec 2021 19:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230503AbhLIT5X (ORCPT ); Thu, 9 Dec 2021 14:57:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbhLIT5U (ORCPT ); Thu, 9 Dec 2021 14:57:20 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0246EC061746 for ; Thu, 9 Dec 2021 11:53:47 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id x10so7949257ioj.9 for ; Thu, 09 Dec 2021 11:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AsRhowv9GS1BKrI5gLUKrzXf/xeqD8Q3rmF2XHzw6BY=; b=nxtp/Y6SruBNWzzF3mxw+BpDtxyJ3nmA38o2BTE4uqJ89CHbnxDbOOGhJtE0VvGAze VpjOIHKyLuP8OxUuG6bN9WT84fY/AHWvvxf09IMWySC5+UaBnneIP30IhlvkIZmEIcBT ntHPkcU9Gw+9zxkDXQAiwUoj1/x18QX/jfzJcCCPl53/xkwLk0w1YbCKkwCubq65+zBN uBvuJwkf07D+PDibvKwdnDfcYMsv7VD4VMR0ofcF0YvSW+grPmCtMRBRol5JOnQCnXf8 8lt/JQa0sblWdJnNxgdsWF693XU+3nI9qHKB0w9nUai5nMJPbMZr8HZdcfXztQcTHL83 7Qzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AsRhowv9GS1BKrI5gLUKrzXf/xeqD8Q3rmF2XHzw6BY=; b=25kKUE5D10nIpeIzNUYPfW1nd0nhrS9tBaOOsxV999Dya30OjvFoqnmnj17p8fEL3w KfLNQIc1/TZtRYNRxhhCFg+d9B79F/WcCItT2BrDBhbJ9d6dAQDQ0+lduOceS3TJ/Yii tldduNmi5vpGnEGldEWNOKKhN+l1X8IuLJNfWMgPS6Ib/DnFfm+NylopKIjiw77BpE9p blZfdzTCjN2gd9vNZMpbeRRZHnG0vpGvjG8gb3+tfUS0v3tw1YA8fm+26GnQzyyj3+K/ OHQvo9feg2qp/Ozsmgyqq18CuRNDOikwoFeSWTr0teE2+E06kkGUc/fcCuolxQZwxB5B aZTQ== X-Gm-Message-State: AOAM531ScMFjESiZI92JuBqeaTO4Wpih7/QLnzBHv0j6hSQH6AOyPJi1 u3XmSR+nFLz+1az+tAadeFBM24oJ8Ss= X-Google-Smtp-Source: ABdhPJwrfxKWzSlOOJYpZDFhMegFEzxUiZeRbSlDD5nSxEHRD188dmMXxsYli5D/dufV56QiSC9x5A== X-Received: by 2002:a05:6602:2d84:: with SMTP id k4mr17200622iow.168.1639079626397; Thu, 09 Dec 2021 11:53:46 -0800 (PST) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:554d:272f:69a0:1745]) by smtp.gmail.com with ESMTPSA id k9sm383541ilv.61.2021.12.09.11.53.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 11:53:45 -0800 (PST) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 7/7] NFSv4.1 test and add 4.1 trunking transport Date: Thu, 9 Dec 2021 14:53:35 -0500 Message-Id: <20211209195335.32404-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211209195335.32404-1-olga.kornievskaia@gmail.com> References: <20211209195335.32404-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia For each location returned in FS_LOCATION query, establish a transport to the server, send EXCHANGE_ID and test for trunking, if successful, add the transport to the exiting client. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4proc.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 9a6b53ec0eaa..0529c60c27e9 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3933,6 +3933,56 @@ int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) return err; } +static void test_fs_location_for_trunking(struct nfs4_fs_location *location, + struct nfs_client *clp, + struct nfs_server *server) +{ + int i; + + for (i = 0; i < location->nservers; i++) { + struct nfs4_string *srv_loc = &location->servers[i]; + struct sockaddr addr; + size_t addrlen; + struct xprt_create xprt_args = { + .ident = 0, + .net = clp->cl_net, + }; + struct nfs4_add_xprt_data xprtdata = { + .clp = clp, + }; + struct rpc_add_xprt_test rpcdata = { + .add_xprt_test = clp->cl_mvops->session_trunk, + .data = &xprtdata, + }; + char *servername = NULL; + + if (!srv_loc->len) + continue; + + addrlen = nfs_parse_server_name(srv_loc->data, srv_loc->len, + &addr, sizeof(addr), + clp->cl_net, server->port); + if (!addrlen) + return; + xprt_args.dstaddr = &addr; + xprt_args.addrlen = addrlen; + servername = kmalloc(srv_loc->len + 1, GFP_KERNEL); + if (!servername) + return; + memcpy(servername, srv_loc->data, srv_loc->len); + servername[srv_loc->len] = '\0'; + xprt_args.servername = servername; + + xprtdata.cred = nfs4_get_clid_cred(clp); + rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args, + rpc_clnt_setup_test_and_add_xprt, + &rpcdata); + if (xprtdata.cred) + put_cred(xprtdata.cred); + kfree(servername); + } +} + static int _nfs4_discover_trunking(struct nfs_server *server, struct nfs_fh *fhandle) { @@ -3942,7 +3992,7 @@ static int _nfs4_discover_trunking(struct nfs_server *server, struct nfs_client *clp = server->nfs_client; const struct nfs4_state_maintenance_ops *ops = clp->cl_mvops->state_renewal_ops; - int status = -ENOMEM; + int status = -ENOMEM, i; cred = ops->get_state_renewal_cred(clp); if (cred == NULL) { @@ -3960,6 +4010,10 @@ static int _nfs4_discover_trunking(struct nfs_server *server, cred); if (status) goto out; + + for (i = 0; i < locations->nlocations; i++) + test_fs_location_for_trunking(&locations->locations[i], clp, + server); out: if (page) __free_page(page);