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 5594DC3DA41 for ; Mon, 8 Jul 2024 19:01:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5B3F6B00A1; Mon, 8 Jul 2024 15:01:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0B786B00A2; Mon, 8 Jul 2024 15:01:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD45F6B00A3; Mon, 8 Jul 2024 15:01:49 -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 A8C7B6B00A1 for ; Mon, 8 Jul 2024 15:01:49 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 34D321A14BD for ; Mon, 8 Jul 2024 19:01:49 +0000 (UTC) X-FDA: 82317504738.13.118A345 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 6DD7C1C0027 for ; Mon, 8 Jul 2024 19:01:47 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="iqkkvI/h"; spf=pass (imf18.hostedemail.com: domain of djwong@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=djwong@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720465292; a=rsa-sha256; cv=none; b=gRdkgSVnGb9a5XaeY1EukQBKfoQ3FaeZ7xJrxFByViO+FzahsNtkAWnMatJ0xMn4072MWE BAi+1nlCXsUSrO2oQfh0TtKxmjd7oaNmS43K9FDiobJuhK8jZnJYDpDrukSwZ2Ybu3wTEN /mD/B0cgmzbNJ9kARQ9PXNUa1qO03NE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="iqkkvI/h"; spf=pass (imf18.hostedemail.com: domain of djwong@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=djwong@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=1720465292; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TTClWkIZXG/CANL3V/DwMOSIlcffHLF3+wd6eD6ebeY=; b=XhFXkzlvZ8sDvP9IVDSOL+rZ7O/WoVcopdKgSBGX6Baql1U3qQi/Nuht+KMGXj8/hRSFlU yX4CwO3GbJYaDQQHRNMWBOd2O5t3evKPve2vYQEzkYt7WSWimGTdH+53ncP4J9UOf1QcIK x2x3JTvBHkApLPIO7hbMH33PMld2KgE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6A30660FBD; Mon, 8 Jul 2024 19:01:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14F6DC116B1; Mon, 8 Jul 2024 19:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720465306; bh=1hW/kypdr+uaGZf3TpRDZkCzjeuosv/ANU6YTGTLXeI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iqkkvI/hBM0I8W+ZlvH3nLQoPJO9QM8LmBrpuyAneOgy7NF+RSRTyrPIWVCAxl5OK Qj7h38Si0auCjMoYaBibCpq8aDetMl4COkWD0P6xktZmsKwRtdqJ2x55/O2ja9TXot SLWLacZcZ+Ayzt6msQoyxlKdrXzStPcaO4ML88Q1wl5xuA1dOmXa1k4i3ZjM9ak3fT Q4fOFD8pQY0YtIHBbyjIuL67+JTPJXsN6RpcsGvIOgkW1o/JtRgcMxa6vARj9gM0RD eGE9ck/XLn75yxhkgIqQ1RohuU0oxUUxLiizAAfuEVRq0M3xm29w8uUJ17fmIRfiEP EsVzG2aeV0ySQ== Date: Mon, 8 Jul 2024 12:01:45 -0700 From: "Darrick J. Wong" To: Jeff Layton Cc: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet , Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v4 6/9] xfs: switch to multigrain timestamps Message-ID: <20240708190145.GR612460@frogsfrogsfrogs> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> <20240708-mgtime-v4-6-a0f3c6fb57f3@kernel.org> <20240708184739.GP612460@frogsfrogsfrogs> <28e7a6c193674f2aa41ab1eec9bb8747ddba1a4c.camel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <28e7a6c193674f2aa41ab1eec9bb8747ddba1a4c.camel@kernel.org> X-Stat-Signature: f7nk16goqcc3781cpb7t1pccywq6mbnr X-Rspamd-Queue-Id: 6DD7C1C0027 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1720465307-719739 X-HE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m+maiZW4JimRdMQSAl7m2Yofn4eZz7GHUTVERFVq3RjJssLBej7DL9moGZO6b7cV7r1VLZ5U52v5BePiX19rtC4kUohx8yMt775vc1NuqxMET/Jt64/twwHchfD62eG7n5NIsnktF7ycsutJrmRyHs3acM1IzPqKxHso5/OFV1ZpwoXCCw== 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: List-Subscribe: List-Unsubscribe: On Mon, Jul 08, 2024 at 02:51:07PM -0400, Jeff Layton wrote: > On Mon, 2024-07-08 at 11:47 -0700, Darrick J. Wong wrote: > > On Mon, Jul 08, 2024 at 11:53:39AM -0400, Jeff Layton wrote: > > > Enable multigrain timestamps, which should ensure that there is an > > > apparent change to the timestamp whenever it has been written after > > > being actively observed via getattr. > > > > > > Also, anytime the mtime changes, the ctime must also change, and those > > > are now the only two options for xfs_trans_ichgtime. Have that function > > > unconditionally bump the ctime, and ASSERT that XFS_ICHGTIME_CHG is > > > always set. > > > > > > Finally, stop setting STATX_CHANGE_COOKIE in getattr, since the ctime > > > should give us better semantics now. > > > > > > Signed-off-by: Jeff Layton > > > --- > > > fs/xfs/libxfs/xfs_trans_inode.c | 6 +++--- > > > fs/xfs/xfs_iops.c | 10 +++------- > > > fs/xfs/xfs_super.c | 2 +- > > > 3 files changed, 7 insertions(+), 11 deletions(-) > > > > > > diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c > > > index 69fc5b981352..1f3639bbf5f0 100644 > > > --- a/fs/xfs/libxfs/xfs_trans_inode.c > > > +++ b/fs/xfs/libxfs/xfs_trans_inode.c > > > @@ -62,12 +62,12 @@ xfs_trans_ichgtime( > > > ASSERT(tp); > > > xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); > > > > > > - tv = current_time(inode); > > > + /* If the mtime changes, then ctime must also change */ > > > + ASSERT(flags & XFS_ICHGTIME_CHG); > > > > > > + tv = inode_set_ctime_current(inode); > > > if (flags & XFS_ICHGTIME_MOD) > > > inode_set_mtime_to_ts(inode, tv); > > > - if (flags & XFS_ICHGTIME_CHG) > > > - inode_set_ctime_to_ts(inode, tv); > > > if (flags & XFS_ICHGTIME_CREATE) > > > ip->i_crtime = tv; > > > } > > > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c > > > index a00dcbc77e12..d25872f818fa 100644 > > > --- a/fs/xfs/xfs_iops.c > > > +++ b/fs/xfs/xfs_iops.c > > > @@ -592,8 +592,9 @@ xfs_vn_getattr( > > > stat->gid = vfsgid_into_kgid(vfsgid); > > > stat->ino = ip->i_ino; > > > stat->atime = inode_get_atime(inode); > > > - stat->mtime = inode_get_mtime(inode); > > > - stat->ctime = inode_get_ctime(inode); > > > + > > > + fill_mg_cmtime(stat, request_mask, inode); > > > > Sooo... for setting up a commit-range operation[1], XFS_IOC_START_COMMIT > > could populate its freshness data by calling: > > > > struct kstat dummy; > > > > fill_mg_ctime(&dummy, STATX_CTIME | STATX_MTIME, inode); > > > > and then using dummy.[cm]time to populate the freshness data that it > > gives to userspace, right? Having set QUERIED, a write to the file > > immediately afterwards will cause a (tiny) increase in ctime_nsec which > > will cause the XFS_IOC_COMMIT_RANGE to reject the commit[2]. Right? > > > > Yes. Once you call fill_mg_ctime, the first write after that point > should cause the kernel to ensure that there is a distinct change in > the ctime. > > IOW, I think this should alleviate the concerns I had before with using > timestamps with the XFS_IOC_COMMIT_RANGE interface. Cool, thank you! Apologies for roaring earlier. --D > > --D > > > > [1] https://lore.kernel.org/linux-xfs/20240227174649.GL6184@frogsfrogsfrogs/ > > [2] https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/commit/?h=atomic-file-commits&id=0520d89c2698874c1f56ddf52ec4b8a3595baa14 > > > > > + > > > stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks); > > > > > > if (xfs_has_v3inodes(mp)) { > > > @@ -603,11 +604,6 @@ xfs_vn_getattr( > > > } > > > } > > > > > > - if ((request_mask & STATX_CHANGE_COOKIE) && IS_I_VERSION(inode)) { > > > - stat->change_cookie = inode_query_iversion(inode); > > > - stat->result_mask |= STATX_CHANGE_COOKIE; > > > - } > > > - > > > /* > > > * Note: If you add another clause to set an attribute flag, please > > > * update attributes_mask below. > > > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c > > > index 27e9f749c4c7..210481b03fdb 100644 > > > --- a/fs/xfs/xfs_super.c > > > +++ b/fs/xfs/xfs_super.c > > > @@ -2052,7 +2052,7 @@ static struct file_system_type xfs_fs_type = { > > > .init_fs_context = xfs_init_fs_context, > > > .parameters = xfs_fs_parameters, > > > .kill_sb = xfs_kill_sb, > > > - .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, > > > + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP | FS_MGTIME, > > > }; > > > MODULE_ALIAS_FS("xfs"); > > > > > > > > > -- > > > 2.45.2 > > > > > > > > -- > Jeff Layton >