[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240701152437.GE21023@twin.jikos.cz>
Date: Mon, 1 Jul 2024 17:24:37 +0200
From: David Sterba <dsterba@...e.cz>
To: Jeff Layton <jlayton@...nel.org>
Cc: Josef Bacik <josef@...icpanda.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Chandan Babu R <chandan.babu@...cle.com>,
"Darrick J. Wong" <djwong@...nel.org>,
Theodore Ts'o <tytso@....edu>,
Andreas Dilger <adilger.kernel@...ger.ca>, Chris Mason <clm@...com>,
David Sterba <dsterba@...e.com>, Hugh Dickins <hughd@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andi Kleen <ak@...ux.intel.com>, kernel-team@...com,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, linux-xfs@...r.kernel.org,
linux-ext4@...r.kernel.org, linux-btrfs@...r.kernel.org,
linux-mm@...ck.org, linux-nfs@...r.kernel.org
Subject: Re: [PATCH v2 09/11] btrfs: convert to multigrain timestamps
On Mon, Jul 01, 2024 at 09:57:43AM -0400, Jeff Layton wrote:
> On Mon, 2024-07-01 at 09:49 -0400, Josef Bacik wrote:
> > On Mon, Jul 01, 2024 at 06:26:45AM -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.
> > >
> > > Beyond enabling the FS_MGTIME flag, this patch eliminates
> > > update_time_for_write, which goes to great pains to avoid in-memory
> > > stores. Just have it overwrite the timestamps unconditionally.
> > >
> > > Signed-off-by: Jeff Layton <jlayton@...nel.org>
> > > ---
> > > fs/btrfs/file.c | 25 ++++---------------------
> > > fs/btrfs/super.c | 3 ++-
> > > 2 files changed, 6 insertions(+), 22 deletions(-)
> > >
> > > diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> > > index d90138683a0a..409628c0c3cc 100644
> > > --- a/fs/btrfs/file.c
> > > +++ b/fs/btrfs/file.c
> > > @@ -1120,26 +1120,6 @@ void btrfs_check_nocow_unlock(struct
> > > btrfs_inode *inode)
> > > btrfs_drew_write_unlock(&inode->root->snapshot_lock);
> > > }
> > >
> > > -static void update_time_for_write(struct inode *inode)
> > > -{
> > > - struct timespec64 now, ts;
> > > -
> > > - if (IS_NOCMTIME(inode))
> > > - return;
> > > -
> > > - now = current_time(inode);
> > > - ts = inode_get_mtime(inode);
> > > - if (!timespec64_equal(&ts, &now))
> > > - inode_set_mtime_to_ts(inode, now);
> > > -
> > > - ts = inode_get_ctime(inode);
> > > - if (!timespec64_equal(&ts, &now))
> > > - inode_set_ctime_to_ts(inode, now);
> > > -
> > > - if (IS_I_VERSION(inode))
> > > - inode_inc_iversion(inode);
> > > -}
> > > -
> > > static int btrfs_write_check(struct kiocb *iocb, struct iov_iter
> > > *from,
> > > size_t count)
> > > {
> > > @@ -1171,7 +1151,10 @@ static int btrfs_write_check(struct kiocb
> > > *iocb, struct iov_iter *from,
> > > * need to start yet another transaction to update the
> > > inode as we will
> > > * update the inode when we finish writing whatever data
> > > we write.
> > > */
> > > - update_time_for_write(inode);
> > > + if (!IS_NOCMTIME(inode)) {
> > > + inode_set_mtime_to_ts(inode,
> > > inode_set_ctime_current(inode));
> > > + inode_inc_iversion(inode);
> >
> > You've dropped the
> >
> > if (IS_I_VERSION(inode))
> >
> > check here, and it doesn't appear to be in inode_inc_iversion. Is
> > there a
> > reason for this? Thanks,
> >
>
> AFAICT, btrfs always sets SB_I_VERSION. Are there any cases where it
> isn't? If so, then I can put this check back. I'll make a note about it
> in the changelog if not.
Yes it's always set and I don't see anything in the generic code that
would unset it so it's safe to drop the IS_I_VERSION check.
The check was originally added in November 2012 by 6c760c072403f4
("Btrfs: do not call file_update_time in aio_write") and then moved a
few times. Enabling the super block flags was added in May 2012 by
0c4d2d95d06e92 ("Btrfs: use i_version instead of our own sequence") so
the check was not necessary from the beginning.
Powered by blists - more mailing lists