Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1110675ybz; Thu, 16 Apr 2020 03:07:29 -0700 (PDT) X-Google-Smtp-Source: APiQypJXghKm+0oXa5mpRhts8XPwL3n+J28/yib04XLgM7KoiggJRngY4P9ZDvdbdhn8D/AuSfs6 X-Received: by 2002:aa7:c401:: with SMTP id j1mr1330059edq.31.1587031649184; Thu, 16 Apr 2020 03:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587031649; cv=none; d=google.com; s=arc-20160816; b=FLMyKbJNo3r3IP6SXPjEbeMVxcl4phIyUDgrtVTc5TebFdhgRyCFXqvQOVocUWIGYa ITsFQNSAkyjE1XQowR5i1KCyG9BZptNEdcHvpdJexA1HlEGGiHzUkIZF/Z1KHADfpVpg B4BK5qinxRpTfnbvb6h0c7BxptEPvb/AiJg699mL/Afq4HuSu5fC5TVdXoGm3a8k5nou rumWepAd5m5FMr0StK2Qobm2QG+JsaF0UXmSYFSWoHXNG4Esiz/36+RhzAl6AHXSt7pj QQC1hXjlRiPjSIjeqMI43S4qOzX7F5ZEvluyF2gftDvNq1iXxchdTEBPlR1l/cZs+gSW t83A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=ATfoQl4JvbUU7lHAEAmxYMWCFvGqdCs55ii+BLfprRc=; b=yqY3h5wd78WRcxb7E85Lp4PxZahB5yTMMlUaTrAPW8tCAg0S7ijV/CpTJfe7mY73Sf lUqFiv6LUZNHiC/stIAkkf7qpOmmxe6NlHesrWJo4hw4NiCxTkn3+F+hMTyO2J0HbHwV QHRGVoMGD5z/RItUvfQfEf/iGvsuRO4/EGLswsgflsTtebGBOhsA8c2KiLd2vjw/UvQ7 TwCAMvtRLV+j2xZmoD8S7m8veb1zhuiVRW8YyBJUcydpVSbKjap2r4CRFdo/zil2htRY xo/jFaCdA0hZYy4pD9hLnmuy2JodFEv5UHHj651nfaXTKhkGnnW3y4RnREcyBvfNLrYQ TpAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b912E6Me; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fi25si8189333ejb.25.2020.04.16.03.06.53; Thu, 16 Apr 2020 03:07:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@redhat.com header.s=mimecast20190719 header.b=b912E6Me; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504704AbgDPKGV (ORCPT + 99 others); Thu, 16 Apr 2020 06:06:21 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:31810 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2504706AbgDPKGQ (ORCPT ); Thu, 16 Apr 2020 06:06:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587031573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=ATfoQl4JvbUU7lHAEAmxYMWCFvGqdCs55ii+BLfprRc=; b=b912E6MeGsO3eQgx38oHjYLMXjWSEakGfgdFRQMhboGTEpQ28WshD7T2uk7aNDhjuxepq+ HYFX+0w2UgzYHaqyMfZRiFPS97egngdL7o2U7nCKG5BnvoARwMKZ+bnZ0TcaGb04skx0eg NNqnmUr5l4MHrN4DZup1wEDRmsh1Sv0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-67-ZLOG4qF0OG6Cdf_mmu6tcA-1; Thu, 16 Apr 2020 06:06:12 -0400 X-MC-Unique: ZLOG4qF0OG6Cdf_mmu6tcA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47227802561 for ; Thu, 16 Apr 2020 10:06:10 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-89.rdu2.redhat.com [10.10.113.89]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D9212272A0; Thu, 16 Apr 2020 10:06:09 +0000 (UTC) From: Dave Wysochanski To: linux-nfs@vger.kernel.org Cc: dhowells@redhat.com Subject: [PATCH v2 3/3] NFSv4: Fix fscache cookie aux_data to ensure change_attr is included Date: Thu, 16 Apr 2020 06:06:08 -0400 Message-Id: <1587031568-32604-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- 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 f51718415606..a60df88efc40 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -225,6 +225,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. */ @@ -238,14 +251,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, @@ -265,11 +271,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; } @@ -309,11 +311,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); -- 1.8.3.1