autofs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Ian Kent <raven@themaw.net>
Cc: autofs@vger.kernel.org
Subject: [PATCH 2/3] Fix monotonic_elapsed.
Date: Mon, 29 Jan 2018 18:19:54 +1100	[thread overview]
Message-ID: <151721039460.27355.12976027743239873668.stgit@noble> (raw)
In-Reply-To: <151721021295.27355.1968703903360394469.stgit@noble>

When automount probes multiple hosts to find the one which
responds most quickly, it currently ignores the nanoseconds.
This often makes the cost "0", which makes weights ineffective.

The cause is that monotonic_elapsed() casts tv_nsec to a
double *after* dividing by 1 billion, rather than before.

With this change, weights become effective for choosing
between hosts which respond in under one second.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 lib/rpc_subs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
index 73097c9d4238..60ede9f8c085 100644
--- a/lib/rpc_subs.c
+++ b/lib/rpc_subs.c
@@ -1093,9 +1093,9 @@ double monotonic_elapsed(struct timespec start, struct timespec end)
 	double t1, t2;
 
 	t1 =  (double) start.tv_sec +
-		(double) (start.tv_nsec/(1000*1000*1000));
+		((double) start.tv_nsec/(1000*1000*1000));
 	t2 =  (double) end.tv_sec +
-		(double) (end.tv_nsec/(1000*1000*1000));
+		((double) end.tv_nsec/(1000*1000*1000));
 	return t2 - t1;
 }
 


--
To unsubscribe from this list: send the line "unsubscribe autofs" in

  parent reply	other threads:[~2018-01-29  7:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29  7:19 [PATCH 0/3] Assorted autofs fixes NeilBrown
2018-01-29  7:19 ` [PATCH 1/3] use_hostname_for_mounts shouldn't prevent selection among replicas NeilBrown
2018-01-29 10:57   ` Ian Kent
2018-01-29  7:19 ` NeilBrown [this message]
2018-01-29  8:31   ` [PATCH 2/3] Fix monotonic_elapsed Ian Kent
2018-01-29  7:19 ` [PATCH 3/3] Makefiles.rules: remove 'samples' from SUBDIRS NeilBrown
2018-01-29  9:27 ` [PATCH 0/3] Assorted autofs fixes Ian Kent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=151721039460.27355.12976027743239873668.stgit@noble \
    --to=neilb@suse.com \
    --cc=autofs@vger.kernel.org \
    --cc=raven@themaw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).