svn commit: r209784 - stable/8/sys/kern

Lawrence Stewart lstewart at FreeBSD.org
Thu Jul 8 02:41:55 UTC 2010


Author: lstewart
Date: Thu Jul  8 02:41:55 2010
New Revision: 209784
URL: http://svn.freebsd.org/changeset/base/209784

Log:
  MFC r206026:
  
  - Factor code to destroy an ALQ out of alq_close() into a private alq_destroy().
  
  - Use the new alq_destroy() to properly handle a failure case in alq_open().
  
  Sponsored by:	FreeBSD Foundation
  Reviewed by:	dwmalone, jeff, rpaulo, rwatson (as part of a larger patch)

Modified:
  stable/8/sys/kern/kern_alq.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/kern/kern_alq.c
==============================================================================
--- stable/8/sys/kern/kern_alq.c	Thu Jul  8 02:35:37 2010	(r209783)
+++ stable/8/sys/kern/kern_alq.c	Thu Jul  8 02:41:55 2010	(r209784)
@@ -103,6 +103,7 @@ static void ald_deactivate(struct alq *)
 
 /* Internal queue functions */
 static void alq_shutdown(struct alq *);
+static void alq_destroy(struct alq *);
 static int alq_doio(struct alq *);
 
 
@@ -263,6 +264,18 @@ alq_shutdown(struct alq *alq)
 	crfree(alq->aq_cred);
 }
 
+void
+alq_destroy(struct alq *alq)
+{
+	/* Drain all pending IO. */
+	alq_shutdown(alq);
+
+	mtx_destroy(&alq->aq_mtx);
+	free(alq->aq_first, M_ALD);
+	free(alq->aq_entbuf, M_ALD);
+	free(alq, M_ALD);
+}
+
 /*
  * Flush all pending data to disk.  This operation will block.
  */
@@ -420,8 +433,11 @@ alq_open(struct alq **alqp, const char *
 
 	alp->ae_next = alq->aq_first;
 
-	if ((error = ald_add(alq)) != 0)
+	if ((error = ald_add(alq)) != 0) {
+		alq_destroy(alq);
 		return (error);
+	}
+
 	*alqp = alq;
 
 	return (0);
@@ -525,22 +541,9 @@ alq_flush(struct alq *alq)
 void
 alq_close(struct alq *alq)
 {
-	/*
-	 * If we're already shuting down someone else will flush and close
-	 * the vnode.
-	 */
-	if (ald_rem(alq) != 0)
-		return;
-
-	/*
-	 * Drain all pending IO.
-	 */
-	alq_shutdown(alq);
-
-	mtx_destroy(&alq->aq_mtx);
-	free(alq->aq_first, M_ALD);
-	free(alq->aq_entbuf, M_ALD);
-	free(alq, M_ALD);
+	/* Only flush and destroy alq if not already shutting down. */
+	if (ald_rem(alq) == 0)
+		alq_destroy(alq);
 }
 
 static int


More information about the svn-src-stable-8 mailing list