Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2967147ybk; Mon, 18 May 2020 12:19:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx/ZDWcRAcmxbBODNfAjpjebgfTMeVnU3i16n18dUrjCuOkc3j66LJKklj8YsjFXlkvMXt X-Received: by 2002:a17:906:edb5:: with SMTP id sa21mr16683218ejb.78.1589829556377; Mon, 18 May 2020 12:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589829556; cv=none; d=google.com; s=arc-20160816; b=gdoX5RCm6hZIINnBGIQE1seQ4UlsSD8DWqyUNYF/m9MUl4/AT0HEPEU9eHDH6b61e/ ts1nY9w8mJ45Z30gk+o1TRHiRyw2vz4u1dBqdbwOsomIX3J9OoNbQQMT5614Fv7MoYuy qxVEyO1sdN441y+Lj92cPueZjMO6bP4nSN2Q3Mgus1vDYSY4ac3Yr1xVl3d+L8GyCm7A 22lI6EP9Qd5YzdO8eO6UDHcHwB7zKWFvatqyJeviPepoGxQuGRl5bretA/+fBOT5GB0/ nzpsQYg70EfBftH4lZGFicIrWpfYvGDEuVMq5q2T+XKAMM+Beh4vHAXssbuVTuQeejJj QlJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kO65tCem9vJX3RR+uu1wOgctmq0fALA6yY/qcSGNfr0=; b=SyVwv8zDIQ48LOcz4LX0G5tgqsCT+LMDKK2MPjSvXmhOHYMsoU3q7KM5y0mDE8cp2l y1ZNKH2nHwYM2ot5JNpn5aRxBZe5KcgLGa6fLd1y7h7pZ31PUM//JCf/ege6mGYpE1g4 Fq79e3yZPoHwbhiOhcl7/SBAlflsfMy7T2Uhd7bCqU3PETXnEY/D+ZHZLF/Xwnyseo0e 8LBuxoE1HyBZDCZ0l62hPky9ETA6zDwrgayEGKczebomm+ATCf+idI8cD+vdEzSwn8gV plcVYgh2wRd92axuQ/+5j5/s857209R3KZUSPpWCoBYYDq7SyuC5Apw2mZTLfyB3iCly 1ehA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=md9UwGjp; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oq5si7087774ejb.395.2020.05.18.12.18.53; Mon, 18 May 2020 12:19:16 -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=@kernel.org header.s=default header.b=md9UwGjp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730396AbgERRvt (ORCPT + 99 others); Mon, 18 May 2020 13:51:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:54606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730330AbgERRvo (ORCPT ); Mon, 18 May 2020 13:51:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB50120829; Mon, 18 May 2020 17:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589824302; bh=plqYo22biTGHgNsqsufKV0Ht2FGCe/Y2/qOpDAwRLo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=md9UwGjptTlt2edX345D92kKHSrbVvm/LSH7jQxqBB9NoGI3s0ftF+qtV4zRTrfh/ nGnPQumBdKfFCJQ2amxNgryfHQVuPlljtZMtjl0W34hNmQD+eL050iwwqGgjvddpHq ERXGYibA1qOcyVONacPyq4+G/E8r0UHU2677N2g8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Wysochanski , David Howells , Sasha Levin Subject: [PATCH 4.19 38/80] NFSv4: Fix fscache cookie aux_data to ensure change_attr is included Date: Mon, 18 May 2020 19:36:56 +0200 Message-Id: <20200518173458.056584883@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.097837707@linuxfoundation.org> References: <20200518173450.097837707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Wysochanski [ Upstream commit 50eaa652b54df1e2b48dc398d9e6114c9ed080eb ] Commit 402cb8dda949 ("fscache: Attach the index key and aux data to the cookie") added the aux_data and aux_data_len to parameters to fscache_acquire_cookie(), and updated the callers in the NFS client. In the process it modified the aux_data to include the change_attr, but missed adding change_attr to a couple places where aux_data was used. Specifically, when opening a file and the change_attr is not added, the following attempt to lookup an object will fail inside cachefiles_check_object_xattr() = -116 due to nfs_fscache_inode_check_aux() failing memcmp on auxdata and returning FSCACHE_CHECKAUX_OBSOLETE. Fix this by adding nfs_fscache_update_auxdata() to set the auxdata from all relevant fields in the inode, including the change_attr. Fixes: 402cb8dda949 ("fscache: Attach the index key and aux data to the cookie") Signed-off-by: Dave Wysochanski Signed-off-by: David Howells Signed-off-by: Sasha Levin --- fs/nfs/fscache.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c index 0a4d6b35545a3..7dfa45a380882 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -231,6 +231,19 @@ void nfs_fscache_release_super_cookie(struct super_block *sb) } } +static void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *auxdata, + struct nfs_inode *nfsi) +{ + memset(auxdata, 0, sizeof(*auxdata)); + auxdata->mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; + auxdata->mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; + auxdata->ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; + auxdata->ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; + + if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) + auxdata->change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode); +} + /* * Initialise the per-inode cache cookie pointer for an NFS inode. */ @@ -244,14 +257,7 @@ void nfs_fscache_init_inode(struct inode *inode) if (!(nfss->fscache && S_ISREG(inode->i_mode))) return; - memset(&auxdata, 0, sizeof(auxdata)); - auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; - auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; - auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; - auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; - - if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) - auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode); + nfs_fscache_update_auxdata(&auxdata, nfsi); nfsi->fscache = fscache_acquire_cookie(NFS_SB(inode->i_sb)->fscache, &nfs_fscache_inode_object_def, @@ -271,11 +277,7 @@ void nfs_fscache_clear_inode(struct inode *inode) dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie); - memset(&auxdata, 0, sizeof(auxdata)); - auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; - auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; - auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; - auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; + nfs_fscache_update_auxdata(&auxdata, nfsi); fscache_relinquish_cookie(cookie, &auxdata, false); nfsi->fscache = NULL; } @@ -315,11 +317,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp) if (!fscache_cookie_valid(cookie)) return; - memset(&auxdata, 0, sizeof(auxdata)); - auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; - auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; - auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; - auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; + nfs_fscache_update_auxdata(&auxdata, nfsi); if (inode_is_open_for_write(inode)) { dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi); -- 2.20.1