From 0d8e04054ee6de957268ecbe4ff1b453263f32d1 Mon Sep 17 00:00:00 2001 From: Matt Joras Date: Mon, 16 Oct 2017 16:14:50 +0000 Subject: [PATCH] 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 Approved by: rstone (mentor) Sponsored by: Dell EMC Isilon --- sys/kern/subr_unit.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sys/kern/subr_unit.c b/sys/kern/subr_unit.c index c2110d72169..867edbe7546 100644 --- a/sys/kern/subr_unit.c +++ b/sys/kern/subr_unit.c @@ -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