Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.kernel > #93798
| From | Vincent Lefevre <vincent@vinc17.net> |
|---|---|
| Newsgroups | linux.debian.bugs.dist, linux.debian.kernel |
| Subject | Bug#1144613: linux-image-7.1.6+deb14-amd64: ext4 st_mtime and time() inconsistency |
| Date | 2026-08-19 17:20 +0200 |
| Message-ID | <NtQf7-bUnP-7@gated-at.bofh.it> (permalink) |
| References | (3 earlier) <NtNAB-bSXq-3@gated-at.bofh.it> <NtOZH-bTCD-1@gated-at.bofh.it> <NtPsJ-bTWa-9@gated-at.bofh.it> <NsTI5-bnRg-1@gated-at.bofh.it> <NtPsJ-bTWa-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Cross-posted to 2 groups.
On 2026-08-19 16:22:53 +0200, Vincent Lefevre wrote:
> On 2026-08-19 15:50:16 +0200, Salvatore Bonaccorso wrote:
> > I think this is a consequence of 4e40eff0b5737c ("fs: add
> > infrastructure for multigrain timestamps") and following in 6.13-rc1.
Probably not (or not entirely), as there is another issue not involving
the filesystem (see below).
> > time(2) has only an accurancy in second, so the code might need to
> > use clock_gettime(2).
>
> The accuracy does not matter. This is a question of consistency.
> If an event A occurs before an event B, one expects to have
> time(A) <= time(B).
Now, comparing time(NULL) and clock_gettime(CLOCK_REALTIME, &ts):
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
while (1)
{
struct timespec ts;
time_t t;
clock_gettime(CLOCK_REALTIME, &ts);
t = time(NULL);
if (ts.tv_nsec < 0)
exit(1);
if (t < ts.tv_sec)
printf("%ld %ld\n", (long) t, (long) ts.tv_sec);
}
}
Since clock_gettime is called before time(NULL), one expects that
its time (including nanoseconds) is <= t, and since the number of
nanoseconds is non-negative (which is checked by the above code),
one should have ts.tv_sec <= t, i.e. the test t < ts.tv_sec should
be always false. But I get output at each second!
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
Back to linux.debian.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bug#1144613: linux-image-7.1.6+deb14-amd64: ext4 st_mtime and time() inconsistency Vincent Lefevre <vincent@vinc17.net> - 2026-08-19 14:00 +0200
Bug#1144613: linux-image-7.1.6+deb14-amd64: ext4 st_mtime and time() inconsistency Vincent Lefevre <vincent@vinc17.net> - 2026-08-19 14:30 +0200
Processed: Re: linux-image-7.1.6+deb14-amd64: ext4 st_mtime and time() inconsistency "Debian Bug Tracking System" <owner@bugs.debian.org> - 2026-08-19 14:30 +0200
Bug#1144613: linux-image-7.1.6+deb14-amd64: ext4 st_mtime and time() inconsistency Salvatore Bonaccorso <carnil@debian.org> - 2026-08-19 16:00 +0200
Bug#1144613: linux-image-7.1.6+deb14-amd64: ext4 st_mtime and time() inconsistency Vincent Lefevre <vincent@vinc17.net> - 2026-08-19 16:30 +0200
Bug#1144613: linux-image-7.1.6+deb14-amd64: ext4 st_mtime and time() inconsistency Vincent Lefevre <vincent@vinc17.net> - 2026-08-19 17:20 +0200
Bug#1144613: linux-image-7.1.6+deb14-amd64: ext4 st_mtime and time() inconsistency Vincent Lefevre <vincent@vinc17.net> - 2026-08-19 19:20 +0200
csiph-web