Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Oct 2017 16:14:50 +0000 (UTC)
From:      Matt Joras <mjoras@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324666 - head/sys/kern
Message-ID:  <201710161614.v9GGEoUN094644@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjoras
Date: Mon Oct 16 16:14:50 2017
New Revision: 324666
URL: https://svnweb.freebsd.org/changeset/base/324666

Log:
  Properly reset the fields in clean_unrhdr.
  
  In r324542 I neglected to reset the first and last fields of struct
  unrhdr. This causes a tmpfs to fail the unr(9) consistency checks with
  DIAGNOSTIC on. Fix this by resetting the fields by calling init_unrhdr.
  While here, change a loop to use TAILQ_FOREACH_SAFE since it is more
  readable and equally fast.
  
  Reported by:	David Wolfskill <david@catwhisker.org>
  Approved by:	rstone (mentor)
  Sponsored by:	Dell EMC Isilon

Modified:
  head/sys/kern/subr_unit.c

Modified: head/sys/kern/subr_unit.c
==============================================================================
--- head/sys/kern/subr_unit.c	Mon Oct 16 15:16:24 2017	(r324665)
+++ head/sys/kern/subr_unit.c	Mon Oct 16 16:14:50 2017	(r324666)
@@ -373,18 +373,17 @@ clear_unrhdr(struct unrhdr *uh)
 
 	KASSERT(TAILQ_EMPTY(&uh->ppfree),
 	    ("unrhdr has postponed item for free"));
-	up = TAILQ_FIRST(&uh->head);
-	while (up != NULL) {
-		uq = TAILQ_NEXT(up, list);
+	TAILQ_FOREACH_SAFE(up, &uh->head, list, uq) {
 		if (up->ptr != uh) {
 			Free(up->ptr);
 		}
 		Free(up);
-		up = uq;
 	}
-	TAILQ_INIT(&uh->head);
 	uh->busy = 0;
 	uh->alloc = 0;
+	init_unrhdr(uh, uh->low, uh->high, uh->mtx);
+
+	check_unrhdr(uh, __LINE__);
 }
 
 static __inline int



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