Series to change autofs to using a monotonic clock
Subsystems (2)
Ian Kent
maintainerv5 cover Series to change autofs to using a monotonic clock
This is what I get using "stg mail" when mailing patch series.
I've made a few changes to te breakdown of the patches. I tried to implement the alarm module change we discussued. I changed the mount and expire condition to use a monotonic clock as well for both the direc and indirect modules for completeness. And I changed the patch descriptions a bit.
I'll add my "Signed-off-by" after we've verified the series is OK and I've completed some samity testing.
The series should apply, I don't think there are conflicts with patches in my queue that are before them. The CHANGELOG hunk will be a problem though, as expected, and will likely change due to me changing the patch order before actually committing them.
Let me know if you can see any problem with the series.
---
Ian Kent (1):
autofs-5.1.1 - remove unused function elapsed()
Yu Ning (7):
autofs-5.1.1 - define monotonic clock helper functions autofs-5.1.1 - use monotonic clock for alarm thread condition wait autofs-5.1.1 - define pending condition init helper function autofs-5.1.1 - use monotonic clock for direct mount condition autofs-5.1.1 - use monotonic clock for indirect mount condition autofs-5.1.1 - change remaining gettimeofday() to use clock_gettime() autofs-5.1.1 - change time() to use monotonic_clock()
CHANGELOG | 7 +++++++ daemon/automount.c | 4 ++-- daemon/direct.c | 24 ++++++++---------------- daemon/indirect.c | 24 ++++++++---------------- daemon/lookup.c | 6 +++--- daemon/state.c | 2 +- include/automount.h | 31 +++++++++++++++++++++++++++++++ include/rpc_subs.h | 1 + lib/alarm.c | 28 ++++++++++++++++++++++------ lib/cache.c | 2 +- lib/master.c | 4 ++-- lib/rpc_subs.c | 20 +++++++++++--------- modules/dclist.c | 2 +- modules/lookup_file.c | 8 ++++---- modules/lookup_hesiod.c | 6 +++--- modules/lookup_hosts.c | 4 ++-- modules/lookup_ldap.c | 10 +++++----- modules/lookup_nisplus.c | 10 +++++----- modules/lookup_program.c | 10 +++++----- modules/lookup_sss.c | 6 +++--- modules/lookup_userhome.c | 2 +- modules/lookup_yp.c | 8 ++++---- modules/mount_autofs.c | 2 +- modules/parse_amd.c | 2 +- modules/replicated.c | 34 ++++++++++++++++------------------ 25 files changed, 148 insertions(+), 109 deletions(-)
--
Ian
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerPATCH v5 1/8 autofs-5.1.1 - define monotonic clock helper functions
From: Yu Ning <[email protected]>
The time returned by gettimeofday() is affected by discontinuous jumps in the system time, so it causes an issue that autofs may not auto unmount a mount point if system time is manually changed by the system administrator.
To fix the issue we need to convert to using a monotonic clock source instead of the clock source used by gettimeofday().
Start by defining two helper functions that will be used by later patches.
--- CHANGELOG | 1 + include/automount.h | 10 ++++++++++ include/rpc_subs.h | 1 + lib/rpc_subs.c | 11 +++++++++++ 4 files changed, 23 insertions(+)
CHANGELOG +1 -0
@@ -18,6 +18,7 @@ - fix handling of ldap bind/unbind operations. - fix error handling of is_mounted(). - Add a mode option for master map entries. +- define monotonic clock helper functions. 21/04/2015 autofs-5.1.1 =======================
include/automount.h +10 -0
@@ -566,6 +566,16 @@ do { \fatal (_m_unlock); \ }while (0 ) +static inline time_t monotonic_time(time_t *t) +{ +struct timespec ts; + +clock_gettime (CLOCK_MONOTONIC , &ts); +if (t) + *t = (time_t ) ts.tv_sec; +return (time_t ) ts.tv_sec; +} +/* Expire alarm handling routines */ int alarm_start_handler (void );int alarm_add (struct autofs_point *ap,time_t seconds);
include/rpc_subs.h +1 -0
@@ -71,6 +71,7 @@ int rpc_portmap_getport(struct conn_info *, struct pmap *, unsigned short *);int rpc_ping_proto (struct conn_info *);int rpc_ping (const char *,long ,long ,unsigned int );double elapsed (struct timeval ,struct timeval ); +double monotonic_elapsed (struct timespec ,struct timespec );int rpc_time (const char *,unsigned int ,unsigned int ,long ,long ,unsigned int ,double *);const char *get_addr_string (struct sockaddr *,char *,socklen_t );
lib/rpc_subs.c +11 -0
@@ -1086,6 +1086,17 @@ double elapsed(struct timeval start, struct timeval end)return t2-t1; } +double monotonic_elapsed (struct timespec start,struct timespec end) +{ +double t1, t2; + + t1 = (double ) start.tv_sec + + (double ) (start.tv_nsec/(1000 *1000 *1000 )); + t2 = (double ) end.tv_sec + + (double ) (end.tv_nsec/(1000 *1000 *1000 )); +return t2 - t1; +} +int rpc_time (const char *host,unsigned int ping_vers,unsigned int ping_proto,long seconds,long micros,unsigned int option,double *result)
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerPATCH v5 2/8 autofs-5.1.1 - use monotonic clock for alarm thread condition wait
In reply to Ian KentFrom: Yu Ning <[email protected]>
The time returned by gettimeofday() is affected by discontinuous jumps in the system time, so it causes an issue that autofs may not auto unmount a mount point if system time is manually changed by the system administrator.
To fix the issue we need to convert to using a monotonic clock source instead of the clock source used by gettimeofday().
Convert the alarm_handler() to use a monotonic clock source.
--- CHANGELOG | 1 + lib/alarm.c | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-)
CHANGELOG +1 -0
@@ -19,6 +19,7 @@ - fix error handling of is_mounted(). - Add a mode option for master map entries. - define monotonic clock helper functions. +- use monotonic clock for alarm thread condition wait. 21/04/2015 autofs-5.1.1 =======================
lib/alarm.c +22 -6
@@ -23,7 +23,7 @@ struct alarm { };static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ; -static pthread_cond_t cond =PTHREAD_COND_INITIALIZER ; +static pthread_cond_t cond;static LIST_HEAD (alarms);#define alarm_lock () \
@@ -46,7 +46,7 @@ int alarm_add(struct autofs_point *ap, time_t seconds)struct list_head *head;struct list_head *p;struct alarm *new; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t next_alarm =0 ;unsigned int empty =1 ;int status;
@@ -175,17 +175,18 @@ static void *alarm_handler(void *arg) first = list_entry(head->next, struct alarm, list); - now =time (NULL ); + now =monotonic_time (NULL );if (first->time > now) { -struct timeval usecs; +struct timespec nsecs; +/* * Wait for alarm to trigger or a new alarm * to be added. */ -gettimeofday (&usecs,NULL ); +clock_gettime (CLOCK_MONOTONIC , &nsecs); expire.tv_sec = first->time; - expire.tv_nsec = usecs.tv_usec *1000 ; + expire.tv_nsec = nsecs.tv_nsec; status =pthread_cond_timedwait (&cond, &mutex, &expire);if (status && status !=ETIMEDOUT )
@@ -212,6 +213,7 @@ int alarm_start_handler(void)pthread_t thid;pthread_attr_t attrs;pthread_attr_t *pattrs = &attrs; +pthread_condattr_t condattrs;int status; status =pthread_attr_init (pattrs);
@@ -224,8 +226,22 @@ int alarm_start_handler(void)#endif } + status =pthread_condattr_init (&condattrs); +if (status) +fatal (status); + + status =pthread_condattr_setclock (&condattrs,CLOCK_MONOTONIC ); +if (status) +fatal (status); + + status =pthread_cond_init (&cond, &condattrs); +if (status) +fatal (status); + status =pthread_create (&thid, pattrs, alarm_handler,NULL ); +pthread_condattr_destroy (&condattrs); +if (pattrs)pthread_attr_destroy (pattrs);
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerPATCH v5 3/8 autofs-5.1.1 - define pending condition init helper function
In reply to Ian KentFrom: Yu Ning <[email protected]>
The time returned by gettimeofday() is affected by discontinuous jumps in the system time, so it causes an issue that autofs may not auto unmount a mount point if system time is manually changed by the system administrator.
To fix the issue we need to convert to using a monotonic clock source instead of the clock source used by gettimeofday().
We also want to use a monotonic clock source for the condition wait of both the direct and indirect mount thread creation as well the expire thread creation of each. So create a common helper function to initialize a condition variable to use a monotonic clock source.
--- CHANGELOG | 1 + include/automount.h | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+)
CHANGELOG +1 -0
@@ -20,6 +20,7 @@ - Add a mode option for master map entries. - define monotonic clock helper functions. - use monotonic clock for alarm thread condition wait. +- define pending condition init helper function. 21/04/2015 autofs-5.1.1 =======================
include/automount.h +21 -0
@@ -413,6 +413,27 @@ struct pending_args { };#ifdef INCLUDE_PENDING_FUNCTIONS +static void pending_cond_init (void *arg) +{ +struct pending_args *mt = (struct pending_args *) arg; +pthread_condattr_t condattrs; +int status; + + status =pthread_condattr_init (&condattrs); +if (status) +fatal (status); + + status =pthread_condattr_setclock (&condattrs,CLOCK_MONOTONIC ); +if (status) +fatal (status); + + status =pthread_cond_init (&mt->cond, &condattrs); +if (status) +fatal (status); + +pthread_condattr_destroy (&condattrs); +} +static void pending_cond_destroy (void *arg) {struct pending_args *mt = (struct pending_args *) arg;
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerPATCH v5 4/8 autofs-5.1.1 - use monotonic clock for direct mount condition
In reply to Ian KentFrom: Yu Ning <[email protected]>
The time returned by gettimeofday() is affected by discontinuous jumps in the system time, so it causes an issue that autofs may not auto unmount a mount point if system time is manually changed by the system administrator.
To fix the issue we need to convert to using a monotonic clock source instead of the clock source used by gettimeofday().
Change the direct mount and expire thread creation to use a monotonic clock source.
--- CHANGELOG | 1 + daemon/direct.c | 20 ++++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-)
CHANGELOG +1 -0
@@ -21,6 +21,7 @@ - define monotonic clock helper functions. - use monotonic clock for alarm thread condition wait. - define pending condition init helper function. +- use monotonic clock for direct mount condition. 21/04/2015 autofs-5.1.1 =======================
daemon/direct.c +6 -14
@@ -1045,7 +1045,6 @@ int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_dichar buf[MAX_ERR_BUF ];pthread_t thid;struct timespec wait; -struct timeval now;int status, state;pthread_setcancelstate (PTHREAD_CANCEL_DISABLE , &state);
@@ -1115,9 +1114,7 @@ int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_direturn 1 ; } - status =pthread_cond_init (&mt->cond,NULL ); -if (status) -fatal (status); +pending_cond_init (mt); status =pthread_mutex_init (&mt->mutex,NULL );if (status)
@@ -1163,9 +1160,8 @@ int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_di mt->signaled =0 ;while (!mt->signaled) { -gettimeofday (&now,NULL ); - wait.tv_sec = now.tv_sec +2 ; - wait.tv_nsec = now.tv_usec *1000 ; +clock_gettime (CLOCK_MONOTONIC , &wait); + wait.tv_sec +=2 ; status =pthread_cond_timedwait (&mt->cond, &mt->mutex, &wait);if (status && status !=ETIMEDOUT )fatal (status);
@@ -1300,7 +1296,6 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_char buf[MAX_ERR_BUF ];int status =0 ;struct timespec wait; -struct timeval now;int ioctlfd, len, state;unsigned int kver_major =get_kver_major ();unsigned int kver_minor =get_kver_minor ();
@@ -1431,9 +1426,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_ }memset (mt,0 ,sizeof (struct pending_args )); - status =pthread_cond_init (&mt->cond,NULL ); -if (status) -fatal (status); +pending_cond_init (mt); status =pthread_mutex_init (&mt->mutex,NULL );if (status)
@@ -1482,9 +1475,8 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_ mt->signaled =0 ;while (!mt->signaled) { -gettimeofday (&now,NULL ); - wait.tv_sec = now.tv_sec +2 ; - wait.tv_nsec = now.tv_usec *1000 ; +clock_gettime (CLOCK_MONOTONIC , &wait); + wait.tv_sec +=2 ; status =pthread_cond_timedwait (&mt->cond, &mt->mutex, &wait);if (status && status !=ETIMEDOUT )fatal (status);
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerPATCH v5 5/8 autofs-5.1.1 - use monotonic clock for indirect mount condition
In reply to Ian KentFrom: Yu Ning <[email protected]>
The time returned by gettimeofday() is affected by discontinuous jumps in the system time, so it causes an issue that autofs may not auto unmount a mount point if system time is manually changed by the system administrator.
To fix the issue we need to convert to using a monotonic clock source instead of the clock source used by gettimeofday().
Change the indirect mount and expire thread creation to use a monotonic clock source.
--- CHANGELOG | 1 + daemon/indirect.c | 20 ++++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-)
CHANGELOG +1 -0
@@ -22,6 +22,7 @@ - use monotonic clock for alarm thread condition wait. - define pending condition init helper function. - use monotonic clock for direct mount condition. +- use monotonic clock for indirect mount condition. 21/04/2015 autofs-5.1.1 =======================
daemon/indirect.c +6 -14
@@ -640,7 +640,6 @@ int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_char buf[MAX_ERR_BUF ];pthread_t thid;struct timespec wait; -struct timeval now;int status, state;pthread_setcancelstate (PTHREAD_CANCEL_DISABLE , &state);
@@ -658,9 +657,7 @@ int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_return 1 ; } - status =pthread_cond_init (&mt->cond,NULL ); -if (status) -fatal (status); +pending_cond_init (mt); status =pthread_mutex_init (&mt->mutex,NULL );if (status)
@@ -695,9 +692,8 @@ int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_ mt->signaled =0 ;while (!mt->signaled) { -gettimeofday (&now,NULL ); - wait.tv_sec = now.tv_sec +2 ; - wait.tv_nsec = now.tv_usec *1000 ; +clock_gettime (CLOCK_MONOTONIC , &wait); + wait.tv_sec +=2 ; status =pthread_cond_timedwait (&mt->cond, &mt->mutex, &wait);if (status && status !=ETIMEDOUT )fatal (status);
@@ -799,7 +795,6 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missinchar buf[MAX_ERR_BUF ];struct pending_args *mt;struct timespec wait; -struct timeval now;struct mapent *me;int status, state;
@@ -845,9 +840,7 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin }memset (mt,0 ,sizeof (struct pending_args )); - status =pthread_cond_init (&mt->cond,NULL ); -if (status) -fatal (status); +pending_cond_init (mt); status =pthread_mutex_init (&mt->mutex,NULL );if (status)
@@ -888,9 +881,8 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin mt->signaled =0 ;while (!mt->signaled) { -gettimeofday (&now,NULL ); - wait.tv_sec = now.tv_sec +2 ; - wait.tv_nsec = now.tv_usec *1000 ; +clock_gettime (CLOCK_MONOTONIC , &wait); + wait.tv_sec +=2 ; status =pthread_cond_timedwait (&mt->cond, &mt->mutex, &wait);if (status && status !=ETIMEDOUT )fatal (status);
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerPATCH v5 6/8 autofs-5.1.1 - change remaining gettimeofday() to use clock_gettime()
In reply to Ian KentFrom: Yu Ning <[email protected]>
The time returned by gettimeofday() is affected by discontinuous jumps in the system time, so it causes an issue that autofs may not auto unmount a mount point if system time is manually changed by the system administrator.
To fix the issue we need to convert to using a monotonic clock source instead of the clock source used by gettimeofday().
Change the reamining gettimeofday() function calls to clock_gettime() calls.
--- CHANGELOG | 1 + lib/rpc_subs.c | 9 ++++----- modules/replicated.c | 30 ++++++++++++++---------------- 3 files changed, 19 insertions(+), 21 deletions(-)
CHANGELOG +1 -0
@@ -23,6 +23,7 @@ - define pending condition init helper function. - use monotonic clock for direct mount condition. - use monotonic clock for indirect mount condition. +- change remaining gettimeofday() to use clock_gettime(). 21/04/2015 autofs-5.1.1 =======================
lib/rpc_subs.c +4 -5
@@ -1103,19 +1103,18 @@ int rpc_time(const char *host, {int status;double taken; -struct timeval start, end; -struct timezone tz; +struct timespec start, end;int proto = (ping_proto &RPC_PING_UDP ) ?IPPROTO_UDP :IPPROTO_TCP ;unsigned long vers = ping_vers; -gettimeofday (&start, &tz); +clock_gettime (CLOCK_MONOTONIC , &start); status =__rpc_ping (host, vers, proto, seconds, micros, option); -gettimeofday (&end, &tz); +clock_gettime (CLOCK_MONOTONIC , &end);if (status ==RPC_PING_FAIL || status <0 )return status; - taken =elapsed (start, end); + taken =monotonic_elapsed (start, end);if (result !=NULL ) *result = taken;
modules/replicated.c +14 -16
@@ -231,8 +231,7 @@ static unsigned int get_nfs_info(unsigned logopt, struct host *host,socklen_t len =INET6_ADDRSTRLEN ;char buf[len +1 ];struct pmap parms; -struct timeval start, end; -struct timezone tz; +struct timespec start, end;unsigned int supported =0 ;double taken =0 ;int status, count =0 ;
@@ -292,9 +291,9 @@ static unsigned int get_nfs_info(unsigned logopt, struct host *host, supported = status; goto done_ver; }else if (!status) { -gettimeofday (&start, &tz); +clock_gettime (CLOCK_MONOTONIC , &start); status =rpc_ping_proto (rpc_info); -gettimeofday (&end, &tz); +clock_gettime (CLOCK_MONOTONIC , &end);if (status == -ETIMEDOUT ) { supported = status; goto done_ver;
@@ -306,7 +305,7 @@ static unsigned int get_nfs_info(unsigned logopt, struct host *host,debug (logopt,"nfs v4 random selection time: %f" , reply); }else { - reply =elapsed (start, end); + reply =monotonic_elapsed (start, end);debug (logopt,"nfs v4 rpc ping time: %f" , reply); } taken += reply;
@@ -351,9 +350,9 @@ v3_ver: supported = status; goto done_ver; }else if (!status) { -gettimeofday (&start, &tz); +clock_gettime (CLOCK_MONOTONIC , &start); status =rpc_ping_proto (rpc_info); -gettimeofday (&end, &tz); +clock_gettime (CLOCK_MONOTONIC , &end);if (status == -ETIMEDOUT ) { supported = status; goto done_ver;
@@ -365,7 +364,7 @@ v3_ver:debug (logopt,"nfs v3 random selection time: %f" , reply); }else { - reply =elapsed (start, end); + reply =monotonic_elapsed (start, end);debug (logopt,"nfs v3 rpc ping time: %f" , reply); } taken += reply;
@@ -407,9 +406,9 @@ v2_ver: supported = status; goto done_ver; }else if (!status) { -gettimeofday (&start, &tz); +clock_gettime (CLOCK_MONOTONIC , &start); status =rpc_ping_proto (rpc_info); -gettimeofday (&end, &tz); +clock_gettime (CLOCK_MONOTONIC , &end);if (status == -ETIMEDOUT ) supported = status;else if (status >0 ) {
@@ -420,7 +419,7 @@ v2_ver:debug (logopt,"nfs v2 random selection time: %f" , reply); }else { - reply =elapsed (start, end);; + reply =monotonic_elapsed (start, end);;debug (logopt,"nfs v2 rpc ping time: %f" , reply); } taken += reply;
@@ -523,8 +522,7 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,struct conn_info pm_info, rpc_info;int proto;unsigned int vers; -struct timeval start, end; -struct timezone tz; +struct timespec start, end;double taken =0 ;time_t timeout =RPC_TIMEOUT ;int status =0 ;
@@ -610,16 +608,16 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,if (status == -EHOSTUNREACH ) goto done;else if (!status) { -gettimeofday (&start, &tz); +clock_gettime (CLOCK_MONOTONIC , &start); status =rpc_ping_proto (&rpc_info); -gettimeofday (&end, &tz); +clock_gettime (CLOCK_MONOTONIC , &end);if (status >0 ) {if (random_selection) {/* Random value between 0 and 1 */ taken = ((float )random ())/((float )RAND_MAX +1 );debug (logopt,"random selection time %f" , taken); }else { - taken =elapsed (start, end); + taken =monotonic_elapsed (start, end);debug (logopt,"rpc ping time %f" , taken); } }
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerPATCH v5 7/8 autofs-5.1.1 - change time() to use monotonic_clock()
In reply to Ian KentFrom: Yu Ning <[email protected]>
The time returned by gettimeofday() is affected by discontinuous jumps in the system time, so it causes an issue that autofs may not auto unmount a mount point if system time is manually changed by the system administrator.
To fix the issue we need to convert to using a monotonic clock source instead of the clock source used by gettimeofday().
Finally hange the time() function calls to monotonic_clock() calls.
--- CHANGELOG | 1 + daemon/automount.c | 4 ++-- daemon/direct.c | 4 ++-- daemon/indirect.c | 4 ++-- daemon/lookup.c | 6 +++--- daemon/state.c | 2 +- lib/cache.c | 2 +- lib/master.c | 4 ++-- modules/dclist.c | 2 +- modules/lookup_file.c | 8 ++++---- modules/lookup_hesiod.c | 6 +++--- modules/lookup_hosts.c | 4 ++-- modules/lookup_ldap.c | 10 +++++----- modules/lookup_nisplus.c | 10 +++++----- modules/lookup_program.c | 10 +++++----- modules/lookup_sss.c | 6 +++--- modules/lookup_userhome.c | 2 +- modules/lookup_yp.c | 8 ++++---- modules/mount_autofs.c | 2 +- modules/parse_amd.c | 2 +- modules/replicated.c | 4 ++-- 21 files changed, 51 insertions(+), 50 deletions(-)
CHANGELOG +1 -0
@@ -24,6 +24,7 @@ - use monotonic clock for direct mount condition. - use monotonic clock for indirect mount condition. - change remaining gettimeofday() to use clock_gettime(). +- change time() to use monotonic_clock(). 21/04/2015 autofs-5.1.1 =======================
daemon/automount.c +2 -2
@@ -1454,7 +1454,7 @@ static void *statemachine(void *arg)break ;case SIGHUP : -do_hup_signal (master_list,time (NULL )); +do_hup_signal (master_list,monotonic_time (NULL ));break ;default :
@@ -2005,7 +2005,7 @@ int main(int argc, char *argv[])unsigned ghost, logging, daemon_check;unsigned dumpmaps, foreground, have_global_options;time_t timeout; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );struct rlimit rlim;const char *options ="+hp:t:vmdD:fVrO:l:n:CF" ;static const struct option long_options[] = {
daemon/direct.c +2 -2
@@ -468,7 +468,7 @@ int mount_autofs_direct(struct autofs_point *ap)struct mapent_cache *nc, *mc;struct mapent *me, *ne, *nested;struct mnt_list *mnts; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );if (strcmp (ap->path,"/-" )) {error (ap->logopt,"expected direct map, exiting" );
@@ -1387,7 +1387,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_ }/* Check if we recorded a mount fail for this key */ -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) { ops->send_fail (ap->logopt, ioctlfd, pkt->wait_queue_token, -ENOENT ); ops->close (ap->logopt, ioctlfd);
daemon/indirect.c +2 -2
@@ -201,7 +201,7 @@ out_err:int mount_autofs_indirect (struct autofs_point *ap,const char *root) { -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );int status;int map;
@@ -817,7 +817,7 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin/* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, pkt->name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) { ops->send_fail (ap->logopt, ap->ioctlfd, pkt->wait_queue_token, -ENOENT );cache_unlock (me->mc);
daemon/lookup.c +3 -3
@@ -875,7 +875,7 @@ static int lookup_name_file_source_instance(struct autofs_point *ap, struct map_struct map_source *instance;char src_file[] ="file" ;char src_prog[] ="program" ; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );struct stat st;char *type, *format;
@@ -915,7 +915,7 @@ static int lookup_name_source_instance(struct autofs_point *ap, struct map_sourc {struct map_source *instance;const char *format; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );if (*name =='/' && map->flags &MAP_FLAG_FORMAT_AMD )return lookup_amd_instance (ap, map, name, name_len);
@@ -1079,7 +1079,7 @@ static void update_negative_cache(struct autofs_point *ap, struct map_source *soelse map = entry->maps;if (map) { -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );int rv =CHE_FAIL ;cache_writelock (map->mc);
daemon/state.c +1 -1
@@ -564,7 +564,7 @@ static unsigned int st_readmap(struct autofs_point *ap)pthread_t thid;struct readmap_args *ra;int status; -int now =time (NULL ); +int now =monotonic_time (NULL );debug (ap->logopt,"state %d path %s" , ap->state, ap->path);
lib/cache.c +1 -1
@@ -775,7 +775,7 @@ void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout) { - time_t now = time(NULL); + time_t now = monotonic_time(NULL);struct mapent *me;int rv =CHE_OK ;
lib/master.c +2 -2
@@ -1484,7 +1484,7 @@ int dump_map(struct master *master, const char *type, const char *name)struct map_source *source;struct master_mapent *this;struct autofs_point *ap; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL ); this = list_entry(p, struct master_mapent, list); p = p->next;
@@ -1602,7 +1602,7 @@ int master_show_mounts(struct master *master)struct map_source *source;struct master_mapent *this;struct autofs_point *ap; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );unsigned int count =0 ; this = list_entry(p, struct master_mapent, list);
modules/dclist.c +1 -1
@@ -568,7 +568,7 @@ struct dclist *get_dc_list(unsigned int logopt, const char *uri)if (!list) goto out_error; - dclist->expire =time (NULL ) + min_ttl; + dclist->expire =monotonic_time (NULL ) + min_ttl; dclist->uri = list;return dclist;
modules/lookup_file.c +4 -4
@@ -743,7 +743,7 @@ static int match_key(struct autofs_point *ap, {char buf[MAX_ERR_BUF ];struct mapent_cache *mc; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );char *lkp_key;char *prefix;size_t map_key_len;
@@ -808,7 +808,7 @@ static int lookup_one(struct autofs_point *ap,struct mapent_cache *mc = source->mc;char mkey[KEY_MAX_LEN +1 ];char mapent[MAPENT_MAX_LEN +1 ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );FILE *f;unsigned int k_len, m_len;int entry, ret;
@@ -914,7 +914,7 @@ static int lookup_wild(struct autofs_point *ap,struct mapent_cache *mc;char mkey[KEY_MAX_LEN +1 ];char mapent[MAPENT_MAX_LEN +1 ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );FILE *f;unsigned int k_len, m_len;int entry, ret;
@@ -1118,7 +1118,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {
modules/lookup_hesiod.c +3 -3
@@ -163,7 +163,7 @@ static int lookup_one(struct autofs_point *ap, }cache_writelock (mc); - ret =cache_update (mc, source, key, best_record,time (NULL )); + ret =cache_update (mc, source, key, best_record,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {hesiod_free_list (ctxt->hesiod_context, hes_result);
@@ -228,7 +228,7 @@ static int lookup_one_amd(struct autofs_point *ap, }cache_writelock (mc); - ret =cache_update (mc, source, lkp_key, *hes_result,time (NULL )); + ret =cache_update (mc, source, lkp_key, *hes_result,monotonic_time (NULL ));cache_unlock (mc);if (hes_result)
@@ -339,7 +339,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {
modules/lookup_hosts.c +2 -2
@@ -284,7 +284,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *struct mapent *me;char *mapent =NULL ;int mapent_len; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );int ret; source = ap->entry->current;
@@ -296,7 +296,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {
modules/lookup_ldap.c +5 -5
@@ -999,7 +999,7 @@ static int do_reconnect(unsigned logopt,uris_mutex_lock (ctxt);if (ctxt->dclist) { -if (!ldap || ctxt->dclist->expire <time (NULL )) { +if (!ldap || ctxt->dclist->expire <monotonic_time (NULL )) {free_dclist (ctxt->dclist); ctxt->dclist =NULL ; }
@@ -2913,7 +2913,7 @@ static int lookup_one(struct autofs_point *ap, struct map_source *source,struct mapent_cache *mc;int rv, i, l, ql, count;char buf[MAX_ERR_BUF ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );char *query;LDAPMessage *result =NULL , *e;char *class, *info, *entry;
@@ -3278,7 +3278,7 @@ static int lookup_one_amd(struct autofs_point *ap,struct berval **bvKey;struct berval **bvValues;char buf[MAX_ERR_BUF ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int rv, l, ql, count;int ret =CHE_MISSING ;
@@ -3483,7 +3483,7 @@ static int check_map_indirect(struct autofs_point *ap,unsigned int is_amd_format = source->flags &MAP_FLAG_FORMAT_AMD ;struct mapent_cache *mc;struct mapent *me; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t t_last_read;int ret, cur_state;int status;
@@ -3621,7 +3621,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {
modules/lookup_nisplus.c +5 -5
@@ -288,7 +288,7 @@ static int lookup_one(struct autofs_point *ap,nis_result *result;nis_object *this;char *mapent; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret, cur_state;char buf[MAX_ERR_BUF ];
@@ -400,7 +400,7 @@ static int lookup_wild(struct autofs_point *ap,nis_result *result;nis_object *this;char *mapent; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret, cur_state;char buf[MAX_ERR_BUF ];
@@ -487,7 +487,7 @@ static int lookup_amd_defaults(struct autofs_point *ap, mapent =ENTRY_VAL (this,1 );cache_writelock (mc); - ret =cache_update (mc, source,"/defaults" , mapent,time (NULL )); + ret =cache_update (mc, source,"/defaults" , mapent,monotonic_time (NULL ));cache_unlock (mc);nis_freeresult (result);
@@ -505,7 +505,7 @@ static int check_map_indirect(struct autofs_point *ap,unsigned int is_amd_format = source->flags &MAP_FLAG_FORMAT_AMD ;struct mapent_cache *mc;struct mapent *me, *exists; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t t_last_read;int ret =0 ;
@@ -650,7 +650,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {
modules/lookup_program.c +5 -5
@@ -369,7 +369,7 @@ static int lookup_amd_defaults(struct autofs_point *ap,while (isblank (*start)) start++;cache_writelock (mc); - ret =cache_update (mc, source,"/defaults" , start,time (NULL )); + ret =cache_update (mc, source,"/defaults" , start,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {free (ment);
@@ -438,7 +438,7 @@ static int match_key(struct autofs_point *ap, start++; }cache_writelock (mc); - ret =cache_update (mc, source, lkp_key, start,time (NULL )); + ret =cache_update (mc, source, lkp_key, start,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {free (ment);
@@ -491,7 +491,7 @@ static int match_key(struct autofs_point *ap,while (isblank (*start)) start++;cache_writelock (mc); - ret =cache_update (mc, source, match, start,time (NULL )); + ret =cache_update (mc, source, match, start,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {free (match);
@@ -537,7 +537,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {
@@ -586,7 +586,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void ** proceed with the program map lookup. */ if (strchr (name,'/' ) || - me->age + ap->negative_timeout >time (NULL )) { + me->age + ap->negative_timeout >monotonic_time (NULL )) {char *ent =NULL ;if (me->mapent) {
modules/lookup_sss.c +3 -3
@@ -380,7 +380,7 @@ static int lookup_one(struct autofs_point *ap,struct mapent_cache *mc;struct mapent *we;void *sss_ctxt =NULL ; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );char buf[MAX_ERR_BUF ];char *value =NULL ;char *s_key;
@@ -501,7 +501,7 @@ static int check_map_indirect(struct autofs_point *ap,struct map_source *source;struct mapent_cache *mc;struct mapent *me; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t t_last_read;int ret, cur_state;
@@ -595,7 +595,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {
modules/lookup_userhome.c +1 -1
@@ -77,7 +77,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void * }cache_writelock (mc); - ret =cache_update (mc, source, name,NULL ,time (NULL )); + ret =cache_update (mc, source, name,NULL ,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {
modules/lookup_yp.c +4 -4
@@ -405,7 +405,7 @@ static int lookup_one(struct autofs_point *ap,char *mapname;char *mapent;int mapent_len; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret; mc = source->mc;
@@ -517,7 +517,7 @@ static int lookup_wild(struct autofs_point *ap,char *mapname;char *mapent;int mapent_len; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret; mc = source->mc;
@@ -598,7 +598,7 @@ static int lookup_amd_defaults(struct autofs_point *ap,return CHE_FAIL ;cache_writelock (mc); - ret =cache_update (mc, source,"/defaults" , mapent,time (NULL )); + ret =cache_update (mc, source,"/defaults" , mapent,monotonic_time (NULL ));cache_unlock (mc);return ret;
@@ -753,7 +753,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {
modules/mount_autofs.c +1 -1
@@ -242,7 +242,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, source =master_add_map_source (entry, info->type, info->format, -time (NULL ), argc, argv); +monotonic_time (NULL ), argc, argv);if (!source) {error (ap->logopt,MODPREFIX "failed to add map source to entry" );
modules/parse_amd.c +1 -1
@@ -1181,7 +1181,7 @@ static int do_host_mount(struct autofs_point *ap, const char *name, "hosts", "sun", argc, pargv);if (!instance) { instance =master_add_source_instance (source, -"hosts" ,"sun" ,time (NULL ), argc, pargv); +"hosts" ,"sun" ,monotonic_time (NULL ), argc, pargv);if (!instance) {error (ap->logopt,MODPREFIX "failed to create source instance for hosts map" );
modules/replicated.c +2 -2
@@ -69,14 +69,14 @@ void seed_random(void) fd =open_fd ("/dev/urandom" ,O_RDONLY );if (fd <0 ) { -srandom (time (NULL )); +srandom (monotonic_time (NULL ));return ; }if (read (fd, &seed,sizeof (seed)) !=-1 )srandom (seed);else -srandom (time (NULL )); +srandom (monotonic_time (NULL ));close (fd);
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Re: [PATCH v5 7/8] autofs-5.1.1 - change time() to use monotonic_clock()
Quoted 42 lines · Ian Kent
From: Yu Ning <[email protected]>
The time returned by
gettimeofday()is affected by discontinuous jumps in the system time, so it causes an issue that autofs may not auto unmount a mount point if system time is manually changed by the system administrator.To fix the issue we need to convert to using a monotonic clock source instead of the clock source used by
gettimeofday().Finally hange the
time()function calls tomonotonic_clock()calls.Signed-off-by Yu Ning <[email protected]>--- CHANGELOG | 1 + daemon/automount.c | 4 ++-- daemon/direct.c | 4 ++-- daemon/indirect.c | 4 ++-- daemon/lookup.c | 6 +++--- daemon/state.c | 2 +- lib/cache.c | 2 +- lib/master.c | 4 ++-- modules/dclist.c | 2 +- modules/lookup_file.c | 8 ++++---- modules/lookup_hesiod.c | 6 +++--- modules/lookup_hosts.c | 4 ++-- modules/lookup_ldap.c | 10 +++++----- modules/lookup_nisplus.c | 10 +++++----- modules/lookup_program.c | 10 +++++----- modules/lookup_sss.c | 6 +++--- modules/lookup_userhome.c | 2 +- modules/lookup_yp.c | 8 ++++---- modules/mount_autofs.c | 2 +- modules/parse_amd.c | 2 +- modules/replicated.c | 4 ++-- 21 files changed, 51 insertions(+), 50 deletions(-)CHANGELOG +0
-0
CHANGELOG line 27
Quoted 4 lines
CHANGELOG +1
-0@@ -24,6 +24,7 @@ - use monotonic clock for direct mount condition. - use monotonic clock for indirect mount condition. - change remaining gettimeofday() to use clock_gettime(). +- change time() to use monotonic_clock().
I guess monotonic_clock() shall be monotonic_time(), ;)
Quoted 523 lines
CHANGELOG +0
-021/04/2015 autofs-5.1.1 =======================daemon/automount.c +2
-2@@ -1454,7 +1454,7 @@ static void *statemachine(void *arg)break ;case SIGHUP : -do_hup_signal (master_list,time (NULL )); +do_hup_signal (master_list,monotonic_time (NULL ));break ;default :@@ -2005,7 +2005,7 @@ int main(int argc, char *argv[])unsigned ghost, logging, daemon_check;unsigned dumpmaps, foreground, have_global_options;time_t timeout; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );struct rlimit rlim;const char *options ="+hp:t:vmdD:fVrO:l:n:CF" ;static const struct option long_options[] = {daemon/direct.c +2
-2@@ -468,7 +468,7 @@ int mount_autofs_direct(struct autofs_point *ap)struct mapent_cache *nc, *mc;struct mapent *me, *ne, *nested;struct mnt_list *mnts; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );if (strcmp (ap->path,"/-" )) {error (ap->logopt,"expected direct map, exiting" );@@ -1387,7 +1387,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_ }/* Check if we recorded a mount fail for this key */ -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) { ops->send_fail (ap->logopt, ioctlfd, pkt->wait_queue_token, -ENOENT ); ops->close (ap->logopt, ioctlfd);daemon/indirect.c +2
-2@@ -201,7 +201,7 @@ out_err:int mount_autofs_indirect (struct autofs_point *ap,const char *root) { -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );int status;int map;@@ -817,7 +817,7 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin/* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, pkt->name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) { ops->send_fail (ap->logopt, ap->ioctlfd, pkt->wait_queue_token, -ENOENT );cache_unlock (me->mc);daemon/lookup.c +3
-3@@ -875,7 +875,7 @@ static int lookup_name_file_source_instance(struct autofs_point *ap, struct map_struct map_source *instance;char src_file[] ="file" ;char src_prog[] ="program" ; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );struct stat st;char *type, *format;@@ -915,7 +915,7 @@ static int lookup_name_source_instance(struct autofs_point *ap, struct map_sourc {struct map_source *instance;const char *format; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );if (*name =='/' && map->flags &MAP_FLAG_FORMAT_AMD )return lookup_amd_instance (ap, map, name, name_len);@@ -1079,7 +1079,7 @@ static void update_negative_cache(struct autofs_point *ap, struct map_source *soelse map = entry->maps;if (map) { -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );int rv =CHE_FAIL ;cache_writelock (map->mc);daemon/state.c +1
-1@@ -564,7 +564,7 @@ static unsigned int st_readmap(struct autofs_point *ap)pthread_t thid;struct readmap_args *ra;int status; -int now =time (NULL ); +int now =monotonic_time (NULL );debug (ap->logopt,"state %d path %s" , ap->state, ap->path);lib/cache.c +1
-1@@ -775,7 +775,7 @@ void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout) { - time_t now = time(NULL); + time_t now = monotonic_time(NULL);struct mapent *me;int rv =CHE_OK ;lib/master.c +2
-2@@ -1484,7 +1484,7 @@ int dump_map(struct master *master, const char *type, const char *name)struct map_source *source;struct master_mapent *this;struct autofs_point *ap; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL ); this = list_entry(p, struct master_mapent, list); p = p->next;@@ -1602,7 +1602,7 @@ int master_show_mounts(struct master *master)struct map_source *source;struct master_mapent *this;struct autofs_point *ap; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );unsigned int count =0 ; this = list_entry(p, struct master_mapent, list);modules/dclist.c +1
-1@@ -568,7 +568,7 @@ struct dclist *get_dc_list(unsigned int logopt, const char *uri)if (!list) goto out_error; - dclist->expire =time (NULL ) + min_ttl; + dclist->expire =monotonic_time (NULL ) + min_ttl; dclist->uri = list;return dclist;modules/lookup_file.c +4
-4@@ -743,7 +743,7 @@ static int match_key(struct autofs_point *ap, {char buf[MAX_ERR_BUF ];struct mapent_cache *mc; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );char *lkp_key;char *prefix;size_t map_key_len;@@ -808,7 +808,7 @@ static int lookup_one(struct autofs_point *ap,struct mapent_cache *mc = source->mc;char mkey[KEY_MAX_LEN +1 ];char mapent[MAPENT_MAX_LEN +1 ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );FILE *f;unsigned int k_len, m_len;int entry, ret;@@ -914,7 +914,7 @@ static int lookup_wild(struct autofs_point *ap,struct mapent_cache *mc;char mkey[KEY_MAX_LEN +1 ];char mapent[MAPENT_MAX_LEN +1 ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );FILE *f;unsigned int k_len, m_len;int entry, ret;@@ -1118,7 +1118,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_hesiod.c +3
-3@@ -163,7 +163,7 @@ static int lookup_one(struct autofs_point *ap, }cache_writelock (mc); - ret =cache_update (mc, source, key, best_record,time (NULL )); + ret =cache_update (mc, source, key, best_record,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {hesiod_free_list (ctxt->hesiod_context, hes_result);@@ -228,7 +228,7 @@ static int lookup_one_amd(struct autofs_point *ap, }cache_writelock (mc); - ret =cache_update (mc, source, lkp_key, *hes_result,time (NULL )); + ret =cache_update (mc, source, lkp_key, *hes_result,monotonic_time (NULL ));cache_unlock (mc);if (hes_result)@@ -339,7 +339,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_hosts.c +2
-2@@ -284,7 +284,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *struct mapent *me;char *mapent =NULL ;int mapent_len; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );int ret; source = ap->entry->current;@@ -296,7 +296,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_ldap.c +5
-5@@ -999,7 +999,7 @@ static int do_reconnect(unsigned logopt,uris_mutex_lock (ctxt);if (ctxt->dclist) { -if (!ldap || ctxt->dclist->expire <time (NULL )) { +if (!ldap || ctxt->dclist->expire <monotonic_time (NULL )) {free_dclist (ctxt->dclist); ctxt->dclist =NULL ; }@@ -2913,7 +2913,7 @@ static int lookup_one(struct autofs_point *ap, struct map_source *source,struct mapent_cache *mc;int rv, i, l, ql, count;char buf[MAX_ERR_BUF ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );char *query;LDAPMessage *result =NULL , *e;char *class, *info, *entry;@@ -3278,7 +3278,7 @@ static int lookup_one_amd(struct autofs_point *ap,struct berval **bvKey;struct berval **bvValues;char buf[MAX_ERR_BUF ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int rv, l, ql, count;int ret =CHE_MISSING ;@@ -3483,7 +3483,7 @@ static int check_map_indirect(struct autofs_point *ap,unsigned int is_amd_format = source->flags &MAP_FLAG_FORMAT_AMD ;struct mapent_cache *mc;struct mapent *me; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t t_last_read;int ret, cur_state;int status;@@ -3621,7 +3621,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_nisplus.c +5
-5@@ -288,7 +288,7 @@ static int lookup_one(struct autofs_point *ap,nis_result *result;nis_object *this;char *mapent; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret, cur_state;char buf[MAX_ERR_BUF ];@@ -400,7 +400,7 @@ static int lookup_wild(struct autofs_point *ap,nis_result *result;nis_object *this;char *mapent; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret, cur_state;char buf[MAX_ERR_BUF ];@@ -487,7 +487,7 @@ static int lookup_amd_defaults(struct autofs_point *ap, mapent =ENTRY_VAL (this,1 );cache_writelock (mc); - ret =cache_update (mc, source,"/defaults" , mapent,time (NULL )); + ret =cache_update (mc, source,"/defaults" , mapent,monotonic_time (NULL ));cache_unlock (mc);nis_freeresult (result);@@ -505,7 +505,7 @@ static int check_map_indirect(struct autofs_point *ap,unsigned int is_amd_format = source->flags &MAP_FLAG_FORMAT_AMD ;struct mapent_cache *mc;struct mapent *me, *exists; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t t_last_read;int ret =0 ;@@ -650,7 +650,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_program.c +5
-5@@ -369,7 +369,7 @@ static int lookup_amd_defaults(struct autofs_point *ap,while (isblank (*start)) start++;cache_writelock (mc); - ret =cache_update (mc, source,"/defaults" , start,time (NULL )); + ret =cache_update (mc, source,"/defaults" , start,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {free (ment);@@ -438,7 +438,7 @@ static int match_key(struct autofs_point *ap, start++; }cache_writelock (mc); - ret =cache_update (mc, source, lkp_key, start,time (NULL )); + ret =cache_update (mc, source, lkp_key, start,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {free (ment);@@ -491,7 +491,7 @@ static int match_key(struct autofs_point *ap,while (isblank (*start)) start++;cache_writelock (mc); - ret =cache_update (mc, source, match, start,time (NULL )); + ret =cache_update (mc, source, match, start,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {free (match);@@ -537,7 +537,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {@@ -586,7 +586,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void ** proceed with the program map lookup. */ if (strchr (name,'/' ) || - me->age + ap->negative_timeout >time (NULL )) { + me->age + ap->negative_timeout >monotonic_time (NULL )) {char *ent =NULL ;if (me->mapent) {modules/lookup_sss.c +3
-3@@ -380,7 +380,7 @@ static int lookup_one(struct autofs_point *ap,struct mapent_cache *mc;struct mapent *we;void *sss_ctxt =NULL ; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );char buf[MAX_ERR_BUF ];char *value =NULL ;char *s_key;@@ -501,7 +501,7 @@ static int check_map_indirect(struct autofs_point *ap,struct map_source *source;struct mapent_cache *mc;struct mapent *me; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t t_last_read;int ret, cur_state;@@ -595,7 +595,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_userhome.c +1
-1@@ -77,7 +77,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void * }cache_writelock (mc); - ret =cache_update (mc, source, name,NULL ,time (NULL )); + ret =cache_update (mc, source, name,NULL ,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {modules/lookup_yp.c +4
-4@@ -405,7 +405,7 @@ static int lookup_one(struct autofs_point *ap,char *mapname;char *mapent;int mapent_len; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret; mc = source->mc;@@ -517,7 +517,7 @@ static int lookup_wild(struct autofs_point *ap,char *mapname;char *mapent;int mapent_len; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret; mc = source->mc;@@ -598,7 +598,7 @@ static int lookup_amd_defaults(struct autofs_point *ap,return CHE_FAIL ;cache_writelock (mc); - ret =cache_update (mc, source,"/defaults" , mapent,time (NULL )); + ret =cache_update (mc, source,"/defaults" , mapent,monotonic_time (NULL ));cache_unlock (mc);return ret;@@ -753,7 +753,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/mount_autofs.c +1
-1@@ -242,7 +242,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, source =master_add_map_source (entry, info->type, info->format, -time (NULL ), argc, argv); +monotonic_time (NULL ), argc, argv);if (!source) {error (ap->logopt,MODPREFIX "failed to add map source to entry" );modules/parse_amd.c +1
-1@@ -1181,7 +1181,7 @@ static int do_host_mount(struct autofs_point *ap, const char *name, "hosts", "sun", argc, pargv);if (!instance) { instance =master_add_source_instance (source, -"hosts" ,"sun" ,time (NULL ), argc, pargv); +"hosts" ,"sun" ,monotonic_time (NULL ), argc, pargv);if (!instance) {error (ap->logopt,MODPREFIX "failed to create source instance for hosts map" );modules/replicated.c +1
-1@@ -69,14 +69,14 @@ void seed_random(void) fd =open_fd ("/dev/urandom" ,O_RDONLY );if (fd <0 ) { -srandom (time (NULL )); +srandom (monotonic_time (NULL ));return ;
modules/replicated.c void seed_random(void) · line 82
Quoted 10 lines
modules/replicated.c +1
-1}if (read (fd, &seed,sizeof (seed)) !=-1 )srandom (seed);else -srandom (time (NULL )); +srandom (monotonic_time (NULL ));close (fd);
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerRe: [PATCH v5 7/8] autofs-5.1.1 - change time() to use monotonic_clock()
Quoted 38 lines · Ning Yu
Quoted 37 lines · Ian Kent
From: Yu Ning <[email protected]>
The time returned by
gettimeofday()is affected by discontinuous jumps in the system time, so it causes an issue that autofs may not auto unmount a mount point if system time is manually changed by the system administrator.To fix the issue we need to convert to using a monotonic clock source instead of the clock source used by
gettimeofday().Finally hange the
time()function calls tomonotonic_clock()calls.Signed-off-by Yu Ning <[email protected]>--- CHANGELOG | 1 + daemon/automount.c | 4 ++-- daemon/direct.c | 4 ++-- daemon/indirect.c | 4 ++-- daemon/lookup.c | 6 +++--- daemon/state.c | 2 +- lib/cache.c | 2 +- lib/master.c | 4 ++-- modules/dclist.c | 2 +- modules/lookup_file.c | 8 ++++---- modules/lookup_hesiod.c | 6 +++--- modules/lookup_hosts.c | 4 ++-- modules/lookup_ldap.c | 10 +++++----- modules/lookup_nisplus.c | 10 +++++----- modules/lookup_program.c | 10 +++++----- modules/lookup_sss.c | 6 +++--- modules/lookup_userhome.c | 2 +- modules/lookup_yp.c | 8 ++++---- modules/mount_autofs.c | 2 +- modules/parse_amd.c | 2 +- modules/replicated.c | 4 ++-- 21 files changed, 51 insertions(+), 50 deletions(-)
Quoted 11 lines
CHANGELOG line 27
Quoted 9 lines
CHANGELOG +1
-0@@ -24,6 +24,7 @@ - use monotonic clock for direct mount condition. - use monotonic clock for indirect mount condition. - change remaining gettimeofday() to use clock_gettime(). +- change time() to use monotonic_clock().I guess
monotonic_clock()shall bemonotonic_time(), ;)
Oops, yes.
Quoted 531 lines
Quoted 531 lines
CHANGELOG +0
-021/04/2015 autofs-5.1.1 =======================daemon/automount.c +2
-2@@ -1454,7 +1454,7 @@ static void *statemachine(void *arg)break ;case SIGHUP : -do_hup_signal (master_list,time (NULL )); +do_hup_signal (master_list,monotonic_time (NULL ));break ;default :@@ -2005,7 +2005,7 @@ int main(int argc, char *argv[])unsigned ghost, logging, daemon_check;unsigned dumpmaps, foreground, have_global_options;time_t timeout; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );struct rlimit rlim;const char *options ="+hp:t:vmdD:fVrO:l:n:CF" ;static const struct option long_options[] = {daemon/direct.c +2
-2@@ -468,7 +468,7 @@ int mount_autofs_direct(struct autofs_point *ap)struct mapent_cache *nc, *mc;struct mapent *me, *ne, *nested;struct mnt_list *mnts; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );if (strcmp (ap->path,"/-" )) {error (ap->logopt,"expected direct map, exiting" );@@ -1387,7 +1387,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_ }/* Check if we recorded a mount fail for this key */ -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) { ops->send_fail (ap->logopt, ioctlfd, pkt->wait_queue_token, -ENOENT ); ops->close (ap->logopt, ioctlfd);daemon/indirect.c +2
-2@@ -201,7 +201,7 @@ out_err:int mount_autofs_indirect (struct autofs_point *ap,const char *root) { -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );int status;int map;@@ -817,7 +817,7 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin/* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, pkt->name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) { ops->send_fail (ap->logopt, ap->ioctlfd, pkt->wait_queue_token, -ENOENT );cache_unlock (me->mc);daemon/lookup.c +3
-3@@ -875,7 +875,7 @@ static int lookup_name_file_source_instance(struct autofs_point *ap, struct map_struct map_source *instance;char src_file[] ="file" ;char src_prog[] ="program" ; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );struct stat st;char *type, *format;@@ -915,7 +915,7 @@ static int lookup_name_source_instance(struct autofs_point *ap, struct map_sourc {struct map_source *instance;const char *format; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );if (*name =='/' && map->flags &MAP_FLAG_FORMAT_AMD )return lookup_amd_instance (ap, map, name, name_len);@@ -1079,7 +1079,7 @@ static void update_negative_cache(struct autofs_point *ap, struct map_source *soelse map = entry->maps;if (map) { -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );int rv =CHE_FAIL ;cache_writelock (map->mc);daemon/state.c +1
-1@@ -564,7 +564,7 @@ static unsigned int st_readmap(struct autofs_point *ap)pthread_t thid;struct readmap_args *ra;int status; -int now =time (NULL ); +int now =monotonic_time (NULL );debug (ap->logopt,"state %d path %s" , ap->state, ap->path);lib/cache.c +1
-1@@ -775,7 +775,7 @@ void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout) { - time_t now = time(NULL); + time_t now = monotonic_time(NULL);struct mapent *me;int rv =CHE_OK ;lib/master.c +2
-2@@ -1484,7 +1484,7 @@ int dump_map(struct master *master, const char *type, const char *name)struct map_source *source;struct master_mapent *this;struct autofs_point *ap; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL ); this = list_entry(p, struct master_mapent, list); p = p->next;@@ -1602,7 +1602,7 @@ int master_show_mounts(struct master *master)struct map_source *source;struct master_mapent *this;struct autofs_point *ap; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );unsigned int count =0 ; this = list_entry(p, struct master_mapent, list);modules/dclist.c +1
-1@@ -568,7 +568,7 @@ struct dclist *get_dc_list(unsigned int logopt, const char *uri)if (!list) goto out_error; - dclist->expire =time (NULL ) + min_ttl; + dclist->expire =monotonic_time (NULL ) + min_ttl; dclist->uri = list;return dclist;modules/lookup_file.c +4
-4@@ -743,7 +743,7 @@ static int match_key(struct autofs_point *ap, {char buf[MAX_ERR_BUF ];struct mapent_cache *mc; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );char *lkp_key;char *prefix;size_t map_key_len;@@ -808,7 +808,7 @@ static int lookup_one(struct autofs_point *ap,struct mapent_cache *mc = source->mc;char mkey[KEY_MAX_LEN +1 ];char mapent[MAPENT_MAX_LEN +1 ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );FILE *f;unsigned int k_len, m_len;int entry, ret;@@ -914,7 +914,7 @@ static int lookup_wild(struct autofs_point *ap,struct mapent_cache *mc;char mkey[KEY_MAX_LEN +1 ];char mapent[MAPENT_MAX_LEN +1 ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );FILE *f;unsigned int k_len, m_len;int entry, ret;@@ -1118,7 +1118,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_hesiod.c +3
-3@@ -163,7 +163,7 @@ static int lookup_one(struct autofs_point *ap, }cache_writelock (mc); - ret =cache_update (mc, source, key, best_record,time (NULL )); + ret =cache_update (mc, source, key, best_record,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {hesiod_free_list (ctxt->hesiod_context, hes_result);@@ -228,7 +228,7 @@ static int lookup_one_amd(struct autofs_point *ap, }cache_writelock (mc); - ret =cache_update (mc, source, lkp_key, *hes_result,time (NULL )); + ret =cache_update (mc, source, lkp_key, *hes_result,monotonic_time (NULL ));cache_unlock (mc);if (hes_result)@@ -339,7 +339,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_hosts.c +2
-2@@ -284,7 +284,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *struct mapent *me;char *mapent =NULL ;int mapent_len; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );int ret; source = ap->entry->current;@@ -296,7 +296,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_ldap.c +5
-5@@ -999,7 +999,7 @@ static int do_reconnect(unsigned logopt,uris_mutex_lock (ctxt);if (ctxt->dclist) { -if (!ldap || ctxt->dclist->expire <time (NULL )) { +if (!ldap || ctxt->dclist->expire <monotonic_time (NULL )) {free_dclist (ctxt->dclist); ctxt->dclist =NULL ; }@@ -2913,7 +2913,7 @@ static int lookup_one(struct autofs_point *ap, struct map_source *source,struct mapent_cache *mc;int rv, i, l, ql, count;char buf[MAX_ERR_BUF ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );char *query;LDAPMessage *result =NULL , *e;char *class, *info, *entry;@@ -3278,7 +3278,7 @@ static int lookup_one_amd(struct autofs_point *ap,struct berval **bvKey;struct berval **bvValues;char buf[MAX_ERR_BUF ]; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int rv, l, ql, count;int ret =CHE_MISSING ;@@ -3483,7 +3483,7 @@ static int check_map_indirect(struct autofs_point *ap,unsigned int is_amd_format = source->flags &MAP_FLAG_FORMAT_AMD ;struct mapent_cache *mc;struct mapent *me; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t t_last_read;int ret, cur_state;int status;@@ -3621,7 +3621,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_nisplus.c +5
-5@@ -288,7 +288,7 @@ static int lookup_one(struct autofs_point *ap,nis_result *result;nis_object *this;char *mapent; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret, cur_state;char buf[MAX_ERR_BUF ];@@ -400,7 +400,7 @@ static int lookup_wild(struct autofs_point *ap,nis_result *result;nis_object *this;char *mapent; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret, cur_state;char buf[MAX_ERR_BUF ];@@ -487,7 +487,7 @@ static int lookup_amd_defaults(struct autofs_point *ap, mapent =ENTRY_VAL (this,1 );cache_writelock (mc); - ret =cache_update (mc, source,"/defaults" , mapent,time (NULL )); + ret =cache_update (mc, source,"/defaults" , mapent,monotonic_time (NULL ));cache_unlock (mc);nis_freeresult (result);@@ -505,7 +505,7 @@ static int check_map_indirect(struct autofs_point *ap,unsigned int is_amd_format = source->flags &MAP_FLAG_FORMAT_AMD ;struct mapent_cache *mc;struct mapent *me, *exists; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t t_last_read;int ret =0 ;@@ -650,7 +650,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_program.c +5
-5@@ -369,7 +369,7 @@ static int lookup_amd_defaults(struct autofs_point *ap,while (isblank (*start)) start++;cache_writelock (mc); - ret =cache_update (mc, source,"/defaults" , start,time (NULL )); + ret =cache_update (mc, source,"/defaults" , start,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {free (ment);@@ -438,7 +438,7 @@ static int match_key(struct autofs_point *ap, start++; }cache_writelock (mc); - ret =cache_update (mc, source, lkp_key, start,time (NULL )); + ret =cache_update (mc, source, lkp_key, start,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {free (ment);@@ -491,7 +491,7 @@ static int match_key(struct autofs_point *ap,while (isblank (*start)) start++;cache_writelock (mc); - ret =cache_update (mc, source, match, start,time (NULL )); + ret =cache_update (mc, source, match, start,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {free (match);@@ -537,7 +537,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {@@ -586,7 +586,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void ** proceed with the program map lookup. */ if (strchr (name,'/' ) || - me->age + ap->negative_timeout >time (NULL )) { + me->age + ap->negative_timeout >monotonic_time (NULL )) {char *ent =NULL ;if (me->mapent) {modules/lookup_sss.c +3
-3@@ -380,7 +380,7 @@ static int lookup_one(struct autofs_point *ap,struct mapent_cache *mc;struct mapent *we;void *sss_ctxt =NULL ; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );char buf[MAX_ERR_BUF ];char *value =NULL ;char *s_key;@@ -501,7 +501,7 @@ static int check_map_indirect(struct autofs_point *ap,struct map_source *source;struct mapent_cache *mc;struct mapent *me; -time_t now =time (NULL ); +time_t now =monotonic_time (NULL );time_t t_last_read;int ret, cur_state;@@ -595,7 +595,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/lookup_userhome.c +1
-1@@ -77,7 +77,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void * }cache_writelock (mc); - ret =cache_update (mc, source, name,NULL ,time (NULL )); + ret =cache_update (mc, source, name,NULL ,monotonic_time (NULL ));cache_unlock (mc);if (ret ==CHE_FAIL ) {modules/lookup_yp.c +4
-4@@ -405,7 +405,7 @@ static int lookup_one(struct autofs_point *ap,char *mapname;char *mapent;int mapent_len; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret; mc = source->mc;@@ -517,7 +517,7 @@ static int lookup_wild(struct autofs_point *ap,char *mapname;char *mapent;int mapent_len; -time_t age =time (NULL ); +time_t age =monotonic_time (NULL );int ret; mc = source->mc;@@ -598,7 +598,7 @@ static int lookup_amd_defaults(struct autofs_point *ap,return CHE_FAIL ;cache_writelock (mc); - ret =cache_update (mc, source,"/defaults" , mapent,time (NULL )); + ret =cache_update (mc, source,"/defaults" , mapent,monotonic_time (NULL ));cache_unlock (mc);return ret;@@ -753,7 +753,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, key,LKP_DISTINCT );if (me) { -if (me->status >=time (NULL )) { +if (me->status >=monotonic_time (NULL )) {cache_unlock (me->mc);return NSS_STATUS_NOTFOUND ; }else {modules/mount_autofs.c +1
-1@@ -242,7 +242,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, source =master_add_map_source (entry, info->type, info->format, -time (NULL ), argc, argv); +monotonic_time (NULL ), argc, argv);if (!source) {error (ap->logopt,MODPREFIX "failed to add map source to entry" );modules/parse_amd.c +1
-1@@ -1181,7 +1181,7 @@ static int do_host_mount(struct autofs_point *ap, const char *name, "hosts", "sun", argc, pargv);if (!instance) { instance =master_add_source_instance (source, -"hosts" ,"sun" ,time (NULL ), argc, pargv); +"hosts" ,"sun" ,monotonic_time (NULL ), argc, pargv);if (!instance) {error (ap->logopt,MODPREFIX "failed to create source instance for hosts map" );modules/replicated.c +2
-2@@ -69,14 +69,14 @@ void seed_random(void) fd =open_fd ("/dev/urandom" ,O_RDONLY );if (fd <0 ) { -srandom (time (NULL )); +srandom (monotonic_time (NULL ));return ; }if (read (fd, &seed,sizeof (seed)) !=-1 )srandom (seed);else -srandom (time (NULL )); +srandom (monotonic_time (NULL ));
Quoted 3 lines
modules/replicated.c void seed_random(void) · line 82
Quoted 3 lines
modules/replicated.c +0
-0close (fd);
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerPATCH v5 8/8 autofs-5.1.1 - remove unused function elapsed()
In reply to Ian KentNow that the monotonic clock source is used the elapsed() function is no longer used, remove it.
--- lib/rpc_subs.c | 8 -------- 1 file changed, 8 deletions(-)
lib/rpc_subs.c +0 -8
@@ -1078,14 +1078,6 @@ int rpc_ping(const char *host, long seconds, long micros, unsigned int option)return status; } -double elapsed (struct timeval start,struct timeval end) -{ -double t1, t2; - t1 = (double )start.tv_sec + (double )start.tv_usec/(1000 *1000 ); - t2 = (double )end.tv_sec + (double )end.tv_usec/(1000 *1000 ); -return t2-t1; -} -double monotonic_elapsed (struct timespec start,struct timespec end) {double t1, t2;
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Re: [PATCH v5 8/8] autofs-5.1.1 - remove unused function elapsed()
Quoted 7 lines · Ian Kent
Now that the monotonic clock source is used the
elapsed()function is no longer used, remove it.Signed-off-by Ian Kent <[email protected]>--- lib/rpc_subs.c | 8 -------- 1 file changed, 8 deletions(-)
Oh, I think we also need to remove the declaration of elapsed() in include/rpc_subs.h
Quoted 11 lines
lib/rpc_subs.c +0
-1@@ -1078,14 +1078,6 @@ int rpc_ping(const char *host, long seconds, long micros, unsigned int option)return status; } -double elapsed (struct timeval start,struct timeval end)
lib/rpc_subs.c int rpc_ping(const char *host, long seconds, long micros, unsigned int option) · line 1083
Quoted 10 lines
lib/rpc_subs.c +0
-7-{ -double t1, t2; - t1 = (double )start.tv_sec + (double )start.tv_usec/(1000 *1000 ); - t2 = (double )end.tv_sec + (double )end.tv_usec/(1000 *1000 ); -return t2-t1; -} -double monotonic_elapsed (struct timespec start,struct timespec end) {double t1, t2;
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerRe: [PATCH v5 8/8] autofs-5.1.1 - remove unused function elapsed()
Quoted 11 lines · Ning Yu
Quoted 7 lines · Ian Kent
Now that the monotonic clock source is used the
elapsed()function is no longer used, remove it.Signed-off-by Ian Kent <[email protected]>--- lib/rpc_subs.c | 8 -------- 1 file changed, 8 deletions(-)Oh, I think we also need to remove the declaration of
elapsed()ininclude/rpc_subs.h
Ha, indeed we do.
Quoted 10 lines
Quoted 10 lines
lib/rpc_subs.c +0
-0@@ -1078,14 +1078,6 @@ int rpc_ping(const char *host, long seconds, long micros, unsigned int option)return status; }
Quoted 12 lines
lib/rpc_subs.c int rpc_ping(const char *host, long seconds, long micros, unsigned int option) · line 1083
Quoted 12 lines
lib/rpc_subs.c +0
-8-double elapsed (struct timeval start,struct timeval end) -{ -double t1, t2; - t1 = (double )start.tv_sec + (double )start.tv_usec/(1000 *1000 ); - t2 = (double )end.tv_sec + (double )end.tv_usec/(1000 *1000 ); -return t2-t1; -} -double monotonic_elapsed (struct timespec start,struct timespec end) {double t1, t2;
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Quoted 11 lines · Ian Kent
This is what I get using "stg mail" when mailing patch series.
I've made a few changes to te breakdown of the patches. I tried to implement the alarm module change we discussued. I changed the mount and expire condition to use a monotonic clock as well for both the direc and indirect modules for completeness. And I changed the patch descriptions a bit.
I'll add my "Signed-off-by" after we've verified the series is OK and I've completed some samity testing.
Quoted 7 lines
The series should apply, I don't think there are conflicts with patches in my queue that are before them. The CHANGELOG hunk will be a problem though, as expected, and will likely change due to me changing the patch order before actually committing them.
Let me know if you can see any problem with the series.
It looks much more better than my original version, thanks very much. I'm OK with it, and hope it won't cause any regression issue ;)
Quoted 42 lines
---
Ian Kent (1):
autofs-5.1.1 - remove unused functionelapsed()Yu Ning (7):
autofs-5.1.1 - define monotonic clock helper functions autofs-5.1.1 - use monotonic clock for alarm thread condition wait autofs-5.1.1 - define pending condition init helper function autofs-5.1.1 - use monotonic clock for direct mount condition autofs-5.1.1 - use monotonic clock for indirect mount condition autofs-5.1.1 - change remaininggettimeofday()to useclock_gettime()autofs-5.1.1 - changetime()to usemonotonic_clock()CHANGELOG | 7 +++++++ daemon/automount.c | 4 ++-- daemon/direct.c | 24 ++++++++---------------- daemon/indirect.c | 24 ++++++++---------------- daemon/lookup.c | 6 +++--- daemon/state.c | 2 +- include/automount.h | 31 +++++++++++++++++++++++++++++++ include/rpc_subs.h | 1 + lib/alarm.c | 28 ++++++++++++++++++++++------ lib/cache.c | 2 +- lib/master.c | 4 ++-- lib/rpc_subs.c | 20 +++++++++++--------- modules/dclist.c | 2 +- modules/lookup_file.c | 8 ++++---- modules/lookup_hesiod.c | 6 +++--- modules/lookup_hosts.c | 4 ++-- modules/lookup_ldap.c | 10 +++++----- modules/lookup_nisplus.c | 10 +++++----- modules/lookup_program.c | 10 +++++----- modules/lookup_sss.c | 6 +++--- modules/lookup_userhome.c | 2 +- modules/lookup_yp.c | 8 ++++---- modules/mount_autofs.c | 2 +- modules/parse_amd.c | 2 +- modules/replicated.c | 34 ++++++++++++++++------------------ 25 files changed, 148 insertions(+), 109 deletions(-)
Quoted 2 lines
--
Ian
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerQuoted 17 lines · Ning Yu
Quoted 16 lines · Ian Kent
This is what I get using "stg mail" when mailing patch series.
I've made a few changes to te breakdown of the patches. I tried to implement the alarm module change we discussued. I changed the mount and expire condition to use a monotonic clock as well for both the direc and indirect modules for completeness. And I changed the patch descriptions a bit.
I'll add my "Signed-off-by" after we've verified the series is OK and I've completed some samity testing.
The series should apply, I don't think there are conflicts with patches in my queue that are before them. The CHANGELOG hunk will be a problem though, as expected, and will likely change due to me changing the patch order before actually committing them.
Quoted 4 lines
Quoted 2 lines
Let me know if you can see any problem with the series.
It looks much more better than my original version, thanks very much.
Really it's much the same, but thanks,
Quoted 1 line
I'm OK with it, and hope it won't cause any regression issue ;)
Yeah, but this is very much about changes to expire and that's fairly easy to test, we'll see.
Quoted 43 lines
Quoted 43 lines
---
Ian Kent (1):
autofs-5.1.1 - remove unused functionelapsed()Yu Ning (7):
autofs-5.1.1 - define monotonic clock helper functions autofs-5.1.1 - use monotonic clock for alarm thread condition wait autofs-5.1.1 - define pending condition init helper function autofs-5.1.1 - use monotonic clock for direct mount condition autofs-5.1.1 - use monotonic clock for indirect mount condition autofs-5.1.1 - change remaininggettimeofday()to useclock_gettime()autofs-5.1.1 - changetime()to usemonotonic_clock()CHANGELOG | 7 +++++++ daemon/automount.c | 4 ++-- daemon/direct.c | 24 ++++++++---------------- daemon/indirect.c | 24 ++++++++---------------- daemon/lookup.c | 6 +++--- daemon/state.c | 2 +- include/automount.h | 31 +++++++++++++++++++++++++++++++ include/rpc_subs.h | 1 + lib/alarm.c | 28 ++++++++++++++++++++++------ lib/cache.c | 2 +- lib/master.c | 4 ++-- lib/rpc_subs.c | 20 +++++++++++--------- modules/dclist.c | 2 +- modules/lookup_file.c | 8 ++++---- modules/lookup_hesiod.c | 6 +++--- modules/lookup_hosts.c | 4 ++-- modules/lookup_ldap.c | 10 +++++----- modules/lookup_nisplus.c | 10 +++++----- modules/lookup_program.c | 10 +++++----- modules/lookup_sss.c | 6 +++--- modules/lookup_userhome.c | 2 +- modules/lookup_yp.c | 8 ++++---- modules/mount_autofs.c | 2 +- modules/parse_amd.c | 2 +- modules/replicated.c | 34 ++++++++++++++++------------------ 25 files changed, 148 insertions(+), 109 deletions(-)
Quoted 2 lines
Quoted 2 lines
--
Ian
--
To unsubscribe from this list: send the line "unsubscribe autofs" in