Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1952818ima; Thu, 25 Oct 2018 07:30:08 -0700 (PDT) X-Google-Smtp-Source: AJdET5fiX+fspfhXOM0qh+rTC/KvVvk+zfhLzaqJ2H36jv7KxRdXVers7VQ7IRJixYsZA6RBhrnh X-Received: by 2002:a17:902:8c84:: with SMTP id t4-v6mr1774276plo.188.1540477808802; Thu, 25 Oct 2018 07:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477808; cv=none; d=google.com; s=arc-20160816; b=ngdm1nkSEXzgecCL30kQ8AGqjJ00HCRyjJt9lP2GYr9dcilculHKPtakjyTQF4xfmS DuPdgzSb7pQ4Hv0ZpiUHpoBfgg/6bnw5lgHtJWSWeFOAHOZ00lgNXCP51YQareXpAaN5 irbvkwgUkNjwZDk2BFgV/5xBkRWglMiEAgvSKISeCmhDBQwEB32TjQUnVho1Ns+a9eAO QV5+6sEvP7boZcApx/hWyGVJWULjP5SYeBykZMSzGM5gbcNM/mOEaFP8iSjQ2wThNEjp YqAGkAOsPHjFFWMeKomyTj2WmI1g1d61rGeU83rNDXKRxVdgIKlYGMh7h3tPZ/cvON9L KPxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=2rlG0O992w/H1g+pkTRoiFzG5sD2e6qwylgsd2sgUGo=; b=0aWfRZbkHWc4hf8816DcxKI8CpKhNnb4hZp3dm/V1LQdr2hnjpz7o15i8CyT2XECm0 q9cZ6LCVy4/3qmLWeReysPwb+12/SwHa+KuKkjYMHDyNKYb4KOW9snrWmIuahFXKcI/b /0yjJhbaEnmngL8fEYOtOvQJNCYJpoWKtzU1Z+x/jga5qSb/i8JGdpqO3LJEOpVVx2fN zcLzx9V1VKIFHn6E9oRY5fAUzCH/X62LiQax2Kls1j1x+4p4MuLKEHLTVkeT8EXMYJy+ 4MQRR0Er6sAph22zIX7Wp6B5/QRT0U+VihwAl7mDQnE8+RQpuVhcpjWnoeaqnC2dwd8U K5xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s01DbUZB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14-v6si8083970pgm.556.2018.10.25.07.29.18; Thu, 25 Oct 2018 07:30:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s01DbUZB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730581AbeJYWwa (ORCPT + 99 others); Thu, 25 Oct 2018 18:52:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:34532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729490AbeJYWwa (ORCPT ); Thu, 25 Oct 2018 18:52:30 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 209B92086D; Thu, 25 Oct 2018 14:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540477171; bh=q6VmlWSjVJmU9lQfV9JAj2GBLXxysmGqVludBepks0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s01DbUZBd028fkjCLw+U0/SDKtF+wMvw8TPTnjPQXTImQ16fs0zqnwej0foVugfrb 00Pr/RMuZuXXv31rZM01B7lVghtH/p/JnXTKbRVb/8iKwJ2KQfbrMvXTC1VjMrD3L2 /S+NovyNu14a5PZAwDYgm/yAqXWQFtUlOdccONsE= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Trond Myklebust , Sasha Levin Subject: [PATCH AUTOSEL 3.18 24/98] NFSv4: Cache the NFSv4/v4.1 client owner_id in the struct nfs_client Date: Thu, 25 Oct 2018 10:17:39 -0400 Message-Id: <20181025141853.214051-24-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141853.214051-1-sashal@kernel.org> References: <20181025141853.214051-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit ceb3a16c070c403f5f9ca46b46cf2bb79ea11750 ] Ensure that we cache the NFSv4/v4.1 client owner_id so that we can verify it when we're doing trunking detection. Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/nfs4client.c | 1 + fs/nfs/nfs4proc.c | 19 +++++++++++++++---- include/linux/nfs_fs_sb.h | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 723c656ebd28..d748d403bab1 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -228,6 +228,7 @@ static void nfs4_shutdown_client(struct nfs_client *clp) kfree(clp->cl_serverowner); kfree(clp->cl_serverscope); kfree(clp->cl_implid); + kfree(clp->cl_owner_id); } void nfs4_free_client(struct nfs_client *clp) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 321044c183f5..db8456b4ecb8 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -4913,11 +4913,14 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp, } static unsigned int -nfs4_init_nonuniform_client_string(const struct nfs_client *clp, +nfs4_init_nonuniform_client_string(struct nfs_client *clp, char *buf, size_t len) { unsigned int result; + if (clp->cl_owner_id != NULL) + return strlcpy(buf, clp->cl_owner_id, len); + rcu_read_lock(); result = scnprintf(buf, len, "Linux NFSv4.0 %s/%s %s", clp->cl_ipaddr, @@ -4926,24 +4929,32 @@ nfs4_init_nonuniform_client_string(const struct nfs_client *clp, rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_PROTO)); rcu_read_unlock(); + clp->cl_owner_id = kstrdup(buf, GFP_KERNEL); return result; } static unsigned int -nfs4_init_uniform_client_string(const struct nfs_client *clp, +nfs4_init_uniform_client_string(struct nfs_client *clp, char *buf, size_t len) { const char *nodename = clp->cl_rpcclient->cl_nodename; + unsigned int result; + + if (clp->cl_owner_id != NULL) + return strlcpy(buf, clp->cl_owner_id, len); if (nfs4_client_id_uniquifier[0] != '\0') - return scnprintf(buf, len, "Linux NFSv%u.%u %s/%s", + result = scnprintf(buf, len, "Linux NFSv%u.%u %s/%s", clp->rpc_ops->version, clp->cl_minorversion, nfs4_client_id_uniquifier, nodename); - return scnprintf(buf, len, "Linux NFSv%u.%u %s", + else + result = scnprintf(buf, len, "Linux NFSv%u.%u %s", clp->rpc_ops->version, clp->cl_minorversion, nodename); + clp->cl_owner_id = kstrdup(buf, GFP_KERNEL); + return result; } /* diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index fd249ab2718f..4ac99c07406a 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -74,6 +74,9 @@ struct nfs_client { /* idmapper */ struct idmap * cl_idmap; + /* Client owner identifier */ + const char * cl_owner_id; + /* Our own IP address, as a null-terminated string. * This is used to generate the mv0 callback address. */ -- 2.17.1