On Sat, May 03, 2025 at 02:10:12AM +0200, Samuel Thibault wrote:
> Zhaoming Luo, le ven. 02 mai 2025 22:45:44 +0800, a ecrit:
> > Get the time with higher resolution from kernel using host_get_time64()
> > when possible.
>
> It seems there's a misunderstanding. I explained that the mapped time
> does have 64bit precision fields, that's what I mean we want to use,
> rather than the costly RPC. When we discussed about it on IRC, I didn't
> know that libdiskfs already uses maptime, so advised to just use the RPC
> since it's simpler. But since libdiskfs already uses maptime, better
> just extend maptime with 64b capability (falling back to 32b if the 64b
> fields are zero).
>
But the issue is that maptime_read does not support 10ns resolution
which is host_get_time64 can offer, and I haven't got an idea of how to
do that on maptime_read. The function call of hpclock is provided in
kernel.
Zhaoming
>
> > - maptime_read (diskfs_mtime, &t);
> > + /* Get time from kernel. If host_get_time64 is not supported by the
> > + kernel, step back to use maptime_read. */
> > + if (host_get_time64 (mach_host_self (), &t) == MIG_BAD_ID)
> > + {
> > + maptime_read (diskfs_mtime, &mt);
> > + t.seconds = mt.tv_sec;
> > + t.nanoseconds = mt.tv_usec * 1000;
> > + }
> >
> > /* We are careful to test and reset each of these individually, so there
> > is no race condition where a dn_set_?time flag setting gets lost. It
> > @@ -85,22 +94,22 @@ diskfs_set_node_times (struct node *np)
> > the update will happen at the next call. */
> > if (np->dn_set_mtime)
> > {
> > - np->dn_stat.st_mtim.tv_sec = t.tv_sec;
> > - np->dn_stat.st_mtim.tv_nsec = t.tv_usec * 1000;
> > + np->dn_stat.st_mtim.tv_sec = t.seconds;
> > + np->dn_stat.st_mtim.tv_nsec = t.nanoseconds;
> > np->dn_stat_dirty = 1;
> > np->dn_set_mtime = 0;
> > }
> > if (np->dn_set_atime)
> > {
> > - np->dn_stat.st_atim.tv_sec = t.tv_sec;
> > - np->dn_stat.st_atim.tv_nsec = t.tv_usec * 1000;
> > + np->dn_stat.st_atim.tv_sec = t.seconds;
> > + np->dn_stat.st_atim.tv_nsec = t.nanoseconds;
> > np->dn_stat_dirty = 1;
> > np->dn_set_atime = 0;
> > }
> > if (np->dn_set_ctime)
> > {
> > - np->dn_stat.st_ctim.tv_sec = t.tv_sec;
> > - np->dn_stat.st_ctim.tv_nsec = t.tv_usec * 1000;
> > + np->dn_stat.st_ctim.tv_sec = t.seconds;
> > + np->dn_stat.st_ctim.tv_nsec = t.nanoseconds;
> > np->dn_stat_dirty = 1;
> > np->dn_set_ctime = 0;
> > }
> > --
> > 2.49.0
> >
> >
>
> --
> Samuel
> * D a decide de peter un cable dans son rapport de pfp
> <c> et il a bien raison ;-)
> <c> tu vas dire quoi ?
> <D> j'ai mis les paroles de "le coq est mort" en en-tete
> -+- #ens-mim et la peufeupeu -+-