Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Oct 2014 10:31:32 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272403 - head/sys/fs/autofs
Message-ID:  <201410021031.s92AVW0d096515@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Thu Oct  2 10:31:32 2014
New Revision: 272403
URL: https://svnweb.freebsd.org/changeset/base/272403

Log:
  Make autofs timeout handling use timeout task instead of callout;
  that's because the handler can sleep on sx lock.
  
  Reviewed by:	kib
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/fs/autofs/autofs.c
  head/sys/fs/autofs/autofs.h
  head/sys/fs/autofs/autofs_vfsops.c
  head/sys/fs/autofs/autofs_vnops.c

Modified: head/sys/fs/autofs/autofs.c
==============================================================================
--- head/sys/fs/autofs/autofs.c	Thu Oct  2 10:02:38 2014	(r272402)
+++ head/sys/fs/autofs/autofs.c	Thu Oct  2 10:31:32 2014	(r272403)
@@ -76,6 +76,7 @@
 #include <sys/sx.h>
 #include <sys/sysctl.h>
 #include <sys/syscallsubr.h>
+#include <sys/taskqueue.h>
 #include <sys/vnode.h>
 #include <machine/atomic.h>
 #include <vm/uma.h>
@@ -260,7 +261,7 @@ autofs_path(struct autofs_node *anp)
 }
 
 static void
-autofs_callout(void *context)
+autofs_task(void *context, int pending)
 {
 	struct autofs_request *ar;
 
@@ -414,9 +415,14 @@ autofs_trigger_one(struct autofs_node *a
 		strlcpy(ar->ar_options,
 		    amp->am_options, sizeof(ar->ar_options));
 
-		callout_init(&ar->ar_callout, 1);
-		callout_reset(&ar->ar_callout,
-		    autofs_timeout * hz, autofs_callout, ar);
+		TIMEOUT_TASK_INIT(taskqueue_thread, &ar->ar_task, 0,
+		    autofs_task, ar);
+		error = taskqueue_enqueue_timeout(taskqueue_thread,
+		    &ar->ar_task, autofs_timeout * hz);
+		if (error != 0) {
+			AUTOFS_WARN("taskqueue_enqueue_timeout() failed "
+			    "with error %d", error);
+		}
 		refcount_init(&ar->ar_refcount, 1);
 		TAILQ_INSERT_TAIL(&autofs_softc->sc_requests, ar, ar_next);
 	}
@@ -451,7 +457,8 @@ autofs_trigger_one(struct autofs_node *a
 		 * XXX: Is it safe?
 		 */
 		sx_xunlock(&autofs_softc->sc_lock);
-		callout_drain(&ar->ar_callout);
+		taskqueue_cancel_timeout(taskqueue_thread, &ar->ar_task, NULL);
+		taskqueue_drain_timeout(taskqueue_thread, &ar->ar_task);
 		sx_xlock(&autofs_softc->sc_lock);
 		uma_zfree(autofs_request_zone, ar);
 	}

Modified: head/sys/fs/autofs/autofs.h
==============================================================================
--- head/sys/fs/autofs/autofs.h	Thu Oct  2 10:02:38 2014	(r272402)
+++ head/sys/fs/autofs/autofs.h	Thu Oct  2 10:31:32 2014	(r272403)
@@ -97,7 +97,7 @@ struct autofs_request {
 	char				ar_prefix[MAXPATHLEN];
 	char				ar_key[MAXPATHLEN];
 	char				ar_options[MAXPATHLEN];
-	struct callout			ar_callout;
+	struct timeout_task		ar_task;
 	volatile u_int			ar_refcount;
 };
 

Modified: head/sys/fs/autofs/autofs_vfsops.c
==============================================================================
--- head/sys/fs/autofs/autofs_vfsops.c	Thu Oct  2 10:02:38 2014	(r272402)
+++ head/sys/fs/autofs/autofs_vfsops.c	Thu Oct  2 10:31:32 2014	(r272403)
@@ -40,6 +40,7 @@
 #include <sys/module.h>
 #include <sys/mount.h>
 #include <sys/sx.h>
+#include <sys/taskqueue.h>
 #include <sys/vnode.h>
 
 #include <fs/autofs/autofs.h>

Modified: head/sys/fs/autofs/autofs_vnops.c
==============================================================================
--- head/sys/fs/autofs/autofs_vnops.c	Thu Oct  2 10:02:38 2014	(r272402)
+++ head/sys/fs/autofs/autofs_vnops.c	Thu Oct  2 10:31:32 2014	(r272403)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/namei.h>
 #include <sys/signalvar.h>
 #include <sys/systm.h>
+#include <sys/taskqueue.h>
 #include <sys/vnode.h>
 #include <machine/atomic.h>
 #include <vm/uma.h>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410021031.s92AVW0d096515>