[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240907-rekonstruieren-gejagt-06d24089f842@brauner>
Date: Sat, 7 Sep 2024 12:21:38 +0200
From: Christian Brauner <brauner@...nel.org>
To: Jeff Layton <jlayton@...nel.org>
Cc: Chuck Lever <chuck.lever@...cle.com>, Neil Brown <neilb@...e.de>,
Olga Kornievskaia <okorniev@...hat.com>, Dai Ngo <Dai.Ngo@...cle.com>, Tom Talpey <tom@...pey.com>,
Trond Myklebust <trondmy@...nel.org>, Anna Schumaker <anna@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>, Jan Kara <jack@...e.cz>, Tom Haynes <loghyr@...il.com>,
linux-nfs@...r.kernel.org, linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH v4 09/11] fs: handle delegated timestamps in
setattr_copy_mgtime
On Thu, Sep 05, 2024 at 01:46:14PM GMT, Jeff Layton wrote:
> On Thu, 2024-09-05 at 11:44 -0400, Chuck Lever wrote:
> > On Thu, Sep 05, 2024 at 08:41:53AM -0400, Jeff Layton wrote:
> > > When updating the ctime on an inode for a SETATTR with a multigrain
> > > filesystem, we usually want to take the latest time we can get for the
> > > ctime. The exception to this rule is when there is a nfsd write
> > > delegation and the server is proxying timestamps from the client.
> > >
> > > When nfsd gets a CB_GETATTR response, we want to update the timestamp
> > > value in the inode to the values that the client is tracking. The client
> > > doesn't send a ctime value (since that's always determined by the
> > > exported filesystem), but it can send a mtime value. In the case where
> > > it does, then we may need to update the ctime to a value commensurate
> > > with that instead of the current time.
> > >
> > > If ATTR_DELEG is set, then use ia_ctime value instead of setting the
> > > timestamp to the current time.
> > >
> > > With the addition of delegated timestamps we can also receive a request
> > > to update only the atime, but we may not need to set the ctime. Trust
> > > the ATTR_CTIME flag in the update and only update the ctime when it's
> > > set.
> > >
> > > Signed-off-by: Jeff Layton <jlayton@...nel.org>
> > > ---
> > > fs/attr.c | 28 +++++++++++++--------
> > > fs/inode.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > include/linux/fs.h | 2 ++
> > > 3 files changed, 94 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/fs/attr.c b/fs/attr.c
> > > index 3bcbc45708a3..392eb62aa609 100644
> > > --- a/fs/attr.c
> > > +++ b/fs/attr.c
> > > @@ -286,16 +286,20 @@ static void setattr_copy_mgtime(struct inode *inode, const struct iattr *attr)
> > > unsigned int ia_valid = attr->ia_valid;
> > > struct timespec64 now;
> > >
> > > - /*
> > > - * If the ctime isn't being updated then nothing else should be
> > > - * either.
> > > - */
> > > - if (!(ia_valid & ATTR_CTIME)) {
> > > - WARN_ON_ONCE(ia_valid & (ATTR_ATIME|ATTR_MTIME));
> > > - return;
> > > + if (ia_valid & ATTR_CTIME) {
> > > + /*
> > > + * In the case of an update for a write delegation, we must respect
> > > + * the value in ia_ctime and not use the current time.
> > > + */
> > > + if (ia_valid & ATTR_DELEG)
> > > + now = inode_set_ctime_deleg(inode, attr->ia_ctime);
> > > + else
> > > + now = inode_set_ctime_current(inode);
> > > + } else {
> > > + /* If ATTR_CTIME isn't set, then ATTR_MTIME shouldn't be either. */
> > > + WARN_ON_ONCE(ia_valid & ATTR_MTIME);
> > > }
> > >
> > > - now = inode_set_ctime_current(inode);
> > > if (ia_valid & ATTR_ATIME_SET)
> > > inode_set_atime_to_ts(inode, attr->ia_atime);
> > > else if (ia_valid & ATTR_ATIME)
> > > @@ -354,8 +358,12 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode,
> > > inode_set_atime_to_ts(inode, attr->ia_atime);
> > > if (ia_valid & ATTR_MTIME)
> > > inode_set_mtime_to_ts(inode, attr->ia_mtime);
> > > - if (ia_valid & ATTR_CTIME)
> > > - inode_set_ctime_to_ts(inode, attr->ia_ctime);
> > > + if (ia_valid & ATTR_CTIME) {
> > > + if (ia_valid & ATTR_DELEG)
> > > + inode_set_ctime_deleg(inode, attr->ia_ctime);
> > > + else
> > > + inode_set_ctime_to_ts(inode, attr->ia_ctime);
> > > + }
> > > }
> > > EXPORT_SYMBOL(setattr_copy);
> > >
> >
> > This patch fails to apply cleanly to my copy of nfsd-next:
> >
> > error: `git apply --index`: error: patch failed: fs/attr.c:286
> > error: fs/attr.c: patch does not apply
> >
> > Before I try jiggling this to get it to apply, is there anything
> > I should know? I worry about a potential merge conflict here,
> > hopefully it will be no more complicated than that.
> >
> >
>
> This is based on a combo of your nfsd-next branch and Christian's
> vfs.mgtime branch. This patch in particular depends on the multigrain
> patches in his tree.
>
> I think we can just drop this patch from the series in your tree, and
> I'll get Christian to pick it up in his tree. The ctime setting will be
> a bit racy without it but everything should still work.
>
> Sound ok? Christian, are you OK with picking this up in vfs.mgtime?
Yep, of course. Already picked it up.
Powered by blists - more mailing lists