xfs
[Top] [All Lists]

[patch 1/1] Make XFS sysctl parameters use USER_HZ instead of HZ.

To: linux-xfs@xxxxxxxxxxx
Subject: [patch 1/1] Make XFS sysctl parameters use USER_HZ instead of HZ.
From: bart@xxxxxxxxx
Date: Sat, 03 Apr 2004 13:12:40 +0200
Cc: bart@xxxxxxxxx
Sender: linux-xfs-bounce@xxxxxxxxxxx
From: Bart Samwel <bart@xxxxxxxxx>

The sysctl parameters sync_interval, flush_interval and age_buffer are
in units of jiffies, which are very variable between kernels and
architectures. These parameters should use USER_HZ, which is meant for
use in external interfaces.

Rationale: If there is no interface with a reliable unit, the laptop mode
control script can never work reliably, because it then needs to know the
value of HZ, which is intentionally not exported from the kernel anywhere.

Possible improvement (matter of taste): renaming the variables, so that
old code knows that the new variables are in new units. I suggest to not
do this, because the variables previously didn't have any usable unit
anyway. Any code that was written against this interface had to assume
some HZ and would _have_ to have known that it would break with _any_ 
change in HZ.


---

 linux-2.6.4-bsamwel/fs/xfs/linux/xfs_globals.c |   26 ++++++++++++-------------
 linux-2.6.4-bsamwel/fs/xfs/linux/xfs_linux.h   |    6 ++---
 2 files changed, 16 insertions(+), 16 deletions(-)

diff -puN fs/xfs/linux/xfs_globals.c~xfs-sysctl-centisecs 
fs/xfs/linux/xfs_globals.c
--- linux-2.6.4/fs/xfs/linux/xfs_globals.c~xfs-sysctl-centisecs 2004-04-03 
12:41:05.000000000 +0200
+++ linux-2.6.4-bsamwel/fs/xfs/linux/xfs_globals.c      2004-04-03 
12:52:05.000000000 +0200
@@ -50,19 +50,19 @@ unsigned long xfs_physmem;
  */
 
 xfs_param_t xfs_params = {
-                         /*    MIN     DFLT    MAX     */
-       .restrict_chown = {     0,      1,      1       },
-       .sgid_inherit   = {     0,      0,      1       },
-       .symlink_mode   = {     0,      0,      1       },
-       .panic_mask     = {     0,      0,      127     },
-       .error_level    = {     0,      3,      11      },
-       .sync_interval  = {     HZ,     30*HZ,  60*HZ   },
-       .stats_clear    = {     0,      0,      1       },
-       .inherit_sync   = {     0,      1,      1       },
-       .inherit_nodump = {     0,      1,      1       },
-       .inherit_noatim = {     0,      1,      1       },
-       .flush_interval = {     HZ/2,   HZ,     30*HZ   },
-       .age_buffer     = {     1*HZ,   15*HZ,  300*HZ  },
+                         /*    MIN             DFLT            MAX             
*/
+       .restrict_chown = {     0,              1,              1               
},
+       .sgid_inherit   = {     0,              0,              1               
},
+       .symlink_mode   = {     0,              0,              1               
},
+       .panic_mask     = {     0,              0,              127             
},
+       .error_level    = {     0,              3,              11              
},
+       .sync_interval  = {     USER_HZ,        30*USER_HZ,     60*USER_HZ      
},
+       .stats_clear    = {     0,              0,              1               
},
+       .inherit_sync   = {     0,              1,              1               
},
+       .inherit_nodump = {     0,              1,              1               
},
+       .inherit_noatim = {     0,              1,              1               
},
+       .flush_interval = {     USER_HZ/2,      USER_HZ,        30*USER_HZ      
},
+       .age_buffer     = {     USER_HZ,        15*USER_HZ,     30*USER_HZ      
},
 };
 
 /*
diff -puN fs/xfs/linux/xfs_linux.h~xfs-sysctl-centisecs fs/xfs/linux/xfs_linux.h
--- linux-2.6.4/fs/xfs/linux/xfs_linux.h~xfs-sysctl-centisecs   2004-04-03 
12:47:00.000000000 +0200
+++ linux-2.6.4-bsamwel/fs/xfs/linux/xfs_linux.h        2004-04-03 
12:52:34.000000000 +0200
@@ -134,13 +134,13 @@ static inline void set_buffer_unwritten_
 #define irix_symlink_mode      xfs_params.symlink_mode.val
 #define xfs_panic_mask         xfs_params.panic_mask.val
 #define xfs_error_level                xfs_params.error_level.val
-#define xfs_syncd_interval     xfs_params.sync_interval.val
+#define xfs_syncd_interval     (xfs_params.sync_interval.val * HZ / USER_HZ)
 #define xfs_stats_clear                xfs_params.stats_clear.val
 #define xfs_inherit_sync       xfs_params.inherit_sync.val
 #define xfs_inherit_nodump     xfs_params.inherit_nodump.val
 #define xfs_inherit_noatime    xfs_params.inherit_noatim.val
-#define xfs_flush_interval     xfs_params.flush_interval.val
-#define xfs_age_buffer         xfs_params.age_buffer.val
+#define xfs_flush_interval     (xfs_params.flush_interval.val * HZ / USER_HZ)
+#define xfs_age_buffer         (xfs_params.age_buffer.val * HZ / USER_HZ)
 
 #define current_cpu()          smp_processor_id()
 #define current_pid()          (current->pid)

_


<Prev in Thread] Current Thread [Next in Thread>