Take 2: Allow passing fine resolution timing options to mount
Subsystems (2)
PATCH 1/1 Take 2: Allow passing fine resolution timing options to mount
This patch modifies parsing of mount options to allows passing units along with the options. Valid units are "s" for seconds and "ms" for milliseconds. When not specified, the unit defaults to seconds.
For example, "-o acdirmin=20ms" can be specified for 20 milliseconds, and "-o acdirmin=3s" or just "-o acdirmin=3" for 3 seconds.
This code also changes the display of options in /proc/<pid>/mountstats from seconds to milliseconds to reflect the accuracy.
fs/nfs/client.c +4 -4
@@ -1295,10 +1295,10 @@if (data->wsize) server->wsize =nfs_block_size (data->wsize,NULL ); - server->acregmin = data->acregmin *HZ ; - server->acregmax = data->acregmax *HZ ; - server->acdirmin = data->acdirmin *HZ ; - server->acdirmax = data->acdirmax *HZ ; + server->acregmin = (data->acregmin *HZ ) /1000 ; + server->acregmax = (data->acregmax *HZ ) /1000 ; + server->acdirmin = (data->acdirmin *HZ ) /1000 ; + server->acdirmax = (data->acdirmax *HZ ) /1000 ; server->port = data->nfs_server.port;
fs/nfs/super.c +69 -21
173 lines not on this page · raw message
include/linux/nfs_fs.h +4 -4
@@ -20,10 +20,10 @@#define NFS_MAX_UDP_TIMEOUT (60*HZ)#define NFS_MAX_TCP_TIMEOUT (600*HZ) -#define NFS_DEF_ACREGMIN (3) -#define NFS_DEF_ACREGMAX (60) -#define NFS_DEF_ACDIRMIN (30) -#define NFS_DEF_ACDIRMAX (60) +#define NFS_DEF_ACREGMIN (3000) +#define NFS_DEF_ACREGMAX (60000) +#define NFS_DEF_ACDIRMIN (30000) +#define NFS_DEF_ACDIRMAX (60000)/* * When flushing a cluster of dirty pages, there can be different
Signature · 2 lines
May the source be with you. http://cis.ksu.edu~/gud
Quoted 9 lines · Amit Gud
This patch modifies parsing of mount options to allows passing units along with the options. Valid units are "s" for seconds and "ms" for milliseconds. When not specified, the unit defaults to seconds.
For example, "-o acdirmin=20ms" can be specified for 20 milliseconds, and "-o acdirmin=3s" or just "-o acdirmin=3" for 3 seconds.
This code also changes the display of options in /proc/<pid>/mountstats from seconds to milliseconds to reflect the accuracy.
This won't work. Suddenly the contents of /proc/self/mountinfo can no longer be used as intended because acdirmin/max/... are being displayed in milliseconds, whereas the default unit is in seconds. Furthermore, you'll have rounding errors when converting backwards and forwards into HZ, since the latter is usually > 1ms.
I agree with Neil. I think it would be better to use a 3 decimal fixed point notation instead. Couldn't something like the following be made to work?
static int nfs_parse_mstimeo(const char *str, unsigned long *res)
{
unsigned int msecs;
char *str2;
msecs = (unsigned int)simple_strtoul(str, &str2, 10);
msecs *= 1000;
/* Check if we're being given fixed point decimal notation */
if (*str2 == '.') {
unsigned long m;
size_t ndec = strlen(++str2);
/* Disallow more than 1/1000 precision */
if (ndec > 3)
goto out_inval;
if (strict_strtoul(str2, 10, &m))
goto out_inval;
switch (ndec) {
case 1:
m *= 10;
case 2:
m *= 10;
break;
}
msecs += (unsigned int)m;
} else if (*str2 != '\0' || str2 == str)
goto out_inval;
*res = msecs_to_jiffies(msecs);
return 0;
out_inval:
return -EINVAL;
}static void nfs_display_mstimeo(struct seq_file *m, unsigned long val)
{
unsigned int msec = jiffies_to_msecs(val);
unsigned int rem = msec % 1000;
seq_printf(m, "%u", msec / 1000);
if (rem != 0)
seq_printf(m, ".%.3u", rem);
}Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com