Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2972352ybk; Mon, 18 May 2020 12:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnT5zpAq5sWZyi29JppCWAVSFF2IMzH2p6vF9SEAfghIiVFvSATdKep2Vx1DjqTa6YKt8k X-Received: by 2002:a05:6402:150f:: with SMTP id f15mr9822768edw.36.1589830102880; Mon, 18 May 2020 12:28:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589830102; cv=none; d=google.com; s=arc-20160816; b=peIfsrw6aJRt6j/5DDJDGBjOlVFAAed0WE232H0bhvyhXV+re4jznMMxco05XRG+Ro kaF1hZ4X1NpuPC6xkYPMM6roiG4yca8OwY9HqH0FB+pbOtJFfHs1QjrkDHvZ1vqHY0tw UyZhYZIFGPOYVkSLXwCMA5hAl3aOOJXVjKfY7L0SwSpeVAQC5eajIPiFVEn7FB86NU6E RZMGjTIBfBeUEKNlqiBpZBDLDTkCKQs/mqDgGXDiLx3GQZrXuGTMe6PGJH+WZtcPgvtP qdtEuOIKEVDJNnclCaEiXSESrj9BcTWDbjEYd9ak4h443IBpyy20nCo/BDffsE8IE1Bb n3sQ== 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=tCBDJaAaWsNpbMR1PD7UYIGOYd5aloNppVzckgTQ8HU=; b=QKXtaR1Dk7x2wIzh0/ZVBC1WdSCWmtkezU6RD/qf4p8svptswoSqmhlJa8T+H671mc I2aZSwcVUGN3gXuKs+wGXtv8D5HodtAXAk/7JIAOvDt+SilijFaXlvLZCA6ENmrVVXf3 YpBghK4KQXdvc1evZg84WuYOQ0Z0Qxg7jsrNJ1QC4TAR6KOScg6sObjiI7tDjiUKzk1l dJi2L+3QsrPkNHz2Pvbl28Cfm6fpFE+w2se6P0yklt1Xo+tXLHHn8FW+CohMOJKhNNEm C7AZF/wACXpno3jH+MtnynWd6UEtgfzO+a6K6/xI13InUihugwNwm2YMZQeMTaxtlxzp QYXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PWdjmkmg; 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 i14si1881059ejp.246.2020.05.18.12.27.59; Mon, 18 May 2020 12:28:22 -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=PWdjmkmg; 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 S1730685AbgERR6m (ORCPT + 99 others); Mon, 18 May 2020 13:58:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:38280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731922AbgERR6k (ORCPT ); Mon, 18 May 2020 13:58:40 -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 4BCE520849; Mon, 18 May 2020 17:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589824719; bh=NexhZO8KU731jrVhj/4ZheMV293i2c59rM7N1run5IU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PWdjmkmgmzU6GPu7z34Zt8cyO329OkfBVLwhuz4gjCAvfAQioGUYEmm+DC6yy1Pp5 OzgMALet0AC/dxc46IHD1UYhMBIGDfhJLN2qnEcpF6TpcImOSQfZQofiSF63WE5oEe MG3XKKl5srbph0DLJdECP9ih2E5xBNIAGFRL9KAo= 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 5.4 076/147] NFSv4: Fix fscache cookie aux_data to ensure change_attr is included Date: Mon, 18 May 2020 19:36:39 +0200 Message-Id: <20200518173523.307922408@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173513.009514388@linuxfoundation.org> References: <20200518173513.009514388@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 d0c629f97789e..7d6721ec31d4d 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -227,6 +227,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. */ @@ -240,14 +253,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, @@ -267,11 +273,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; } @@ -311,11 +313,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