Skip to content

libfs: fix multigrain timestamps of tmpfs directories

Christian Brauner linux-fsdevel stable 1 version In review

Get series with b4
b4 am [email protected] change-id 20261125-work-libfs-mgtime-513953909f3d

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2libfs: don't copy the child's ctime to the parent directoryfs/libfs.c+4 -42 replies
2/2selftests/filesystems: test multigrain timestamps of tmpfs directoriestools/testing/selftests/filesystems/.gitignore tools/testing/selftests/filesystems/Makefile tools/testing/selftests/filesystems/mgtime_test.c+246 -00 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchJeff LaytonJan Kara
1/2R-b R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] libfs: fix multigrain timestamps of tmpfs directories

simple_link() and __simple_unlink() copy the child's new ctime into the parent directory. That doesn't work with multigrain timestamps. The child's ctime is only fine-grained if the child itself was queried and copying it clears the I_CTIME_QUERIED flag of the directory.

tmpfs is the only multigrain filesystem that uses these helpers. So since v6.13 a tmpfs directory whose timestamps were queried can come out of link(), unlink(), rmdir() or a rename over an existing entry with the same ctime and mtime as before. If the renamed entry comes from another directory size and link count stay the same as well and userspace has no way to tell that the directory changed at all. In a VM that happened in 1738 of 2000 tries.

Give the directory its own inode_set_ctime_current() call like the other multigrain filesystems do and add a selftest that checks the timestamps of the parent directory after each directory operation.

---
Christian Brauner (2):
libfs: don't copy the child's ctime to the parent directory selftests/filesystems: test multigrain timestamps of tmpfs directories

 fs/libfs.c                                        |   8 +-
 tools/testing/selftests/filesystems/.gitignore    |   1 +
 tools/testing/selftests/filesystems/Makefile      |   1 +
 tools/testing/selftests/filesystems/mgtime_test.c | 244 ++++++++++++++++++++++
 4 files changed, 250 insertions(+), 4 deletions(-)

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261125-work-libfs-mgtime-513953909f3d