All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Steve Dickson <SteveD@redhat.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
	Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH 6/7] mountd: allow alternate ttl to be specified for dump_to_cache.
Date: Fri, 29 Jul 2016 15:03:36 +1000	[thread overview]
Message-ID: <146976861681.20186.16926967483251671716.stgit@noble> (raw)
In-Reply-To: <146976807524.20186.8871903418718212567.stgit@noble>

The default will not always be best.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 utils/mountd/cache.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index ec86a22613cf..9cc270690d90 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -881,12 +881,16 @@ static void write_secinfo(char **bp, int *blen, struct exportent *ep, int flag_m
 
 }
 
-static int dump_to_cache(int f, char *buf, int buflen, char *domain, char *path, struct exportent *exp)
+static int dump_to_cache(int f, char *buf, int buflen, char *domain,
+			 char *path, struct exportent *exp, int ttl)
 {
 	char *bp = buf;
 	int blen = buflen;
 	time_t now = time(0);
 
+	if (ttl <= 1)
+		ttl = DEFAULT_TTL;
+
 	qword_add(&bp, &blen, domain);
 	qword_add(&bp, &blen, path);
 	if (exp) {
@@ -913,7 +917,7 @@ static int dump_to_cache(int f, char *buf, int buflen, char *domain, char *path,
 			qword_addhex(&bp, &blen, u, 16);
 		}
 	} else
-		qword_adduint(&bp, &blen, now + DEFAULT_TTL);
+		qword_adduint(&bp, &blen, now + ttl);
 	qword_addeol(&bp, &blen);
 	if (blen <= 0) return -1;
 	if (write(f, buf, bp - buf) != bp - buf) return -1;
@@ -1273,7 +1277,7 @@ static void lookup_nonexport(int f, char *buf, int buflen, char *dom, char *path
 	struct exportent *eep;
 
 	eep = lookup_junction(dom, path, ai);
-	dump_to_cache(f, buf, buflen, dom, path, eep);
+	dump_to_cache(f, buf, buflen, dom, path, eep, 0);
 	if (eep == NULL)
 		return;
 	exportent_release(eep);
@@ -1283,7 +1287,7 @@ static void lookup_nonexport(int f, char *buf, int buflen, char *dom, char *path
 static void lookup_nonexport(int f, char *buf, int buflen, char *dom, char *path,
 		struct addrinfo *UNUSED(ai))
 {
-	dump_to_cache(f, buf, buflen, dom, path, NULL);
+	dump_to_cache(f, buf, buflen, dom, path, NULL, 0);
 }
 #endif	/* !HAVE_NFS_PLUGIN_H */
 
@@ -1330,11 +1334,11 @@ static void nfsd_export(int f)
 	found = lookup_export(dom, path, ai);
 
 	if (found) {
-		if (dump_to_cache(f, buf, sizeof(buf), dom, path, &found->m_export) < 0) {
+		if (dump_to_cache(f, buf, sizeof(buf), dom, path, &found->m_export, 0) < 0) {
 			xlog(L_WARNING,
 			     "Cannot export %s, possibly unsupported filesystem"
 			     " or fsid= required", path);
-			dump_to_cache(f, buf, sizeof(buf), dom, path, NULL);
+			dump_to_cache(f, buf, sizeof(buf), dom, path, NULL, 0);
 		}
 	} else
 		lookup_nonexport(f, buf, sizeof(buf), dom, path, ai);
@@ -1423,7 +1427,7 @@ static int cache_export_ent(char *buf, int buflen, char *domain, struct exporten
 	f = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY);
 	if (f < 0) return -1;
 
-	err = dump_to_cache(f, buf, buflen, domain, exp->e_path, exp);
+	err = dump_to_cache(f, buf, buflen, domain, exp->e_path, exp, 0);
 	if (err) {
 		xlog(L_WARNING,
 		     "Cannot export %s, possibly unsupported filesystem or"
@@ -1464,7 +1468,7 @@ static int cache_export_ent(char *buf, int buflen, char *domain, struct exporten
 				continue;
 			dev = stb.st_dev;
 			path[l] = 0;
-			dump_to_cache(f, buf, buflen, domain, path, exp);
+			dump_to_cache(f, buf, buflen, domain, path, exp, 0);
 			path[l] = c;
 		}
 		break;



  reply	other threads:[~2016-07-29  5:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-29  5:03 [PATCH 0/7] Assorted mount/mountd nfs-utils patches - V2 NeilBrown
2016-07-29  5:03 ` NeilBrown [this message]
2016-08-03 17:31   ` [PATCH 6/7] mountd: allow alternate ttl to be specified for dump_to_cache Steve Dickson
2016-08-03 17:59     ` Steve Dickson
2016-07-29  5:03 ` [PATCH 3/7] mount: don't treat temporary name resolution failure as permanent NeilBrown
2016-07-29  5:03 ` [PATCH 2/7] mountd: remove the --exports-file option NeilBrown
2016-07-29  5:03 ` [PATCH 1/7] nfs.man: clarify effect of 'retry' option NeilBrown
2016-07-29  5:03 ` [PATCH 7/7] mountd: fail nfsd.export lookup for path to unmounted exportpoint NeilBrown
2016-07-29 19:04   ` J. Bruce Fields
2016-07-29  5:03 ` [PATCH 4/7] mount: use a public address for IPv6 callback NeilBrown
2016-07-29  5:03 ` [PATCH 5/7] mount: fix memory leak in v4root_add_parents NeilBrown
2016-07-29 19:05 ` [PATCH 0/7] Assorted mount/mountd nfs-utils patches - V2 J. Bruce Fields
2016-08-04 11:50 ` Steve Dickson
2016-08-04 12:06   ` NeilBrown
2016-08-04 17:29     ` Steve Dickson

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=146976861681.20186.16926967483251671716.stgit@noble \
    --to=neilb@suse.com \
    --cc=SteveD@redhat.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.