Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1626950pxb; Fri, 20 Nov 2020 14:40:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3UtBoInDGN27I+iqxGOwgYXY4SDHijnpJEc/XkZ6lr6eT/W/cpoXmsDGwftupJMWUMhTD X-Received: by 2002:a17:906:af47:: with SMTP id ly7mr36656185ejb.532.1605912042403; Fri, 20 Nov 2020 14:40:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605912042; cv=none; d=google.com; s=arc-20160816; b=I1GDo7SRxPcyv7y2ajfp9EJ2TUWf2ZfS/V9o+drOPrFs5DGIkTeFm/O1+od8lMyAAp OEccTSypKAnPi3ThTpRpWHQ95y1an+NPRojX9OyahisRKv+aeoYD+1Mi9T6Ok50Nn/aE Umxq7TTvqU8Xh9MLfOFnPmVFINrECXZC3THgkMxtsdndSCwa+7+ipCdj+fBLAFc/iPQG bQ65fP0gHFnocLE44oPuM5lrhMPpGFhFhAa9XCCcyKr4gRNmYYOsIMvHPDefef4BjOuq jB7wipXHatTgLPXP0cbcm2HYR7sl96rqN3VAPbNnbI5mE017ywZT4nZCN5dLf37+JnCH D88g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-filter; bh=ikJtujSxmvyE/EKeFp4r86OIfHI4q0JMAPDEoom6wkw=; b=DWqLaf6j1NEyBLUugGyzX/EkPrL+5EeG676YSvLti5Xb0D5Z5Wfs9kOKypVUyRmboq wkUcbKf+B/HwDX/w7qi0/iH+m55wPlaZZw8aEkPZU8bTpC/B++bOU32COBskqMBui11L +C4f9mXyzNg3ogpKmGQ9cwB2zgO4ZJ86i0NFsk7fVf6hBPfCx2knoL0BaFf87zAis10z YuobMl5/33D+RXlo2l8YWzho9QEcIYjRVUgEKZpleAwk9IfYHcCVpQyQuiAqcM9iouF9 Yx+9Wjjx5hFpbIjF/jufshq3+f/b9+EZ2TR06DC94cu7MyD9/3omZbXoWPAF/Xph+vzh 0iww== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 gn19si2584523ejc.336.2020.11.20.14.40.19; Fri, 20 Nov 2020 14:40:42 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728886AbgKTWjY (ORCPT + 99 others); Fri, 20 Nov 2020 17:39:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728891AbgKTWjX (ORCPT ); Fri, 20 Nov 2020 17:39:23 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7625C061A49 for ; Fri, 20 Nov 2020 14:39:22 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id 3CAF76E9D; Fri, 20 Nov 2020 17:39:22 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 3CAF76E9D From: "J. Bruce Fields" To: Jeff Layton Cc: Daire Byrne , Trond Myklebust , linux-cachefs , linux-nfs , "J. Bruce Fields" Subject: [PATCH 5/8] nfs: use change attribute for NFS re-exports Date: Fri, 20 Nov 2020 17:39:17 -0500 Message-Id: <1605911960-12516-5-git-send-email-bfields@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1605911960-12516-1-git-send-email-bfields@redhat.com> References: <20201120223831.GB7705@fieldses.org> <1605911960-12516-1-git-send-email-bfields@redhat.com> 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 3430d6891e89..0b10c5946060 100644 --- a/fs/nfs/export.c +++ b/fs/nfs/export.c @@ -167,8 +167,26 @@ 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, }; diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h index 45bd776290d5..2656a3464c6c 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) { @@ -259,7 +260,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 3ceb72b67a7a..da6f0a905b94 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 *); }; extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid, -- 2.28.0