Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1698564pxb; Fri, 20 Nov 2020 17:02:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJtdg6n5XQV8E6sWZnZ6uE2NmDakNqywzEoS6BOUz1D9TJulT2EYt+OxQaRy0dDqB4yCRB X-Received: by 2002:a17:906:ad8e:: with SMTP id la14mr31307000ejb.264.1605920568718; Fri, 20 Nov 2020 17:02:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605920568; cv=none; d=google.com; s=arc-20160816; b=R1juVTxAun6PNZ5GuaZg2b2O/1tovxPdd8hI/CeBAmrzMNIxoEOlTw03jA9t/9LEiW nUNdvmCPOzWwSiLoz5aiMGU7cViPpt/RY+G+NZJHvF/dsoAeb+/+iYnRdjIkVxiyUYBs sAjlBT1JZrTjWBVJxb5bsMEc1Q9mVw1b8891E98xzA1iDfGo6+La36Zwnl7kEdNw9gdC zC1t5a1c8t0Z9moOPEvTv2Buca/GUO7p1c/2bK1t4+ZSwRsbk/D+/Dwrf0CUSagyZblj 6+wPWlQLb1DanKFvLdkp0j1xu7yEonOeeTK5pVwXrhKHG5c5te1eTHbA+TyML6t+zs8K PBqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=13JX49lgMqG7h+XNqlVi/YgKnlesi9HqI9UIEURl69Q=; b=gE4kn6iTqKxVTazS0RHA2PRKPNXdxZ/S7Bptl+gSN3/vrcN6/MH4Bqpj+MvwrXY4/7 KbmVBEmynCNFWMLqoMN8baXeyNt4MWU8o9gYmPfKOBpM9pCf9ZOQkFdvzEDIgVOM+LAf vB497G3AmpxRtMzbkCf2ijjJjAQvJTmsNW3OqCZfQMIJB+WxS+ut9Cl46L6KOwnti6m6 wrjgswoytbXfMt9pitavSepuY72cKFL5DP9UJdL4uZfSuJfjdepLj1NXis4ObMBjYRCM I2ZbXW9NAYdrgoRfXbqVTrpe/mjbtdvO/Jf8DG/AKqrDK8zbIE9Ve5aBMj8pDLIhi2++ pJRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cYnfzFxQ; 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 u1si2830747edb.36.2020.11.20.17.02.26; Fri, 20 Nov 2020 17:02:48 -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=@redhat.com header.s=mimecast20190719 header.b=cYnfzFxQ; 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 S1727367AbgKUBBl (ORCPT + 99 others); Fri, 20 Nov 2020 20:01:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22386 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727163AbgKUBBl (ORCPT ); Fri, 20 Nov 2020 20:01:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605920500; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=13JX49lgMqG7h+XNqlVi/YgKnlesi9HqI9UIEURl69Q=; b=cYnfzFxQ8J+AjiXwUG30Scd1rN3mbEd+oTPOuCwlUGKkCtGdUcr7FVCgs3557cpOPN/tdH xfJ/FzKUiuu9GASX2OGpVDnzNDXEeZivIcs9STJoZTHOqMvrsgpIZxsqmAoG+3j7SXpnpe 40W6MjdNxM13k60mpYdAHxLPCPiB7jY= 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-424-XIs8jj_FOI29uYl3U4sXIw-1; Fri, 20 Nov 2020 20:01:35 -0500 X-MC-Unique: XIs8jj_FOI29uYl3U4sXIw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D21010059A4; Sat, 21 Nov 2020 01:01:34 +0000 (UTC) Received: from pick.fieldses.org (ovpn-113-103.rdu2.redhat.com [10.10.113.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CDBC60853; Sat, 21 Nov 2020 01:01:29 +0000 (UTC) Received: by pick.fieldses.org (Postfix, from userid 2815) id 6559F12033D; Fri, 20 Nov 2020 20:01:28 -0500 (EST) Date: Fri, 20 Nov 2020 20:01:28 -0500 From: "J. Bruce Fields" To: Jeff Layton Cc: Daire Byrne , Trond Myklebust , linux-cachefs , linux-nfs Subject: Re: [PATCH 6/8] nfsd: move change attribute generation to filesystem Message-ID: <20201121010128.GK136478@pick.fieldses.org> References: <20201120223831.GB7705@fieldses.org> <1605911960-12516-1-git-send-email-bfields@redhat.com> <1605911960-12516-6-git-send-email-bfields@redhat.com> <6c2bb6ae1ad586d6bf369afe561b77b271cd2ac8.camel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6c2bb6ae1ad586d6bf369afe561b77b271cd2ac8.camel@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Nov 20, 2020 at 07:58:38PM -0500, Jeff Layton wrote: > On Fri, 2020-11-20 at 17:39 -0500, J. Bruce Fields wrote: > > diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c > > index 465fd9e048d4..b950fac3d7df 100644 > > --- a/fs/xfs/xfs_export.c > > +++ b/fs/xfs/xfs_export.c > > @@ -16,6 +16,7 @@ > > ?#include "xfs_inode_item.h" > > ?#include "xfs_icache.h" > > ?#include "xfs_pnfs.h" > > +#include > > ? > > > > > > > > ?/* > > ??* Note that we only accept fileids which are long enough rather than allow > > @@ -234,4 +235,5 @@ const struct export_operations xfs_export_operations = { > > ? .map_blocks = xfs_fs_map_blocks, > > ? .commit_blocks = xfs_fs_commit_blocks, > > ?#endif > > + .fetch_iversion = generic_fetch_iversion, > > ?}; > > It seems a little weird to call a static inline here. I imagine that > means the compiler has to add a duplicate inline in every .o file that > does this? It may be cleaner to move generic_fetch_iversion into > fs/libfs.c so we only have one copy of it. OK. (To be honest, I was a little suprised this worked.) --b. > > > diff --git a/include/linux/iversion.h b/include/linux/iversion.h > > index 3bfebde5a1a6..ded74523c8a6 100644 > > --- a/include/linux/iversion.h > > +++ b/include/linux/iversion.h > > @@ -328,6 +328,32 @@ inode_query_iversion(struct inode *inode) > > ? return cur >> I_VERSION_QUERIED_SHIFT; > > ?} > > ? > > > > > > > > +/* > > + * We could use i_version alone as the NFSv4 change attribute. However, > > + * i_version can go backwards after a reboot. On its own that doesn't > > + * necessarily cause a problem, but if i_version goes backwards and then > > + * is incremented again it could reuse a value that was previously used > > + * before boot, and a client who queried the two values might > > + * incorrectly assume nothing changed. > > + * > > + * By using both ctime and the i_version counter we guarantee that as > > + * long as time doesn't go backwards we never reuse an old value. > > + * > > + * A filesystem that has an on-disk boot counter or similar might prefer > > + * to use that to avoid the risk of the change attribute going backwards > > + * if system time is set backwards. > > + */ > > +static inline u64 generic_fetch_iversion(struct inode *inode) > > +{ > > + u64 chattr; > > + > > + chattr = inode->i_ctime.tv_sec; > > + chattr <<= 30; > > + chattr += inode->i_ctime.tv_nsec; > > + chattr += inode_query_iversion(inode); > > + return chattr; > > +} > > + > > ?/* > > ??* For filesystems without any sort of change attribute, the best we can > > ??* do is fake one up from the ctime: > > -- > Jeff Layton >