bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hurd/libdiskfs: I added in the `relatime' mount option.


From: Ryan Jeffrey
Subject: Re: [PATCH] hurd/libdiskfs: I added in the `relatime' mount option.
Date: Sun, 27 Sep 2020 20:41:03 -0700
User-agent: mu4e 1.4.13; emacs 27.1

Samuel Thibault <samuel.thibault@gnu.org> writes:

> Also,
>
> Ryan Jeffrey, le jeu. 10 sept. 2020 14:01:58 -0700, a ecrit:
>> diff -ruN a/hurd/libdiskfs/file-statfs.c b/hurd/libdiskfs/file-statfs.c
>> --- a/hurd/libdiskfs/file-statfs.c   2020-07-18 12:08:35.000000000 -0700
>> +++ b/hurd/libdiskfs/file-statfs.c   2020-09-08 02:21:25.000000000 -0700
>> @@ -43,6 +43,8 @@
>>      statbuf->f_flag |= ST_SYNCHRONOUS;
>>    if (_diskfs_noatime)
>>      statbuf->f_flag |= ST_NOATIME;
>> +  else if (_diskfs_relatime)
>> +    statbuf->f_flag |= ST_RELATIME;
>>  
>>    diskfs_set_statfs (statbuf);
>>  
>
> Since ST_RELATIME comes from glibc, which is not released yet with that
> macro, please but these two lines inside #ifdef ST_RELATIME so the hurd
> can be built with an older glibc.
>
> Samuel

Speaking of libc, I submitted a request-assign.future to assign@gnu.org for a 
small patch containing the "ST_RELATIME" enum and macro, but they never got 
back to me on it. Should I email them?


Anyway, here is a patch to the previous patch:

diff -x '.*' -x 'README*' -ruN a/hurd/doc/hurd.texi b/hurd/doc/hurd.texi
--- a/hurd/doc/hurd.texi        2020-09-27 16:26:08.000000000 -0700
+++ b/hurd/doc/hurd.texi        2020-09-27 16:57:08.000000000 -0700
@@ -3973,7 +3973,9 @@
 
 @deftypefun void diskfs_set_node_atime (@w{struct node *@var{np}})
 If disk is not readonly and the noatime option is not enabled, set
-@code{@var{np}->dn_set_atime}.
+@code{@var{np}->dn_set_atime}. If relatime is enabled, only set
+@code{@var{np}->dn_set_atime} if the atime has not been updated today,
+or if ctime or mtime are more recent than atime.
 @end deftypefun
 
 @deftypefun void diskfs_set_node_times (@w{struct node *@var{np}})
diff -x '.*' -x 'README*' -ruN a/hurd/libdiskfs/file-statfs.c 
b/hurd/libdiskfs/file-statfs.c
--- a/hurd/libdiskfs/file-statfs.c      2020-09-27 16:28:11.000000000 -0700
+++ b/hurd/libdiskfs/file-statfs.c      2020-09-27 16:57:07.000000000 -0700
@@ -21,6 +21,10 @@
 #include "priv.h"
 #include "fs_S.h"
 
+#ifndef ST_RELATIME
+#      define ST_RELATIME 4096
+#endif /* ST_RELATIME */
+
 /* Implement file_getcontrol as described in <hurd/fs.defs>. */
 kern_return_t
 diskfs_S_file_statfs (struct protid *file,
diff -x '.*' -x 'README*' -ruN a/hurd/libdiskfs/node-times.c 
b/hurd/libdiskfs/node-times.c
--- a/hurd/libdiskfs/node-times.c       2020-09-27 16:28:11.000000000 -0700
+++ b/hurd/libdiskfs/node-times.c       2020-09-27 16:57:07.000000000 -0700
@@ -26,12 +26,14 @@
 
 /* If the disk is not readonly and noatime is not set, then check relatime
    conditions: if either `np->dn_stat.st_mtim.tv_sec' or
-   `np->dn_stat.st_ctim.tv_sec' is less than `np->dn_stat.st_atim.tv_sec',
+   `np->dn_stat.st_ctim.tv_sec' is greater than `np->dn_stat.st_atim.tv_sec',
    or if the atime is greater than 24 hours old, return true.
    */
 int
 atime_should_update (struct node *np)
 {
+  struct timeval t;
+
   if (_diskfs_noatime)
     return 0;
 
@@ -41,16 +43,12 @@
       if (np->dn_stat.st_mtim.tv_sec > np->dn_stat.st_atim.tv_sec)
         return 1;
       /* Update atime if ctime is younger than atime. */
-      else if (np->dn_stat.st_ctim.tv_sec > np->dn_stat.st_atim.tv_sec)
+      if (np->dn_stat.st_ctim.tv_sec > np->dn_stat.st_atim.tv_sec)
         return 1;
       /* Update atime if current atime is more than 24 hours old. */
-      else
-      {
-        struct timeval t;
-        maptime_read (diskfs_mtime, &t);
-        if ((long)(t.tv_sec - np->dn_stat.st_atim.tv_sec) >= 24 * 60 * 60)
-            return 1;
-      }
+      maptime_read (diskfs_mtime, &t);
+      if ((long)(t.tv_sec - np->dn_stat.st_atim.tv_sec) >= 24 * 60 * 60)
+          return 1;
       return 0;
     }
 
diff -x '.*' -x 'README*' -ruN a/hurd/libdiskfs/priv.h b/hurd/libdiskfs/priv.h
--- a/hurd/libdiskfs/priv.h     2020-09-27 16:28:11.000000000 -0700
+++ b/hurd/libdiskfs/priv.h     2020-09-27 16:57:07.000000000 -0700
@@ -104,7 +104,7 @@
 
 /* If the disk is not readonly and noatime is not set, then check relatime
    conditions: if either `np->dn_stat.st_mtim.tv_sec' or
-   `np->dn_stat.st_ctim.tv_sec' is less than `np->dn_stat.st_atim.tv_sec',
+   `np->dn_stat.st_ctim.tv_sec' is greater than `np->dn_stat.st_atim.tv_sec',
    or if the atime is greater than 24 hours old, return true.
    */
 int atime_should_update (struct node *np);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]