linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] overlayfs: set ctime when setting mtime and atime
@ 2023-09-13 13:33 Jeff Layton
  2023-09-13 13:35 ` Jeff Layton
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Jeff Layton @ 2023-09-13 13:33 UTC (permalink / raw)
  To: Miklos Szeredi, Amir Goldstein, Nathan Chancellor,
	Christian Brauner, Alexander Viro
  Cc: linux-fsdevel, linux-unionfs, linux-kernel, Jeff Layton

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 analogies, so add ATTR_CTIME to the bitmask.
notify_change will fill in the value.

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>


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-09-25 12:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).