diff options
| author | Hungyu Lin <dennylin0707@gmail.com> | 2026-11-01 11:38:15 +0000 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-11-05 18:21:58 +0100 |
| commit | 55a0c91000646b008261e3b1e15d1e774f3026e4 (patch) | |
| tree | 9d90df49b68944809bd6769918225cbb1bbd6271 /include/linux/timerqueue.h | |
| parent | 965e5e451146a19f69523fbcbc73d07e401a3775 (diff) | |
vfs: preserve subsecond timestamps at filesystem time limits
timestamp_truncate() clears tv_nsec whenever the clamped seconds equal
either filesystem time limit. This also drops the fractional part of
timestamps whose seconds were already within the supported range.
For example, setting a JFS mtime to 0.123456789 produces 0.000000000,
although the filesystem can store the requested value. Utilities such
as touch and cp -p consequently lose valid subsecond timestamps when
preserving these endpoint values. Timestamps strictly between the
filesystem limits are unaffected.
Only clear tv_nsec when clamping actually changes tv_sec. Continue to
truncate in-range nanoseconds to the filesystem's timestamp granularity,
including when the seconds equal either endpoint.
Ben Hutchings suggested comparing clamped and original seconds in the
2019 utimes review. That caller was switched to timestamp_truncate(),
but the helper retained its endpoint equality check.
Link: https://lore.kernel.org/lkml/12c095e595836a7ff7f2c7b2a32cb5544dd29b55.camel@codethink.co.uk/
Fixes: 50e17c000c46 ("vfs: Add timestamp_truncate() api")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
Link: https://patch.msgid.link/20261101113815.52911-1-dennylin0707@gmail.com
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include/linux/timerqueue.h')
0 files changed, 0 insertions, 0 deletions
