Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2044200pxb; Fri, 29 Jan 2021 11:29:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFJ56aVVZ+IHFLa74Pdc8PXk6k3IOtNYW6ci2G9FDbeEA00G2KZERqrHLrXRgmATxc4cyh X-Received: by 2002:a17:906:b757:: with SMTP id fx23mr6171633ejb.273.1611948552910; Fri, 29 Jan 2021 11:29:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611948552; cv=none; d=google.com; s=arc-20160816; b=KC2osGyChVhdqXvA5HtYwCMAxWJgkf7T5NosC0r56W9TLuQha8kvHQCQiTOUOuNBj5 XFfm5e7ElK9ciMRFN+r3eLe5wr/bCvp7hLVUBpmLQ6TkyA9HXYGPAZHWgdcpeMDkbxJ1 b0mxwk0ZMGFNWI/igFOx0ZjiXEC8gVoJXw2vhzu/vWIo3XeMSHrTQrvUDBGGt22kgnpL /LtgNoSRamAh/cVEfqH4fAJGHv54SURxb8gfrRWQodohno1vm/KbtaB9WeuVzggQWtLW qaIYLl4m43KC7GIM84e3OZ2rmoksk8dcxUt2Ydi9irHTMH2lYnmKdz+3NqUir0yvKc5o 1LSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:from:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date :dkim-signature:dkim-filter; bh=IKc4YVXlVWfq6OM6YgIY+dz4pchSgHfEqRNyoKpUKQA=; b=JumuyAnEyFVXcYkpg7lTpCjcWcDpj+fDTk4tDk7iqCKeJjoLQdWjqou302VDvBW00/ IID1v4XJIR7vMLZquldJDvP0LS1CJk6GdLUOglnNOQ1uBpkBmmLRJH6qoDTv0iDwoJdx q3USfjCF5543/CV1WeFI1JlHg9FgbNSPypQ2EkjLzUm3nHQLD9btGqFWXPLLpJ7TFA/3 2QNgsibkQund9b//ZnACBLEJp2OoX+9I+PsweNcjyRNuwlefR4GsVVP6IZMGMX/3WEkI VMA7woQvOhqZT/5rPSfpA5vQVAH7ZoYBBzY+tHopi6C+Nx79W4269hIK2Mn2HtuNXQcO QWFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=BhvXmL6y; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k26si6372661eds.217.2021.01.29.11.28.49; Fri, 29 Jan 2021 11:29:12 -0800 (PST) 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=@fieldses.org header.s=default header.b=BhvXmL6y; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232878AbhA2T1M (ORCPT + 99 others); Fri, 29 Jan 2021 14:27:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232855AbhA2T1K (ORCPT ); Fri, 29 Jan 2021 14:27:10 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5285EC061573; Fri, 29 Jan 2021 11:26:30 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id B520B4163; Fri, 29 Jan 2021 14:26:29 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org B520B4163 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1611948389; bh=IKc4YVXlVWfq6OM6YgIY+dz4pchSgHfEqRNyoKpUKQA=; h=Date:To:Cc:Subject:References:In-Reply-To:From:From; b=BhvXmL6yOG+7ocg5WqrxnR+u+TZp1aJVeaGF0bUkRkz0gwoEiLtJJnm2dhJ1g4jl3 GyFQAgoa6KROzYTJDR5j9zgHjNdSVwP750a/lGfRz7ri6+XrJbBzJGVTjcwqoaaM4o 2HfJN7pkyKwKa+VZRFVzdU/8TT+61gbkA2/Gdmcw= Date: Fri, 29 Jan 2021 14:26:29 -0500 To: Christoph Hellwig Cc: "J. Bruce Fields" , linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Trond Myklebust , Anna Schumaker , Chuck Lever Subject: [PATCH 1/2 v2] nfs: use change attribute for NFS re-exports Message-ID: <20210129192629.GC8033@fieldses.org> References: <1611084297-27352-1-git-send-email-bfields@redhat.com> <1611084297-27352-3-git-send-email-bfields@redhat.com> <20210120084638.GA3678536@infradead.org> <20210121202756.GA13298@pick.fieldses.org> <20210122082059.GA119852@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210122082059.GA119852@infradead.org> User-Agent: Mutt/1.5.21 (2010-09-15) From: bfields@fieldses.org (J. Bruce Fields) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: "J. Bruce Fields" When exporting NFS, we may as well use the real change attribute returned by the original server instead of faking up a change attribute from the ctime. Note we can't do that by setting I_VERSION--that would also turn on the logic in iversion.h which treats the lower bit specially, and that doesn't make sense for NFS. So instead we define a new export operation for filesystems like NFS that want to manage the change attribute themselves. Signed-off-by: J. Bruce Fields --- fs/nfs/export.c | 18 ++++++++++++++++++ fs/nfsd/nfsfh.h | 5 ++++- include/linux/exportfs.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/fs/nfs/export.c b/fs/nfs/export.c index 7412bb164fa7..f2b34cfe286c 100644 --- a/fs/nfs/export.c +++ b/fs/nfs/export.c @@ -167,10 +167,28 @@ nfs_get_parent(struct dentry *dentry) return parent; } +static u64 nfs_fetch_iversion(struct inode *inode) +{ + struct nfs_server *server = NFS_SERVER(inode); + + /* Is this the right call?: */ + nfs_revalidate_inode(server, inode); + /* + * Also, note we're ignoring any returned error. That seems to be + * the practice for cache consistency information elsewhere in + * the server, but I'm not sure why. + */ + if (server->nfs_client->rpc_ops->version >= 4) + return inode_peek_iversion_raw(inode); + else + return time_to_chattr(&inode->i_ctime); +} + const struct export_operations nfs_export_ops = { .encode_fh = nfs_encode_fh, .fh_to_dentry = nfs_fh_to_dentry, .get_parent = nfs_get_parent, + .fetch_iversion = nfs_fetch_iversion, .flags = EXPORT_OP_NOWCC|EXPORT_OP_NOSUBTREECHK| EXPORT_OP_CLOSE_BEFORE_UNLINK|EXPORT_OP_REMOTE_FS| EXPORT_OP_NOATOMIC_ATTR, diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h index cb20c2cd3469..f58933519f38 100644 --- a/fs/nfsd/nfsfh.h +++ b/fs/nfsd/nfsfh.h @@ -12,6 +12,7 @@ #include #include #include +#include static inline __u32 ino_t_to_u32(ino_t ino) { @@ -264,7 +265,9 @@ fh_clear_wcc(struct svc_fh *fhp) static inline u64 nfsd4_change_attribute(struct kstat *stat, struct inode *inode) { - if (IS_I_VERSION(inode)) { + if (inode->i_sb->s_export_op->fetch_iversion) + return inode->i_sb->s_export_op->fetch_iversion(inode); + else if (IS_I_VERSION(inode)) { u64 chattr; chattr = stat->ctime.tv_sec; diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h index 9f4d4bcbf251..fe848901fcc3 100644 --- a/include/linux/exportfs.h +++ b/include/linux/exportfs.h @@ -213,6 +213,7 @@ struct export_operations { bool write, u32 *device_generation); int (*commit_blocks)(struct inode *inode, struct iomap *iomaps, int nr_iomaps, struct iattr *iattr); + u64 (*fetch_iversion)(struct inode *); #define EXPORT_OP_NOWCC (0x1) /* don't collect v3 wcc data */ #define EXPORT_OP_NOSUBTREECHK (0x2) /* no subtree checking */ #define EXPORT_OP_CLOSE_BEFORE_UNLINK (0x4) /* close files before unlink */ -- 2.29.2