diff mbox series

[2/2] cifs: reschedule DNS resolve worker based on dns_interval

Message ID 20220608215444.1216-3-ematsumiya@suse.de (mailing list archive)
State New, archived
Headers show
Series Introduce dns_interval procfs setting | expand

Commit Message

Enzo Matsumiya June 8, 2022, 9:54 p.m. UTC
This patch makes use of the dns_interval introduced in the previous
commit when re/scheduling the resolve worker.

Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
---
 fs/cifs/connect.c     | 4 ++--
 fs/cifs/dns_resolve.c | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 06bafba9c3ff..edd4f0020f9c 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -92,7 +92,7 @@  static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
 	int len;
 	char *unc, *ipaddr = NULL;
 	time64_t expiry, now;
-	unsigned long ttl = SMB_DNS_RESOLVE_INTERVAL_DEFAULT;
+	unsigned long ttl = dns_interval;
 
 	if (!server->hostname ||
 	    server->hostname[0] == '\0')
@@ -130,7 +130,7 @@  static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
 			 * To make sure we don't use the cached entry, retry 1s
 			 * after expiry.
 			 */
-			ttl = max_t(unsigned long, expiry - now, SMB_DNS_RESOLVE_INTERVAL_MIN) + 1;
+			ttl = max_t(unsigned long, expiry - now, dns_interval) + 1;
 	}
 	rc = !rc ? -1 : 0;
 
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c
index 0458d28d71aa..eff1e61180ed 100644
--- a/fs/cifs/dns_resolve.c
+++ b/fs/cifs/dns_resolve.c
@@ -67,6 +67,14 @@  dns_resolve_server_name_to_ip(const char *unc, char **ip_addr, time64_t *expiry)
 	/* Perform the upcall */
 	rc = dns_query(current->nsproxy->net_ns, NULL, hostname, len,
 		       NULL, ip_addr, expiry, false);
+
+	/*
+	 * If the upcall didn't get a TTL, we use the value from dns_interval
+	 * procfs setting
+	 */
+	if (expiry && *expiry == 0)
+		*expiry = dns_interval;
+
 	if (rc < 0)
 		cifs_dbg(FYI, "%s: unable to resolve: %*.*s\n",
 			 __func__, len, len, hostname);