HomeFreeBSD

MFC jail: Add pr_state to struct prison

Description

MFC jail: Add pr_state to struct prison

Rather that using references (pr_ref and pr_uref) to deduce the state
of a prison, keep track of its state explicitly. A prison is either
"invalid" (pr_ref == 0), "alive" (pr_uref > 0) or "dying"
(pr_uref == 0).

State transitions are generally tied to the reference counts, but with
some flexibility: a new prison is "invalid" even though it now starts
with a reference, and jail_remove(2) sets the state to "dying" before
the user reference count drops to zero (which was prviously
accomplished via the PR_REMOVE flag).

pr_state is protected by both the prison mutex and allprison_lock, so
it has the same availablity guarantees as the reference counts do.

Differential Revision: https://reviews.freebsd.org/D27876

(cherry picked from commit 1158508a8086a1a93492c1a2e22b61cd7fee4ec7)

MFC jail: Fix a LOR introduced in 1158508a8086

(cherry picked from commit 701d6b50ae7b0b2b50fbd191c2dbd646ef3b4a67)

Details

Provenance
jamieAuthored on Feb 21 2021, 9:24 PM
Differential Revision
D27876: jail: Add pr_state to struct prison
Parents
rGec24f78e5b20: x86: tsc: deprioritize TSC on VirtualBox
Branches
Unknown
Tags
Unknown