From: Jeff Layton <jlayton@kernel.org>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
Nathan Chancellor <nathan@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] overlayfs: set ctime when setting mtime and atime
Date: Thu, 14 Sep 2023 06:27:15 -0400 [thread overview]
Message-ID: <b107db96b12f4ab5b2edfbaa42bc0032205d24cc.camel@kernel.org> (raw)
In-Reply-To: <CAOQ4uxhYRnX0NChCU2tsEi7eUPqbqQDeOwQT4ubWUgtCN0OVfA@mail.gmail.com>
On Wed, 2023-09-13 at 20:36 +0300, Amir Goldstein wrote:
> On Wed, Sep 13, 2023 at 4:33 PM Jeff Layton <jlayton@kernel.org> wrote:
> >
> > Nathan reported that he was seeing the new warning in
> > setattr_copy_mgtime pop when starting podman containers. Overlayfs is
> > trying to set the atime and mtime via notify_change without also
> > setting the ctime.
> >
> > POSIX states that when the atime and mtime are updated via utimes() that
> > we must also update the ctime to the current time. The situation with
> > overlayfs copy-up is analogous, so add ATTR_CTIME to the bitmask.
> > notify_change will fill in the value.
> >
>
> IDGI, if ctime always needs to be set along with ATIME / MTIME, why not
> let notify_change() set the bit instead of assert and fix all the callers?
> But maybe I am missing something.
>
Traditionally notify_change has always been given an explicit mask of
attrs to change by the caller. I'm a little hesitant to start putting
POSIX policy in there.
Still, that may be the better thing to do over the long haul. I think
that there are some other bugs in the notify_change callers as well: for
instance, cachefiles_adjust_size truncates files, but doesn't update the
timestamps. I'm pretty sure that's wrong.
I think if we want to change how setattr ctime updates work, we'll
probably need to do it in the context of a larger notify_change
overhaul.
> Anyway, I have no objection to the ovl patch.
> It's fine by me if Christian applies it to the vfs.ctime branch with my ACK.
>
Many thanks!
> Thanks,
> Amir.
>
> > Reported-by: Nathan Chancellor <nathan@kernel.org>
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> > The new WARN_ON_ONCE in setattr_copy_mgtime caught a bug! Fix up
> > overlayfs to ensure that the ctime on the upper inode is also updated
> > when copying up the atime and mtime.
> > ---
> > fs/overlayfs/copy_up.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
> > index d1761ec5866a..ada3fcc9c6d5 100644
> > --- a/fs/overlayfs/copy_up.c
> > +++ b/fs/overlayfs/copy_up.c
> > @@ -337,7 +337,7 @@ static int ovl_set_timestamps(struct ovl_fs *ofs, struct dentry *upperdentry,
> > {
> > struct iattr attr = {
> > .ia_valid =
> > - ATTR_ATIME | ATTR_MTIME | ATTR_ATIME_SET | ATTR_MTIME_SET,
> > + ATTR_ATIME | ATTR_MTIME | ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_CTIME,
> > .ia_atime = stat->atime,
> > .ia_mtime = stat->mtime,
> > };
> >
> > ---
> > base-commit: 9cb8e7c86ac793862e7bea7904b3426942bbd7ef
> > change-id: 20230913-ctime-299173760dd9
> >
> > Best regards,
> > --
> > Jeff Layton <jlayton@kernel.org>
> >
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2023-09-14 10:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 13:33 [PATCH] overlayfs: set ctime when setting mtime and atime Jeff Layton
2023-09-13 13:35 ` Jeff Layton
2023-09-13 16:45 ` Christian Brauner
2023-09-13 17:04 ` Jeff Layton
2023-09-13 17:36 ` Amir Goldstein
2023-09-14 10:27 ` Jeff Layton [this message]
2023-09-13 19:57 ` Nathan Chancellor
2023-09-14 8:39 ` Christian Brauner
2023-09-22 13:52 ` Jeff Layton
2023-09-23 9:32 ` Amir Goldstein
2023-09-25 12:51 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b107db96b12f4ab5b2edfbaa42bc0032205d24cc.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=nathan@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).