From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6AA7C76196 for ; Tue, 11 Apr 2023 16:05:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 553B7900003; Tue, 11 Apr 2023 12:05:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 503D7900002; Tue, 11 Apr 2023 12:05:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CB96900003; Tue, 11 Apr 2023 12:05:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2E6FB900002 for ; Tue, 11 Apr 2023 12:05:59 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D4FD5160E85 for ; Tue, 11 Apr 2023 16:05:58 +0000 (UTC) X-FDA: 80669586396.05.11D1BA0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id B6D9C140020 for ; Tue, 11 Apr 2023 16:05:56 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nVHHH8o0; spf=pass (imf23.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681229156; h=from:from:sender: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:dkim-signature; bh=ICN3trb3ZDK9bKM4mdKX9DiZTIBziWitxqAI6VdxcR0=; b=eYtjDeWWm2bgRpggdlZXQZORjuxNvBSalbyCGXgZNtvJn5jqiC8Nx7X6BWhmbgdxJ9SCUW OBj+Q2e2JXUDaXLcCwIjWXU96QYWkfIbrxeNXIY2CCtpVaqG/F1+2nfVXgbe0FaXJ0gujJ dQu1Lvfc09gsCqunEKGCWA531qKHemo= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nVHHH8o0; spf=pass (imf23.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681229156; a=rsa-sha256; cv=none; b=XZkmavbd1Xl9unbFM6hYlp3m6gL11tfb6d1///otlvRLy4ikqsY9DKIQeLlGi47Q/UyANc zVObbkBNi4J8vKqS+DR7Zg9QPLB92bIIVKAurphxwDrprAYPT6rFMI6g01q034MomHqYFT cUTQGvMP95EMSfPZmvvjt3Kjej+bNjA= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C6D7460EF6; Tue, 11 Apr 2023 16:05:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DF29C433D2; Tue, 11 Apr 2023 16:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681229155; bh=UhFoUimr4E+kAi0DTUaR5SoiaG0yY7YeJ3s83ABlPnQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=nVHHH8o0xPJq3ovnT8qOLgkdAJT0eGwj7204IcQReuHJUxFDmZSnpzWlND2AN9VJU jmwrxXEDH2imFkbD15V0MPXftO/lYyKYP1UL7FmSMg7no9sfktv/J+dPC6MZ+doXrE yWXGYepApuc5EVf/kWle73g3/BRlXoyYy+owZ8FshA5fPAA/YbrNWrJKucvhoK0cPd E165ccN5qTL3WOvznEghkExgz3Km0sBIlWOC+T/KuyNEcLmu94LKQd0wNf/TWesFNa duT/U4f5jfC+15OQWIq3TggvEqWRufuRLxKXDoihphRJ95cFNqNU2z1eTShuUfpZWn 5n9mpRfskTB1w== Message-ID: <2ce237b80e2b134d86042f69e6857dcb8ae53629.camel@kernel.org> Subject: Re: [RFC PATCH 3/3][RESEND] xfs: mark the inode for high-res timestamp update in getattr From: Jeff Layton To: Christian Brauner , "Darrick J. Wong" Cc: Alexander Viro , Hugh Dickins , Andrew Morton , Dave Chinner , Chuck Lever , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Date: Tue, 11 Apr 2023 12:05:52 -0400 In-Reply-To: <20230411-schokolade-hegemonie-83b1f0ecfd6c@brauner> References: <20230411143702.64495-1-jlayton@kernel.org> <20230411143702.64495-4-jlayton@kernel.org> <20230411145446.GG360895@frogsfrogsfrogs> <20230411-schokolade-hegemonie-83b1f0ecfd6c@brauner> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B6D9C140020 X-Stat-Signature: ffdxe9u8d1gamszgdoqkd5qcxs7f17hr X-Rspam-User: X-HE-Tag: 1681229156-264577 X-HE-Meta: U2FsdGVkX1843EzJ4CzZl/MiR113Dn/udCFCVKUaP1MJQhrkp/MZ89fx7bx6V0sBWeqlaXUPdcIWXnrS5hQFoIyT8lskdkBUbXwMRnHHlw69TnHLrWAvg9tfCTC3Ms1ZkWdctwBdv9C+0sSj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/x/ixOPpQ0AD28XnPHnpqbvf5ZyrH8cOPgbvijJg1SNpeN7L/6gsVSlDt8k4gvWza+PigF93dnBA740mU1viDRnZMG2THT5YVoSMdwEY8HLggwGCrnI5EGtJQXcAOhguOdhbwrhzyKsiI8gYQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 2023-04-11 at 17:15 +0200, Christian Brauner wrote: > On Tue, Apr 11, 2023 at 07:54:46AM -0700, Darrick J. Wong wrote: > > On Tue, Apr 11, 2023 at 10:37:02AM -0400, Jeff Layton wrote: > > > When the mtime or ctime is being queried via getattr, ensure that we > > > mark the inode for a high-res timestamp update on the next pass. Also= , > > > switch to current_cmtime for other c/mtime updates. > > >=20 > > > With this change, we're better off having the NFS server just ignore > > > the i_version field and have it use the ctime instead, so clear the > > > STATX_CHANGE_COOKIE flag in the result mask in ->getattr. > > >=20 > > > Signed-off-by: Jeff Layton > > > --- > > > fs/xfs/libxfs/xfs_trans_inode.c | 2 +- > > > fs/xfs/xfs_acl.c | 2 +- > > > fs/xfs/xfs_inode.c | 2 +- > > > fs/xfs/xfs_iops.c | 15 ++++++++++++--- > > > 4 files changed, 15 insertions(+), 6 deletions(-) > > >=20 > > > diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_tran= s_inode.c > > > index 8b5547073379..9ad7c229c617 100644 > > > --- a/fs/xfs/libxfs/xfs_trans_inode.c > > > +++ b/fs/xfs/libxfs/xfs_trans_inode.c > > > @@ -63,7 +63,7 @@ xfs_trans_ichgtime( > > > ASSERT(tp); > > > ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); > > > =20 > > > - tv =3D current_time(inode); > > > + tv =3D current_cmtime(inode); > > > =20 > > > if (flags & XFS_ICHGTIME_MOD) > > > inode->i_mtime =3D tv; > > > diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c > > > index 791db7d9c849..461adc58cf8c 100644 > > > --- a/fs/xfs/xfs_acl.c > > > +++ b/fs/xfs/xfs_acl.c > > > @@ -233,7 +233,7 @@ xfs_acl_set_mode( > > > xfs_ilock(ip, XFS_ILOCK_EXCL); > > > xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); > > > inode->i_mode =3D mode; > > > - inode->i_ctime =3D current_time(inode); > > > + inode->i_ctime =3D current_cmtime(inode); > >=20 > > Hmm, now we're adding a spinlock to all these updates. > > Does lockdep have anything exciting to say about this? > >=20 > > (I don't think it will, just wondering aloud...) > >=20 > > > xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); > > > =20 > > > if (xfs_has_wsync(mp)) > > > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c > > > index 5808abab786c..80f9d731e261 100644 > > > --- a/fs/xfs/xfs_inode.c > > > +++ b/fs/xfs/xfs_inode.c > > > @@ -843,7 +843,7 @@ xfs_init_new_inode( > > > ip->i_df.if_nextents =3D 0; > > > ASSERT(ip->i_nblocks =3D=3D 0); > > > =20 > > > - tv =3D current_time(inode); > > > + tv =3D current_cmtime(inode); > > > inode->i_mtime =3D tv; > > > inode->i_atime =3D tv; > > > inode->i_ctime =3D tv; > > > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c > > > index 24718adb3c16..a0b07f90e16c 100644 > > > --- a/fs/xfs/xfs_iops.c > > > +++ b/fs/xfs/xfs_iops.c > > > @@ -565,6 +565,15 @@ xfs_vn_getattr( > > > if (xfs_is_shutdown(mp)) > > > return -EIO; > > > =20 > > > + /* > > > + * XFS uses the i_version infrastructure to track any change to > > > + * the inode, including atime updates. This means that the i_versio= n > > > + * returned by getattr doesn't conform to what the callers expect. > > > + * Clear it here so that nfsd will fake up a change cookie from the > > > + * ctime instead. > > > + */ > > > + stat->result_mask &=3D ~STATX_CHANGE_COOKIE; > > > + > > > stat->size =3D XFS_ISIZE(ip); > > > stat->dev =3D inode->i_sb->s_dev; > > > stat->mode =3D inode->i_mode; > > > @@ -573,8 +582,8 @@ xfs_vn_getattr( > > > stat->gid =3D vfsgid_into_kgid(vfsgid); > > > stat->ino =3D ip->i_ino; > > > stat->atime =3D inode->i_atime; > > > - stat->mtime =3D inode->i_mtime; > > > - stat->ctime =3D inode->i_ctime; > > > + if (request_mask & (STATX_CTIME|STATX_MTIME)) > > > + fill_cmtime_and_mark(inode, stat); > >=20 > > Should we be setting STATX_[CM]TIME in the result_mask, just in case th= e > > caller asked for ctime and not mtime? >=20 > I think the expectation is that everything in STATX_BASIC_MASK is always > returned to allow equivalence between stat() and statx(). So requesting > STATX_CTIME separately from STATX_MTIME isn't implemented widely, maybe > even not at atll?, yet. Right. Probably we ought to be more selective with how the result_mask gets set in vfs_getattr_nosec. Applications that use statx() effectively are still pretty rare, so most calls will fetch both times anyway. --=20 Jeff Layton